Announcement

Collapse
No announcement yet.

Joystick Plugin

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

    https://drive.google.com/open?id=1T8...84NfLXaXHZWnOW and here it is with the demo project showing how to use it. If you have multiple controllers, don't forget to change the controllerID

    Comment


      Originally posted by tsky View Post

      Hi,
      you can go to my repo (which DescendentStudios forked from). I updated the plugin and the links with an demo.
      tsky​​​​​​​
      Hello, Tsky. May I ask for little help? I am investigating possibility to get joystick axis that are added thru your plugin to remappers. I am guessing, I have to use some axis status/name node that is exposed in Blueprints, but looking at Joystick Plugin nodes (your branches) I am kinda lost. I can get values, i can get joystick overall info, but i am not sure can i get axis status/name/something that can be introduced to re-binders in some menus Blueprints? Could you give some idea about this?
      P.S.: thru your plugin, buttons registers in remappers no problem. Axis - they work, when set in Project Settings - Inputs, but they are not "seen" by remappers in Blueprints. I am guessing some node needs to be added.
      I would really appreciate help on this, very much so. Thanks in advance!

      Comment


        Is now any update?

        Comment


          I've made some changes to the latest version of the plugin for UE4.22 to get it to compile on Ubuntu-18.04 LTS. I'm getting a linker error because it cant find Version.lib, which I think is a Windows Visual Studio library file.

          Code:
          [2/3] Link (ld) libUE4Editor-JoystickPlugin.so
          /project/software/library/unrealengine-4.22/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v13_clang-7.0.1-centos7/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld: cannot find -lVersion.lib
          This is a diff of the changes I've made to commit 4e6fc92c0e77364b70cbc0f7b58020584256fc68 in https://github.com/tsky1971/UEJoystickPlugin

          Code:
          diff --git a/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/DeviceSDL.cpp b/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/DeviceSDL.cpp
          index 62e7578..0178c51 100644
          --- a/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/DeviceSDL.cpp
          +++ b/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/DeviceSDL.cpp
          @@ -12,13 +12,26 @@
           #include <Engine.h>
          
           // @third party code - BEGIN SDL
          +#define HAVE_IMMINTRIN_H 1
          +#if PLATFORM_WINDOWS
          +#if ENGINE_MAJOR_VERSION==4 && ENGINE_MINOR_VERSION==22
          +#include "Windows/AllowWindowsPlatformTypes.h"
          +#else
           #include "AllowWindowsPlatformTypes.h"
          +#endif
          +#endif
          
           #include "SDL.h"
           #include "SDL_joystick.h"
           #include "SDL_gamecontroller.h"
          
          +#if PLATFORM_WINDOWS
          +#if ENGINE_MAJOR_VERSION==4 && ENGINE_MINOR_VERSION==22
          +#include "Windows/HideWindowsPlatformTypes.h"
          +#else
           #include "HideWindowsPlatformTypes.h"
          +#endif
          +#endif
           // @third party code - END SDL
          
           DEFINE_LOG_CATEGORY(JoystickPluginLog);
          diff --git a/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/JoystickDevice.cpp b/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/JoystickDevice.cpp
          index 5e42709..1d64d1b 100644
          --- a/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/JoystickDevice.cpp
          +++ b/Plugins/JoystickPlugin/Source/JoystickPlugin/Private/JoystickDevice.cpp
          @@ -13,7 +13,11 @@
          
           #include <Engine.h>
           #include <SlateBasics.h>
          -#include <Text.h>
          +//#if ENGINE_MAJOR_VERSION==4 && ENGINE_MINOR_VERSION==22
          +#include <Internationalization/Text.h>
          +//#else
          +//#include <Text.h>
          +//#endif
          
           #define LOCTEXT_NAMESPACE "JoystickPlugin"
          
          diff --git a/Plugins/JoystickPlugin/Source/JoystickPlugin/Public/IJoystickPlugin.h b/Plugins/JoystickPlugin/Source/JoystickPlugin/Public/IJoystickPlugin.h
          index ec474c5..20d8b6f 100644
          --- a/Plugins/JoystickPlugin/Source/JoystickPlugin/Public/IJoystickPlugin.h
          +++ b/Plugins/JoystickPlugin/Source/JoystickPlugin/Public/IJoystickPlugin.h
          @@ -2,7 +2,11 @@
          
           #pragma once
          
          +#if ENGINE_MAJOR_VERSION==4 && ENGINE_MINOR_VERSION==22
          +#include <Modules/ModuleManager.h>
          +#else
           #include <ModuleManager.h>
          +#endif
           #include <IInputDeviceModule.h>
          
           /**

          Comment


            getting a pretty odd issue when using a stick as an input axis with this, If i print out the axis outputs of the stick directly, it works fine, all as expected so sticks and the plugin's core is working. But, through inputaxis, with only the one device bound to that axis, some frames it will double the inputaxis value at random. For example, looking at 5 frames: (Pitch left, yaw on right)

            0.128208 | 0.999939
            0.25544 | 0.991211
            0.126621 |0.979247
            0.251411 | 1.926389
            0.124668 | 0.947264

            Sometimes it only doubles one axis and sometimes doubles both... pretty confusing, i imagine it must be happening quite a bit maybe without other people noticing though? Been looking through the source but im not very familiar with this part of the engine and how the inputaxis polling might be double counting.

            Edit: it is framerate dependent. If i limit framerate to 10 it sometimes multiplies the axis value, which is supposed to be at most 1.0, up to around 8. Obviously having axis inputs be framerate dependent is a bit of a nonstarter for an input plugin :s. I will continue to dig but i havent identified a cause yet.
            Last edited by Mattk50; 08-27-2019, 03:04 PM.

            Comment


              Originally posted by Mattk50 View Post
              getting a pretty odd issue when using a stick as an input axis with this, If i print out the axis outputs of the stick directly, it works fine, all as expected so sticks and the plugin's core is working. But, through inputaxis, with only the one device bound to that axis, some frames it will double the inputaxis value at random. For example, looking at 5 frames: (Pitch left, yaw on right)

              0.128208 | 0.999939
              0.25544 | 0.991211
              0.126621 |0.979247
              0.251411 | 1.926389
              0.124668 | 0.947264

              Sometimes it only doubles one axis and sometimes doubles both... pretty confusing, i imagine it must be happening quite a bit maybe without other people noticing though? Been looking through the source but im not very familiar with this part of the engine and how the inputaxis polling might be double counting.

              Edit: it is framerate dependent. If i limit framerate to 10 it sometimes multiplies the axis value, which is supposed to be at most 1.0, up to around 8. Obviously having axis inputs be framerate dependent is a bit of a nonstarter for an input plugin :s. I will continue to dig but i havent identified a cause yet.
              Yes, i'm getting this bug too. I'm using axis directly instead of input events as a workaround.

              Comment


                Im not sure why exactly it multiplies the inputs, but it looks like this plugin is sending it's inputs through Slate somehow before it gets to the inputevents. Im not sure why slate is being used, i looked at the steam controller and oculus plugins and they all use some seemingly more direct messaging system instead and that's apparantly bypassing whatever is happening in slate that messes with the axis values.

                It seems like it may be worth going in and reworking some of the plugin so that it communicates with input events through messaging instead of slate to fix that, but it would be a big task, and it would be nice to know why the original developers of this plugin chose to go through slate to begin with. Im not sure what decisions drove that design but there may be some pretty good reasons behind it.

                Fixing this is a prereq for in-game axis re binding working, i finally got an axis rebinder working but with if using the event binds breaks the inputs its not very usable.

                Comment


                  fixed the problem, now to dissapear into the ether... kidding.

                  after having another look tonight after letting this lie since my last post. I swapped the slate message system to the standard messaging system (that was a learning experience...) but it had no effect. Realized the problem was because of SDL updating at a different tick rate than the joystick module. This makes me worry that the SDL might update at a lower rate than the game tickrate sometimes, but i havent observed that happening yet, only a higher rate.

                  My version of the plugin is a disaster atm so i cant easily push the fix for now, but basically the dumb fix is to create a map of DeviceId to TArrays of axis values in the joystickdevice.h. For each axis (say in JoystickAxis()) get the array of the relevant deviceid and check of that axis is already in the array. If it is, do nothing. If not, send the axis event as usual then add the axis to the array. Then on tick, clear the array, this ensures each axis only gets added to once per tick. If anyone has better ideas or a way to lock the SDL's update rate more properly, do contribute to the discussion.

                  Comment

                  Working...
                  X