Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    Hey, so I'm getting a crash on exiting the built app. I'm fairly sure it's just that I'm not shutting things down correctly or something, but the actual error is happening within Rewired, so I figured I'd come here for some guidance.

    The relevant part of the stack trace is:

    Cannot create web request without initializing the system
    UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
    UnityEngine.DebugLogHandler:LogException (System.Exception,UnityEngine.Object)
    UnityEngine.Logger:LogException (System.Exception,UnityEngine.Object)
    UnityEngine.Debug:LogException (System.Exception)
    UnityEngine.EventSystems.ExecuteEvents:Execute<UnityEngine.EventSystems.IPointerExitHandler> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<UnityEngine.EventSystems.IPointerExitHandler>) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:276)
    UnityEngine.EventSystems.BaseInputModule:HandlePointerExitAndEnter (UnityEngine.EventSystems.PointerEventData,UnityEngine.GameObject) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInputModule.cs:211)
    Rewired.Integration.UnityUI.RewiredPointerInputModule:ClearSelection () (at C:/Users/samba/Documents/Beyond These Stars/Assets/Plugins/Rewired/Integration/UnityUI/RewiredPointerInputModule.cs:522)
    Rewired.Integration.UnityUI.RewiredStandaloneInputModule:DeactivateModule () (at C:/Users/samba/Documents/Beyond These Stars/Assets/Plugins/Rewired/Integration/UnityUI/RewiredStandaloneInputModule.cs:661)
    UnityEngine.EventSystems.EventSystem:OnDisable () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:466)



    So the short version is it looks like Rewired is throwing an exception after the web reporting systems have been shut down, and it looks like sending a web request at that point is counted as a Fatal Error -> Crash. My actual question is what (if anything) do I need to be doing at exit to make sure that Rewired will shutdown cleanly and not generate whatever exception this is? As far as I can tell I'm removing any events I've attached to. I do have a call to RemoveLastActiveControllerChangedDelegate that I'm deliberately *not* making, as I'm checking ReInput.isReady and it's false at that point
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    Rewired is not throwing this exception. Something receiving an event from Unity's Event System is. See the stack trace. The last line that involves any Rewired code is highlighted in red. The line that is throwing the exception is highlighted in blue: UnityEngine.EventSystems.ExecuteEvents.Execute<UnityEngine.EventSystems.IPointerExitHandler>.

    Cannot create web request without initializing the system
    UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
    UnityEngine.DebugLogHandler:LogException (System.Exception,UnityEngine.Object)
    UnityEngine.Logger:LogException (System.Exception,UnityEngine.Object)
    UnityEngine.Debug:LogException (System.Exception)
    UnityEngine.EventSystems.ExecuteEvents:Execute<UnityEngine.EventSystems.IPointerExitHandler> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<UnityEngine.EventSystems.IPointerExitHandler>) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:276)
    UnityEngine.EventSystems.BaseInputModule:HandlePointerExitAndEnter (UnityEngine.EventSystems.PointerEventData,UnityEngine.GameObject) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInputModule.cs:211)
    Rewired.Integration.UnityUI.RewiredPointerInputModule:ClearSelection () (at C:/Users/samba/Documents/Beyond These Stars/Assets/Plugins/Rewired/Integration/UnityUI/RewiredPointerInputModule.cs:522)
    Rewired.Integration.UnityUI.RewiredStandaloneInputModule:DeactivateModule () (at C:/Users/samba/Documents/Beyond These Stars/Assets/Plugins/Rewired/Integration/UnityUI/RewiredStandaloneInputModule.cs:661)
    UnityEngine.EventSystems.EventSystem:OnDisable () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:466)

    This issue doesn't have anything to do with Rewired shutting down or the ReInput class in any way.

    Rewired is only involved in this stack trace because it is designated as the Input Module for the EventSystem. OnDisable is called on the EventSystem, then that apparently calls ClearSelection() on whatever PointerInputModule happens to be associated to that EventSystem. It happens to be Rewired, in your case. PointerInputModule.ClearSelection() then calls BaseInputModule.HandlePointerExitAndEnter(), presumably to clear any mouse highlighting on UI elements when the component is disabled.

    This is the source code from Unity's PointerInputModule. You will see it makes the same call as Rewired's PointerInputModule (Rewired's is heavily based on Unity's):

    Code (csharp):
    1. protected void ClearSelection()
    2.         {
    3.             var baseEventData = GetBaseEventData();
    4.  
    5.             foreach (var pointer in m_PointerData.Values)
    6.             {
    7.                 // clear all selection
    8.                 HandlePointerExitAndEnter(pointer, null);
    9.             }
    10.  
    11.             m_PointerData.Clear();
    12.             eventSystem.SetSelectedGameObject(null, baseEventData);
    13.         }
    This is Rewired's version of the same function. The only difference is that Rewired can handle multiple pointers (PlayerMouse software pointers).
    Code (csharp):
    1. protected void ClearSelection() {
    2.             var baseEventData = GetBaseEventData();
    3.  
    4.             foreach(var playerSetKVP in m_PlayerPointerData) {
    5.                 var byIndex = playerSetKVP.Value;
    6.                 for(int i = 0; i < byIndex.Length; i++) {
    7.                     foreach(var buttonSetKVP in byIndex[i]) {
    8.                         // clear all selection
    9.                         HandlePointerExitAndEnter(buttonSetKVP.Value, null);
    10.                     }
    11.                     byIndex[i].Clear();
    12.                 }
    13.             }
    14.             eventSystem.SetSelectedGameObject(null, baseEventData);
    15.         }
    I have absolutely no idea why the fact that Unity's EventSystem is sending a pointer exit event is resulting in a web request of some kind. My first guess is that you have some UI element or something that implements IPointerExitHandler in your scene that is responding to a pointer exit event by making a web request and it is invalid to do so during application shutdown.
     
  3. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    Thank you so much, that's much clearer! :)
     
  4. The_wARmAcH1n3

    The_wARmAcH1n3

    Joined:
    Aug 5, 2023
    Posts:
    126
    I don't get rid off this warning: Rewired Control Mapper: 22 is not a valid Action id!

    I have looked everywhere, I don't find any action id 22. I don't know how to delete this id 22. The warning happens only in the options-scene where the controlmapper is. I use everything as a prefab.

    Another question about the update. I use the "Rewired Event System", "Rewired Initializer" and the "Rewired Input Manager" as a perfab in my own game folder. The Rewired folder is untouched. Now there was an update of your Rewired in the packed manager. I have it updated. Are now my prefabs in my own gamefolder updated too? Or is there any action needed to update my prefabs?
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658

    https://guavaman.com/projects/rewired/docs/ControlMapper.html#inspector-options



    This is either linked to the wrong Rewired Input Manager prefab or else you have selected some Action in the inspector which no longer exists. Any inspector field that allows selection of an Action could be using outdated information if you once had a different Rewired Input Manager linked or once selected an Action from a dropdown that no longer exists. Check all your fields.





    Your prefabs contain nothing but data. There is nothing to be updated.
     
    The_wARmAcH1n3 likes this.
  6. The_wARmAcH1n3

    The_wARmAcH1n3

    Joined:
    Aug 5, 2023
    Posts:
    126
    Thanks, I got the warning away, the error was in the screen control actions.
     
  7. BlooBaba

    BlooBaba

    Joined:
    May 10, 2020
    Posts:
    3
    Hey @guavaman, really appreciate the work you've done on Rewired.

    Using the SimpleControlRemapping as a start I have my own script that updates the InputMapper. The issue I'm having is that when I remap a button/key to an action that is already assigned to another button/key, that action seems to be removed from the controller map.

    Code (CSharp):
    1.  
    2. private IEnumerator StartListeningDelayed(int actionId, Button chosenButton) {
    3.  
    4.         int mapID = 0;
    5.  
    6.         foreach (var item in controllerMap.ElementMapsWithAction(actionId)){
    7.          
    8.             if (item.actionId == actionId) {
    9.  
    10.                 mapID = item.id;
    11.  
    12.             }
    13.  
    14.         }
    15.  
    16.         // Don't allow a binding for a short period of time after input field is activated
    17.         // to prevent button bound to UI Submit from binding instantly when input field is activated.    
    18.         yield return new WaitForSecondsRealtime(0.1f);
    19.  
    20.         // Start listening
    21.         inputMapper.Start(
    22.             new InputMapper.Context() {
    23.                 actionId = actionId,
    24.                 controllerMap = controllerMap,
    25.                 actionRange = controllerMap.GetElementMap(mapID).axisRange,
    26.                 actionElementMapToReplace = controllerMap.GetElementMap(mapID)
    27.             }
    28.         );      
    29.  
    30.         // Disable the UI Controller Maps while listening to prevent UI control and submissions.
    31.         player.controllers.maps.SetMapsEnabled(false, uiCategory);
    32.  
    33.         // Update the UI text
    34.         listening.text = "Listening...";
    35.  
    36.         chosenButton.image.sprite = listeningQuestionMark;
    37.  
    38.     }
    Example: If action Punch is assigned 'P' and action Kick is assigned 'K'. If I remap Punch to the 'K' key, then the Kick action is removed from the map.

    The strange part is that the InputMapper.mappingcontext has the correct Count of actions, but in the function below, the same count is decreased by 1.

    Code (CSharp):
    1.  
    2. private void OnInputMapped(InputMapper.InputMappedEventData data) {              
    3.         CheckControllerType(controller);
    4.     }
    Hopefully I'm just missing something obvious, but any help would be appreciated. I'd be more than happy to share more code if needed.
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    See InputMapper.Options:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_InputMapper_Options.htm

    https://guavaman.com/projects/rewir...er_Options_defaultActionWhenConflictFound.htm

    The default defaultActionWhenConflictFound is ConflictResponse.Replace.

    From the Input Mapper documentation:
    https://guavaman.com/projects/rewired/docs/InputMapper.html#conflicts

    6. Handle assignment conflicts (optional)

    Conflict checking is enabled by default in InputMapper.Options. See How To's - Conflict Checking for more information.

    If you subscribed to the InputMapper.ConflictFoundEvent, you will receive a notification when a conflicting assignment was found during input mapping. The object returned contains complete information about the assignment, the conflicts that were found, and provides a callback to be used to respond to the event.

    Code (csharp):
    1. private InputMapper.ConflictFoundEventData conflictData;
    2.  
    3. void OnConflictFound(InputMapper.ConflictFoundEventData data) {
    4.    conflictData = data; // store the event data for use in user response
    5.  
    6.    if(data.isProtected) { // the conflicting assignment was protected and cannot be replaced
    7.        // Display some message to the user asking whether to cancel or add the new assignment.
    8.        // Protected assignments cannot be replaced.
    9.        // ...
    10.  
    11.         // ... After the user has made a decision
    12.        conflictData.responseCallback(InputMapper.ConflictResponse.Cancel); // cancel polling
    13.  
    14.    } else {
    15.        // Display some message to the user asking whether to cancel, replace the existing,
    16.        // or add the new assignment.
    17.        // ...
    18.  
    19.         // ... After the user has made a decision
    20.  
    21.         // Tell the Input Mapper to replace the conflicting assignments
    22.        conflictData.responseCallback(InputMapper.ConflictResponse.Replace);
    23.    }
    24. }
    If you do not subscribe to the ConflictsFoundEvent and you have left conflict checking enabled in the Options.checkForConflicts property, the default action specified in Options.defaultActionWhenConflictFound will be used to resolve the conflict(s).
     
  9. BlooBaba

    BlooBaba

    Joined:
    May 10, 2020
    Posts:
    3
    Oh my goodness, I didn't think to check the conflicts since the mappings were happening. Thank you for your time, I got a solution working with the event checks. :)

    Ugh and the reason is it doesn't happen in the SimpleControlRemapping is because it's (re-)creating UI based on the default actions in the category... dang.
     
  10. joonturbo

    joonturbo

    Joined:
    Jun 24, 2013
    Posts:
    78
    Using Rewired 1.1.51.0.U2021, is there a way to detect and use Steam Controller?

    controller.GetExtension<SteamControllerExtension>()


    doesn't work since SteamControllerExtension is internal.


    edit: I assume it's because of the reasons listed here: https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-controller

    If the extension won't work, what's the best way to detect Steam controller? Just by name comparison of the Hardware Name?
     
    Last edited: May 21, 2024
  11. Homoludens_Julien

    Homoludens_Julien

    Joined:
    Jun 24, 2021
    Posts:
    2
    Hey !

    We're using RewiredStandaloneInputModule to handle UI input in our game but we noticied that the Submit and Cancel events are actually sent when the button are initialy pushed down on the controller instead of when they are released. This behaviour seem counterintuitive (Validate on release is the standard for most game and for most mouse interaction) and even cause bug in some place in our game.

    Is there an easy way to change that behaviour ?

    So far the only option we though about was to duplicate the code for RewiredStandaloneModule and to change that ourselves..
     
  12. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    Me again :)

    I've been struggling for ages with an issue:
    1. Press play in the editor
    2. Click on the Load Menu button, which brings up a panel with a scrollable list of saved games
    3. Put the mouse over the list of games and scroll the mouse wheel
    4. Nothing happens
    5. Click on something in the Inspector panel, or off the editor or whatever
    6. Click back on the Game panel
    7. Put the mouse over the list of games and scroll the mouse wheel
    8. list moves
    This also happens in a build, so it's not just an Editor issue. By running debug statements I've determined that Input.mouseScrollDelta.y and Input.GetAxis("Mouse ScrollWheel") are returning 0 until I click off the Game panel and back on.

    I then tried in a fresh scene:
    1. New scene, add Canvas, Add Scrollview, Populate with elements.
    2. Run scene
    3. Mouse wheel works, scrolls the list
    4. Add Rewired Input Manager into the scene
    5. Run scene
    6. Mouse wheel doesn't scroll the list
    7. Click off and back on
    8. Mouse wheel does scroll the list
    I've noticed that on clicking of+off the Game panel or the build, the OnApplicationFocus method within Rewired is being called of course, but I can't see how that would be affecting anything. As far as I'm able to tell we're not doing anything weird in our Rewired settings, but there are so many that I can't be sure. Any thoughts?
     
    Last edited: May 21, 2024
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    No, there is generally no way to detect a Steam Controller. This is a complicated question because Steam is very complicated and works differently across all platforms and input sources. On Windows alone, Steam Controllers (including Steam-configured controllers) can be exposed through HID, Raw Input, Direct Input, XInput, and Windows Gaming Input. Each API works differently and provides different information (or lack thereof) for identifying a controller. Steam intentionally makes their virtual controllers appear to the system as Xbox controllers so everything works in applications that have no awareness of Steam (old games). One some platforms and some input sources, Rewired maps the Steam Controller to the Steam Controller definition, and therefore it will have its own Guid. But that is the exception, not the rule. On most platforms and input sources, it simply appears to the system as an Xbox 360 controller.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    The Rewired Standalone Input Module is heavily based on Unity's Standalone Input Module and works virtually identically to Unity's design. Unity's design dictates that button events are triggered on button down, not up, and Rewired doesn't attempt to change that. The only way to do what you want is to edit the source code.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    Update Rewired. This issue was fixed in 1.1.47.0.

    Release notes:

    1.1.47.0:

    Bug fixes:
    - Windows Standalone, Raw Input: Fixed bug introduced in 1.1.45.2 causing Raw Input events to not be forwarded to UnityEngine.Input until the application first lost and then received focus again. This only affected UnityEngine.Input mouse axis values.
     
  16. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    Oh, wonderful thank you!
     
  17. andrey-shchegolev

    andrey-shchegolev

    Joined:
    Mar 9, 2022
    Posts:
    1
    Hello,
    We are in progress of updating Unity (2020.3.25f1 -> 2023.2.18f1) and faced with issue of matching Logitech G29 on PS4.
    Rewired ignores hardware joystick map for this device and applied another map (our custom default map for PS4 platform)
    We have installed properly version of Rewired (1.1.54.1), PS4 plugin.
    Problem occures only with this steering wheel and only on console.
    On previous Unity version there is no problems with device. Could you help us?
     
    Last edited: May 22, 2024
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    The Logitech G29 map never applied to the PS4 platform. The PS4 platform has always only supported steering wheels through the Sony PS4 Steering Wheel controller definition, or generically through the Racing Wheel Controller Template. Nothing has changed in Rewired with respect to this.
     
    Last edited: May 22, 2024
  19. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,416
    Hi,
    is "IGamepadTemplate" still a thing in the rewired API?

    I found it on this documentation page:
    https://guavaman.com/projects/rewired/docs/ControllerTemplates.html

    Yet the link to it ends in a 404:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_IGamepadTemplate.html

    Also the type "IGamepadTemplate" does not exists in the assembly. This is the code I tried:
    Code (CSharp):
    1. ReInput.players.AllPlayers[0].controllers.GetFirstControllerWithTemplate<IGamepadTemplate>();
    upload_2024-6-4_11-53-18.png

    Not 100% sure if this is even right API to use. I want to check if the A button was pressed on a gamepad. I don't want to use actions or any mappings. I want to know if (on any of the supported gamepads) the closest thing to the A button was pressed.

    TLDR: I am looking for something like
    ReInput.LastUsedGamepad.wasActionBottomRow1Pressed()
    .

    upload_2024-6-4_11-58-12.png

    Am using 1.1.55.0.U2020 on Unity 2020.3.30f1
    Thank you.
     
    Last edited: Jun 4, 2024
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    Yes, IGamepadTemplate still exists. This is just a problem with the API documentation generation. IGamepadTemplate is not defined in Rewired_Core.dll. It is defined in Rewired/Internal/Scripts/ControllerTemplates/ControllerTemplate.cs because these classes and interfaces are generated from the Controller Template definitions. This is because new Controller Templates can be created by the user.

    Use IGamepadTemplate.a or IGamepadTemplate.actionBottomRow1.
     
    Last edited: Jun 4, 2024
  21. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,416
    Okay thanks. I got it to work, though I had to change the code a bit as my own code is in another assembly (using asmdefs) and thus I could not reference the generated templates.

    If anyone has similar issues then the cleanest solution I think is to either use IGamepadTemplate only in code that's not in another assembly OR you add an asmdef to Rewired so you can properly reference it.

    If all else fails then the code below will give you access to a controller template to work with:
    Code (CSharp):
    1. ReInput.controllers.GetLastActiveController(ControllerType.Joystick).GetTemplate<IControllerTemplate>();
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
  23. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    Is there a way to completely disable joysticks? The situation is that we're most of the way through adding controller support, but have disabled it for now because it's not ready and we have other priorities for the moment.

    But some of our players, specifically playing on "handheld PCs" like the Legion Go, are getting odd behaviour that feels like joysticks are being used even when we don't want them to. It's still quite likely that the issue is in our code somewhere of course - all we're doing to "turn off' the controller mode is not running the code inside our AddLastActiveControllerChangedDelegate that was choosing what UI/UX mode we run in, but for now I'm wondering if there's a way to make Rewired just pretend there are no joysticks or something. I couldn't see anything like this in the documentation or in the Rewired Editor, but I may have missed it. Turning off auto-assign joysticks doesn't appear to have helped, although I haven't tested that on an affected device yet

    The other version of the question, is is there anything within Rewired that doesn't like working on handheld (I'm *guessing* touchscreen, but possibly not) PCs? We don't have touch controls enabled, and at least one of the players are attempting to play with Mouse+Keyboard, but still it doesn't work - no mouse pointer appears apart from anything else
     
    Last edited: Jun 9, 2024
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    Joysticks cannot produce any input in the Player if the Player has no Joystick Maps loaded, or if Joysticks were not assigned to the Player, or if Joysticks that are assigned to the Player are disabled. If Joystick Auto-Assignment is disabled and you do not have code somewhere that is assigning Joysticks to Players, and you are not using UserDataStore_PlayerPrefs with Joystick Assignment saving / loading enabled which may have loaded some old saved assignment data, there's no way possible that Joysticks are contributing to input in the Player. Rewired will never assign controllers to a Player unless it is told to do so.

    Any controller can be disabled:
    https://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_Controller_enabled.htm
    https://guavaman.com/projects/rewired/docs/HowTos.html#connect-disconnect-events

    Contributing input sources to an Action can be logged:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources
     
  25. Xangis

    Xangis

    Joined:
    Jul 18, 2013
    Posts:
    5
    I'd like to request a small feature/change with ControlMapper themes:

    Please make the ControlMapper member variable _themeSettings public or add a setter of some sort.

    I have a themeable game, and the themes are loaded at runtime. I hand-edited the ControlMapper.cs file to make _themeSettings public so I could do this when I activate one of the themes on game load (before showing any UI):

    Code (CSharp):
    1. var controlMapper = UnityEngine.Object.FindObjectOfType<Rewired.UI.ControlMapper.ControlMapper>();
    2. if (uiTheme.controlMapperTheme != null)
    3. {
    4.     controlMapper._themeSettings = uiTheme.controlMapperTheme;
    5. }
    It works great, but it's not ideal since my change will get overwritten when I update Rewired. It would be nice if there was an official way to do this.
     
  26. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    We figured out what the actual problem was - nothing to do with joysticks as such. The players that have reported this have all been on portable PCs with touchscreens - Legion Go, Rog Ally - and when they disable their touchscreen in the Device Manager input starts working correctly. As far as I am aware we do not have any kind of touchscreen support turned on, either in Rewired or Unity, but I'm wondering if there's something else we need to do? The main symptom is that clicking on the main menu buttons with the mouse cursor does nothing
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html#inspector-options

    See:
    Allow Mouse Input if Touch Supported
     
    Last edited: Jun 11, 2024
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    The theme was never meant to be modifiable at runtime. The entire UI would need to be rebuilt for it to work correctly. The code would need to be changed to do this to support this new feature.
     
  29. Xangis

    Xangis

    Joined:
    Jul 18, 2013
    Posts:
    5
    OK, fair enough, no big deal if it's a hassle. I'll comment the heck out of my code so it's obvious what I need to do if my change ever breaks.
     
  30. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    26
    I just want to say I hope you know how much we appreciate your SPECTACULAR customer support. It makes such a huge difference to working with Rewired :)
     
    guavaman likes this.
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    You could copy ControlMapper.cs outside the Rewired folder, rename it, and then maintain your own version that would not get reverted if updates are made. You probably would also have to copy the editor inspector script too.
     
    Xangis likes this.
  32. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    541
    Hi there, I've received this usual message I would get when going up to a new major version of Unity, and I'm aware of the steps to resolve it, to clear out the package, download and install it fresh in the new version of Unity here:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed

    But it doesn't seem to be working for me. I just keep getting this message:
    Rewired: The version of Rewired installed (1.1.55.0.U2023) was not designed for Unity 6000. Please install Rewired for Unity 6000

    So I'm just wondering if that's perhaps the version for Unity 6000 is not ready as yet, or if you have any other ideas on what I might be doing wrong, thanks.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    I have not released a Unity 6 branch yet. I have been working on other additions for several months that I need to finish first.
     
  34. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,558
    Hi @guavaman, IDualShock4Extension/IDualSenseExtension has a SetLightColor function (which works great), but I'm curious if it's possible to get the current color of the lightbar somehow? If it's connected to a console via Bluetooth and to Windows via USB, and the console or game changes it, I'd like to update my on-screen representation in Windows so it matches the physical controller's lighting (if that's possible). Thanks
     
  35. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    541
    No worries, I’ll look out for an update, just good to know I’m not doing something wrong, thanks.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    No, there isn't. The light color is set in the output report. It is not reported in the input report. Same with vibration levels.
     
  37. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,558
    Okay - thanks for the definitive answer, I didn't think it was possible after searching around but wanted to ask anyway just in case.
     
  38. Slaktus

    Slaktus

    Joined:
    Dec 5, 2012
    Posts:
    63
    Hey,

    I'm using the InputMapper to remap controls, and that's working fine except for one small detail: Conflicts across different devices.

    I want to only have one binding per action when the player is using mouse and keyboard, so if the player has bound the action Fire to the left mouse button and then decides to remap the action Fire to the F key on the keyboard, the left mouse button binding should be removed.

    The problem is that I can't remove the mapping from the other controller. DeleteElementMap does not work, DeleteButtonMapsWithAction does not work, DeleteElementMapsWithAction does not work, RemoveElementAssignmentConflicts does not work.

    How can I use an action ID and/or an ElementMap to remove a binding from a controller? I have looked at the documentation, and it suggests using the MapHelper but I have no luck with that either.

    Please note that the problem is NOT that I am trying to remove the action from the wrong controller. I keep track of which controller in the mouse/keyboard pair is being remapped, the problem is that I can not work out how to actually remove the mapping.

    What am I missing?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    All of those functions should work. If they're not doing what you expect them to, you are probably passing the wrong values to them or calling them on the wrong ControllerMap instance.

    ControllerMap.DeleteElementMap deletes the ActionElementMap contained in the ControllerMap that has the same unique ActionElementMap id the passed in elementMapId value. This function does work and will delete the ActionElementMap.

    Every time an ActionElementMap is added or replaced, the ActionElementMap.id will change. Every ActionElementMap at runtime has a unique id, assigned upon creation. It's just a static counter.

    In case you are not aware, "id" in rewired is not the same as an index. This is a common misunderstanding that can cause all manner of issues:
    https://guavaman.com/projects/rewired/docs/BasicUsage.html

    "Id" is NOT an "Index"

    Anywhere the term Id is used in the API is a UNIQUE ID, not an Index, and cannot be used to iterate over items or get the first Joystick.

    ControllerMap.DeleteElementMapsWithAction will delete all ActionElementMaps contained in the ControllerMap that are bound to the specified Action. If this function is not working, you are either passing in the incorrect Action Id / Name, or you are calling this function on the wrong Controller Map instance.

    If you are retaining a reference to a ControllerMap somewhere, it may have become outdated. This could happen for a variety of reasons, such as after loading saved user data from XML / JSON, after loading a different Controller Map after changing layouts, or a number of other scenarios, which would all delete and re-create Controller Maps.

    I suggest using Debug Information to view what Controller Maps exist in the Player at runtime while you're doing this. Each Controller Map has its own unique id as well which can be used to determine if the Controller Map instance you are working with matches what's in the Player.

    Player.ControllerHelper.MapHelper gives access to the Controller Maps loaded in the Player at runtime. This is the only way to access runtime Controller Maps in a Player. Controller Maps can be iterated and modified manually or some information can be accessed in them through the use of the convenience functions in that class. Player.ControllerHelper.MapHelper does not contain any convenience functions for deleting bindings, so to delete bindings, you have to use the functions in ControllerMap or its subclasses. Obtain the Controller Map through the functions provided in Player.ControllerHelper.MapHelper, then use the functions provided in ControllerMap to delete the bindings.
     
    Slaktus likes this.
  40. Adam_Benko

    Adam_Benko

    Joined:
    Jun 16, 2018
    Posts:
    107
    Hi. I have multiple action categories. Ships and cars. Both use keys W and S for something else. Everything works fine but when the player wants to, lets say invert the W and S in vehicles category, it will delete the keybind for ships as well for the default W throttle key.
    How can I make them separate, so that the rewired default control mapper UI wont replace the same keys that are located in different action categories when player wants to rebind them?
    Thanks.
     
  41. Slaktus

    Slaktus

    Joined:
    Dec 5, 2012
    Posts:
    63
    Thanks a lot! Looks like the problem was outdated cached ControllerMap instances. I fetch new ones now before attempting to call DeleteElementMapsWithAction and everything is working as expected.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    Configure Conflict Checking for your Map Categories:
    https://guavaman.com/projects/rewired/docs/HowTos.html#conflict-checking
     
  43. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,759
    can you please check rewired on Unity 6 which is already on final releases? On android I'm getting weird interface not implemented errors for
    IExternalTools.WindowsStandalone_ForwardRawInput(IntPtr, IntPtr, uint, IntPtr, uint)
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    If you're getting compiler errors, you're not using the latest version of Rewired.

    https://guavaman.com/projects/rewired/docs/ReleaseNotes.txt

    1.1.52.0:

    Changes:
    - Updated Unity version check handling for Unity 6 in preparation for Unity 6 support. (Unity 6 support has not been added in this release.)

    The compiler error you are talking about would only happen if Rewired/Internal/Scripts/Misc/ExternalTools.cs does not contain the new changes made in 1.1.52.0 adding the preprocessor #if declarations for UNITY_6000. This would result in the IExternalTools interface in Rewired_Core.dll declaring the WindowsStandalone_ForwardRawInput function, but the implementer of IExternalTools in the CS file not implementing that function because it thinks you are using a version of Unity older than Unity 2021 (the version in which the function was added to the interface.) Update Rewired. The current version is 1.1.55.0.
     
  45. Adam_Benko

    Adam_Benko

    Joined:
    Jun 16, 2018
    Posts:
    107
    I have created 2 new map categories and moved there all actions that need to be there. However, when I open the control mapper UI, I dont see any assigned binds to them (used the "reset to default" too), nor do they respond to the player input. Have I made a mistake ?
    Thanks.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    I don't have enough information to tell you what you missed. I can only guess.

    If the Controller Map is not designated to be loaded in the Player on start, it's not going to show up in Control Mapper. Rewired Input Manager -> Players.

    Use Debug Information to view the Controller Maps and Action Element Maps in the Player at runtime:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  47. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    824
    Hi! I believe I might have a bug report, but maybe I'm just misunderstanding the API.

    Using Element.compoundElement returns null for an element that is indeed a member of a compound element.

    For example, on a DualShock:

    Code (CSharp):
    1. var elementId = 0; // Left stick horizontal axis
    2. var element = controller.GetElementById(elementId); // Valid
    3. var compoundElement = element.compoundElement; // Null!
    As a workaround, I can fetch it by interating on Controller.CompoundElements, casting each item to Axis2D, and comparing IDs, but it feels like going the long way around?

    Code (CSharp):
    1. private Controller.CompoundElement GetCompoundElement(Controller controller, Controller.Element element)
    2. {
    3.     foreach (var compoundElement in controller.CompoundElements)
    4.     {
    5.         if (compoundElement is Controller.Axis2D axis2D)
    6.         {
    7.             if (axis2D.xAxis.id == element.id || axis2D.yAxis.id == element.id)
    8.             {
    9.                 return compoundElement;
    10.             }
    11.         }
    12.         else if (compoundElement is Controller.Hat hat)
    13.         {
    14.             if (hat.Buttons.Any(b => b.id == element.id))
    15.             {
    16.                 return compoundElement;
    17.             }
    18.         }
    19.     }
    20.  
    21.     return null;
    22. }
    23.  
    Also, there is a typo in another call of the API: GetCompundElementById

    (Rewired Version 1.55.0.U2020)
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,658
    You are correct on both. Thanks.