1

I'm wondering how it be possible to configure a keybind to use RapidFire with xdotool and xbindkeys to a gamepad input?

I have a Logitech F310, and I want to know how I can pass keybinds to simulate RapidFire to the gamepad while playing games. Linux registers this gamepad as Generic X-Box pad the device input is /dev/input/js0 with help of jstest-gtk it can tell me the key mappings of the gamepad and they are as follows;

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

I often play games on emulators and button mappings will be different names, like with ppsspp for example;

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+

How would I be able to use this to map the keybinds I want to simulate RapidFire? For example I want to simulate RapidFire presses for Y button on the gamepad, how would I map this be translated for xbindkeys and xdotool so it performs the automated button presses to the gamepad?

0

Ok so I had a little figuring out myself and ended up coming across this of getting it to work with what I wanted in mind, it could be improved on to make it better though, perhaps shorter lines of code?

#!/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
  • This works to infinitely spam the specified key ("x"). Is there a while condition to monitor the hotkey to only do this while the key is pressed? (or until condition until the key is released). – Jay M Feb 15 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy