RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Launch script with Joystick

    Scheduled Pinned Locked Moved Help and Support
    rpi4retropiescriptmapping8bitdo
    8 Posts 2 Posters 394 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dthgti
      last edited by dthgti

      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 1

      2 switch source to hdmi where the rpi is connected ((changesource.sh))
      echo 'as' | cec-client -s -d 1

      Ok, 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.

      mituM 1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator @dthgti
        last edited by

        @dthgti Look-up triggerhappy - it runs as a service and listens to input events (Keyboard/Controller/etc.).

        D 2 Replies Last reply Reply Quote 0
        • D
          dthgti @mitu
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • D
            dthgti @mitu
            last edited by dthgti

            @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 button

            Knowing 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?

            1 Reply Last reply Reply Quote 0
            • D
              dthgti
              last edited by

              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

              ¿?¿?¿?

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @dthgti
                last edited by

                @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/.

                1 Reply Last reply Reply Quote 0
                • D
                  dthgti
                  last edited by

                  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?

                  1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator
                    last edited by

                    @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.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post

                    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.