Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. HWIvan

    HWIvan

    Joined:
    Jan 21, 2019
    Posts:
    12
    Using Bluetooth yeah. The D-Pad works fine in other (non-Unity) games. D-Pad also works fine on iOS and tvOS with Rewired; only macOS is causing issues.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    There is no way to know what input APIs those games are using. It's possible they're using Apple's Game Controller Framework, not I/O kit. That is definitely the case on iOS and tvOS.
     
  3. HWIvan

    HWIvan

    Joined:
    Jan 21, 2019
    Posts:
    12
    I see. Are there any plans for a Game Controller Framework input source for macOS (iOS and tvOS too; would be cool too to bypass Unity there as well)?
     
  4. LoopIssuer

    LoopIssuer

    Joined:
    Jan 27, 2020
    Posts:
    105
    I have question about mouse sensitivity.
    I change in Input Behaviour Mouse XY Axes Sensitivity - tried values like 0.1, 1, 1000, but I can't see any result - cursor still moves with the same speed/sensitivity.
    Please tell me how to change this.
    Is there sth like PlayerMouse prefab/script needed?

    Thanks in advance
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Rewired cannot change the OS cursor position:
    https://guavaman.com/projects/rewired/docs/FAQ.html#set-mouse-cursor-position

    If you are using Player Mouse, you cannot change the speed the cursor moves if you are using the Hardware Pointer Position:

    https://guavaman.com/projects/rewired/docs/PlayerControllers.html#player-mouse

    Use Hardware Pointer Position If enabled, the hardware pointer position will be used for mouse input. Otherwise, the position of the pointer will be calculated only from the Axis Action values. The Player that owns this Player Mouse must have the physical mouse assigned to it in order for the hardware position to be used, ex: player.controllers.hasMouse == true.

    The OS cursor speed can only be changed by the user through Windows control panel or you would have to implement a slider in-game using Windows API function calls.
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    There are no plans to implement native input on iOS or tvOS.

    I have been working on Game Controller Framework support for MacOS off and on for 6 years. At the time I started, I discovered eventually that it was simply not possible to do due to problems in Unity preventing it from ever working. Later they fixed this issue to make it at least possible to access the API. I have revisited this 3-4 times since then, but haven't completed or released any of the implementations for a variety of different reasons. I don't have any announcements to make on this at this time.
     
  7. HWIvan

    HWIvan

    Joined:
    Jan 21, 2019
    Posts:
    12
    Fair enough, thanks for the info.

    Is there a way (or do you plan for there to be a way) to write our own Input Source?
     
  8. hipinds

    hipinds

    Joined:
    Aug 31, 2017
    Posts:
    5
    Hey, guava,
    First, I would like to thank you for the fantastic asset that rewired is!
    Second (the issue :D): Do you know why the debug canvas is triggering when the game starts? I mean, somehow, none of the input events work on the controller. However, they still work on the keyboard. When I move the right analogic down (only move, not press), the debug canvas opens and goes crazy. This started to happen a few days ago, both on unity versions 2021.2.10 and 2021.2.14.
     

    Attached Files:

  9. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    I'm tring to get to have to different layouts in a game, one for normal gameplay and one for the UI.

    This is how my Layout manager rules are setup:

    This is the Joystick map:

    On boot up I added to the player like so (default ID in rewired is 1 and the UI is 4):

    Code (CSharp):
    1.      var ruleSet1 = ReInput.mapping.GetControllerMapLayoutManagerRuleSetInstance(1);
    2.         var ruleSet2 = ReInput.mapping.GetControllerMapLayoutManagerRuleSetInstance(4);
    3.  
    4.         m_player.controllers.maps.layoutManager.ruleSets.Add(ruleSet1);
    5.         m_player.controllers.maps.layoutManager.ruleSets.Add(ruleSet2);
    6.  
    7.         m_player.controllers.maps.layoutManager.Apply();
    And whenever I want to enable or disable I do this:

    Code (CSharp):
    1.  List<ControllerMapLayoutManager.RuleSet> ruleSets = m_player.controllers.maps.layoutManager.ruleSets;
    2.  
    3.         foreach (ControllerMapLayoutManager.RuleSet ruleSet in ruleSets)
    4.         {
    5.             ruleSet.enabled = ruleSet.tag.Equals(p_tag);
    6.         }
    7.  
    8.        m_player.controllers.maps.layoutManager.Apply();
    In the rewired debug it shows the correct set rule is enable or disable but inside the game both rules are providing output.

    What am I doing wrong?

    Thanks!
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Unfortunately, no. It's too complicated and involves too many internal classes and the requirement that the Controller Definition code be changed to support the new platform.

    The only way you can support a platform that doesn't work out of the box is by piping input in through Custom Controllers.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    I need clear information to understand what problem you're having. I don't know anything about a "debug canvas" -- that's not part of Rewired. I don't know how you've designed your canvas / UI to trigger when to open so I can't even come up with a theory of what would be causing it to open, etc.

    You're saying UI control is somehow messed up when using a game controller trying to navigate your canvas. "Going crazy" could mean a lot of different things. The best assumption I can make is you're saying the UI is navigating by itself randomly from joystick noise.

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

    Figure out where the input is coming from. All Actions in the Player are exposed here. All Controllers are also exposed. You can view the live values of both at runtime. All the currently-loaded Controller Maps are also available here, so you can see exactly what Actions are mapped to elements on specific controllers.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Look at the actual Controller Maps loaded in the Player.

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

    Only enabled Controller Maps in a Player can contribute to input in that Player.

    Also, LayoutManager must be enabled or it will do nothing. It is not enabled by default. And seeing that you've chosen to initialize it by code in the Player instead of using the UI, you probably did not enable it.

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


     
    Misscelan likes this.
  13. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Hi,

    I imported Rewired in Unity2020.3.30f1(LTS) and got this error

    Assets\Rewired\Internal\Scripts\Misc\ExternalTools.cs(84,34): error CS0535: 'ExternalTools' does not implement interface member 'IExternalTools.WindowsStandalone_ForwardRawInput(IntPtr, IntPtr, uint, IntPtr, uint)'

    Rewired version is Version 1.1.41.5 - January 27, 2022

    Project is very fresh(empty) and it uses old unity input.

    I tried using an old Rewired version from my other projects but they didn't build with IL2CPP in this Unity version.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    You've installed Rewired Unity 2021 in Unity 2020.

    Rewired version always has an appended Unity major version.

    Menu -> Rewired -> Help -> About

    You will see Rewired 1.1.41.5.U2021 shown there.

    Rewired for Unity 2021 cannot be used in Unity 2020.

    See this:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed
     
    kopanz likes this.
  15. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,630
    Hello, I forgot about this because I reverted rewired and completely erased from my mind. Now I updated it again and I have the problem again. I am not sure why you think it's a problem with my project, the method is not found in any of the rewired files now present.

    If I look for ForwardRawInput this is what I find:

    upload_2022-3-14_15-33-5.png

    this is the method your code is looking for:

    Rewired.Internal.Windows.Functions.ForwardRawInput(...)

    maybe I should unzip one of the integration zip files where I can find the code missing? or maybe it's defined in some dll?
     
  16. Hi_ImTemmy

    Hi_ImTemmy

    Joined:
    Jul 8, 2015
    Posts:
    174
    Hello,

    Is there an event / delegate that will fire whenever any input is detected from attached devices? I've basically got a 'press any key to continue' screen and I want it to respond to any input such as a key press, mouse button press, or joystick button press.

    I've tried using...
    player.AddInputEventDelegate(OnInputUpdate, UpdateLoopType.Update, InputActionEventType.ButtonJustPressed);

    ...but that only handles buttons that are setup on the player.

    Thanks!
     
    Last edited: Mar 14, 2022
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    I'm saying something is wrong with your project because it's not possible to get this error with a proper, normal installation of Rewired. The file it is looking for is one of the files included in the base Rewired installation in the Unity package.

    Unless you've installed Rewired for Unity 2021 in Unity 2020 or some other mismatching combination, you would have to have partially installed the Rewired files or deleted some files somehow to get this error, or you would have to have some kind of ASMDEF setup that is causing it to compile some of its scripts in the wrong assembly.

    So the only possibilities are:
    • Installing the wrong version of Rewired for Unity you are using.
    • Only partially installed files from the Rewired Unitypackage.
    • Custom ASMDEF files causing scripts to be compiled in the wrong assembly.
    I cannot tell based on the error alone.

    Delete the Unity Asset Store package cache:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed

    Delete Rewired entirely and reinstall it:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#clean-reinstall
     
    sebas77 likes this.
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    https://guavaman.com/projects/rewired/docs/HowTos.html#important-classes

    Global Information:


    There is no event. Input events only exist for the Player-Action input system. You have to poll:

    https://guavaman.com/projects/rewir...ReInput_ControllerHelper_GetAnyButtonDown.htm
     
    Last edited: Mar 15, 2022
    Fira-Soft likes this.
  19. Hi_ImTemmy

    Hi_ImTemmy

    Joined:
    Jul 8, 2015
    Posts:
    174
    Thank you. Working great.
     
  20. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    A tiny addition to ThemeSettings (it adds the option to choose a custom Capital style setting too for TMP texts)
     

    Attached Files:

  21. s8cusyqr

    s8cusyqr

    Joined:
    Jul 9, 2018
    Posts:
    7
    There is error when installing. Input manager couldn't be added to execution order, so I should do it manually, but on script execution order list there is only inputmanager_base, but not inputmanager, so I can't add it, why?
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    What is the error? There should never be an error on installation and you should never have to manually set anything.

    Delete Rewired entirely and reinstall it.

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

    InputManager is compiled by Unity from a script. If Unity cannot or is not compiling that script, then it will not be listed. That would explain why Rewired's having an error too. It can't install if the scripts included with Rewired are not compiled or are compiled to the wrong assembly.
     
  23. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Hi,

    I'm trying to provide support for all Fanatec Wheel Bases and Steering Wheels.
    I received an excel file from Fanatec that includes product ids, product names and some information of axes that their wheel bases and pedals use.

    There might be an issue to detect Fanatec Wheel Bases in current setup of the Rewired. Fanatec only have product ids for the wheel bases. Steering wheels are connecting on wheel bases. Because that many different steering wheels could be connected to fanatec wheel base it's not very clear that how many buttons and hats that a Fanatec Wheel Base is going to have(It's probably a fixed value but hard to guess).

    Rewired uses Axis/button/hat counts along with product name and product id to identify a joystick.
    Can I just leave axis, button and hat count fields empty(or enter zero) and let the Rewired detect fanatec hardware just by using product id and product name ?
    I know Rewired Control Mapper can map any joystick but I want to recognize Fanatec wheels in the game and provide at least basic functionality for the wheel and pedals.

    csl.JPG
    There are some info in their driver files. But the axis/button numbering is not very consistent. Does rewired counts all available axes and buttons without getting confused by the inconsistency of the driver file like shown above ?

    Thank you
     
    Last edited: Mar 22, 2022
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Hardware where some elements can change cannot be supported by the controller recognition system. The base assumption of this system is that a controller can be positively identified through identifying information to a definition of the controller that contains a static list of known elements and their mappings.

    It depends on the platform and input source. A few support ignoring element counts with -1. Most don't.

    The controller definition it gets matched to would have to be able to support all possible buttons and axes that might be used by any of the add-on wheels or none of those elements would be usable. Rewired will not dynamically add elements to a controller definition based on HID information. Controller definitions are static and pre-defined. Making a definition that contains a bunch of buttons and axes so any elements could be used is nothing more than making the Unknown Controller all over again, in which case, just use the Unknown Controller and let the user map their controls at runtime.

    To even make a partial definition that could match all these combinations, you would have to be assured that every configuration exposes the wheel and pedals on the same axis and button indices. Then you would have to make a bunch of additional sequential axes and buttons to be able to support any additional functionality the device has, just like the Unknown Controller does. If button or axis indices of the base elements you're trying to support ever change among the different configurations, the whole plan will fail, making having a broken controller definition worse than having nothing at all and allowing the user map their controls as an Unknown Controller.
     
    Last edited: Mar 23, 2022
  25. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,549
    It is interesting that supports all 3 platforms (PC/XBOX/PS4) with the same wheel. Which is different than what ThurstMaster and Logitech do (PS/PC or XBOX/PC models). It is also interesting that everything plugs into the base and no separate USB connections for pedals or handbrakes like the other brands have. I guess that makes sense for the console world.

    Which you can see at around 2:30 in the video for connections in the back of the base. And the software at around the 13:58 timestamp.

     
    guavaman likes this.
  26. pocolomos

    pocolomos

    Joined:
    Nov 8, 2018
    Posts:
    5
    Hi guys

    I got a problem with button Square on ps4 ps5(not sure in other device). When i press button Square then the action before be replication.
    E.g: L1 to next
    R1 to previous
    Square no function
    I press L1 next, Square it next more time, i press R1 previous, Square it previous more time.

    I have setting joysick with map is ps4 ps5 and gamepad template. But it have issue like i explain, so i try to delete map ps4 ps5 but it not solved. Anyone have the ideal?

    Below is all setting i using:
    upload_2022-3-23_18-31-26.png

    upload_2022-3-23_18-31-56.png

    upload_2022-3-23_18-32-15.png

    upload_2022-3-23_18-32-23.png
     

    Attached Files:

  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    There is no possible map you could create that would result in the Square button changing functionality from Previous to Next dependent on the last button you pressed.

    Your question is about Unity UI (inferred from your images), therefore there is a lot more involved than just mappings. Inspector settings in the Rewired Standalone Input Module are involved, but also the entire Unity UI system is involved. This includes all the Buttons, Sliders, etc., that make up your scene. These Selectable objects are what actually respond to input events generated by the Input Module and navigate from one Selectable to the next. Problems could exist anywhere in this chain.

    You need to rule out the controller element values and Action values.

    The tool for the job:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Check the value of the UI Actions live at runtime and watch what is happening when you're pressing the buttons. Are they doing what you expect? Is Next Tab actually activating when you press Square? If it is, look through all the Controller Maps in your Player and find out which map is mapping Square to the Next Tab action. If it's not, then you can be sure the problem is not coming from the Next Tab or Previous Tab Action.
     
  28. nigelsherrier

    nigelsherrier

    Joined:
    Oct 17, 2021
    Posts:
    3
    First Id like to applaud you for keeping up the soul support for such an incredibly long time , im sure many in this forum are deeply grateful, myself included.

    Secondly Ive had an amazing experience using Rewired for my single player game dev projects. But Im looking for some answers to an issue im having involving PhotonPun 2 , and build inputs, Im making a Multiplayer FPS in Bolt VS. and Im testing the Inputs in build and editor.


    For some reason regardless of the configuration I cant seem to stop input from being read on both builds of my game at the same time when using Rewired, Ive been dealing with this all day and have narrowed it down to a Rewired issue.it works fine outside of rewired and my code is set to only listen to input from the owner as seen above, but im not sure if its my implication or something im forgetting?

    I only have 1 player profile made but I figured this should be fine for an Online multiplayer game. Im not sure if this is the issue but I wouldnt really know how to go about creating a new profile for each player connected to the match if necessary.
     
  29. pocolomos

    pocolomos

    Joined:
    Nov 8, 2018
    Posts:
    5

    Hi Guavaman
    I'm trying to log all function be attach to controller, and just one function to assign for Square. And i checked that that function not make replication. I'm not sure why until now
    upload_2022-3-24_17-54-15.png
     

    Attached Files:

  30. pocolomos

    pocolomos

    Joined:
    Nov 8, 2018
    Posts:
    5
    Even i removed all function attached for Square, but it still replication upload_2022-3-24_18-3-8.png
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    As I said previously, you need to Look at the live value of the Actions. That is the most important thing to see. Only the Action values you assigned to the Rewired Standalone Input Manager inspector can trigger navigation events. If the Next Tab or Previous Tab is non-zero when you're pressing Square, then something is seriously wrong. If it is, look at the value of the joystick elements themselves.

    If the Actions values are always 0, then something entirely different is happening. It could simply be drift from the joystick axes that have too small a dead zone for your particular stick. This is all easy to debug using Debug Information. You have visual access to every single piece of data that makes up the input stack.
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    I don't understand what you're asking. No matter how many times I read it, I cannot be sure I understand what your problem is. "I cant seem to stop input from being read on both builds of my game at the same time when using Rewired." I don't know what that means. Under what circumstance would you want to stop input from being read and how are you trying to achieve this? I know nothing about Photon Pun 2, but that should not even be relevant to how Rewired works. Rewired does not and should never know anything about any other connected networked players. Rewired is a client-side-only input system that is only concerned with input on the machine on which it is being run. It has no concept of networking. It provides input to your scripts. Your scripts do with it whatever they want, whether that is processing the input to move an object, sending input to a server so it can move the object, processing input to moving an object and then sending that resulting change in the object over the network, etc.

    Is the problem here you're trying to synchronize disabling input between two networked instances of your game so input stops working at the exact same time on both machines? If so, that would be entirely on Photon and how it handles networking. I don't know if it's even possible to guarantee that because of network latency. Each machine has its own copy of Rewired and each are being updated every frame by Unity in the Update loop. There's nothing special about Rewired in that Regard. Rewired is no different than any other script that you can write. It just runs every time Update is called and does its thing. If it's possible to somehow guarantee both machines will receive the message to stop over the network at the exact same time, then both would be perfectly in sync. That doesn't sound possible. Again, I don't know anything about Photon Pun 2. I'm just speaking generally.
     
    Last edited: Mar 24, 2022
  33. nigelsherrier

    nigelsherrier

    Joined:
    Oct 17, 2021
    Posts:
    3
    Sorry I was testing input in the unity editor and the build version of my game , which both had instanced players on my network , I was controlling both at the same time even when tabbed out which i did not want ,I only wanted to control 1.
    But I realized that both instances of the game were referencing the same joystick controller so the inputs were controlling both games

    simply launching the build version on a different computer from my editor fixes the problem.
    Its just something I didnt expect as Unity by default doesnt do that , no worries on that!

    But I would like to know if there is a way to essentially disable rewired input with a line of code?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    No. Rewired, like Unity's input system, does not have a global input on/off switch. In my opinion, the need for something like this reveals weak design of input processing logic. This is almost always asked because Rewired (the input system) is being used as the sole flow control for input processing. Scripts simply consume and process whatever input is received without regard to any other factors that should affect whether this input should be processed at this time. The application should implement a separate state permission system or other means of flow controlling the processing of input rather than flow controlling the input itself. With some kind of state permission system in place, input processing could be easily toggled, filtered, or otherwise modified depending on current game/application states.

    From the documentation:

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

    Rewired’s Purpose and Responsibilities

    It is common for Rewired's Action system to be used in an unintended manner as an integral part of or in place of a separate game state management system. This is not what Rewired was designed for and not how it is intended to be used.

    • Rewired’s sole purpose is to read user input.
    • All “Actions” in Rewired are actually “Input Actions” and should not be used for any other purpose than to get information about the user’s intent. They should not be confused with or used as game states or actions.
    • The Action “Jump” does not designate “Player is jumping,” but rather “The user wants to jump.”
    • The game should implement permission and state management systems that evaluate user input and then change states. After that point, what happens is outside the responsibility of the input system.
    https://guavaman.com/projects/rewired/docs/FAQ.html#consume-input

    How do you consume/use an input?

    There is no "consume" or "use" concept in Rewired. You cannot change or override the final Action input values because they are set by the hardware events and then calculated based on combined values of all input sources that contribute to that Action.

    This question is almost always asked due to the desire to use the input system as part of in-game player state/permission management. For example, you should not think of Rewired's Player.GetButtonDown as a flag denoting "game player is now firing". It should be thought of as a signal of the user's intent entirely separate from the game simulation. GetButtonDown("Fire") is equal to "the user wants to fire". Whether or not the game player is allowed to fire at that moment is a game player state management issue and needs to be handled in your game code.

    "User wants to fire" -> If "game player is allowed to fire" -> then "fire".

    Using Rewired or any input system as an integral part of game state or permission management is not a correct usage. This way there is no need for something like consuming input and injecting your game state permission management into the input system.

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

    Regardless, input values returned by Rewired can be flow controlled in many ways. There is no global on/off switch for all input (apart from disabling and shutting down Rewired entirely which has many other consequences), but there are many ways to affect the resulting input values for controllers, Actions, etc.
    1. Disable the Controller.
    2. Disable the Controller Map.
    3. Disable the Action Element Map.
    4. Delete the Action Element Map from the Controller Map.
    5. Unassign the Controller from the Player.
    6. Remove the Controller Map from the Player.
     
    Last edited: Mar 24, 2022
    andreiagmu likes this.
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    Ignore Input When App Not In Focus
    Ignores input if the application is not in focus. This setting has no effect on some platforms.

    NOTE: Disabling this does not guarantee that input will be processed when the application is out of focus. Whether input is received by the application or not is dependent on A) the input device type B) the current platform C) the input source(s) being used.
     
    andreiagmu likes this.
  36. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    Hello, I am wanting to make an android game where I can use a bluetooth button. The kind of button that you can get from aliexpress for taking a selfie without needing to be touching the phone.
    Does Rewired detect these devices?
    How would I go about figuring out how these inputs are labled?
    I'd like to have 4 of these buttons working at the same time, think buzzers on a gameshow.
    Is this possible?
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    >> Does Rewired detect these devices?

    I don't know. Rewired is 100% dependent on UnityEngine.Input for all input and device detection on the Android platform:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    If Unity sees it and exposes it as a Joystick, then yes. If not, then no.

    >> How would I go about figuring out how these inputs are labled?

    They would be 4 individual Joysticks that would have one functioning button each. They would be treated as Unknown Controllers. The name displayed would be whatever the manufacturer set as the Product Name in the HID descriptor.

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

    Controllers with Extended Support
    Controllers with hardware definitions are recognized on each platform and are fully mappable by element name, have standardized axis directions, and may be compatible with a Controller Template for easy mapping. For all other controllers that do not appear in the following tables, please see this important note.

    All other controllers not listed above
    Any controller which does not have a hardware definition will be usable only through user mapping or by mapping actions to numbered axes and buttons in the Unknown Controller map. These unrecognized controllers can only be supported if you provide your users a way to remap their controls, such as by using the included Control Mapper or by creating a custom control remapping screen. If you do not provide users with a way to map their controls, only the above listed recognized controllers will be usable. If you do provide your users a way to map their controls, virtually any controller will be usable.
     
  38. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    Thanks for that. I'll see what I can discover.
     
  39. Michal_G

    Michal_G

    Joined:
    Jan 22, 2020
    Posts:
    2
    Hi. First of all thank you for all the effort you put into replying to this thread, it is much appreciated.

    I am currently working with Rewired for the first time after switching from Unity's
    New Input System
    and I'm having some issues that I'd like to consult.
    I have two actions defined, across two different maps (same layout, different category to be exact - since from what I grasp Rewired's Maps are a combination of the two). Demonstrated as below:
    upload_2022-3-29_10-47-6.png upload_2022-3-29_10-47-27.png

    Now for the issue, I have registered the callbacks for each of those actions, using
    AddInputEventDelegate
    , setting the update loop to
    Update
    and the input action event type to
    InputActionEventType.ButtonJustPressed
    . The situation is as follows - clicking the action in the UI map closes the game's UI and switches player's map to the Defaut category, as follows:
    Code (CSharp):
    1. public void SwitchToGameplayMap()
    2. {
    3.         _rewiredPlayer.controllers.maps.SetAllMapsEnabled(false);
    4.         _rewiredPlayer.controllers.maps.SetMapsEnabled(true, "Default");
    5.         //[...]
    6. }
    However, as soon as I switch the maps the input action registered for the Left Mouse Button in the "Default" category map is fired as well. (The stack trace does indeed show that the execution of the function traces all the way back to the rewired callback). From the tests that I performed, I'd have to wait around 10-20 frames after the first callback before I switch the map in order to avoid the key press "passing" to the new map.
    I would expect such "on-the-fly" map switching to be supported so I'm a bit confused. Am I misunderstanding something and abusing the mechanics?
     
    Last edited: Mar 29, 2022
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Actions don't work like that.

    Rewired is a frame-based input system. Actions are virtual controller elements whose value is populated by any number of incoming input sources of any type (physical or virtual), can be queried as both axes and buttons, and simulate different events by comparing the current frame value to the previous frame value. The "ButtonDown" value of an Action is nothing more than a comparison of current frame hold state vs previous frame hold state. Further, Rewired calculates all its Action values at the beginning of the frame when Rewired's update runs before your scripts. All values remain constant throughout the frame unitl the next Rewired update. You making calls to enable and disable Controller Maps does not force Rewired to recalculate Action values, nor does it clear any Action values in that frame. Because of this, the "ButtonDown" state will remain true whether you disable or enable Controller Maps.

    In addition, Actions do not belong to a specific Controller Map or binding on that Controller Map, nor do they even belong to a specific Controller or controller type. Each Action is an independent object that belongs to a specific Player and can be contributed value by any number of Controllers belonging to that Player. You can have any number of Controller Maps and bindings that contribute to that same Action in the Player. Because of this, disabling a Controller Map does not directly affect the Actions it binds. This is important when you consider the Action's previous and current value and how those compare.

    In your case, some Controller Map (Controller Map A) is disabled that binds some Action (ActionA) to Button X, for example. You have a second Controller Map (Controller Map B) that is enabled that binds ActionB to the same Button X. When you press Button X, ActionB returns True, then you disable Controller Map B and Enable Controller Map A. On the next frame, Action A is evaluated to generate events: In the previous frame, Action A's button hold value was False, but because Button X is currently held and contributing a True value to Action A's combined button value, Action A's new button held value is True, therefore Action A's ButtonDown becomes True for one frame and you get the ButtonJustPressed event.

    Because Actions combine input from any number of elements of any type, the underlying element's "Down" state is not tracked separately from its "Hold" state and is not directly used in the Action's button value. In order to accommodate all types of input, the Actions use the frame comparison method to determine up and down states.

    There is only one exception case that was hacked into Rewired's Action system years ago that makes an exception to this system to silence the ButtonDown state when switching Controller Maps. The only time a ButtonDown state is silenced is when ALL Controller Maps in a Player that bind a particular Action are disabled, thereby making the Action go into an idle state (sleep), and then one Controller Map that binds that Action is enabled. Only in that special case does the ButtonDown state get silenced on the first frame the Action "awakens" due to the first Controller Map that binds that Action being enabled. If any Controller Maps for any controller types including keyboard, etc., that bind an Action exist in the Player and are enabled, the Action will not sleep, and therefore awakening cannot be detected, and it will always generate Up and Down events based on the value of the previous frame to current frame of the Action. This hack was put in place due to issues exactly as you're describing to provide some kind of limited workaround. But there is no way to make the Action based system as it and Rewired's frame-update are designed, capable of supporting unlimited different types of contributing inputs and input types that can be interpreted as both axes and buttons, work as one would expect it to work when considering only the needs of binding a single button on a single controller to an Action.
     
    Last edited: Mar 29, 2022
  41. fordtimelord

    fordtimelord

    Joined:
    Nov 3, 2020
    Posts:
    20
    I have a fresh install of Unity 2021.2.17f with only Corgi Engine and Rewired, and I get a console error, which I see other people having an issue with in the past but no solutions. Any idea? This is the error:

    "Assets\Rewired\Internal\Scripts\Misc\ExternalTools.cs(816,13): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'Rewired.Internal' (are you missing an assembly reference?)"
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    The only way this could happen is if you've installed Rewired Unity 2020 in Unity 2021.

    Rewired version always has an appended Unity major version.

    Menu -> Rewired -> Help -> About

    You will see Rewired 1.1.41.5.U2020 shown there.

    Rewired for Unity 2020 cannot be used in Unity 2021.

    See this:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#wrong-rewired-version-installed
     
  43. fordtimelord

    fordtimelord

    Joined:
    Nov 3, 2020
    Posts:
    20
    Thanks to guavaman's help, I got there. I haven't encountered this before, but maybe it's just my beginner brain so I'll try to explain it here for future me and anyone like me: Rewired downloads a completely different version of itself depending on which Unity you have installed. So I had just updated it within the day, but in a project that was 2020.3. I thought "that was the most recent version, so why would I need to get it again?" Turns out if you have a 2021.2 project you need to re-download within that project to get the 2021 version of rewired. Maybe this is all stuff everyone knows and I'm just the last to find out, but hopefully it's not and this is helpful to someone like me. The support page is clear about this as guavaman says above, but I read it a dozen times and still misinterpreted it. Thank you, guavaman!
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Actually, this is entirely on the Package Manager (formerly the Asset Store). Rewired doesn't download anything. The Package Manager inherited the same structure from the old Asset Store. It downloads all files into a single cache folder on your computer regardless of the version of Unity you're using to download. Rewired is submitted to the Asset Store in Unity 4.3, 5.0, 2017.1, 2018.4, 2019.1, 2020.1, and 2021.1. (4.3-2017 are deprecated and Unity doesn't allow any more updates). Each version is a different build, with the included libraries linked to the appropriate Unity libraries. The Package Manager is responsible for delivering the correct version of the asset to the user based on the version of Unity they are using to download.

    The Package Manager just downloads a .Unityasset file with no version information. So if you download an asset in Unity 2021, then go back and use Unity 2019, when you open the Package Manager, it sees the asset file is in the cache and shows you the "Import" button. If you import it, you've just imported Unity 2021 data in Unity 2019 with no warning. There's no guarantee an old version of Unity can even correctly open data from a future version of Unity. Same thing happens the other way around. It happens all the time. The user has no idea what version of an asset they're importing. Unity really needs to change this system.

    This is just how the Package Manager / Asset Store works. It's not intuitive or obvious. The only reason I know about how it works is because of all the problems Rewired users have had over all these years because of it. I figured it out by trial and error.
     
    Last edited: Mar 30, 2022
    fordtimelord likes this.
  45. fordtimelord

    fordtimelord

    Joined:
    Nov 3, 2020
    Posts:
    20
    Wow, well I appreciate how much effort you've had to put into that now for sure. I hope they fix that situation at some point because that sounds brutal for an asset developer to deal with.
     
  46. JacobDzwinel

    JacobDzwinel

    Joined:
    Dec 19, 2013
    Posts:
    26
    Hello,
    Is it possible to map a button to two actions using InputMapper?

    On the Keyboard&Mouse settings I allow the player to bind seperate buttons for two actions like for example :

    [Hold] Left Shift - Sprint
    E - Interaction

    On the Controller settings however, there is only one button for these two actions

    A - Interaction / Sprint

    I want in Controller settings, allow the player to map one button for two actions using InputMapper functionality but it looks like I can't provide more informations to InputMapper.Context() and after I use the InputMapper, my default doubled assigned actions are removed from the controller map.

    Is it possible? If not, how can I make that newly mapped button assigned for both actions rather than just one?
     
    Last edited: Mar 31, 2022
  47. Michal_G

    Michal_G

    Joined:
    Jan 22, 2020
    Posts:
    2
    Thank you for the explanation. So to put this into perspective - is there anything me and my team can "cleanly" do to avoid actions assigned to the newly enabled categories instantly triggering their callbacks, or should we just assume that all actions are listening to input at all times "in the background" and that's that.
     
  48. nighty2

    nighty2

    Joined:
    Dec 29, 2020
    Posts:
    29
    Hi guavaman,

    you seem to be rather busy here, so I really tried to do the proper research. But I am stuck and would greatly appreciate your help.

    [tldr]
    Main issue:
    Axis input, although received as seen in DebugInformation, is not recognized when trying to assign an axis with the ControlMapper. In other words the assignment just doesn't happen, during and after the timer runs out.
    [/tldr]


    More Details:

    I am using Arduino Pro Micro boards (or rather Sparkfun Pro Micro boards) which can connnect as HID interface and are successfully recognized as Joystick. (Maybe creating definitions for them would be useful if there are more inquiries about them).

    Lesser issue:
    Joystick maps are, but default key bindings don't get assigned to my controllers. Maybe because of the use of a controlMapper and it's "memory" of them to not being assigned, then that would be fine.

    In DebugInformation
    (screenshot 1)
    - the device is shown
    - under Controllers:
    - under Players: Player[0] as Joystick (see screenshot 1)
    - the device is enabled
    - axis input is received

    (screenshot 2)
    - joystick maps are assigned
    1: category "Default", layout "Joystick1", enabled
    2: category "Default", layout "Joystick2", enabled
    3: category "HelmControl", layout "ThrottleQuadrant", enabled
    - but inside these maps, there are no bindings on buttons or axes (see screenshot 2), although I created default bindings for the templates "gamepad" and "unkown-controller".

    In the ControlMapper

    - the device is shown
    - the buttons can be assigned
    - the calibration of the axes seems to work
    - but moving the axes is not reconized when trying to assign them

    Auto-Assignment of bindings is not important to me, but manually assigning them is.

    Hope you can help.
    Kind regards,
    Michael
     

    Attached Files:

    • 1.png
      1.png
      File size:
      72.9 KB
      Views:
      217
    • 2.png
      2.png
      File size:
      80.6 KB
      Views:
      224
    Last edited: Mar 31, 2022
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    See these forum posts:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-157#post-7824264
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-129#post-6082446

    Also, as I said in my previous post:
    You can take advantage of that hack by disabling ALL the Controller Maps that map that Action when you disable them. Not just on your controller, but everything including keyboard and mouse. Then it will silence the Down event when the Action is first awakened when you enable the Controller Maps.
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    No it's not. Input Mapper does not support that functionality. If you want to do something like that, you have to manage it yourself using the manual controller mapping API to create/remove/replace the binding you want and deal with conflicts manually:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ControllerMap.htm
    https://guavaman.com/projects/rewir...Rewired_Player_ControllerHelper_MapHelper.htm

    There is no documentation for using the manual rebinding API. Example code can be found in the Control Mapper source code.
     
    JacobDzwinel likes this.