我想知道如何配置按键绑定以将 RapidFire 与xdotool
游戏xbindkeys
手柄输入一起使用?
我有一台 Logitech F310,我想知道如何在玩游戏时通过按键绑定来模拟 RapidFire 到游戏手柄。 Linux将此游戏手柄注册为Generic X-Box pad
设备输入,/dev/input/js0
它jstest-gtk
可以告诉我游戏手柄的按键映射,如下所示;
Axis
ABS_X
ABS_Y
ABS_Z
ABS_RX
ABS_RY
ABS_RZ
ABS_HAT0X
ABS_HAT0Y
Buttons
BTN_A
BTN_B
BTN_X
BTN_Y
BTN_TL
BTN_TR
BTN_START
BTN_SELECT
BTN_MODE
BTN_THUMBL
BTN_THUMBR
我经常在模拟器上玩游戏,按钮映射会有不同的名称,例如ppsspp
:
Dpad UP = pad1.Y HAT-
Dpad DWN = pad1.Y HAT+
Dpad LEFT = pad1.X HAT-
Dpad RIGHT = pad1.X HAT+
CIRCLE = pad1.DOWN
X = pad1.UP
SQUARE = pad1.LEFT
TRIANGLE = pad1.RIGHT
START = pad1.b6
SELECT = pad1.b5
L = pad1.b10
R = pad1.b9
Analogue UP = pad1.Y AXIS-
Analogue DWN = pad1.Y AXIS+
Analogue LEFT = pad1.X AXIS-
Analogue RIGHT = pad1.X AXIS+
我如何能够使用它来映射我想要模拟 RapidFire 的按键绑定?例如,我想模拟 RapidFire 按下Y游戏手柄上的按钮,我将如何映射它xbindkeys
并对其进行转换,xdotool
以便它执行对游戏手柄的自动按钮按下?
答案1
好吧,我自己做了一些思考,最后发现了让它按照我想要的方式工作,但可以改进以使其更好,也许可以更短的代码行?
#!/bin/bash
## RapidFire key modifier for games.
## if you need it to work for something other then
## edit the search parameter name to focus it on that window only.
## You may want to modify the command to include the 'windowactivate' option.
winid=$(xdotool search "PPSSPP 1.0.1" | head -n1)
while true
do
# This will spam the console with echo messages.
# edit out '| echo' if you want a quiet console.
xdotool keydown --window $winid "x" | echo "RapidFire ON" # holding key X down
xdotool keyup --window $winid "x" | echo "RapidFire OFF" # release key X up
done
exit 0
# Press C^ to stop it when done.
#
# See manpage for 'xdotool' for more options.
# http://www.semicomplete.com/projects/xdotool/xdotool.xhtml