AutoHotkey: open-source utility to remap gampad input to button input
Please check here for the program.
Below is a sample script to translate both gamepad axis and button inputs.
========
========
Below is a sample script to translate both gamepad axis and button inputs.
========
; Autohotkey Script that matches a few joypad buttons to keyboard events
; Instruction:
; 1) Identify the Joypad buttons that you want to use
; The sample script at
; http://www.autohotkey.com/docs/scripts/JoystickTest.htm
; provides a good way for you to find out the mapping
; 2) Modify Part 0 and Part 1 accordingly.
; 3) Enjoy!
#Persistent ; Keep this script running until the user explicitly exits it.
; Part 0: turbo key config
; State if any keys need turbo ('Y' if needed)
TurboJoy4 = N
TurboJoy1 = N
TurboJoy8 = N
TurboJoy3 = N
TurboJoy2 = Y
TurboJoy6 = N
; main routine
SetTimer, Watch, 5
return
; Watch method
Watch:
SetKeyDelay -1 ; Avoid delays between keystrokes.
; Part 1: key mapping routine each JoyX to be used
; Joy4 -> 'Q'
GetKeyState, Joy4, Joy4
Joy4PPrev = %Joy4P%
if Joy4 = D
{
if TurboJoy4 = Y
{
Send {Q down}
Send {Q up}
Joy4P = Y
}
else if Joy4PPrev =
{
Send {Q down}
Joy4P = Y
}
}
else if Joy4 = U
{
if Joy4PPrev = Y
{
if TurboJoy4 != Y
{
Send {Q up}
}
Joy4P =
}
}
; Joy1 -> 'D'
GetKeyState, Joy1, Joy1
Joy1PPrev = %Joy1P%
if Joy1 = D
{
if TurboJoy1 = Y
{
Send {W down}
Send {W up}
Joy1P = Y
}
else if Joy1PPrev =
{
Send {W down}
Joy1P = Y
}
}
else if Joy1 = U
{
if Joy1PPrev = Y
{
if TurboJoy1 != Y
{
Send {W up}
}
Joy1P =
}
}
; Joy8 -> 'E'
GetKeyState, Joy8, Joy8
Joy8PPrev = %Joy8P%
if Joy8 = D
{
if TurboJoy8 = Y
{
Send {E down}
Send {E up}
Joy8P = Y
}
else if Joy8PPrev =
{
Send {E down}
Joy8P = Y
}
}
else if Joy8 = U
{
if Joy8PPrev = Y
{
if TurboJoy8 != Y
{
Send {E up}
}
Joy8P =
}
}
; Joy3 -> 'A'
GetKeyState, Joy3, Joy3
Joy3PPrev = %Joy3P%
if Joy3 = D
{
if TurboJoy3 = Y
{
Send {A down}
Send {A up}
Joy3P = Y
}
else if Joy3PPrev =
{
Send {A down}
Joy3P = Y
}
}
else if Joy3 = U
{
if Joy3PPrev = Y
{
if TurboJoy3 != Y
{
Send {A up}
}
Joy3P =
}
}
; Joy2 -> 'S'
GetKeyState, Joy2, Joy2
Joy2PPrev = %Joy2P%
if Joy2 = D
{
if TurboJoy2 = Y
{
Send {S down}
Send {S up}
Joy2P = Y
}
else if Joy2PPrev =
{
Send {S down}
Joy2P = Y
}
}
else if Joy2 = U
{
if Joy2PPrev = Y
{
if TurboJoy2 != Y
{
Send {S up}
}
Joy2P =
}
}
; Joy6 -> 'D'
GetKeyState, Joy6, Joy6
Joy6PPrev = %Joy6P%
if Joy6 = D
{
if TurboJoy6 = Y
{
Send {D down}
Send {D up}
Joy6P = Y
}
else if Joy6PPrev =
{
Send {D down}
Joy6P = Y
}
}
else if Joy6 = U
{
if Joy6PPrev = Y
{
if TurboJoy6 != Y
{
Send {D up}
}
Joy6P =
}
}
; Joy10 -> 'Enter'
GetKeyState, Joy10, Joy10
Joy10PPrev = %Joy10P%
if Joy10 = D
{
if Joy10PPrev =
{
Send {Enter down}
Joy10P = Y
}
}
else if Joy10 = U
{
if Joy10PPrev = Y
{
Send {Enter up}
Joy10P =
}
}
; Part 2: D-pad to Keyboard Left, right, Up and down
GetKeyState, JoyX, JoyX ; Get position of X axis.
GetKeyState, JoyY, JoyY ; Get position of Y axis.
JoyLPPrev = %JoyLP%
if JoyX < 30
{
if JoyLPPrev =
{
Send {Left down}
JoyLP = Y
}
}
else
{
if JoyLPPrev = Y
{
Send {Left up}
JoyLP =
}
}
JoyRPPrev = %JoyRP%
if JoyX >70
{
if JoyRPPrev =
{
Send {Right down}
JoyRP = Y
}
}
else
{
if JoyRPPrev = Y
{
Send {Right up}
JoyRP =
}
}
JoyUPPrev = %JoyUP%
if JoyY < 30
{
if JoyUPPrev =
{
Send {Up down}
JoyUP = Y
}
}
else
{
if JoyUPPrev = Y
{
Send {Up up}
JoyUP =
}
}
JoyDPPrev = %JoyDP%
if JoyY > 70
{
if JoyDPPrev =
{
Send {Down down}
JoyDP = Y
}
}
else
{
if JoyDPPrev = Y
{
Send {Down up}
JoyDP =
}
}
return
========
Comments
Post a Comment