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

    How can I emulate a joystick using a python script?

    Scheduled Pinned Locked Moved Help and Support
    python scriptnintendo switchemulatiostationjoystick
    14 Posts 3 Posters 5.0k 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.
    • ?
      A Former User @luizoti
      last edited by A Former User

      @luizoti How exactly would I emulate a joystick? It seems to need a joystick already plugged in...

      1 Reply Last reply Reply Quote 0
      • L
        luizoti
        last edited by luizoti

        @Bluebotlabs How exactly does this control work? I probably didn't understand.

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @luizoti
          last edited by

          @luizoti Ok, so I'm building a nintendo switch, I have two arduino's, one is connected to main one via RF which is connected to the Pi via bluetooth, they both have nintendo switch joysticks in them and will be able to send whatever data they have to to the pi, I need to figure out how I can configure ES to use the controllers, e.g: via a Python script interacting with the controlers and emulating a joystick

          1 Reply Last reply Reply Quote 0
          • L
            luizoti
            last edited by

            Well, if I understand your control connects, but it is not seen as a control, I have already programmed a usb control with arduino, and ES recognized it normally, I believe that via BT it is possible, I did not need any python script.

            The library I used at the time, I remember allowing programming joystick axes.

            About py-udev, remember that it reads the events of the device and you can create a new device based on it, joystick becomes a control for example.

            ? 1 Reply Last reply Reply Quote 1
            • ?
              A Former User @luizoti
              last edited by A Former User

              @luizoti I do not beleive you can emulate a joystick over bluetooth

              Does anybody know how to use python-uinput?

              mituM L 2 Replies Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @A Former User
                last edited by mitu

                @Bluebotlabs said in How can I emulate a joystick using a python script?:

                @luizoti I do not beleive you can emulate a joystick over bluetooth

                Of course you can, there's lots of projects using an inexpensive BLE HID chip to add wireless connectivity to classic controllers (SNES/Megadrive/etc.).

                EDIT: here is one - https://mitxela.com/projects/bluetooth_hid_gamepad.

                1 Reply Last reply Reply Quote 0
                • L
                  luizoti @A Former User
                  last edited by

                  @Bluebotlabs Exactly as mitu said, it is possible, python-uinput would be useless (probably) if your control is not recognized as a control or at least a keyboard, the BLE HID project, seems something much easier to apply.

                  ? 1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User @luizoti
                    last edited by A Former User

                    @luizoti However, the BLE HID project is out of the question for me due to reasons regarding budget, availability, size and others. I have tested python-uinput and pygame appears to detect it, I shall do some further experimentation and update you on the result

                    python-uinput did not work, I'm going to try using evdev, does anybody know how I can emulate a joystick using it?

                    mituM 1 Reply Last reply Reply Quote 0
                    • mituM
                      mitu Global Moderator @A Former User
                      last edited by

                      @Bluebotlabs said in How can I emulate a joystick using a python script?:

                      python-uinput did not work, I'm going to try using evdev, does anybody know how I can emulate a joystick using it?

                      It's actually python-uinput that should be used to create an input device, the evdev part it's used to read from the existing event sources (emph. mine):

                      The evdev interface serves the purpose of passing events generated in the kernel directly to userspace through character devices that are typically located in /dev/input/.

                      This package also comes with bindings to uinput, the userspace input subsystem. Uinput allows userspace programs to create and handle input devices that can inject events directly into the input subsystem.

                      ? 1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User @mitu
                        last edited by

                        @mitu I made a mistake in my testing, I beleive python-uinput my work

                        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.