Search Unity

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
  2. cachi01

    cachi01

    Joined:
    Sep 20, 2020
    Posts:
    2
    Hello, just wanted to report that ticking or unticking "Input Detection Active" in the Corgi Engine integration Rewired Input Manager component does not do anything, it will keep reading input regardless. I've solved it in my project by just adding the conditional that was in the base method to the one in RewiredInputManager's but I think it's worth fixing in an update.

    Just bought the asset today, it's fantastic. Thanks for such a useful tool.
     

    Attached Files:

  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Wherever this value came from, it didn't come from Rewired. I wrote no code that has an inspector value of "Input Detection Active." You can look at the source code of my integration scripts if you want. That value is not there.

    RewiredCorgiEngineInputManager inherits from MoreMountains.CorgiEngine.InputManager. If the author of Corgi Engine decided to add a new value to the base class, it's going to show up in the inspector because that's how Unity's inspectors for inherited classes work. That's not my doing and I can't control that. The Rewired Corgi Engine integration was written for Corgi engine 4.0. As per the documentation:

    https://guavaman.com/projects/rewired/docs/Integration.html#CorgiEngine
    • Corgi Engine v4.0 (No future version compatibility is guaranteed.)
    The Rewired Corgi Engine Input Manager inspector in the version I built the integration for looks like this, and bear in mind ALL of these values came from the MoreMountains.CorgiEngine.InputManager base class. Rewired adds NO inspector assigned values to the class.

    Capture.PNG

    The RewiredCorgiEngineInputManager script has no serialized fields, and therefore none of them are exposed in the inspector:

    Capture.PNG
     
    Last edited: Aug 13, 2022
  4. kaushalJoshi

    kaushalJoshi

    Joined:
    Jun 21, 2022
    Posts:
    3
    Hi,
    Does anyone have tips for the touch joystick? the default one it comes with is very sensitive and spazzes out with the slightest touch. i have tried playing around with the settings such as dead zone but it doesnt seem to help.
     
  5. ObsidianSpire

    ObsidianSpire

    Joined:
    Sep 13, 2013
    Posts:
    48
    Your website may have gone down. I was looking at it today and kept getting 404 errors.
     
    J0shhT likes this.
  6. J0shhT

    J0shhT

    Joined:
    May 13, 2022
    Posts:
    1
    Your website is down so I can't access any of the documentation. There should be a static HTML or PDF version of the documentation that comes with the package so it can be accessed offline.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Thanks. It's back up. After investigating, it looks like the webhost ran some kind of upgrade script that broke my .htaccess file.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The Touch Joystick has many options to change how it behaves. The joystick definitely should not "spazz out", nor have I ever seen it do that in any of my testing in all the years since I made this. There are no settings that should make that possible either. The only things I can think of are 1) problems in the touch data returned by UnityEngine.Input.GetTouches or 2) Some kind of problem in the setup of the UI (Canvas or other UI components). If you want further help, I'll need a much more detailed description of the behavior and the settings you are using.

    You can use any touch controls you want from the Unity Asset Store or make your own. Rewired's touch controls are nothing more than scripts that feed input into a Custom Controller. An old example is included of making a touch joystick from code and feeding its input into a Custom Controller:
    https://guavaman.com/projects/rewired/docs/Examples.html#custom-controllers-touch
     
  9. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi Guys,
    Does anyone have advice on the most straightforward way to implement swapping of the thumbstick, ie swap left / right...create a new layout or are there other better ways?

    Cheers,

    Stefan
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    That's one of the primary purposes of Layouts. There is not a better way.
     
  11. mtrest

    mtrest

    Joined:
    Mar 27, 2020
    Posts:
    10
    Hi,

    I’m using Rewired in my game and for some reason, sometimes when I call GetLastActiveController after a UI button has been clicked, it registers the keyboard even though I was using the gamepad. Any ideas how I can fix this?

    Thanks,

    Max
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There is no code path that would result in what you describe.

    You didn't tell me which GetLastActiveController you were using (Player or ReInput.controllers) and it does matter because they're very different. But regardless, there is no scenario where Keyboard would ever be selected as the last active controller after pressing a button on a different controller. These functions are nothing but comparisons of the timestamp of the last active (non-zero) element on every controller, or in the case of the Player version, of Actions. The only way Keyboard would ever be set as the last active controller would be if 1) No other controllers are connected 2) No other controller has ever contributed any input 3) A key on the keyboard is being pressed, making it take priority. Something else is happening here and I don't have enough information to make a guess at what that is.
     
  13. mtrest

    mtrest

    Joined:
    Mar 27, 2020
    Posts:
    10
    Thanks for the response! I'm using the ReInput.controllers and basically once you start the game if you click on the first selected button, it sometimes doesn't read the last active controller correctly. For some reason if I change the input source this seems to resolve the issue. Any ideas?
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    What do you mean "Click on the first button." Are you talking about clicking on a button with the mouse? If that's the case, the last active controller will be the mouse. The ONLY way the last active controller would be set to Keyboard is if a keyboard key is stuck on. There is no other possibility. The Keyboard cannot become the last active controller if the mouse or a joystick has activated a button/axis after the last pressed keyboard key. It's simply a matter of timestamp comparison.

    What platform is this on?
    What Primary Input Source do you have selected for this platform?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Do you have software installed that creates keyboard key events from game controlers? JoyToKey comes to mind...
     
  16. mtrest

    mtrest

    Joined:
    Mar 27, 2020
    Posts:
    10
    No, I'm using the Rewired event system and using the joystick to click on the buttons. I'm using Windows 11 with raw input. I don't have any software that creates key events from game controllers. I've switched to XInput and this has resolved the issue but I would rather use raw input due to it's advantages.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You would normally use Raw Input + XInput together.

    Rewired cannot possibly create keyboard key events from a controller event. So if this is what is happening, something outside Rewired is doing it. Are you using Steam by any chance? Steam does have the ability to make a gamepad produce keyboard key events.

    Use Debug Information and open the keyboard controller and look at the values of all the keys as you press buttons. If any keyboard key is activating when you press a button, you can be assured something is generating keyboard events from the gamepad buttons.

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    You must click in the Game window before pressing buttons or the application will ignore these events.
     
    Last edited: Aug 20, 2022
  18. samanabo

    samanabo

    Joined:
    Mar 10, 2015
    Posts:
    51
    Hi I had a question about displaying glyphs for the mouse and for custom controllers (like an on screen touch controller).
    I'm following the example here: https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-controller-specific

    Everything is working well for joysticks/gamepads. I'm using the built-in HardwareJoystickMaps to easily connect the elementIdentifiers up to glyphs, in the exact same way as in the example. However, for the mouse there doesn't seem to be a HardwareJoystickMap, and the example does not include a mouse.

    I know this data exists somewhere since the InputManager editor will display a list of mouse hardware elements, but I could not find specific hardware maps or a template hardware map in the included files.

    What is the best approach for displaying/connecting glyphs to element identifiers, for the mouse and for a custom controllers? Should I create my own HardwareJoystickMap for a generic mouse and custom controllers?

    I previously was using a dictionary to match up the hardware guid, and a list of elementIdentifierIds and the glyphs I wanted to display, but connecting the HardwareJoystickMaps scriptable objects is a lot less fragile. So looking for a solution that can be hooked up with scriptable objects if possible.

    Thanks for the help!
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Mouse and Keyboard do not have HardwareJoystickMaps (controller definitions). They are simply hard-coded to have a fixed number of keys and/or buttons/axes. They were designed to mirror the capabilities of UnityEngine.Input's keyboard and mouse support.

    The glyph documentation links two CSV files for these controllers:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-keyboard
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-mouse

    Custom Controllers also do not have controller definitions and need to be matched on Guid as well. They exist only as serialized data in the Rewired Input Manager component.

    The attached zip contains an example I wrote for someone who couldn't write their own code to support keyboard and mouse glyphs using the example code provided in the docs.
     

    Attached Files:

    Last edited: Aug 21, 2022
    samanabo likes this.
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    samanabo likes this.
  21. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    69
    Hello,

    I was wondering if I could get some help with setting up the same button to work with different ActionCategories based on context.

    The code I'm trying looks like this:

    Code (CSharp):
    1.  if (replayer.GetButtonDown(RewiredActions.UIUp))
    2.                     {
    3.                        /// code to navigate up
    4.                     }
    5.                     else if (replayer.GetButtonDown(RewiredActions.UIDown))
    6.                     {                      
    7.                        /// code to navigate down
    8.                     }
    The setup looks like this (there are two ActionCategories, "Default" and "UIControlMapper"):



    The DPad buttons are all mapped to actions that belong to two different ActionCategories. In the code, none of the "UIControlMapper" ActionCategory actions return true. Is it not correct to assign the same button to multiple ActionCategories and use them in different contexts in code?

    Thanks!
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Action Categories have no effect on code at all. They are nothing more than an organizational tool.

    So your question is, "why isn't input working", and the answer to that is always to use Debug Information:
    https://guavaman.com/projects/rewir...l#debug-information-diagnosing-input-problems

    Follow that list.

    By far, the most common reason for the symptom you are describing is loading of outdated saved XML data, overwriting your changes you just made in the Rewired Input Manager:

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#works-in-editor-not-in-build

    That link describes the issue even though the title of it doesn't sound like it. The cause is the same.
     
    fairchild670 likes this.
  23. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    69
    Thank you! Clearing the PlayerPrefs did the trick.

    Appreciate the help!
     
  24. Tretiak

    Tretiak

    Joined:
    Jan 22, 2018
    Posts:
    49
    Hi I started using rewired and want to ask, if its okay if I dont add those inputs in unity input manager that is asked for me during installation. I want to make game compatible only with keyboard, mouse, and xbox controller for windows, linux and maybe mac
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No, it's not. They are not optional. They are required for mouse input on most platforms. And it will sit there throwing exceptions without them. The dialog tells you they are required.
     
  26. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    69
    Hello, I have a question concerning custom input mapping and how to have polling ignore certain buttons and actions.

    I've set up two MapCategories, one as the "Default" and another as the "UIControlMapper". The "UIControlMapper" one has "User Assignable" unchecked.



    I've added Joystick element maps for both categories, one has "Default" action category actions. The other has UI specific actions (also assigned to a "UIControlMapper" action category for consistency).



    The problem I'm currently running into is when I poll for a button press, Rewired is showing there is a conflict for actions that belong to the "UIControlMapper" MapCategory. For example, in my setup for a Joystick "R1" may not be assigned to anything in the "Default" MapCategory but is used in the "UI" MapCategory. If I start polling for a button press and press "R1" it returns an event that there is a conflict because it's used in the "UIControlMapper" MapCategory. In this example it's "UIAltRight".

    I thought because "User Assignable" is unchecked for the "UIControlMapper" MapCategory, it would be excluded from any conflicts. But that does not appear to be the case.

    Is there a way to limit the polling and conflicts to the "Default" MapCategory? I've even tried disabling the "UIControlMapper" MapCategory and ActionElementMaps for all UI buttons and it still doesn't work. I'm afraid I'm missing something.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    https://guavaman.com/projects/rewired/docs/HowTos.html#conflict-checking

    "This conflict checking is configurable independently each way, so if you want one Map Category to conflict check against another but not vice versa, this is possible."

    First, "User Assignable" does not determine whether conflict checking occurs or not. Hover the mouse pointer over the label.

    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#MapCategories

    User Assignable
    Determines whether this category appears in certain lists. Also determines whether element assignments can be automatically removed by conflict checking. If not user assignable, conflict checking cannot automatically remove the assignments. This can be used to protect certain elements and prevent the user from mapping actions to those elements which are used for system actions. For example, ESC.

    Check Conflicts With Specific Categories
    Add specific categories you want to allow conflict checking against. Note that this is not a two-way setting. It only affects conflict checking from controls in this category to the other category. If you want to enable/disable checking for the reverse direction, you must set it in the other category.

    If you want to ignore the UIControlMapper category when you are mapping in the Default category, disable Check Conflicts with All on Default, enable Check Conflicts with Specific Categories on Default and add only the Default category to the list.
     
    fairchild670 likes this.
  28. fairchild670

    fairchild670

    Joined:
    Dec 3, 2012
    Posts:
    69
    Thank you again, that did the trick!! Can't believe I missed that check box.
     
  29. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    Hi, I'm having exactly the same issue, I'm using A for Jump and UISubmit and when remapped I can no longer use it to submit again. Happens only on gamepad but not on keyboard.

    This user managed to fixed, but it seems they don't really know how.

    How could I fix that?

    EDIT:

    I just tried to separate the inputs by creating two maps categories and see if that fixed the issue, but the map category created for the ControllerMapper does not work:




    The debug information, shows the correct category and layout are enabled.


    This is how the Joystick Controller Mapper Category is set (it's the same for keyboard).



    And this is how I enable/diable the categories.

    Code (CSharp):
    1.  
    2. //controller mapping - setup on boot
    3.  
    4. var ruleSetMapper1 = ReInput.mapping.GetControllerMapEnablerRuleSetInstance(2);
    5. var ruleSetMapper2 = ReInput.mapping.GetControllerMapEnablerRuleSetInstance(3);
    6.  
    7. m_player.controllers.maps.mapEnabler.ruleSets.Add(ruleSetMapper1);
    8. m_player.controllers.maps.mapEnabler.ruleSets.Add(ruleSetMapper2);
    9.  
    10. m_player.controllers.maps.mapEnabler.Apply();
    11.  
    12. DisableUIMapCategory();
    13.  
    14.  
    15.  
    16.  
    17. public void DisableUIMapCategory()
    18. {
    19.         foreach (var ruleSet in m_player.controllers.maps.mapEnabler.ruleSets)
    20.         {
    21.             ruleSet.enabled = ruleSet.tag.Equals("ControllerMapperDF");
    22.             ruleSet.rules[0].enable = ruleSet.tag.Equals("ControllerMapperDF");
    23.         }
    24.      
    25.         m_player.controllers.maps.mapEnabler.Apply();
    26. }
    27.  
    28. public void EnableUIMapCategory()
    29. {
    30.         foreach (var ruleSet in m_player.controllers.maps.mapEnabler.ruleSets)
    31.         {
    32.             ruleSet.enabled = ruleSet.tag.Equals("ControllerMapperUI");
    33.             ruleSet.rules[0].enable = ruleSet.tag.Equals("ControllerMapperUI");
    34.         }
    35.  
    36.         m_player.controllers.maps.mapEnabler.Apply();
    37. }
    Thanks!
     
    Last edited: Sep 1, 2022
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Read my response to that message directly below it:

    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-122#post-5693809

    Assignment conflict checking must be configured per Controller Map Category:
    https://guavaman.com/projects/rewired/docs/ControlMapper.html#conflict-checking

    It is not possible to use a single Controller Map category for this purpose because conflict checking rules are based on Map Category.

    I don't see anything showing you ever assigned this Map Category to be assigned to the Player on start for Joysticks. See the Players page.

    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Players

    Simply defining a Controller Map does nothing but create a new map in the database. Without actually loading in a Player or setting it to be loaded in a Player on start, it's does nothing. You would be able to see this using Debug Information:

    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  31. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    What is the best way to detect any input has been just occurred? (no matter the controller type - keyboard, gamepad, mouse etc)

    What I am trying to do is to whenever ControllerType changes, going to change Tutorial's key icon to be updated.

    Ideally something like:
    Code (CSharp):
    1.  ReInput.ControllerTypeChangedEvent += ResetTutorialInputIcon;
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller
     
  33. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
  34. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Hi,

    I want to remove any Rewired data in userDataStore and any other data related to control mappings forcefully.
    I updated the Rewired to latest version(1.1.43.0) but I can't get the Restore Defaults in Control Mapper really work.
    It refuses to remove datas outside of the default category. After restoring many times in Control Mapper by selecting different map and action categories I'm still seeing old actions and mappings in rewired debug window. There is no function in ReInput.userDataStore to clear all data. Please give us a way to remove all user data.

    Edit after 20 minutes: After opening closing Rewired Editor multiple times, clicking on Restore Defaults in Control Mapper multiple times, play/quit game multiple times I've been able to remove user data but I'm not sure how it's happened. I just want a single line of code to remove all user data in Rewired.

    Edit 2: Again the mappings are broken after restarting the game.
     
    Last edited: Sep 2, 2022
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Control Mapper cannot remove all previously saved user data because of the limitations of PlayerPrefs which is used by the UserDataStore_PlayerPrefs component. This is documented:

    Limitations:

    UserDataStore_PlayerPrefs is not the be-all, end-all, automatic data storage system. It has limitations. It does not fully automate everything so you can just set it and forget it. It provides an interface for you to save/load data as necessary for the needs of your game. This sometimes requires manual calls to functions to make data save or load at a particular time. Functionality beyond what is described above is up to the user to implement if desired. UserDataStore_PlayerPrefs is a minimum viable product designed for the most common use case needs and was primarily designed for Control Mapper.

    PlayerPrefs itself has significant limitations and negatives, for example, it isn't possible to clear only Rewired's save data from PlayerPrefs without wiping out all other PlayerPrefs data. If this is something you anticipate needing to do for whatever reason, do not use UserDataStore_PlayerPrefs and instead implement your own extension of the UserDataStore class that saves/loads data to whatever storage system you desire so you can have more control over how data is stored and managed.

    If you need to save which Controller Maps are currently assigned to a Player, for example if you've manually loaded an alternate layout at some point and you want that new layout to be loaded the next time you call UserDataStore.Load instead of the default defined in the Rewired Input Manager, you will have to make a new UserDataStore class extension that can handle these special needs. Copy the UserDataStore_PlayerPrefs, change the class name, and make any modifications necessary to what data is saved and loaded.

    The Restore Defaults button does not remove saved user data. It simply loads the default Controller Maps you assigned to the Player in the Rewired Input Manager. If a Joystick is not connected and assigned to the Player when you press it, it will not do anything at all for that or any other Joysticks because of how loading of Joystick Maps work with regard to Players.

    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#joystick-maps

    How Joystick Maps are Loaded
    Joystick Maps for a particular Joystick do not exist in the Player unless that Joystick is currently connected and assigned to that Player. By default, Rewired auto-assigns Joysticks to each Player as controllers are detected. The Joystick Maps are loaded at assignment time based on the settings defined in the Rewired Input Manager - Player page for that particular Player.

    ------------------

    The code that is executed when Restore Defaults is pressed is this:

    Code (csharp):
    1. private void OnRestoreDefaultsConfirmed(int windowId) {
    2.             if(_restoreDefaultsDelegate == null) {
    3.                 IList<Player> players = ReInput.players.Players;
    4.                 for(int i = 0; i < players.Count; i++) {
    5.                     Player player = players[i];
    6.                     if(_showControllers) player.controllers.maps.LoadDefaultMaps(ControllerType.Joystick);
    7.                     if(_showKeyboard) player.controllers.maps.LoadDefaultMaps(ControllerType.Keyboard);
    8.                     if(_showMouse) player.controllers.maps.LoadDefaultMaps(ControllerType.Mouse);
    9.                 }
    10.             }
    11.             CloseWindow(windowId);
    12.             if(_restoreDefaultsDelegate != null) {
    13.                 _restoreDefaultsDelegate();
    14.             }
    15.         }
    You can see it is calling player.controllers.maps.LoadDefaultMaps for each controller type in every Player. This simply loads into the Player the Controller Maps you defined to be loaded on start in the Player on the Players page of the Rewired Input Manager.

    If you are trying to clear all saved user data, you must clear Player Prefs if your're using UserDataStore_PlayerPrefs. There is no other way. PlayerPrefs has no means of searching keys to find all Rewired keys and only clear those. And there are unlimited possible keys created by user data because the joystick name as reported by the device and other hardware-dependent information are part of the key.

    https://docs.unity3d.com/ScriptReference/PlayerPrefs.DeleteAll.html
     
    kopanz likes this.
  37. joelsinbarba

    joelsinbarba

    Joined:
    Dec 21, 2016
    Posts:
    16
    Hi! I was really happy to find out that the GameController framework was added. I've been experimenting with it already, and I use gyro quite a lot so (Using the ds4 demo):
    Feedback:
    - Sometimes the gyro value jumps around, skipping some values thus making it not smooth. Is there anything that may cause this?
    - Gyro does not work when GameController is selected as the main option. Doing some testing with Apple's unityplugins, I tested that GameController does support gyro but not accelerometer. Would it be possible to have it working?
    - Changing the dualshock, dualsense light is not working for me. This is also supported by GameController.

    .....
    Good stuff:
    - Vibration works, over bluetooth. Awesome!!
    - Gyro is working over bluetooth in native mode. What?! How?! :D

    Keep up the good work!
     
  38. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Thank you for your detailed response.
    I'll read all of them and implement map loading.
    I'm OK with deleting all PlayerPrefs as normally I have a custom game settings system that saves to a binary file in "My Documents/GameName" folder.
    This action mapping resetting thing is very confusing. Sorry for writing here about it often.
    But my game is actually in production and the players are very ruthless about any little problem.
    I have no option to make a mistake :)
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Accelerometer and gyro values are coming directly from Game Controller Framework. I don't add filtering to correct what the system itself is sending. Unless you're talking about Orientation, which is created from gyro and acceleration.

    That should not be possible. There are zero code differences on the GCController side when setting the primary input source to Game Controller or using I/O Kit as the primary with Game Controller Framework as an option. The GCController code path for all controller input is entirely independent and does not change depending on what you choose as the primary input source. If this is happening, then there is no possibility other than it is some kind of Apple bug not activating the PS4 mode of the controller when connected. I have seen quite a few bugs in the Apple framework not handling a lot of things right including known problems with vibration. Another thing I've seen is that vibration, gyro, and other special features of the DS4 frequently fail to work after the controller is connected wirelessly. The only thing that can make it work is disconnecting and reconnecting the controller. Again, this is on Apple's end, not Rewired's.

    It wasn't the last time I checked. In my code:

    /// NOTE: This is not supported in Apple Game Controller API and is therefore not implemented.
    void IDualShock4Extension.SetLightColor(Color color)

    Apple wrote a driver that could do it and included it with MacOS for GCController. The functionality is internal to GCController. There was never any reason it should have worked on Windows but not on Mac. Sending the exact same output report to the device in IO kit fails to activate PS4 mode on the controller while it works on Windows. This has always been an issue with I/O Kit. Apple apparently found a workaround that is not available to the public.
     
    Last edited: Sep 2, 2022
    joelsinbarba likes this.
  40. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Hi, can we use Rewired with New Input System?
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#not-compatible-unity-new-input-system

    Compatibility with Unity's "new" input system
    Update: As of Unity 2021.2.0f1, Rewired can now work alongside Unity's new input system on Windows. If you need to use both Rewired and Unity's new input system simultaneously, update to Unity 2021.2.0f1+. To use both together, use the following setting:

    Player Settings -> Active Input Handling -> Both

    Note: The only platform with known issues running both systems together was Windows Standalone. If other incompatibilites exist on other platforms, they are currently unknown and untested.

    For versions prior to 2021.2.0f1:

    Rewired is not compatible with Unity's new input system. If you enable the new input system by setting this value to "Input System" or "Both", Rewired and/or Unity's input system may not function at all or parts of each system may not function correctly. While some platforms may work, others may not.

    The only setting supported by Rewired is:
    Player Settings -> Active Input Handling -> Input Manager

    --------------

    Rewired cannot use the new input system as a source of input. I would have to 1) write a new, new Unity input system input source manager 2) remap every single device on every single platform for the new input system. Even then, it would only be using the new input system backend, not any of their Action/Player stuff which is redundant with Rewired. There is no benefit for me to do this and it would take months of time to accomplish.
     
    Last edited: Sep 3, 2022
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I just went back and implemented this, but there are all kinds of issues. See below.

    Game Controller Frame work has some serious problems communicating with these controllers. It took me about 5 tries of unpairing and repairing the DS4 to get the special features to work. Disconnecting and reconnecting the controller wasn't changing anything, and neither was quitting and restarting the Unity Editor. Only unpairing and repairing helped. Dual Sense was even worse. It would go into a weird state where it was accepting vibration but not providing any gyro/accelerometer data and not taking most set light commands. Maybe one set light command would get applied on first connect, and then no more. After many unpair and repairings, I was able to get all features working on the Dual Sense.

    This is going to be a huge support headache. Rewired can't make something work if the underlying OS API isn't working. I'm going to have to add yet more known issues in Apple's API.
     
  43. joelsinbarba

    joelsinbarba

    Joined:
    Dec 21, 2016
    Posts:
    16
    Hey! Thank you so much for the quick iteration on this.
    When I tried to implement a partial solution as a CustomController for Rewired, I had something similar happen to me.
    What worked was forcing "sensorsActive" to be true on every update and before getting the gyro/accelerometer data, instead of on initialisation as one would expect. Stupid, yes.
    Hopefully this helps!
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Thanks for the info. If that workaround makes the sensors activate consistently, that's one issue, there are many other issues I was experiencing. For example, I kept having to unpair and re-pair the DS4 because it kept reporting zero vibration motors. This isn't something setting sensors active would affect. And vibration motors must be present when creating the device or Rewired will not support them. The controller properties are not mutable. Also the Dual Sense ignoring light color commands wouldn't be helped either.

    I also wonder if setting sensors active sends a command to the controller. If it does, setting it every frame could be a problem. I had to put in place measures to move vibration commands to a separate thread many years ago and prevent vibration commands from being sent to controllers every frame because of massive slowdowns.
     
  45. joelsinbarba

    joelsinbarba

    Joined:
    Dec 21, 2016
    Posts:
    16
    I'll keep an eye on updates here! At this moment gyro is my main requirement so I'd be happy with that working consistently. I did look out for slowdowns in my version and did not see any, however I did not do an exhaustive comparison. I imagine in any case we can have a checkbox on the OSX options if the performance impact is considerable.
    I'm open for helping test/debug with macos and a dualsense and dualshock 4 controllers.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Well, after implementing it, I'm not finding anything to be working any better than before. In fact, it might be worse. Out of 6 or 7 connection attempts with the DS4, I was only able to get motion sensors and vibration to work once -- the first time I paired. After the first controller power off and then back on, I am unable to ever get vibration motors or sensors to work. I am calling the function to set the sensors active every time any get motion sensor data function is called, limited to calling that function once per second. I have never seen it recover, having sensors start working after the fact. They either work on start or they don't work at all. And I'm also getting entire system stalls (can't move the mouse pointer) for 2-10 second after connecting the DS4 to the system sometimes. This all just seems horribly broken.
     
    Last edited: Sep 4, 2022
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Even hammering sensorsActive every frame doesn't change anything. When the DS4 doesn't want to work, it just doesn't work and nothing short of unpairing and repairing as many times as it takes will make it work. In this state, while the vibration motors are reported as present by GCController, they do nothing. Same thing with motion sensors and the light. Changing the light color has no effect even though the GCController is reporting it has a light and the GCDeviceLight is accepting commands (verified by logging). Note that, as far as I've seen, the controller's buttons and axes always work. So all of these problems are related to the controller's advanced features mode, which has never even been possible to enable in the past on MacOS when connected wirelessly. Clearly Apple still has work to do to make this work correctly.
     
    Last edited: Sep 4, 2022
  48. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No there isn't and I don't understand why you would need a function to tell you that any input occurred on any controller in order to display glyphs for the last used controller.

    Your original message said:
    That can easily be done by using ReInput.controllers.AddLastActiveControllerChangedDelegate and updating your icons when it changes. Or if you just want to know the type and not the specific controller, poll ReInput.controllers.GetLastActiveControllerType.

    I don't see any benefit at all to getting an "any input occurred event" and then checking the last active controller. There's no difference in result vs simply getting the last active controller by event or by polling. If you're expecting it would save some processing time doing it that way, it wouldn't.
     
  50. marchall_box

    marchall_box

    Joined:
    Mar 28, 2013
    Posts:
    139
    ReInput.controllers.AddLastActiveControllerChangedDelegate <-- this was exactly what I was looking for! thank you :)