Launch script with Joystick
-
Hi there! i'm trying to get RetroPie installation accesed without having to use the TV remote, so... i got 2 scripts to controll tv through hdmi-cec:
1 turn on tv ((turnon.sh))
echo 'on 0' | cec-client -s -d 12 switch source to hdmi where the rpi is connected ((changesource.sh))
echo 'as' | cec-client -s -d 1Ok, i've tried those scripts from console and they work, i want to execute both or just one of those, when i hit SOME KEY OF MY JOYSTICK, but i can't find any mapping app inside retropie.
I've being messing with runcommand-menu, and i got both scripts to appear in user menu, and launch those scripts from there, but i need to do that without seein the screein, just by touching keys on joystick.
some data: rpi4 4gb + 8bitdo sf30pro joystick + logitech k400 keyboard (if needed for coding but not willing to use keyboard to execute scripts) + wired ethernet + philips android tv.
Thank you in advice.
-
@dthgti Look-up
triggerhappy
- it runs as a service and listens to input events (Keyboard/Controller/etc.). -
@mitu nice one! it's exactly what i'm looking for, i'll try things with that tool, will tell you later if i can make it.
-
@mitu i've been trying things with triggerhappy but i think it's too difficult for me, can you help me with coding?
"thd --dump /dev/input/event6"
witch this comand i found out the event of the button i want to make tv to turn on. it returns this:"EV_KEY BTN_THUMBL 1 /dev/input/event6
BTN_THUMBL 1 command
EV_KEY BTN_THUMBL 0 /dev/input/event6
BTN_THUMBL 0 command"
so
[EV_KEY BTN_THUMBL] is event produced by button i want.
[0] is release button
[1] is push button
[2] is hold buttonKnowing this, now i'm going to do what guide says:
https://github.com/wertarbyte/triggerhappy*"Event handlers can be defined in configuration files (specified by --triggers).
If a directory is specified, all configuration files within matching the
pattern *.conf are loaded. The files use the following format:<event name> <event value> <command line>
e.g.
KEY_VOLUMEUP 1 /usr/bin/amixer set Master 5%+
KEY_VOLUMEUP 2 /usr/bin/amixer set Master 5%+
KEY_VOLUMEDOWN 1 /usr/bin/amixer set Master 5%-
KEY_VOLUMEDOWN 2 /usr/bin/amixer set Master 5%-"*i don't know how to proceed anymore, after the example, it gives poor info, so i can't just change data and make it work. any suggestion?
-
i think next step is to create the .conf file, i did that, but i'm failing in content of that file, in github it says <event name> <event value> <command line> so i think correct way should be:
BTN_THUMBL 1 "HERE GOES COMAND THAT I WANT TO EXECUTE"
i don't know what comand to write there, remember that i just want to execute this script (named pushstar.sh) [echo 'on 0' | cec-client -s -d 1], so the .conf file should be like this?
BTN_THUMBL 1 ./pushstar.sh
¿?¿?¿?
-
@dthgti as the page says:
For more information, consult the manual pages of "thd" and "th-cmd".
You'll need to add a
.conf
file with the necessary lines in/etc/triggerhapy/triggers.d/
. -
finally i've got it done! with some minor bugs that will try to fix, but work most of the times.
one thing... all this works after i execute this:
thd --triggers /etc/triggerhappy/triggers.d/ /dev/input/event
but, how do i autostart that on every boot?
-
@dthgti said in Launch script with Joystick:
but, how do i autostart that on every boot?
triggerhappy
runs as a service when your system starts. Unless you've disabled it, it should read the configuration file and do the actions configured.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.