Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Exactly the same way you would access it using Unity's Standalone Input Module because the Rewired Standalone Input Module is just a slightly modified version of their system that gets input from Rewired instead of Unity. Create a component that implements IPointerClickHandler interface and put that on your UI GameObject. Ignore the event in code if you don't want it to do anything.

    https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/SupportedEvents.html

    If you are asking how to change it so the Input Module doesn't even send these events, you don't. That's not how Unity UI was designed to work. The Input Module sends events to all listeners. Those listeners choose what to do with them.
     
    nekolyst likes this.
  2. yonathanrus

    yonathanrus

    Joined:
    Apr 28, 2021
    Posts:
    3
    @guavaman
    Hi, just wondering, based on docs
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html
    Extra buttons added in iOS 13 (stick buttons, options, menu) do not currently work because they are not currently supported by Unity.
    Does it mean we can't use L3/Leftstick down, R3/Rightstick down, options, menu on iOS and tvOS?

    it seems the native objective c can detect those button
    upload_2023-9-6_12-21-12.png
    Is it possible to integrate them?
    we tried this on rewired trial 1.1.45.2.U2020 and on our paid license 1.1.39.2.u2020
    and here's how we set the joystick mapping
    upload_2023-9-6_12-22-25.png
    Thanks in advance
     
    Last edited: Sep 6, 2023
  3. yonathanrus

    yonathanrus

    Joined:
    Apr 28, 2021
    Posts:
    3
    Also, adding this might fix the lstick + rstick cannot be detected
    upload_2023-9-6_12-50-43.png

    Native callback
    upload_2023-9-6_12-50-55.png

    Could you check it? if it's working, can we request to add those to the latest build?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    My mappings are based on Unity's own documentation:
    https://docs.unity3d.com/Manual/ios-handle-game-controller-input.html

    If they've changed it and added these elements without updating their documentation, that's news to me. If so, I have no idea when this happened and will not be able to support these elements in any version of Unity prior to whenever they added the mappings.

    Edit: I can confirm these buttons work now even though the documentation does not reflect this. I do not know at what version Unity added support however.
     
    Last edited: Sep 6, 2023
    yonathanrus likes this.
  5. yonathanrus

    yonathanrus

    Joined:
    Apr 28, 2021
    Posts:
    3
    @guavaman
    Could you give us a patch for all working mfi button iOS and tvOS?
    We want to compare our fix patch with yours.
    Thanks again in advance
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    It's no different than what you did except that I moved them up above the D-pad buttons.
     
    yonathanrus likes this.
  7. nivalinternationallimited

    nivalinternationallimited

    Joined:
    Sep 11, 2015
    Posts:
    5
    Hi.

    Any way to get mouse\keyboard disconnecting events? Or at least check if mouse and keyboard are physically connected?
     
  8. hope_unity

    hope_unity

    Joined:
    Feb 12, 2021
    Posts:
    3
    Hello! I'm trouble shooting some edge cases in out MKB behaviour. Essentially, when a controller is plugged in but you are using the mouse, mouse clicks are very inconsistent. I've found, by watching the rewired Debug Information panel, Under Mouse Button > Left Mouse Button, that when a controller is plugged in most LMB clicks will not register, but if I spam click finally it will grab one of the clicks, but then it will keep that click as "pressed" for a few seconds, rather than clicking and releasing like it shows without the controller plugged in, and ignore any more spams. Once it finally releases it from the pressed state i can spam the mouse click to get it to happen again.
    At first I though the problem was our code handling of rewired actions but it looks like its within rewired's ability to interpret the input itself, so I'm not sure how to approach this.
    Any insight is greatly appreciated! I can also get a video if it would help.
     
  9. hope_unity

    hope_unity

    Joined:
    Feb 12, 2021
    Posts:
    3
    Just did a bit more testing and "a few seconds" is more like 8 seconds, and the issue happens with both my offbrands PS4 controller and my PS5 dualsense. The issue also seems to affect RMB.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    No. Rewired does not track this information.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    It's a virtual certainty that you are using a very old version of Rewired before Rewired 1.1.41.0 and a version of Unity 2021.2.0f1 or greater. Update Rewired.

    Read this if you want to know why it's exhibiting those symptoms:
    https://forum.unity.com/threads/windows-mouse-raw-input-mouse-handling-broken-in-rewired.1172786
     
    hope_unity likes this.
  12. hope_unity

    hope_unity

    Joined:
    Feb 12, 2021
    Posts:
    3
    Thanks for the quick reply! I'm getting around to updating right now, we were below 1.1.41 like you said. We are now on 1.1.45.3, using 2021.3.18f. I'm seeing this error, and I see that the rewired documentation advises that it's either the wrong rewired version for the unity editor (which i dont believe is possible as I'm installing it directly from package manager) as well as to try clearing unity cache before redownloading, but that did not remove the error.
    The type or namespace name 'Windows' does not exist in the namespace 'Rewired.Internal'
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    You may have multiple copies of Rewired in your project. See this:
    https://guavaman.com/projects/rewired/docs/Updating.html

    Then do this:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#clean-reinstall

    And reinstall from the Package Manager.

    If the problem persists, then it is definitely downloading the wrong version of Rewired for the version of Unity you are using. Manually delete the Unity download cache again:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed

    If it still persists, then that means the Unity Asset Store is serving the wrong Unitypackage for the editor you are using. This has happened before and it would have to be fixed by Unity at the webserver level.

    The version of Rewired that is installed can be seen from the menu Window -> Rewired -> Help -> About, provided it is able to compile the editor assembly.

    Additionally, if you are using ASMDEF files in your project, you have to manually manage all assemblies generated from scripts in Rewired and its addons / plugins:
    https://guavaman.com/projects/rewired/docs/HowTos.html#asmdef-files
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Rewired 1.1.46.0 is available on the Unity Asset Store:

    See Updating Rewired before updating.

    Release Notes:

    1.1.46.0:

    Changes:
    - Changed Rewired Editor colors and bolded controller names that have an existing controller map due to Unity editor default skin changes at some unknown Unity version in the past causing skin colors to be off.

    API Changes:
    - Added InputMapper.ConflictResponse.Swap enum value.
    - Added InputMapper.ConflictFoundEventData.IsSwapAllowed function.

    Modified Controller Definitions:
    - Apple MFI Controller, iOS Fallback: Added Left Stick Button and Right Stick Button mappings for Xbox and Sony controllers. NOTE: Only works in versions of Unity that support these additional buttons. It is not known at what version the button mappings were added to Unity.
     
    igorskugar likes this.
  15. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    300
    How would we know if a controller is being used by a specific controller template rather than a generic one?

    In Rewired Editor -> Joystick Maps, I filled in the info for both 0: [T] Gamepad Template and 8: Xbox One Controller. Specifically, I'm trying to map the glowing Xbox button in the center to an action so I can use it to open the Steam overlay (I believe this is called the Guide button in Rewired).

    Using ReInput.ControllerConnectedEvent, I tried this code from the docs:

    Code (CSharp):
    1.     void OnControllerConnectedFromRewired(ControllerStatusChangedEventArgs args)
    2.     {
    3.         // Iterate through all Controller Templates implemented by a Controller
    4.         for (int i = 0; i < args.controller.templateCount; i++)
    5.         {
    6.             Debug.Log(args.controller.name + " implements the " + args.controller.Templates[i].name + " Template.");
    7.         }
    8.  
    9.         //this prints XInput Gamepad 2 implements the Gamepad Template.
    10.     }
    So, it would appear that my Xbox controller is being detected as "XInput Gamepad 2", and its template is just Gamepad Template.

    Does this mean that the controller is using the generic template rather than the one for Xbox One? So far it seems that the Guide button isn't doing anything. Is args.controller.name supposed to print something about an Xbox controller?

    To be clear, I'm using this controller: https://www.xbox.com/accessories/controllers/xbox-wireless-controller
    I've never figured out if there's a difference between the original Xbox One controller and this one.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    A Template in Rewired refers to a device that matches a specific profile like Gamepad or Racing Wheel. It looks like what you are trying to do is identify the specific controller, not the Template. You won't get this information from controller.Templates.

    You have to identify the joystick by Guid:
    https://guavaman.com/projects/rewired/docs/HowTos.html#identifying-recognized-controllers

    But that will not give you the information you're looking for either. It seems like you are trying to determine that this controller is an Xbox One controller and not an Xbox 360 Controller. This is impossible because you are using XInput.

    See these:
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#xinput-device-name

    All XInput-compatible gamepads are treated as Xbox 360 Controllers on Windows Standalone when Use XInput is enabled. There is no way to get any further information about the controller because of limitations of XInput.

    As for mapping the Guide button, while the Guide button corresponds to Center 3 on the Gamepad Template, the button will never return any value when using XInput. If Steam's replacement XInput device returns a value for it, it may work, but vanilla XInput without Steam in the mix won't.
     
    Last edited: Sep 14, 2023
    _eternal likes this.
  17. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    300
    Hey, thanks for the detailed reply.

    When you say "Steam's replacement XInput device," would that mean playing the game with Steam Input turned on? I've left it turned off up til now, because I recall there's a page somewhere in the Rewired docs that talks about potential conflicts between Rewired and Steam Input.

    Since Center 3 is the Guide button, I guess I won't need a dedicated Xbox map at all, but it's interesting that the button doesn't work with XInput. In Steam's recent announcement about DualSense support, I think the questionnaire mentioned that a controller's home button "should" open the Steam overlay in order for the game to qualify for Full Controller Support (whether this rule is enforced or not is another question).

    In our case, it sounds like there might be a tradeoff in trying to get that Guide button to work, because I can imagine that things like controller glyphs and remapping will get more complicated if both Steam Input and Rewired are involved.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Not exactly. See this:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-configured-controllers

    This is outdated as Steam has changed their terminology and settings many times since I wrote this, but the basic concept still applies. The user can choose to make Steam "configure" the device. If they do so, Steam will hide the real device from the application and expose a virtual Steam-configured version of the device through Raw Input, Direct Input, and XInput. This puts Steam in full control over the device. This is how Steam allows users to rebind controls, use remote play, and a bunch of other stuff. They hook the Windows input DLLs and substitute their own information, exposing a virtual device to the application with the modifications the user made. You can't prevent your users from enabling this feature. If you're using Steam, it's enabled with no action from you required. The developer can also set per-application defaults for this setting also.

    I don't know what they mean by that. I was looking through the Steam controller interface the other day and I saw they had toggles to allow or deny remapping of the Guide button. I don't know if this needs to be enabled to make it return a value or not. Steam is a constantly evolving, roiling, boiling mess IMO, so I really can't help in this area because my knowledge of what you have to set on their end to get some result you're looking for is always outdated. Steam can't require Steam API input support, and Rewired works using standard Windows APIs (Raw, Direct, X Input, etc.), so Rewired works as any Steam-agnostic application would, following all the rules of the different Windows input APIs, and anything beyond that which affects the application would be on the Steam configuration end and outside the responsibility of the application and Rewired.

    Unfortunately, if you're using Steam, that is a given. There's no way to avoid it. I suggest you read the whole Troubleshooting section on Steam to get an understanding of what is going regarding input on when you publish a game on Steam.
     
    Last edited: Sep 15, 2023
    _eternal likes this.
  19. krmschmitz

    krmschmitz

    Joined:
    Dec 1, 2018
    Posts:
    9
    Running into a problem where when listening for input using InputMapper.Default.Start(context), it won't pick up trigger buttons when trying to remap an action. It picks up every other button just fine, but won't remap an action to trigger buttons on both an XBox One controller and PS4 controller. When I map the trigger buttons manually in the editor, they work fine during gameplay. It's just trying to get Rewired to register them when doing remapping with InputMapper. Downloaded the SimpleControlRemapping example and it works fine there, but I can't for the life of me figure out what setting is different/incorrect that is excluding just the triggers.

    Using the following settings for the InputMapper:

    Code (CSharp):
    1. InputMapper.Default.options.allowAxes = false;
    2. InputMapper.Default.options.allowButtons = true;
    3. InputMapper.Default.options.checkForConflicts = true;
    4. InputMapper.Default.options.defaultActionWhenConflictFound = InputMapper.ConflictResponse.Replace;
    5. InputMapper.Default.options.ignoreMouseXAxis = true;
    6. InputMapper.Default.options.ignoreMouseYAxis = true;
    7. InputMapper.Default.options.timeout = 4;
    Also setting the actionRange to AxisRange.Positive in the InputMapper.Context. Running Unity 2021.3.28f1, and Rewired 1.1.46.0. Any help on what I might have misconfigured is greatly appreciated!
     
    Last edited: Sep 15, 2023
  20. krmschmitz

    krmschmitz

    Joined:
    Dec 1, 2018
    Posts:
    9
    Ah, figure dout the problem was that trigger buttons are axes, which I had disabled. But now it's allowing me to register the sticks as button presses. What is the recommended way to prevent allowing an analog stick from being mapped to an action when listening for input? Thanks again.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    See #7:
    https://guavaman.com/projects/rewired/docs/InputMapper.html

    You are now entering an area that is going to require you know exactly what element identifier ids correspond to on every single device because you can't just say "ignore the sticks" without knowing what is a stick and what isn't. This means you have to identify the device by Guid, then look up what the element is by the element identifier id during polling to exclude it. This topic has links to CSV files of every recognized controller and the element identifier ids of all elements:
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action

    You could also work out what the id of the element that was pressed on the Gamepad Template to determine whether it's a stick, but that will only work for recognized gamepads.

    As for Unknown Controllers:
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#unknown-controllers

    Another approach would be to put the bindings to the sticks on a separate Controller Map and make that category protected from rebinding. https://guavaman.com/projects/rewired/docs/HowTos.html#conflict-checking
     
  22. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    172
    Hello
    I am using the Cinemachine Rewired Bridge.
    VirtualCamera is using POV.

    I hope the Input Axis Value will be delivered to the POV in only certain situations (only when dragging).
    So i want Enable the Bridge when OnBeginDrag,
    and disabling the Bridge at OnEndDrag

    Can I temporarily Enable/Disable the Rewired Bridge?
    Or Is there a better way?
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    The Rewired Cinemachine bridge sets the input delegates in CinemachineCore on Awake and unsets them on Destroy. Enabling and disabling the game object will not work.

    I would say you should flow control using whatever means Cinemachine provides for flow controlling whether inputs are processed. Enabling and disabling the bridge would be akin to enabling and disabling Unity's entire input system whenever you want input to be processed or not. This would not be good design if that were the only way to prevent Cinemachine from processing user input.

    While I wrote the bridge to pipe input from Rewired to Cinemachine instead of UnityEngine.Input, I basically know nothing about Cinemachine or how to use it. I strongly suspect they already have some means built into Cinemachine to flow control whether input should be processed or not. I would look at the Cinemachine documentation.

    As a last resort, you could enable and disable Controller Maps in Rewired, but again, this seems like functionality Cinemachine very likely provides already and flow-controlling the processing of input by flow-controlling whether input is even generated isn't the most elegant way to solve this kind of problem most of the time.
     
    seoyeon222222 likes this.
  24. krmschmitz

    krmschmitz

    Joined:
    Dec 1, 2018
    Posts:
    9
    Thanks, this worked for me for ignoring axis inputs. Much appreciated.

    I'm also looking to recognize the Steam Deck for showing the correct button glyphs. Would a steam deck be recognized as a Steam Controller (2694f4b9-9d84-4f55-9ee8-78fbba744b7d)? Also, I noticed there are no entries for L4, L5, R4, and R5 (the extra buttons on the back of the steam deck). Are there element identifier IDs I can use to recognize these buttons, and if not, plans to support them in the future? Thanks again.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    There is no simple answer. What Steam-configured controllers appear as to the application depends entirely on the platform and input source(s) in use.

    Below are assumptions based on how Xbox Steam-configured controllers appear. The Steam Deck is nothing more than another Steam-configured controller to the application, unless the application is using the Steam Input API. Rewired does not.

    Windows:
    Primary Input Source: Raw Input, Secondary Input Source: XInput = Xbox 360 Controller
    Primary Input Source: Direct Input, Secondary Input Source: XInput = Xbox 360 Controller
    Primary Input Source: XInput = Xbox 360 Controller
    Primary Input Source: Raw Input = Steam Controller
    Primary Input Source: Direct Input = Steam Controller
    Primary Input Source: Unity Input = Xbox 360 Controller?
    Primary Input Source: SDL2 = Xbox 360 Controller (if XInput is enabled in SDL2)

    All of the above would be different for a Linux build. It would presumably appear as Steam Controller like other Steam-configured devices. This is why the Gamepad template exists. Map for the template and you are covered.

    This is because of how Steam works. Steam hides Steam-configured controllers and exposes virtual controllers through the different input APIs. Different input APIs make different information available for identifying a controller. Steam's intent was to make all games written for any Windows input API work, so they mimic the identifying information of Xbox controllers. In the case of XInput, there is no way to get any information about the device except that it is a Gamepad.

    Presumably, it's not possible to disable the Steam-configured status of the Steam Deck.

    More information about Steam:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam

    Those extra buttons are almost certainly only detectable through using the Steam Input API directly. XInput does not support enough buttons to use them. The Linux Steam Controller exposes 6 axes and 11 buttons, also not enough. There are no plans to support the Steam API directly due to many known and potential technical problems and maintenance burden.

    Steam Deck is not explicitly supported by Rewired and is supported only through Rewired's Linux platform support and / or Windows Standalone if using Proton
     
    Last edited: Sep 19, 2023
  26. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Since I updated to the last rewired Input.GetAxis(“Mouse X”) will return always 0 unless I specifically unfocus and refocus the editor screen.

    it also happens in the game. If you compile full screen for windows, the axis for mouse x returns zero unless I switch windows and come back. Funny thing is that mouse position and clicks do work. It just Mouse X and Y axis the ones messed up until I refocus.

    Rolling back to previous version fixes it. No idea what was changed.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    From what version did you update? Nothing has been changed in several years that could have affected UnityEngine.Input. Two years ago there was a change that coincided with Unity's change to using a buffered read of Raw Input events because of slowdowns caused by 8 khz mice that necessitated changes on both Rewired's and Unity's ends to allow Rewired to forward Raw Input events back to Unity after their change.

    Do you happen to be using UnityInputOverride?

    What version of Unity are you using? This matters for the whole event forwarding thing.
     
  28. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    No, I'm not using UnityInputOverride

    using Unity 2022 latest from yesterday
    I also tried with 2023 with same results
     
    Last edited: Sep 24, 2023
  29. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I have a feeling it is related to this change
    1.1.45.2:
    Changes:
    - Windows Standalone, Raw Input: Raw Input events are no longer forwarded to Unity when application is paused or out of focus.
     
  30. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Yep, I rolled back to 1.1.45 of Rewired and issue is gone. it is that change.

    You can reproduce it yourself quickly. Put a debug.log on input.getaxis("mouse x") inside an Update method. Run it on a windows machine, inside the editor or compiled. You will see it will always return 0.
    You have to click somewhere else outside the window, then click back. And mouse X will begin working.

    This is a big problem for Windows games because many of us begin with a full screen game. The Mouse X won't work unless with alt-tab to another window and come back.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    I am able to reproduce it in Unity 2022.3+. Thanks.

    That change was made in response to this thread:
    https://forum.unity.com/threads/dev...-even-with-run-in-background-unticked.1463237

    The default state of application pause is the problem. This default value was inadvertently set to paused by default and doesn't change until a pause change event comes in.

    This does not affect Rewired's mouse input, only UnityEngine.Input, so my recommendation would be to use Rewired for mouse input instead of UnityEngine.Input until this can be fixed. Input.mousePosition and buttons work because they are not driven by Raw Input.

    Edit: Changing the default value does not fix the problem. I'm going to have to investigate further.... It was caused by multiple related things.
     
    Last edited: Sep 24, 2023
  32. alexogorek

    alexogorek

    Joined:
    Jun 21, 2018
    Posts:
    18
    Hey @guavaman thanks for being so active here :)
    I had a question that is (for me at least) seemingly hard to google or find in the Rewired documentation, and this thread is extremely long so i apologize if this was previously answered here.

    I'm using Unity's new UI Toolkit / UIElements, combined with Rewired, and for some reason I'm having troubles getting a Gamepad to navigate a menu.

    I've tried to implement a custom "menu manager" with custom actions for up/down, but it feel entirely unnecessary and feels like I would be missing a bunch of edge cases or having a bunch of extra complexity.

    So I tried looking into the Rewired Standalone Input Module, but that feels like it's more tailored to Canvas? Mouse navigation still works fine, but after creating and remapping my actions to UIHorizontal/UIVertical etc, the gamepad doesn't register any UI event changes.

    Here's an example screenshot of my game when paused -- at first the Resume button is selected -- but the users should be able to (in my ideal experience) navigate to the Right, then progress up/down/left/right on the grid, and when going to the left on the grid it goes back to the Resume or Menu buttons


    upload_2023-9-27_21-28-45.png

    So --

    TLDR: Can Rewired work with UI Toolkit for Gamepad navigation? Or do I have to handle my UI navigation (read: Button / VisualElement Focus state) manually on a screen-by-screen basis?


    Quick edit for Clarification: my own Custom MenuManager navigation with simple list of buttons up/down worked fine -- but with this new screen requiring multi-directional navigation it makes me question my initial approach.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Rewired Standalone Input Module is an integration for Unity UI. It is a modified version of the Unity UI Standalone Input Module.

    Rewired does not support UI Toolkit. That is the reason it is not mentioned in the documentation. I have never used UI Toolkit so I cannot tell you how to implement support for it.
     
  34. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    759
    Don't want to derail the thread, but if you'd like to recreate the more organic selection process that Unity UI supports, the source code for that is available to read for reference. Specifically in the Selectable class, in a method called "FindSelectable". The source files can be opened from within the Packages folder inside your project, or you can read on the GitHub repo here:

    https://github.com/Unity-Technologies/uGUI/blob/2019.1/UnityEngine.UI/UI/Core/Selectable.cs

    Hopefully that'll help you get most of the way there.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Apparently, UI Toolkit uses the same Event System and Input Module as Unity UI according to this:
    https://docs.unity3d.com/Manual/UIE-faq-event-and-input-system.html

    Therefore, the Rewired Standalone Input Module should work to send the events to the UI elements. What happens after the events are sent to the Event System is outside the scope of of the input system (Rewired) and is entirely determined by the UI elements. In Unity UI, this is Selectables. The Input Module reads input and generates events using the Event System. The Event System dispatches these events to the MonoBehaviours on GameObjects -- either the GameObject beneath the mouse pointer or the Event System's currently selected GameObject.

    In Unity UI, keyboard / joystick navigation is determined by inspector settings on the Selectables. Auto navigation is the default and generally has a lot of problems with complex UIs in my experience. You can also define specific UI element navigation targets for the 4 directions relative to the current selectable.

    If input is not working to drive the UI, the first thing to check would be everything related to input:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    The UI Actions in the Player designated to control the UI in the Rewired Standalone Input Module inspector must returning non-zero values at runtime in order to navigate the UI. Second, EventSystem.currentSelectedGameObject must have a non-null GameObject assigned.
     
    Last edited: Sep 28, 2023
  36. alexogorek

    alexogorek

    Joined:
    Jun 21, 2018
    Posts:
    18
    Thank you @flashframe for the link, i'll likely give that a look
    and thank you @guavaman for the detailed answers. That's good to know about how the event system works and how I can incorporate that movement

    But yeah it sounds like when in doubt, I'll end up having to roll my own / figure out navigation events based on element directional input (like the FAQ article you linked)
     
  37. KyleWWG

    KyleWWG

    Joined:
    Jan 13, 2023
    Posts:
    1
    Hello, I've got a question.

    Brief version: Can the Control Mapper support remapping for Custom Controllers at all?

    More details: We've got a touch controller that mimics a regular Xbox controller, and we'd like to support remapping for it since we support remapping for physical controllers as well. I've searched through the documentation and this thread, and I've not seen anybody mention using the Control Mapper in combination with Custom Controllers. Is there a way to do this without extensive additions to Control Mapper code?

    Thanks in advance!
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    No. It only supports keyboard, mouse, and joysticks.
     
  39. OscarLeif

    OscarLeif

    Joined:
    Jul 17, 2016
    Posts:
    69
    Hello is there any plans for native android support ?
    Looks like the Input System is not great for physical gamepads.
    I read on the manual " If there is enough demand, I can write an input library for the platform to replace Unity's flawed input system." this should be great.
     
  40. barodapride

    barodapride

    Joined:
    May 4, 2017
    Posts:
    5
    Hi, is there a way to know if the user is currently using a keyboard & mouse or a gamepad? For example if the user presses a gamepad button I want to switch my game mode to gamepad so that on-screen keyboard appears when clicking a text field and the mouse cursor is pinned to a certain location. And when the user presses a keyboard button it goes back to keyboard & mouse mode. I suppose it's just a matter of getting the current input device from Rewired somehow? Thank you.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    No plans. There has been basically no demand for it.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    See this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#last-used-controller
     
  43. AhmadSannan47

    AhmadSannan47

    Joined:
    Oct 17, 2020
    Posts:
    1
    UPDATE: Issue Fixed !! I just had to re-install rewired. Looks like some files might have been corrupted.

    --Original comment in case someone else with a similar issue needs it--

    Hello !! I am facing a weird issue. I've only seen one other person mention the same issue in this thread, and the answer was that it doesn't make any sense, so I'm trying to bring up the topic again just to see if it has been figured out since then.

    The game runs pretty normally in the editor, but when i make a build, the build succeeds, but these errors show up in the inspector:

    Code (CSharp):
    1. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule::playerMice' from '.../Library/ScriptAssemblies/Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    2. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    3.  
    4. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule/PlayerSetting::playerMice' from '.../Library/ScriptAssemblies/Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    5. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    6.  
    7. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule::playerMice' from '.../Library/PlayerScriptAssemblies/Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    8. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    9.  
    10. Field 'System.Collections.Generic.List`1<Rewired.Components.PlayerMouse> Rewired.Integration.UnityUI.RewiredStandaloneInputModule/PlayerSetting::playerMice' from '/.../Library/PlayerScriptAssemblies/Assembly-CSharp.dll', exception Failed to resolve Rewired.Components.PlayerMouse
    11. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189)
    12.  
    When I run the build, the game crashes instantly, and no Player log file shows up.

    Any hint/clue to where i should be looking at to fix this? Thank you for you time !
     
    Last edited: Oct 12, 2023
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    That's exactly what I was going to tell you to do. Rewired_Core.dll was either missing, extremely outdated (form an old version of Rewired), or excluded from the build target.
     
  45. Kakyouin86

    Kakyouin86

    Joined:
    Oct 16, 2020
    Posts:
    7
    @guavaman Hello! I bought Rewired a couple of months ago and it helped me a lot in many projects. Now I have a serious one using Corgi+Rewired and spent the whole week trying to make it work. Basically the problem is the analog sticks: If I use keyboard or the D-Pad, everything works correctly (strict 1s to every Axis) but for Analogs I can't make them go from 0 to 1, hence this creates really weird stuff such as crawling, aiming in directions it's not supposed to, etc.
    The only thing I need is to make the analogs be a bit more "strict" as if they were the DPad. I tried everything, with no luck :(
    Hope you can help me out!
    Thanks!
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Set Default Joystick Dead Zone Type to Axial:
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings
     
  47. Kakyouin86

    Kakyouin86

    Joined:
    Oct 16, 2020
    Posts:
    7
    Thanks man! Yeah I tried that but didn't work. Instead, after hours of testing, this is what I changed in RewiredCorgiEngineInputManager.cs line 153
    It took me almost 3 days to figure it out hahaha.

    public override void SetMovement()
    {
    if (!_initialized)
    {
    base.SetMovement();
    return;
    }
    if (SmoothMovement)
    {
    _primaryMovement.x = _rewiredPlayer.GetAxis(_rewiredActionId_horizontal);
    _primaryMovement.y = _rewiredPlayer.GetAxis(_rewiredActionId_vertical);

    // Normalize _primaryMovement
    _primaryMovement.x = Mathf.Abs(_primaryMovement.x) > 0.1f ? Mathf.Sign(_primaryMovement.x) : 0f;
    _primaryMovement.y = Mathf.Abs(_primaryMovement.y) > 0.1f ? Mathf.Sign(_primaryMovement.y) : 0f;
    }
    else
    {
    _primaryMovement.x = _rewiredPlayer.GetAxisRaw(_rewiredActionId_horizontal);
    _primaryMovement.y = _rewiredPlayer.GetAxisRaw(_rewiredActionId_vertical);

    // Normalize _primaryMovement
    _primaryMovement.x = _primaryMovement.x != 0f ? Mathf.Sign(_primaryMovement.x) : 0f;
    _primaryMovement.y = _primaryMovement.y != 0f ? Mathf.Sign(_primaryMovement.y) : 0f;
    }
    }
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,577
    Another way would be to change player.GetAxis to player.GetButton and enable Activate Action Buttons on Negative Value. Then the InputBehavior Button Dead Zone would define the minimum dead zone required to trigger the Action.

    You could also have changed the script in Corgi Engine that actually consumes input and moves the character.

    I would be surprised if Corgi Engine didn't already have its own option for analog / digital movement. If simple joystick axis input is causing so many problems in your game even with Axial dead zones enabled, that seems like it would be a common problem with Corgi Engine for old-school 16-bit style games.
     
  49. Kakyouin86

    Kakyouin86

    Joined:
    Oct 16, 2020
    Posts:
    7
    Thanks! I will grab this and save it. It's golden. To be honest, I spent 3 days finding out the causes and believe it or not, I haven't found a solution in the official documentation/Discord. Testing after testing to have it work like a regular D Pad (but with analog sticks). The most serious thing is the diagonals and how "accurate" it tried to be when it needs to be rough (I'm making a Contra-like arcade game). So, well, hope that helps. I'm tweaking Corgi as crazy to meet my demands hahaha but every now and then, I use a blank project to test things on a clean project.
    Have a great weekend my friend.
     
  50. friedelverpoort

    friedelverpoort

    Joined:
    Dec 5, 2017
    Posts:
    1
    Hey @guavaman, I've recently updated the Rewired plugin(1.1.39.3.U2017) in a project Unity 2017.4.16 in the hopes that would fix the fact that PS4 and PS5 controllers over bluetooth are not detected. Our newer project in 2019.4.38(1.1.44.0) where bluetooth PS4 and PS5 controllers work fine. Now I did notice the discrepancy in versions and I was wondering if there is a more up-to-date Rewired version for Unity 2017 out there or if there is any known fix available to support bluetooth ps4 and ps5 connections. Thanks in advance.