Jump to content
LaunchBox Community Forums

AHK to switch ipac from keyboard to xinput?


BigCaah

Recommended Posts

Hi all, question about Launchbox and AHK scripts. I’m using an ipac 4 in my cabinet, and I’d like to create a script that will switch between keyboard mode and xinput mode. I’m awful when it comes to writing scripts, does anyone have any suggestions as to how I could proceed?

Link to comment
Share on other sites

11 hours ago, BigCaah said:

I’m awful when it comes to writing scripts, does anyone have any suggestions as to how I could proceed?

The easiest way is to do a [Google] search for what it is you're wanting to do.  For example: "AutoHotkey send keypress" (or even easier "ahk send keypress").

 

 

12 hours ago, BigCaah said:

create a script that will switch between keyboard mode and xinput mode

My I-Pac is old and doesn't have the option to switch between input modes.  But from what I can see here (click on the Multi-Mode tab), you can switch on-the-fly via a couple of key presses.

Translating from the link above, to switch to Xinput mode you press "1" and "Space" (in that order) and hold them for 10 seconds.  In AutoHotkey lingo, that'd be:

Send, {1 down}
Sleep, 50
Send, {Space down}
Sleep, 10000
Send, {1 up}{Space up}

Here, we add "Sleep, 50" (50 milliseconds) to ensure "1" (I-Pac's default "shift control-key" [not to be confused with "Shift" on the keyboard]) is pressed and held PRIOR to "Space".

 

For Keyboard Mode, it's "1" and "[Left] Ctrl".

Send, {1 down}
Send, 50
Send, {LCtrl down}
Sleep, 10000
Send, {1 up}{LCtrl up}

Both of these assume you haven't reprogrammed the default "Start1" and "P1SW3" (and "P1SW1" respectively) input assignments.

 

An issue you may run into with switching modes just prior to launching a game via LaunchBox is 

Quote

Note that a mode switch is essentially the same as unplugging a USB device and plugging in a different one, into the same port. It will take the host PC up to 30 seconds to notice this and initialize the new device.

Key point being "It will take the host PC up to 30 seconds to notice this and initialize the new device."

 

As a side note, I think most emulators/games that use Xinput also allow you to assign keyboard inputs.  And ones that don't, well... that's where having something like a wireless Xbox 360 controller comes in real handy. ;) 

 

Link to comment
Share on other sites

Thank you for the reply! So summed up for future reference, in command line lingo, SEND causes a command to be sent to the keyboard, SLEEP causes a pause in milliseconds, and brackets { } go around names of keys to be pressed?

I'd avoid using xinput if I could, because the ipac has worked incredibly well out of the box.. but for running fighters from Steam, there doesn't seem to be any other way. The source of my question is due to a problem with multi-mode hotkey switching.. I started off holding the shift+P1SW3 hotkey to switch to xinput, which works splendidly. Upon holding shift+P1SW1 to switch back to keyboard mode, however, fails to switch back, as no shift key appears to be assigned in xinput. Assigning a shift key in win-ipac and switching back to keyboard mode works, but it won't maintain the configuration unless the board is forced to reconfigure from the menu.

What seemed to work, however, was creating separate profiles for the keyboard and xinput modes, and manually switching between them in win-ipac. I forgot to mention in my original post that I e-mailed Andy from Ultimarc; he noted that while the keystrokes work for switching on the fly, switching the profile in win-ipac was in fact the preferred method via command line interface, and also recommended creating a .bat file to do so. After some more searching last night, I found this from their website.. "This program can be run "invisibly" from a command line by simply appending the name of an already-saved IPC (config) file: Winipac.exe <name of IPC file>"

I'm assuming that I would need a startup and a shutdown script to run this properly? A command to open win-ipac, another to run that command to change from the keyboard IPC file to the xinput IPC file, and one more command to close win-ipac.. shutdown would be the opposite, a command to open win-ipac, another to run that command to change from keyboard to xinput, and one more to close win-ipac?

 

 

 

Edited by BigCaah
Link to comment
Share on other sites

41 minutes ago, BigCaah said:

brackets { } go around names of keys to be pressed

Correct on Send and Sleep.  You only need the { } around 'special' named keys.  {Space}{Enter}{Tab}{F1}{Alt}{Ctrl}{LWin}{Shift} etc.  And to convolute things more, the last 4 I list have alternate characters that can be used !, ^, # and +. Respectively.  Individual numbers and letters don't need  { }.  Examples (with options):

;  Copy your highlighted text
Send, {Ctrl down}c{Ctrl up}
Send, ^c

;  Close the active window
Send, {Alt down}{F4}{Alt up}
Send, !{F4}

;  Type text
Send, Joe was here

 

 

1 hour ago, BigCaah said:

creating separate profiles for the keyboard and xinput modes, and manually switching between them in win-ipac. I forgot to mention

DOH_custom.jpeg.1d6db4393cf987a7580f2a40fd675ca6.jpeg

So, you know what the command line looks like:

"D:\Utilities\WinIPAC\WinIPAC.exe" Xinput_profile.ipc
"D:\Utilities\WinIPAC\WinIPAC.exe" Keyboard_profile.ipc

(quotes, in case your path has spaces in it)

The most straight forward way to do this is to load it directly, as an additional app. No batch file nor script needed.  (if it doesn't seem to load correctly, may need to check Wait for Exit)

image.thumb.png.507bb59475469b345c42f8fe702a8340.png

Then add a second Additional App to the game(s) changing the Command-Line to "Keyboard_profile.ipc" and check Run After (instead on Run Before).  You won't need the Wait for Exit.

 

If that creates an undesirable window appear/disappear (though it shouldn't because "it can be run invisibly"), you could create 2 batch files, shortcuts to the batch files, edit the shortcuts as described here, and have the Additional Apps point to the shortcuts.

 

If you have a lot of games you need to add these Additional Apps to (AND they worked after testing them first ;)), you can add them in bulk using this: 

 

  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...

This looks like it should work but it doesn't work as expected. When it's done via the command line, the profile changes correctly and the ipac mode changed to xinput, all good.

But when it's run from the additional apps as shown above, the profile changes then the ipac attempts to switch modes but seems to stop halfway and I get a 'device descriptor' error in device manager. Need to then uninstall the ipac, remove it, reinsert and restart the computer for it to be recognised again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...