[Windows] [Solution] Problem keymapping usb gamepad
#1
Lightbulb 
Having spent a few hours across 2 days tracking this down, let me share my problem and the solution I found.

I wanted to use a sNES usb gamepad with XBMC on my Vista 32bit machine. On the XBMC.log file the name was "USB Gamepad" but using that name to set keymaps would lead to no change.

Using Regedit.exe I searched for the value "USB Gamepad" and changed each on to "ChangedGamepad#" where the # was a number higher for each one I found. Checking the log I found the new name (mine ended up being ChangedGamepad3) and added that to the keymap, and it worked.

Next problem: When using the dpad (it mapped as an x and y axis) each button push would give me 2-10 button presses, far faster than I could use. I downloaded AutoHotKey and use the following script:


PHP Code:
#Persistent  ; Keep this script running until the user explicitly exits it.

SetTimerWatchAxis5
return

WatchAxis:
IfWinActiveXBMC
{
GetKeyStateJoyXJoyX  Get position of X axis.
GetKeyStateJoyYJoyY  Get position of Y axis.
KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).

if 
JoyX 70
    KeyToHoldDown 
Right
else if JoyX 30
    KeyToHoldDown 
Left
else if JoyY 70
    KeyToHoldDown 
Down
else if JoyY 30
    KeyToHoldDown 
Up
else
    
KeyToHoldDown =

if 
KeyToHoldDown = %KeyToHoldDownPrev%  ; The correct key is already down (or no key is needed).
    return  ; Do 
nothing.

Otherwiserelease the previous key and press down the new key:
SetKeyDelay -1  Avoid delays between keystrokes.
if 
KeyToHoldDownPrev   There is a previous key to release.
    
Send, {%KeyToHoldDownPrevup}  ; Release it.
if 
KeyToHoldDown   There is a key to press down.
    
Send, {%KeyToHoldDowndown}  ; Press it down.
return


That allows me to map the dpad to the arrow keys of the keyboard, but only if XBMC is the active window. If an emulator is launched the gamepad is 100% perfect.
Reply

Logout Mark Read Team Forum Stats Members Help
[Windows] [Solution] Problem keymapping usb gamepad0