Announcement

Collapse
No announcement yet.

Joystick Plugin

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Joystick Plugin

    Hi.

    I have created a little plugin to use joysticks with the unreal engine 4. The source is based on the hydra plugin.
    The plugin is still untested but quite usable.
    I'm still very new to Unreal Engine development, so please be clement, if the source code has architectural mistakes...

    Any comment or suggestion is very welcome.


    Resources:
    Plugin download: GitHub

    #2
    Sounds awesome! Personally, I'd like to see more joystick games.

    Comment


      #3
      Elite Dangerous is a good example!

      Comment


        #4
        Steve, you spelled "Steering Wheel" wrong :P
        Tracey White - Senior Design Visualization Artist / PC Game Enthusiast / Drummer
        My Maze Game development video series
        My Maze Game Blog

        Comment


          #5
          Hey Ikarus76 this is very awesome!

          Just tested this plugin on my Saitek Evo Force and it worked out of the box! Because you used the hydra plugin as a basis, I felt straight at home and the component and event driven interface implementation makes me happy. Glad you could make use of the base code

          Feedback(This is my opinion):
          -[Bug]Each event emits twice, I believe this is because you call the delegate event both from within FJoystickPlugin and in JoystickBlueprintDelegate. The hydra plugin was structured like this to support both C++ events and the interface events, but it did this by forwarding the C++ events to the interface events in BlueprintDelegate, whereas you check for changes and emit the interface events a second time.
          -Add input mapping for the buttons and axis
          -Maybe normalize joystick input to 0-1.0 (but this may be difficult since one joystick may emit a different range from another, mine was 0-65536 (2^16) for all axis and sliders, Pov -1 for neutral, 0-31500 for directions)
          -In events I would recommend merging all the axis values into one event e.g. JoystickAxisMoved(FVector) instead of 3 separate events.
          -My joystick has force feedback and I was wondering if there is a way to control or call vibration from within WinJoystick?

          My test graphs:


          where print functions are defined by


          and

          Last edited by getnamo; 11-05-2014, 06:00 PM.
          Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

          Comment


            #6
            How do I use the joystick plugin? I enabled the plugin but I don't see anything related to joysticks in Edit, Project Settings, Input window.

            Comment


              #7
              Made some updates in a fork and I've made a pull request to have those included in the main branch.

              The updates include:
              -Added input mapping support, drag and drop the actor or component and
              use the input mapping system for quick joystick support
              -Automatically normalizes values into a range of -1.0 to 1.0
              -Events emit controller reference with each event allowing for
              in-context additional value lookup
              -POV changed event now emits a enum type, but can query the controller for
              conversion into POV axis
              -16 input mapping buttons are currently supported, can extend to more
              buttons should the need arise
              -Fixed duplicate event emit bug
              -Trimmed blueprintdelegate, not needed in this plugin context

              While the main branch updates you can get the fork build from here. Please test the update with any joysticks you all have as I'm unsure if I haven't simply 'fixed' the range to my joystick or if the range is more or less the same for all joysticks.

              Example of using the input mapping system to add joystick control to the flying template with a Saitek Evo Force


              Edit:
              Originally posted by jeffmorris View Post
              How do I use the joystick plugin? I enabled the plugin but I don't see anything related to joysticks in Edit, Project Settings, Input window.
              You can use the fork if you want input mapping support now or wait for Ikarus to merge/implement his own version in the main branch. You can also use custom input mapping plugin to add input mapping to the plugin indirectly.
              Last edited by getnamo; 11-06-2014, 12:11 AM.
              Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

              Comment


                #8
                Originally posted by getnamo View Post
                You can use the fork if you want input mapping support now or wait for Ikarus to merge/implement his own version in the main branch. You can also use custom input mapping plugin to add input mapping to the plugin indirectly.
                Hey man, grabbed your fork of the plugin, but still no joystick showing up in Input mapping. I put it in the /Plugins folder of the Engine, rebuilt it (4.5 source), and the enabled the plugin in-editor. Any ideas?

                Thanks!

                Comment


                  #9
                  Hi getnamo!
                  Nice to have you on board. Thank you for your awesome contribution. As I told, I have no experience with the unreal engine plugin architecture and i feel, it lacks documentation. Your hydra source was very well structured and I needed to adapt just small parts of the code. I hope I have not destroyed too much !

                  How did you get your knowledge about the plugin architecture?

                  This plugin was meant to add support for the X52 Pro System, so I need at least 32 Buttons. I have also plans to add MFD-Support. But for now I will try to learn from your contribution to understand a little bit more the architecture of the ue4 plugins.

                  Again, thank you very much for your effort, and I hope to hear from you sometimes!

                  Best regards,
                  Michael
                  Last edited by Ikarus76; 11-06-2014, 04:23 AM.

                  Comment


                    #10
                    Originally posted by HateDread View Post
                    Hey man, grabbed your fork of the plugin, but still no joystick showing up in Input mapping. I put it in the /Plugins folder of the Engine, rebuilt it (4.5 source), and the enabled the plugin in-editor. Any ideas?

                    Thanks!
                    Whoops! It seems due to how the architecture is set up you need to not only have a plugin actor dropped into the scene (or add a component to a blueprint) but you also have to have the joystick plugged in before you launch your project for the input mapping events to show up. Obviously this isn't ideal, I'll have a think and push a fix.


                    Originally posted by Ikarus76 View Post
                    Hi getnamo!
                    Nice to have you on board. Thank you for your awesome contribution. As I told, I have no experience with the unreal engine plugin architecture and i feel, it lacks documentation. Your hydra source was very well structured and I needed to adapt just small parts of the code. I hope I have not destroyed too much !

                    How did you get your knowledge about the plugin architecture?

                    This plugin was meant to add support for the X52 Pro System, so I need at least 32 Buttons. I have also plans to add MFD-Support. But for now I will try to learn from your contribution to understand a little bit more the architecture of the ue4 plugins.

                    Again, thank you very much for your effort, and I hope to hear from you sometimes!

                    Best regards,
                    Michael
                    Thanks for the kind words, I think you did a great job merging the architecture with Direct Input, but maybe we need to rethink the architecture for joysticks a little bit. I agree the plugin architecture isn't well documented, I imagine part of the reason is that epic themselves haven't fully committed to how it's currently set up. That said if you poke around enough you can decipher the way plugins currently work, which is what I did back a while ago. It's a great way to learn how to extend blueprints and get a feel for how memory management is done (because you need cross that line by mixing your custom classes with the unreal uobjects which have garbage collection). Things that are missing from plugin support at the moment are automatic dll copying in packaging for launch and shipping modes (currently have to manually copy dlls to support shipping) and blueprint-only shipping support (right now you have to add dummy code to the project for the plugin to get included). Still haven't heard anything from epic on either of these issues.

                    In terms of this plugin, I was thinking about it and I think most people simply want the input mapping, which is typically not enough by itself for more complicated controllers such as a the Leap, Hydra, or Myo. I wonder if it wouldn't be better to have this as some sort of blueprint library that automatically enables the input mapping for the device and auto-ticks, that way people don't have to add any extra steps to get straight into the binding. The event driven nature is actually completely covered by the input mapping events, so maybe our custom events are not needed. Will tinker around and see what I come up with. Extending the input mapping button support to 32 buttons should be fairly straight forward, if a little copy-paste tedium , but if we want to support all 128 buttons we probably need to make a function jump list since switching for button functions would grow exponentially and a worst case scenario would be 128*128 (16384) operations to check all button events (vs current worst case of 256). We could get away with that though, because I highly doubt any human can push 128 buttons at the same time .
                    Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                    Comment


                      #11
                      The fix was surprisingly simple.

                      Update to 0.2.1, pull request added. See fork to test the update.
                      -Input mapping keys and axis now always get exposed.
                      -Hot-plugging of the joystick is now supported.

                      For now I think this is a good solution, because to support hot plugging otherwise (e.g. automatically ticking plugin) would burden any project which has the plugin enabled with a 'tick check' whenever a joystick isn't plugged in. This way the tick cost is only taken by projects which explicitly choose to add the plugin actor or component and otherwise incurs no runtime cost (the cost in either case is absolutely tiny though).

                      Thought I'd add basic setup instructions here:

                      Installation
                      1. Download
                      2. Create new or choose project.
                      3. Browse to your project folder (typically found at Documents/Unreal Project/{Your Project Root})
                      4. Copy Plugins folders into your Project root.
                      5. Restart the Editor and open your project again. Plugin should be enabled.


                      Setup for Use
                      1. Input mapping should be automatically enabled, so you can setup your input mapping binds. But you will not receive joystick input until you've added either a JoystickPluginActor to the scene, or a JoystickComponent to any of your blueprints
                      2. Option A: JoystickPluginActor for simple input mapping support

                        2.1. Select Class Viewer



                        2.2. Find JoystickPluginActor and drag it into the scene. You can confirm it's in the scene by looking at the Scene Outliner.



                        2.3. You're done. Play around with input mapping!

                      3. Option B: Joystick Component and JoystickInterface. If you want control over the joystick in blueprint directly for more fine-tuned control (scaling/mixing etc) as well as full button support (up to 128) past the 16 currently supported IM, this is the method to use.

                        3.1. add a Joystick Component to the relevant blueprint



                        3.2. add a Joystick Interface to the same blueprint



                        3.3. You're done. Right click on the event graph and type 'Joystick' to narrow your events to Joystick related



                        3.4. You can poll by dragging from the component return node, both latest frame and all events emit a JoystickSingleController reference

                      Last edited by getnamo; 11-06-2014, 01:15 PM.
                      Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                      Comment


                        #12
                        I got my Logitech G27 Racing Wheel working in UE4. Go to Start/Devices and Printers, right-click on G27 Racing Wheel, Choose Properties and Settings, and enable "Combined Pedals". After adding the "Joystick Component" and "Joystick Interface" to the blueprint for controlling the vehicle, go to Edit/Project Settings/Input, and assign the steering wheel to "Joystick Axis X" and the brake/throttle pedals to "Joystick Slider". Set the scale for "Joystick Slider" to -1. I didn't assign anything to the clutch pedal or H-shifter yet.

                        Comment


                          #13
                          I couldn't get the clutch pedal working. I got the H-shifter working. I don't know which joystick axis is used by the clutch pedal.

                          Comment


                            #14
                            Maybe a second slider is used... We should implement the 3 pov and 3 sliders available by directinput.

                            Comment


                              #15
                              Originally posted by jeffmorris View Post
                              I got my Logitech G27 Racing Wheel working in UE4. Go to Start/Devices and Printers, right-click on G27 Racing Wheel, Choose Properties and Settings, and enable "Combined Pedals". After adding the "Joystick Component" and "Joystick Interface" to the blueprint for controlling the vehicle, go to Edit/Project Settings/Input, and assign the steering wheel to "Joystick Axis X" and the brake/throttle pedals to "Joystick Slider". Set the scale for "Joystick Slider" to -1. I didn't assign anything to the clutch pedal or H-shifter yet.
                              I suspected it was possible, but it's awesome that this supports steering wheels as well.

                              Originally posted by Ikarus76 View Post
                              Maybe a second slider is used... We should implement the 3 pov and 3 sliders available by directinput.
                              I agree, I'll leave the DirectInput part to you so have a look if you can extend it and maybe add the Input Mapping extension to 32 buttons.

                              Other possible extensions:
                              -MFD
                              -Vibration/Force feedback (I think it uses this part of direct input, but I haven't found C++ examples of it), I'll take a look at this next week when I get some time.
                              Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                              Comment

                              Working...
                              X