workinghard / jslisten

listen to gamepad inputs and trigger a command
GNU General Public License v3.0
31 stars 18 forks source link

How can I bind up, down, right, left direction arrows with mk_joystick #17

Open jon19800404 opened 5 years ago

jon19800404 commented 5 years ago

Hi, first of all it is a very useful program for doing key combinations, I was struggled with it a few days, than I found your solution which is working great, thank you! I want to use the direction arrow keys in the mk_joystick, but I don't know how to do it through the /etc/jslisten.cfg. When I run the jstest /dev/input/js0 I see the values for the buttons as unique numbers, but in the directions when I push on of them I see 32767 or 32768 and -32767 or -32768. Below is the jstest result of it:

Driver version is 2.1.0. Joystick (GPIO Controller 1) has 2 axes (X, Y) and 12 buttons (BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart). Testing ... (interrupt to exit) Axes: 0: 0 1: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off

When I press the Up direction: Axes: 0: 0 1: 32767 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off

When I press the Down direction: Axes: 0: 0 1: -32767 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off

Left: Axes: 0: -32767 1: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off

Right: Axes: 0: 32767 1: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off

What value should I set in the config file? [LCDBrightnessUp] program="/home/pi/commands/LCDBrightness_Up.sh" button1=7 button2=???? button3= button4=

workinghard commented 5 years ago

Right now it's not possible. Program reacts only to button events. Should be pretty easy though to add axis actions as-well. Just need to be careful with analog sticks. They're usually mapped to same axis like digital but triggering/flooding with changing values all the time.