Search Unity

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,627
    Both joysticks will appear as controllers and be assigned to Players if joystick auto-assignment is enabled. The names of the controllers depends on the platform input source(s) in use for that controller and on whether the controller is recognized or not. Rewired was designed for multi-player and supports any number of connected joysticks, subject to limitations of the platform input source(s) in use.
     
    kopanz likes this.
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    There is no guarantee Horizontal and Vertical will be assigned to a single stick. A user certainly has the ability to rebind Horizontal to the left and right triggers and vertical to the D-Pad if they so choose. Rewired's Player-Action system is not a controller-based system and therefore there is no concept of a "stick" at the Action level.

    There are convenience functions to poll for a Vector2 value from two Actions:
    https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_Player_GetAxis2D.htm

    The same does not exist in the event-based API.
     
    Last edited: Nov 19, 2022
    jmgek likes this.
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.1.44.0 is available on the Unity Asset Store.

    See Updating Rewired before updating.

    Release notes:

    1.1.44.0:

    Changes:
    - MacOS, Game Controller Framework: Added support for setting light color on Dual Shock 4 and Dual Sense controllers.
    - Checks Unity Active Input Manager setting on installation and warns user if set to an incompatible setting.
    - Internal changes to allow Rewired plugins to optionally run target platform-specific code in the Unity editor.

    API Changes:
    - Added Rewired.Platforms.Apple.GameController.GCControllerDualShock4Extension.SetLightColor functions.
    - Added Rewired.Platforms.Apple.GameController.GCControllerDualSenseExtension.SetLightColor functions.

    Bug Fixes:
    - Mac OS Standalone, Native, Game Controller Framework enabled: Fixed bug causing crash in MacOS versions prior to 11.0.
    - Reverted old workaround for a platform-specific Unity bug in Rewired Pointer Input Module which disabled the check to see if a mouse is present before processing mouse input events. The workaround caused issues because touch input changes the Unity mouse pointer position.
     
    Last edited: Nov 20, 2022
    adamgolden likes this.
  4. RetroX0

    RetroX0

    Joined:
    Apr 26, 2020
    Posts:
    2
    Hey there. I’m attempting to make on screen button prompts that update depending on the controller type. I’m trying to get the string of the button that’s assigned to an action and display that (Ex. “Button1” is mapped the “W” key on my keyboard in the Input Manager, and I want the on screen text to say “W”). How would I go about doing this?
     
  5. Splashwj

    Splashwj

    Joined:
    Mar 8, 2013
    Posts:
    2
    Hi! I found the following problem:

    When a build is made with the 'Run in Background' option disabled in the player settings and either a Dual-shock 4 or Dual-sense controller is connected while the application has no focus, waiting for more than ten minutes before refocusing on the application, the application will no longer respond and is not actively rendering anymore. Disconnecting the controller will resolve the issue. This happens in a Windows stand-alone build made with Unity 2021.3.12f1 and Rewired version 1.1.43.0. I also tested this with a Xbox One controller and the issue did not occur with that controller. This happens in Development builds as well as Release builds.

    Reproduction: Create an empty project, have some sort of logging that runs in the update or a cube that moves around in the update in order to check if the application is still updating. Disable 'run in background' in the Unity player settings(found in the project settings) and create a build of the project. Connect a Dual-shock 4 or Dual-sense controller and run the application, have the application lose focus by alt-tabbing out of it and leave it going for more than ten minutes(I use twelve minutes just to be sure) without focusing back to it. Go back to the application.

    Do you have any suggestions on how to resolve or prevent the application from being unresponsive after ten minutes in this setup? Thank you!
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    See these:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-element-name-for-action
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I will look into it. There is nothing you can do to resolve this problem without changing code in the DLL. This is undoubtedly due to the low-level Enhanced Device Support for these controllers, doing direct HID communication with the devices to enable all the special features of the controllers. The only thing you can do without modifying the source code is to disable Enhanced Device Support.

    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings
     
  8. Splashwj

    Splashwj

    Joined:
    Mar 8, 2013
    Posts:
    2
    Thank you for looking into it. I tried it with disabling 'Enhanced Device Support' and that does not resolve the issue unfortunately.
     
  9. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    I've updated a project to Rewired 1.1.44.0 in Unity 2022.1.15f1 (update was done by deleting Rewired entirely then installing the new package from the Package Manager). I've used the Tools to rebuild our RewiredConsts.cs to make sure it was compatible.

    Whenever I now go to make a build, I'm getting a stack of namespace related errors in RewiredConsts. These errors did not appear with the previous version of Rewired.

    Any thoughts on what could be causing this?
     
  10. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    Hi there,
    I found an joystick input issue. On Xbox controller, press right D-pad button could trigger others action as well. On DS4 controller, it happends too on left D-pad button. Even I didn't assign D-pad button a Action, it still can trigger other Actions.

    The gif shows that I press DS4 left D-pad reaptly. it should trigger action id:3 (Arrow Left) only, but it trigger other actions some time.
    30.gif

    Also I found similar issue in official Rewired exmaple: SimpleControlRemapping. I use Xbox Controller and press right D-pad button to trigger UIHorizontal action. You can see it some time trigger the Walk action in Default map category.

    31.gif

    Unity version: 2022.2.0b13
     
  11. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Hello.

    The Touch Pad does not track finger movements. On Android device, it follows it if you move slowly, but if you go fast like playing an FPS game requires, it will not move much.

    Just to make it clear. Using the same Android device here are 2 scenarios:
    Scenario #1: a.k.a. Touch Controller Version
    Check ON the Rewired Touch Control Canvas->Touch Controller-> "Disable the mouse input when the touch controller is enabled" box, meaning I'm using the touch controller to pan the camera. See video below.
    Here is the results. Camera does not pan when fingers move fast:



    Scenario #2: a.k.a. "Mouse" Version (Even tho it's really still touch control under the hood)
    Uncheck "Disable the mouse input when the touch controller is enabled", meaning Now I'm no longer using the touch controller to pan the camera, but rather the "Mouse", and it works perfectly the way a touch pad should work.
    Here is the results. Camera pans properly even if I move finger fast.

    So if the actual TouchPad can act like the second video, then that would be the
    fix, that's great. Because this "Mouse" version works perfectly the way a touch control should work. But the problem is it detects any part of the screen and pans the camera even if I am using the joystick, or pressing an attack button, etc.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Inexplicable compiler errors are almost always caused by the use of ASMDEF files in your project:
    https://guavaman.com/projects/rewired/docs/HowTos.html#asmdef-files

    If you set them up in the past, you just deleted them. There is no reason to delete the Rewired folder when updating it.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    1. What platform is this?
    2. Is Steam running or initialized in the project?
    3. Test the Controllers themselves, not the Actions. Debug Information -> Controllers -> THE CONTROLLER -> Axes and Buttons.

    This is absolutely not a normal behavior and I suspect it is being caused by something outside Rewired like hardware, drivers, 3rd part mapping tools, or Steam.
     
  14. nekolyst

    nekolyst

    Joined:
    Mar 12, 2018
    Posts:
    23
    I noticed the JoyToKey is running (I'm using joy-con as quick shortcut on the drawing software).
    After close it, everything was fine.
    Thanks!
     

    Attached Files:

    • 36.gif
      36.gif
      File size:
      214.2 KB
      Views:
      89
    Last edited: Nov 26, 2022
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    The Touch Pad control has a lot of inspector settings. These affect how it behaves:

    https://guavaman.com/projects/rewired/docs/TouchControls.html#touch-pad

    See Touch Pad Mode and Value Format. These must be set to Delta and Pixels to behave like a mouse.

    I just tested this on Android using the Rewired/Extras/TouchControls/Examples/TouchControls1 scene and I do not see any issue with fast swipes using my Samsung Galaxy S20 FE phone. I suggest you test this scene and swipe on the right half of the screen. It is always possible Unity's Input.GetTouches is not working correctly on your device and/or Unity version.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    And when you created your Custom Controller in the Rewired Input Manager, the Axis you created for the touchpad must be set to Relative axis mode. If you leave it the default Absolute axis, values will only be returned in the -1 to +1 range.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Is the primary input source set to Raw Input?
    Is Native Keyboard Handling enabled?
    Is Native Moues Handling enabled?
    If Use XInput is disabled, does the freeze happen using an Xbox controller?

    Edit: So far in my testing, the problem happens with the Dual Sense but does not happen with an old generic gamepad or a Nintendo Switch Pro Controller. Since when Enhanced Device Support is disabled, there is no difference whatsoever in the Raw Input code handling the Dual Sense and other HID controllers, I am 99.9% certain this is not a Rewired issue and is being caused by one or multiple of the device itself, Windows (or the version of Windows), Raw Input, or the driver being used for the device.
     
    Last edited: Nov 26, 2022
  18. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    I use Rewired in my Android game.
    There is a problem that it is not possible to pair with a specific Android and game pad.
    When connecting "Oppo Reno 7a" and "GameSir X2"
    Rewired does not recognize GameSirX2.
    GameSirX2 is recognized by Android and can be used without problems in other games.

    For verification, I installed the latest version of Rewired in a new project and built "ControlMapperDemo1PlayerSimple".
    Xbox and Dualshock4 are connected, but "GameSirX2" cannot press "AssignController".

    Other Androids recognized GameSir X2.
    The only combination I've tried is "Reno7a" and "GameSirX2" that won't connect.
    Any solution?
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    There's no way to make a controller on Android work that does not appear through UnityEngine.Input.GeyJoystickNames or if the controller buttons are not detected by Unity. Rewired is 100% dependent on UnityEngine.Input for all input on the Android platform:

    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    Based on what you've said, the button presses are not being detected by UnityEngine.Input , therefore there is no way to make it work.
     
  20. gamesbydre

    gamesbydre

    Joined:
    Nov 25, 2014
    Posts:
    58
    Is there a way to achieve the "Get Axis Vector" action for playmaker in rewire? I have been trying to figure this out for several days now. I have searched this entire thread after I had already been searching every thread on the playmaker forum. I have not been able to find a solution searching either thread. Is there any playmaker-rewire examples that we can look at to figure out how to move tps characters correctly?
     
  21. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    I'm attempting to acquire the current Element bound to a particular ActionID. To do this, I'm attempting to find the ElementMap with the ActionID for a particular player. The problem I'm finding is there are certain ActionIDs that no matter how I look for them, they always return a null ElementMap.

    I have tried a couple code setups including the following:

    Attempt 1:
    Code (CSharp):
    1.          
    2. Player player = ReInput.players.GetPlayer(0);
    3. List<ActionElementMap> resultList = new List<ActionElementMap>();
    4. player.controllers.maps.GetElementMapsWithAction(rewiredActionId, false, resultList);
    Attempt 2:
    Code (CSharp):
    1.        
    2. Player player = ReInput.players.GetPlayer(0);
    3. ActionElementMap elementMap = player.controllers.maps.GetFirstElementMapWithAction(player.controllers.Keyboard, rewiredActionId, false);
    4.  
    Both of these do get results for a number of Actions, however for a number of actions these always return a null value. One of those ActionIDs is '10' (or PreviousWorld in my setup). Note that this issue occurs regardless of what Key I assign to PreviousWorld. This is how PreviousWorld is setup in the RewiredEditor:

    The Action setup:
    upload_2022-12-1_21-39-40.png

    The Keyboard Element Binding:
    upload_2022-12-1_21-40-49.png

    Any thoughts on what I might be doing wrong?

    Thanks!
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired does not come with any Play Maker examples.

    https://guavaman.com/projects/rewired/docs/Integration.html#PlayMaker

    Documentation:

    There is no PlayMaker-specific documentation. PlayMaker Actions are direct analogues to the methods, properties, fields, and events in the Rewired API. All the standard Rewired documentation applies.

    For example, the Rewired API method:
    player.GetButtonDown

    Corresponds directly to the PlayMaker Action:
    RewiredPlayerGetButtonDown

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

    You should be able to find the Actions you want simply by looking through the Action list in PlayMaker under Rewired.

    RewiredPlayerGetAxis2d is the equivalent of Player.GetAxis2d.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I see no way this could happen if the Action is actually bound to something and that Controller Map is loaded in the Player at the time you call this function. Verify this by using Debug Information at runtime and look at the Controller Maps and Action Element Maps in the Player in question.

    The most likely cause:
    https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced

    The functions in Player are just convenience functions that call functions in Controller Maps that iterate over the Action Element Maps in the Controller Maps loaded in the Player and compare the Action id. Like this:

    Code (csharp):
    1. // This iterates over both Button and Axis maps if the Controller Type supports Axis maps. Axis maps are iterated in the ControllerMapWithAxes override function.
    2.  
    3. internal virtual int GetElementMapsWithAction(int actionId, bool skipDisabledMaps, List<ActionElementMap> results, bool appendResults) {
    4.             if(results == null) throw new ArgumentNullException("results");
    5.             if(!appendResults) results.Clear(); // clear the incoming list first
    6.  
    7.             if(actionId < 0) return 0;
    8.  
    9.             int addCount = 0;
    10.             int count = this.buttonMapCount;
    11.             for(int i = 0; i < count; i++) {
    12.                 var aem = _buttonMaps[i];
    13.                 if(aem._actionId != actionId) continue;
    14.                 if(skipDisabledMaps && !aem._enabled) continue;
    15.                 results.Add(aem);
    16.                 addCount += 1;
    17.             }
    18.  
    19.             return addCount;
    20.         }
    If there is an Action Element Map in a Controller Map in the Player that matches the Action id, it will be returned.
     
    Last edited: Dec 3, 2022
  24. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Hi, I am testing the trial version of this, I am trying to make buttons work on the touchscreen on the nintendo switch. I have filled in that thing on the dev site to get the switch plugin but nothing back yet. Do I need that to get touchable buttons working? With the old input system on unity buttons worked out of the box, but even following the tutorial here https://guavaman.com/projects/rewired/docs/TouchControls.html I cannot seem to get a button to work.

    Also am I supposed to turn off the original button script? Im presuming you dont need a different button on touchscreen otherwise it would get very complex. Any usual gotchas I should know about when doing this?

    It seems like an amazing plugin and will save me time in the long run, but it also seems pretty complex :)
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    That's because the form sends me an email and I have to process every request manually.

    https://guavaman.com/projects/rewired/docs/SpecialPlatformSupport.html#nintendo-switch

    "Fill out the form on the Nintendo Developer Portal for the Rewired Nintendo Switch Plugin and wait until you receive a response by email with instructions on how to download it. You will receive an email with download instructions when your registration has been processed."

    The Rewired Nintendo Switch Plugin cannot be downloaded for the trial version of Rewired. It requires a Unity Asset Store invoice number to download.

    Rewired's touch controls are entirely platform-agnostic and get all of their input through the events sent by the UI Input Module that is in use. The RewiredStandaloneInputModule reads touch input through UnityEngine.Input.GetTouches. The RewiredStandaloneInputModule must not be set to disallow touch input in the inspector. Your Custom Controller created in the Rewired Input Manager must be set up correctly, a Custom Controller Map that maps the touch elements must be created and assigned to be loaded in the Player at start, and Touch Controller and individual touch element inspector settings must be set up correctly to tell them to send their input to the correct Custom Controller elements for the Player to receive the input.

    I don't understand the question. What is the "original button script" you are referring to? If you are using your own touch controls or some that came with Unity and not the ones that Rewired came with, they cannot work unless you do the work to create Custom Controllers and write a script to pipe the input generated by those touch controls into Rewired's Custom Controllers and into the Player-Action system.

    If you are using your own touch controls, the documentation at https://guavaman.com/projects/rewired/docs/TouchControls.html is not relevant to you. That only applies to the Rewired Touch Controls pack.

    A very rudimentary example of using custom touch controls is included in the Examples folder:
    https://guavaman.com/projects/rewired/docs/Examples.html#custom-controllers-touch
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    ... I don't respond well to people who take that kind of attitude with me. There are plenty of examples in this thread. It will not get you anywhere if you want help from me. If you're just here trying to burn a bridge, here's a match. I have no obligation to provide you free support, nor do I have an obligation to take any kind of verbal abuse from you. I have no problem cutting people off from support permanently who act this way toward me. Don't expect to get any groveling corporate boiler plate crap from me in return -- "Oh I'm truly sorry you're not happy with blah blah blah." Not gonna happen.

    You clearly do not understand at all. Rewired can be used with any 3rd party touch controls, as it says in the documentation, however a bridge script has to be written to read input from those controls and pipe it into the Rewired Player-Action system through a Custom Controller. That is what the example I sent to you shows. There is no system on earth that can automatically take some piece of code it has no prior knowledge of that was written for some other framework, modify that code to work with a totally different framework, and just work.

    The Custom Controller provides the interface to push arbitrary input into Rewired's Player-Action system. The script your write bridges the Custom Controller and some other external source of input -- in this case some touch controls you bought somewhere. You write the bridge, then you consume the input through the Player-Action system. All of this information is in the documentation.
     
  27. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    Hi,

    I'm using the InputMapper and I don't want the users to be able to assign buttons to full axis, I have set allowButtonsOnFullAxisAssignment to false and that works fine.

    But I was wondering if the "attempt" is captured by any of the events you can subscribe to, so I can inform the player why the assignment is not successful.

    Thanks!
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    No. Input Mapper does not return a reason for an assignment failure when certain elements are not allowed for assignment They are simply ignored when polling. It does not stop polling when a disallowed assignment is attempted though.
     
  29. blaineOhbibi

    blaineOhbibi

    Joined:
    Dec 6, 2021
    Posts:
    1
    Hello,

    We are using Rewired on our unity project and noticed when doing a memory profiling that the 3DRudder scriptable object is taking almost 8Mb of memory (even though the scriptable object itself is 32Kb) - we tried removing it from the ControllerDataFiles scriptable object but it changed to 3DconnexionKMJEmulator instead...
    I guess there's a copy of a default scriptable object done for all controller types, but I cannot find how this scriptable object is chosen, and why all these copies are done. Or maybe there's a memory leak somewhere.

    upload_2022-12-12_18-9-54.png

    Would you know why there's a controller scriptable object taking that much space in memory, and if there is a way to avoid it?

    Thank you very much!
     
  30. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
    My game has a mechanic that uses scroll wheel to switch equipment in an equipment list based on scroll wheel axis. On Game Pad I want to use D-Pad left to go left in the list, and D-Pad right to go right in the list, so I mapped them to Axis type, positive for right D-Pad and negative for left D-Pad. The problem is, whenever I press right or left D-Pad, the process triggers too many and player immediately goes to the front of the list if I just press D-Pad left once, and end of the list if I press D-Pad right once. Is there a way to slow down?

    I debugged my function,
    Code (CSharp):
    1. HandleInventory(ClampScrollWheelDelta(RPlayer.GetAxisRaw("Scroll")));
    Which basically if value returned from clamp is -1, go to previous slot, and if 1, go to next slot. Anytime I press D-pad left/right once, the process gets fired 12 times. Is there a way to limit the D-Pad from triggering again before it's lifted up (So like my single press won't get fired too many time due to high fps and each frame is a fraction of the speed my finger lifts up from D-Pad).
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    The memory profiler is giving you bad information. This is the memory usage of all controller definitions, not the one it's telling you.

    Relevant:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#increased-compile-play-time-editor
    https://guavaman.com/projects/rewired/docs/HowTos.html#excluding-controller-definitions
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    You should be aware of the differences between Absolute and Relative axes. See this:
    https://guavaman.com/projects/rewired/docs/HowTos.html#relative-absolute-axes

    All joystick axes and buttons read as axes are Absolute.
    All mouse axes are Relative.

    GetAxis gives you the current value of the axis. There is no way to make it only return once per d-pad press. All joystick axes return an absolute value. That means they return the current value of the axis, whatever that happens to be. It is standard practice to multiply absolute axis values by Time.deltaTime to decouple the value from the frame rate. You do not do this with relative axis values, which are delta values that represent the change in value since the last frame.

    The solution as to how to make the d-pad work the way you want isn't to slow down the axis input. The solution is to process that axis input in a way that will result in what you're trying to achieve. Processing of input is done outside the input system in a script, reading the input and processing it in some way to achieve what you want. Once you have the input values, the input system it came from isn't important. For example, any tutorials that pertain to processing or using input that came from Unity's input system would also work exactly the same with input provided by Rewired. Unity's Standalone Input Module has logic to read button and axis input and move the selection based on user-defined criteria (Input Actions Per Second, Repeat Delay). It reads the axis input, but only advances to the next selection after some time has elapsed with continuous input. This logic is outside the input system and acts on the input provided by the input system. You can do the same in your own scripts.

    There are many different ways to handle this depending on how you want your UI to work -- too many for me to list. Apart from coding your own input processing, there are also a few helper functions in Rewired which process input in different ways, which may or may not apply, depending on exactly how you want your UI to work. For example, Action input can be read as various kinds of button (digital) input. GetButtonRepeating may be applicable. The absolute simplest implementation would be to use GetButtonDown which would require the user to press the d-pad each time to move the selection. Note that these helper functions are intentionally limited to a few common use cases, as the input system's primary job is not to do extensive processing of input, but simply to provide the input for you to utilize in whatever way you choose.

    All of that is to say, there is no one correct solution to your problem. This is a task that requires you know what result you want and then figure out what the best way to achieve that result is for your particular use case.
     
    Last edited: Dec 13, 2022
  33. gamesbydre

    gamesbydre

    Joined:
    Nov 25, 2014
    Posts:
    58
    I was told you have an integration with Invector, but upon inspecting your asset, there is none. Is there any integration that works with Invector
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    All integrations that I know of are listed here:
    https://guavaman.com/projects/rewired/docs/Integration.html

    I don't maintain any integrations that are not included with Rewired. It's possible that someone else made one, but I am not aware of anything but the ones listed in the documentation.
     
  35. kevinsyang17

    kevinsyang17

    Joined:
    Apr 3, 2018
    Posts:
    37
    Hi I followed the standalone input module tutorial but it doesn't work on World space UI, is there something I missing

    In addition, does Rewire Mouse work with buttons rendered by code through GUILayout.Button?
     
    Last edited: Dec 14, 2022
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Without information on your entire setup, I can't say whether you missed something or not. If you follow the documentation on setting up the Rewired Standalone Input Module, it will work to generate Unity UI events through the Event System and any elements that consume those events (buttons, scroll bars, etc.) will receive them.

    As with all "input doesn't work" problems, the first place to start is Debug Information:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    No. GUILayout is IMGUI, a totally different system than Unity UI. Standalone Input Module is only for generating events for Unity UI. There is no such system that allows you to change the input source of IMGUI. IMGUI's input handling is entirely internal to Unity and not modifiable.
     
    Last edited: Dec 15, 2022
  37. Reign_of_Light

    Reign_of_Light

    Joined:
    Oct 15, 2014
    Posts:
    46
    Hi,

    is there a way to (at least temporarily) disable Rewired's callback error handling? Since using Rewired, almost all errors I'm receiving in Unity (99% of which are completely unrelated to Rewired other than that some input was involved) are handled through Rewired, which is really inconvenient because:

    1. There's always this text being added to the beginning of the error message:

    An exception occurred inside an event handler or callback.
    Source: Player input event callback
    This happens if your event handler/callback code throws an exception. This means the error is in your code, not Rewired. Read the exception message and the stack trace carefully to find the source of the exception being thrown by your code.
    This can also happen if you forget to unsubscribe to an event in a MonoBehaviour class and that object gets destroyed. Make sure you unsubscribe to events in OnDisable or OnDestroy. Rewired will attempt to continue running.


    .. which I have by now (involuntarily) read 2348980234 times when really I only ever wanted to know the actual error/exception.

    2. I use the "Editor Console Pro" asset which is (among other things) meant to display the stack trace in a much more readable, cleaner way. However, since Rewired takes it on itself to process and log (almost) all errors, I only ever get this stacktrace in 'Editor Console Pro' :


    Logger.LogErrorNow()
    Logger.LogError()
    ReInput.HandleCallbackException()
    ...


    ... which means I still have to deal with the messy plain text stacktrace which is output by Rewired's logger.

    Rewired's error handling is obviously a feature not a bug. But 97% of the time I am not debugging Rewired and I would really love Rewired to not process error messages then.
     
  38. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    ****UPDATE****
    Nevermind I figured it out! :eek:

    The problem was that the Map Category "Action" was not referring to the same "Action" from the Element Properties.

    I'm reading over this now alongside the examples.
    https://guavaman.com/projects/rewired/docs/HowTos.html
    It's a bit overwhelming, but super helpful too.:rolleyes:
    ****UPDATE****




    Hi Guavaman,

    Hope you're doing well.

    I hope you can help me out. I'm at my wits end on this one. :(

    Current outcome: When restoring default values for CONTROLLER, Camera Left\ Right\ Up\ Down are empty.

    Expected outcome: When restoring default values for CONTROLLER, Camera Left\ Right\ Up\ Down appear as set in the Rewired Input Manager. (They are the right analog sticks)

    I messaged you with some videos of the setup as well as the project.

    The controller is the 8BitDo SN30 Pro+

    Thanks for your help
     
    Last edited: Dec 22, 2022
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired is not handling any exceptions at except those which are thrown by code executing in callbacks of Rewired events.

    There's no way to change how these errors are reported by Rewired. Rewired is catching exceptions thrown by code executed in Rewired callbacks. If Rewired didn't catch these exceptions, they would be caught by Unity which would then halt execution of the remaining code Rewired needs to execute in the callback after the exception.

    You can certainly catch your own exceptions in the callback functions and handle them any way you want. Rewired wouldn't even know an exception occurred.
     
    Last edited: Dec 22, 2022
    Reign_of_Light likes this.
  40. Reign_of_Light

    Reign_of_Light

    Joined:
    Oct 15, 2014
    Posts:
    46
    Ah, I see. Okay, Rewired catching exceptions is surely preferable to the execution being halted, in many cases.

    Maybe it is unique to my project or coding patterns (signals that trigger lists of commands), but with my game most errors and exceptions seem to happen in response to some input by the player. But I understand that there is no way to disable Rewired's error handling and that I likely wouldn't even want to, all consequences considered.
     
  41. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    hey small question
    is there a way that we can get the "Active Input Device", which should be the last input device that the player has used?
    i want to check if player is using a controller or keyboard and so on
    i tried with

    Code (CSharp):
    1.             Rewired.Controller lastController = instance.player.controllers.GetLastActiveController();
    2.             if (lastController != null)
    3.             {
    4.                 switch (lastController.type)
    5.                 {
    6.                     case Rewired.ControllerType.Keyboard:
    7.                         return false;
    8.                     case Rewired.ControllerType.Joystick:
    9.                         return true;
    10.                     case Rewired.ControllerType.Mouse:
    11.                         return false;
    12.                     case Rewired.ControllerType.Custom:
    13.                         return true;
    14.                     default:
    15.                         break;
    16.                 }
    17.             }
    but it appears to keep returning null
    Edit:
    Found it, this code works, its just that if we call it before we run any sort of input, then it returns null, so at the start of the game its null, and it gets a value the moment we press any input
    so i needed to check for null value.
     
    Last edited: Dec 23, 2022
  42. jouietamse

    jouietamse

    Joined:
    Nov 24, 2018
    Posts:
    4
    Hi everyone I am new to rewired and I am using it now for my beat em up project but I am stuck at dpad UI navigation problem. Is there a tutorial how to setup for dpad UI navigation? thanks for your help
     
  43. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  44. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @guavaman

    They look very similar to all of the flight controllers you support. :) Regardless it is interesting to see some of many variations used on real controllers (aerospace/defense)

     
    guavaman likes this.
  45. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi Guavaman

    Hope you had a good break.

    I have 2 more questions.

    I'm back to banging my head against the wall again. (In particular the second question)

    #1. I set the "Up Arrow" key as protected. Is there a warning I can say like "This button is protected", currently it says "Already in use and cannot be replaced", which is visually confusing to the player, as you can see in the GIF the "Up Arrow" is not in use. :oops:
    ezgif-4-a5abb22c16.gif

    #2. This is related to the joystick. Since "jump" has not been assigned to an axis, I get a red error.

    Code (CSharp):
    1.  string _s = player.controllers.maps.GetFirstAxisMapWithAction("jump", skipDisabledMaps).elementIdentifierName;
    2.  
    I just want to know if the left\right axes triggers have actions assigned to them.

    The debugger under Axis Maps(8) is showing me that neither Left or Right trigger has been assigned. But how do I get that information via C#? Preferably a return that says both triggers are null or disabled. :oops:

    I thought it was this, but I can't get it to work.
    https://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_ActionElementMap_enabled.htm
    upload_2022-12-24_0-40-37.png


    Thanks for your help
     
    Last edited: Dec 24, 2022
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    There is no tutorial on setting up Unity UI navigation for a d-pad. There is nothing special about a d-pad. A d-pad consists of 4 buttons. There's no difference between a d-pad button, a button on a controller, or a keyboard key.

    As @longroadhwy said, if you are referring to Unity UI navigation, that is handled by the Rewired Standalone Input Module and all setup instructions are at the link provided:
    https://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html

    If you can't find the solution, you will have to describe clearly exactly what problem you're having with d-pad UI navigation.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Cool! :cool:
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    No. Not unless you want to edit Control Mapper and add this feature. The key is in use if you set up a protected bindings. You're just not showing the user what Action is bound to that key in this action list.

    I don't see any Actions named "jump" in your Controller Map, so this can't work. It is throwing a null reference exception because you are chaining function calls. The result is always null if binding with a matching action is present.

    There is also no code there that relates to the trigger elements. If your purpose is to see if anything is bound to some element, you wouldn't be searching for a binding by Action. You'd have to search all possible Actions to rule out something being bound to a particular controller element. That's not an efficient approach.

    What you're trying to do is not simple. Rewired's controller system is not specific to gamepads. There is no guarantee any controller will have triggers. If you want to do that, you have to make the assumption the user is using a gamepad. The only way to know the user is using a gamepad (only recognized gamepads) is to use the Controller Template system.

    https://guavaman.com/projects/rewired/docs/ControllerTemplates.html

    What you want to do requires that you first get the element identifier ids of the triggers for that specific controller from the Controller Template, then search the Controller Maps in that Player for that Controller for Action Element Maps that bind an Action to those trigger element identifier ids.

    Here is an example of working with Controller Templates:
    https://guavaman.com/projects/rewired/docs/Examples.html#gamepad-template-ui
     
  49. cach

    cach

    Joined:
    Jun 9, 2013
    Posts:
    4
    Hey, I've only been using Rewired for a short while but I really like it, it's great!
    I have a couple of questions

    1. Is there a way to "force" an input via code? For example, lets say the player is physically holding a button down. But after a certain time I want the code to ignore that input and act like the button isn't pressed anymore. I realize that I can achieve this behaviour in many ways (and have already done so in my current project), but I'm asking if there's an easier way within Rewired.

    2. In a similar vein, I'm trying to make my character to execute a very typical 1-2-3 combo (same button pressed 3 times with a certain timing) I was wondering if Rewired has something to help this kind of behaviour.
     
  50. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hmm ok. Do you suggest we edit the control mapper?

    Just to throw in a monkey wrench. Since there is a lot of pop up text, how do we localize it for users that don't speak English?:(

    Seems like I dove too deep into the rabbit hole this time eh? :D

    Yea I looked at the Controller Templates project in Unity. Got confused... I'll have to look into that some more.

    Btw both API links are broken. :(
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_IGamepadTemplate.htm
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_GamepadTemplate.htm

    ***UPDATE***
    Ok after my brain melted from reading more of the documents.... I finally hacked together something I can work with.

    Essentially using GetAxisMapsWithAction to find "jump" and saves into List<Rewired.ActionElementMap>. From there I can grab the elementIdentifier ID and assign the appropriate UI Icon.

    (Assuming "jump" was assigned to an AXES and not a BUTTON. I'm sure people are confused.)

    To be honest the most helpful codes examples are found here:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-element-name-for-action

    This was a good starting point too. Albeit a lot to digest..
    https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-template-specific

    Looking through the Unity scenes \ scripts is quite overwhelming for the programmatically challenged, like myself. Less is more I guess. :rolleyes:

    I'm going to go lie down for a bit now ..

    Merry Xmas, thanks again for the help!
     
    Last edited: Dec 24, 2022