Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    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:
    3,676
    Logging Level:
    http://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    Rewired cannot be changed with scripting define symbols. It is a DLL. DLLs are not compiled by Unity and cannot see or react to scripting define symbols in general. The few Rewired does use are specifically set up to use an external CS file that is compiled by Unity, then Rewired's DLL checks this class for results of values gated by these symbols. Silencing a specific warning is not something reasonable to handle this way.

    Rewired does not have a log entry coding system to allow you to silence individual log entries and warnings by number like a C# compiler. This is not something very many applications would go to the effort of doing, including Unity.
     
    bitinn likes this.
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    I'm just guessing but I'm thinking the E at the end may stand for Europe. Mine is U, which probably means United States. Are you in Europe?
     
  3. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    520
    Turns out my issue is caused by physics auto simulation set to false, and the character animation relies on fixed update loop.
     
  4. lyokoguerier_unity

    lyokoguerier_unity

    Joined:
    Feb 14, 2018
    Posts:
    29
    Hello everyone

    here is how to enable "InputMapper" ???

    that I must do ???

    I do not find a video tutorial in the net ???

    And thank you in advance
     
    Last edited: Dec 6, 2018
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Input Mapper documentation is here:
    http://guavaman.com/projects/rewired/docs/InputMapper.html

    Examples are included in the Rewired package:
    http://guavaman.com/projects/rewired/docs/Examples.html#simple-control-remapping
    http://guavaman.com/projects/rewired/docs/Examples.html#simple-combined-keyboard-mouse-remapping

    There is no video tutorial on setting up Input Mapper.
     
  6. lyokoguerier_unity

    lyokoguerier_unity

    Joined:
    Feb 14, 2018
    Posts:
    29
    I thank you very much for your help

    Where can I download this Rewired ???

    my case is the wii remote ???

    and thank you in advance
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Rewired is sold in the Unity Asset Store:
    https://www.assetstore.unity3d.com/en/#!/content/21676

    There is a free trial available on the website:
    http://guavaman.com/rewired/trial

    Rewired does not support the Wii Remote. The list of supported controllers is here:
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html
     
  8. Softdrink

    Softdrink

    Joined:
    Nov 10, 2014
    Posts:
    2
    Hopefully this hasn't been asked too many times, but -

    What is the recommended driver/configuration approach for handling PS3 controllers on Windows with Rewired?

    I normally use SCP drivers, but that doesn't seem to work with Rewired when I test (even though it will work with other software). It could be possible that the drivers themselves are somehow misconfigured, though - I haven't tried reinstalling them yet.

    The strange thing is that Rewired recognizes the controller (It shows up as a PS3 controller when connected, and the correct Maps seem to be loaded) but no inputs are registered from it.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    All controller information is here:
    http://guavaman.com/projects/rewired/docs/SupportedControllers.html

    Dual Shock 3 is not supported via a Bluetooth connection. The link for wired support is shown there.

    >> I normally use SCP drivers, but that doesn't seem to work with Rewired when I test (even though it will work with
    >> other software)

    With the default settings, Rewired uses standard Windows Raw Input Windows API functions to get input from controllers in Raw Input mode. Rewired supports multiple input sources on Windows including Direct Input. There is no way to know what these other games are using. Another way software may get input from devices is by directly reading the HID report.

    You can see the low level information sent by the controller by using the Rewired/DevTools/JoystickElementIdentifier scene. If Rewired isn't getting anything at the low level, it won't be able to use the device.
     
  10. Softdrink

    Softdrink

    Joined:
    Nov 10, 2014
    Posts:
    2
    Oh, well now I feel incredibly silly. I must've overlooked that link somehow when I checked last night. Thanks!
     
  11. MaccyDBoy

    MaccyDBoy

    Joined:
    May 25, 2017
    Posts:
    29
    Hi !

    Any advice on how i could integrate Rewired with FlowCanvas Visual scripting ? Thanks ! :)
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Not really. Making an integration for a visual scripting system involves writing hundreds of method and property wrapper classes. It's not a fun job and takes forever.
     
  13. Miguel_LZ

    Miguel_LZ

    Joined:
    Jan 12, 2018
    Posts:
    14
    Hi again @guavaman

    I have the control mapper completely up and running and the keys swapping definitely works like a charm, so thank you for your help the other day :) I now have a silly question, but I haven't found any info on this (maybe it is because I'm not looking properly). Here's the thing:

    Our game has fairly simple controls, just a couple of buttons and the pause, and I would like to completely ignore the axis input (since right now, mapping the controls allows me to, say, press the right trigger for the "confirm" button action, but after that it behaves weirdly). Is it possible for the controls mapper to ignore the sticks/triggers when polling for input?

    Also, would it be possible to ignore specific keys from the keyboard as well? We are using the ignore flag for Ctrl, Alt, etc. but I'd like to ignore keys such as ; ' { etc.

    I'm sorry to be asking questions that feel basic, but I honestly couldn't find information on this (not in the docs nor in the API). Thanks a lot in advance.
     
  14. MaccyDBoy

    MaccyDBoy

    Joined:
    May 25, 2017
    Posts:
    29
    Okay ! No worries, i'll try to find a way to call custom function made in flowCanvas USING rewired. So i'll tyr the other way around then ! thanks :)
     
  15. lyokoguerier_unity

    lyokoguerier_unity

    Joined:
    Feb 14, 2018
    Posts:
    29
    Thank you very much for your help

    so you're right I saw that the Wiimote is not supported so there is a solution of the Wiimote ??? for who has a resemblance here



    do you have any idea for that ???

    And thank you in advance
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    What do you mean "behaves weirdly." Axes should be fully usable as buttons and work correctly.

    There is no way to specify inputs to accept or ignore in Control Mapper. If you need that functionality, you'll either have to make your own version of Control Mapper or build your own control mapping system:
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    Control Mapper is written to meet the needs of the 95% who just want to drop something in and have it work, but those with extra special needs such as only supporting buttons will have to write their own systems. All optional features it supports are displayed in the inspector.

    Ignoring axes is a bad idea because you never know what kind of controller a user is going to want to use. Some controllers like the 3DRudder, flight pedals, throttle systems, and custom-built controllers may have no buttons at all and wouldn't be able to be used by your game.
     
    Last edited: Dec 7, 2018
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    The video you have posted is for a completely different system called Input Mapper written by a different developer. He has a link in his YouTube video:
    https://github.com/winxalex/Unity3d-InputMapper

    This is not related to Rewired in any way.

    In his system, he has written low-level code specifically to read data from the Wiimote and process that data in such a way as to provide rotational data to the end user. Rewired does not do this for the Wiimote.

    The only way you will be able to get the Wiimote working with Rewired is to write a Custom Controller script that reads the data from the Wiimote and maps that data to axes which can be piped into the Player-Action system.
     
  18. Miguel_LZ

    Miguel_LZ

    Joined:
    Jan 12, 2018
    Posts:
    14
    Hi again, and thanks for your reply. Let me try to explain this (maybe I'm not doing the setup properly). All out Actions are set to the type 'Button'. Everything good so far.

    Then, let's say that I have the "Interact" action mapped to the A button, and then I map it to RT (using the X360 controller for this example). The mapper does its job correctly and maps the action to the right trigger, and then I can use it in the menus or ingame as "Interact". Okay, everything seems fine.

    Then, if I go to the remapper again and use the "Interact" action (RT) to again try to remap that same action, it does the following:

    I squeeze the trigger
    The input polling begins (I still have the trigger held)
    I release RT without doing or pressing anything else
    The key gets assigned again to RT (only when the trigger gets to the fully released position, otherwise the input polling is still listening for input)
    Despite being still assigned to RT, using that trigger does nothing and I can't interact with anything anymore.

    But this must be probably a bug on my end, so you can ignore this. Just letting you know the situation in case the information is of any use to you.
     
    Last edited: Dec 7, 2018
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Thanks for the explanation.

    That behavior is known and unavoidable and the reason Control Mapper displays the extra dialog box when mapping axes that states to zero the axis and press a button. Rewired is designed to be able to listen to and handle any kind of axis regardless of the value that it returns at rest or the sign of the value that it returns when engaged. Many axes exist in the wild that return values such as -1 when at rest. Rewired listens for the change in value from the point you start listening. What you are seeing is the trigger returning a negative value when you release it, the Action is bound to the negative side of the trigger, and you never get any input when pressing it. The extra dialog box prevents this problem. It gives the user a chance to reset their axes (release the trigger) before polling (especially important for throttles).
     
    Last edited: Dec 8, 2018
    Miguel_LZ likes this.
  20. lyokoguerier_unity

    lyokoguerier_unity

    Joined:
    Feb 14, 2018
    Posts:
    29
    I thank you very much for your help
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Please download this testing program I made and run it with only the DS4 attached .
    https://www.dropbox.com/s/rrzd7cl15cpfdb8/RewiredDS4BatteryTest.zip?dl=0

    It will display the input reports from the DS4 on the left side of the screen. It also displays the current battery level as Rewired sees it to the right of that. Send me a screen shot. If you know how full your DS4's battery is otherwise, let me know that as well.
     
  22. Kerrjgan

    Kerrjgan

    Joined:
    May 30, 2016
    Posts:
    5
    Hello. I'm not sure if this is a keyboard regional issue or a software (Rewired) issue. I'm assigning a key to an action via the Rewired editor and when I poll it for input, the responding key is not correct.

    I map the action to this key/char (`) via the "poll button" which is recognised as BackQuote, however during runtime its only activated when I press this key/char (') which are not the same keys.

    Any ideas?
    Here is a small illustration of whats happening. The red key, is what I set via rewired input, but the green key is what Rewired returns true for the action when I press that key. Pressing the red key (at runtime) does not return true for BackQuote on the keyboard map.

    https://gyazo.com/2ee0ee06d9f24b17ae5da0402fb5b98a
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    1. What version of Rewired?
    2. What platform?
    3. What is the primary input source set to on this platform?
    4. Is Native Keyboard Handling enabled?
    5. Easiest to send a screen shot of the Rewired Input Manager -> Settings -> PLATFORM page.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    What keyboard layout is this?

    In the Rewired Input Manager editor, the Poll for Key button uses UnityEngine.Event.current.keyCode in OnGUI to detect the key press in the editor. At runtime, an entirely different system is used. If Windows, Raw/Direct Input + Native Keyboard Handling, Rewired use Raw Input to get key input. Every other platform and configuration, it uses UnityEngine.GetKey for key input.

    All my testing shows that Rewired's native keyboard handling returns identical results to UnityEngine.Input.GetKey for a German keyboard. Because it's just using the virtual keys directly based on the US layout as Unity appears to also, I would think the results would be identical for your keyboard layout as well between Unity's GetKey and Rewired's native keyboard handling. My testing also shows that UnityEditor.Event.current.keyCode seems to be consistent with the results from Input.GetKey... I'm not sure how you could be getting Backquote and Quote transposed.

    Rewired uses the virtual key codes received from Raw Input and maps them to Unity KeyCodes for compatibility with Unity. No extra code has been added to support international keyboards. Rewired's Native Keyboard Handling should give identical results to Unity's keyboard handling as far as which keys return which KeyCode values.
     
    Last edited: Dec 9, 2018
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Using information you provided via email (UK keyboard layout), I’ve done testing with the UK keyboard layout. Here’s what I‘m seeing:

    UnityEngine.Event.current.keyCode in OnGUI:
    When “Backquote” is pressed, it detects “Backquote”
    When “Quote” is pressed, it detects “Backquote”

    UnityEngine.Input.GetKey:
    When “Backquote” is pressed, it detects “Backquote”
    When “Quote” is pressed, it detects “Backquote”

    Rewired Raw Input:
    When “Backquote” is pressed, no key is detected.
    When “Quote” is pressed, it detects “Backquote”

    The behavior between Rewired’s Raw Input and Unity’s system is slightly different, but neither are the result you’re looking for.

    Neither Rewired nor Unity do regional keyboard layout handling. They both use the Virtual Key system in Windows and use the VKey identifier to map keys to KeyCodes. The step of “translating” the key to a Char is skipped for a variety of reasons. (Converting the VKey to a char would result in many keyboards having a bunch of non-functional keys, for example German, which requires you hold various modifier keys to get at very common keys such as [ ] / \, etc. The non-modified versions of those keys are odd characters which would be rarely used in games and do not have a KeyCode. In order to keep Rewired consistent and easily compatible with Unity code, plus because most platforms don’t have native keyboard support, I decided to match their system as best I could.

    I’m not sure why Rewired isn’t detecting any press when Backquote is pressed, so I’ll look into that, but other than that, I don’t know what I could do to make this work short of replacing the whole keyboard system with a Char based system that would drastically change the way keyboard input works. Either that or start maintaining my own per-layout mapping tables.

    Edit: It looks like Unity maps both VKey Oem3 and Oem8 to backquote while I only map Oem3. That would explain the difference. On the UK layout, backquote returns Oem8, while it returns Oem3 on a US keyboard.
     
    Last edited: Dec 9, 2018
  26. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    29
    Are there any helpful assets or tips for implementing a "Button Hint" icon that looks up what key an action is assigned to and then displays a helpful hint/icon to the player? E.g., "Jump! Press [A]", where [A] is a graphic of a green A button, or a red B button if they've re-mapped it.

    At simplest, is there a way to programmatically look up what button a given action is assigned to on the player's current controller?
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    http://guavaman.com/projects/rewired/docs/HowTos.html#get-element-name-for-action
    http://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
    http://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-active-elements
     
  28. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    29
    Thanks guavaman! Figured there might be something and I was just failing at finding it :)
     
    guavaman likes this.
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Rewired 1.1.21.3 is available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    1.1.21.3:

    Changes:
    - Windows Standalone, Raw Input / Direct Input + Native Keyboard Handling: Modified to detect Backquote and Quote keys on UK keyboard layout.

    1.1.21.2:

    Bug Fixes:
    - DS4 battery level can no longer report negative values if invalid data is returned by hardware.
     
  30. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,004
    im testing unity 2019 and it says I need rewired for 2019... where is it available?
     
  31. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,435
    The developer of Rewired @guavaman has stated that betas are not supported. And unity 2019 is alpha state currently ...

    As mentioned in previous posts but here is one for reference.

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

    and also

    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#unity-alpha-beta-preview-experimental
     
    Last edited: Dec 12, 2018
    guavaman likes this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    The message it displays to you in the console should explain the situation:

    The version of Rewired installed (version) was not designed for Unity 2019. Please install Rewired for Unity 2019.
    This warning does not mean that Rewired will not function, but it may not function optimally.
    Some different major versions of Unity download Asset Store assets to the same folder location on disk, so if you download an asset in one version of the Unity editor, then open another version of the Unity editor and install the asset without re-downloading it, the wrong asset version will be installed. To fix this, manually re-download Rewired in the Unity Asset Store panel in this version of the Unity Editor, then install it.

    If you are using a beta version of a new major version of Unity, you will have to wait until the release of the final version before a compatible version of Rewired can be uploaded to the Asset Store. When the new version is ready, it will be available through the Unity Asset Store for download as usual.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
  34. Shredsauce

    Shredsauce

    Joined:
    Apr 4, 2016
    Posts:
    23
    Hello,

    For some reason, UISubmit is not removing focus from input fields with a joystick. I know that I have the Submit button set up correctly, but it doesn't seem to work with inputfields the way Enter/Return does.

    Here is my ugly temporary workaround

    Code (CSharp):
    1.         if (ReInput.players.GetPlayer(0).GetButtonDown("UISubmit")) {
    2.             InputField inputField = EventSystem.current.currentSelectedGameObject.GetComponent<InputField>();
    3.             if (inputField != null) {
    4.                 inputField.DeactivateInputField();
    5.             }
    6.         }
     
    Last edited: Dec 13, 2018
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    UISubmit is not supposed to remove the focus from the currently selected input field. You can submit the same button as many times as you want. This is the way Unity UI works.

    Processing of the UI events after they are sent from the EventSystem is entirely up to the Selectable to handle. The input module is not responsible for this, therefore Rewired isn't involved in the process.
     
  36. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    19
    Yes I'm in Europe. Maybe this is why the difference between the two models.
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    Please run the tool I made you in this post and report the results.
     
  38. Sabrino

    Sabrino

    Joined:
    Aug 8, 2015
    Posts:
    20
    Hi Guavaman, do you have a general idea of when the IL2CPP standalone compatibility issue could be resolved? Thank you.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    No, sorry. There's no ETA on this still.
     
  40. roydor

    roydor

    Joined:
    Mar 16, 2015
    Posts:
    9
    How do I save my changes?
    The editor shows my map as blue with a * beside it, which in every other editor type thing means unsaved changes
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    That has nothing to do with unsaved changes. That means a Controller Map exists in that category / layout.

    Other applications that use the * symbol for unsaved changes would put it in the title bar next to the file name, not on every entry in the interface.

    The Rewired editor is a front-end for serialized data in the GameObject. Data is saved exactly as it is for every other GameObject in Unity (inspector data). Saving your scene saves unsaved data in all serialized objects.
     
    roydor likes this.
  42. Sabrino

    Sabrino

    Joined:
    Aug 8, 2015
    Posts:
    20
    Ah, I see. That's quite a problem. Rewired seems like the most comprehensive solution for input management at the moment, but no IL2CPP on desktop is a no go, and fallback input is no good either, for all the reasons you listed in the Known Issues section. Unfortunately my game has to have input ready in the next month or two.. Ah well, what can you do.
     
  43. roydor

    roydor

    Joined:
    Mar 16, 2015
    Posts:
    9
    ty
     
  44. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    19
    Hello, I run the test and the program crashed. As attachment the data file.
     

    Attached Files:

  45. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    19
    guavaman I have a news about the DS4 battery issue. The value is wrong only just after the plug in of the controller or during the initialization of Rewired. If I check the battery level after the first frame (after the start of the game, or after the controller is plugged in) the battery level is correct.
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    That makes sense. The battery level can only be read through an input report. Input reports are sent by the device every time some value in the control changes. If checked in Awake/Start or in the Controller Connected Event callback, no input reports will have ever been processed for the controller and the raw battery value will always be 0. Only when Rewired's Update runs will the input reports that have been queued be processed and the battery level be updated.
     
  47. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    19
    So which is the best way to when user plug in the pad the battery level?
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,676
    You cannot accurately get the battery level until the controller sends an input report. If the controller was able to be initialized into gyro/extra features mode, it will begin sending reports immediately because of the gyro data. Otherwise, the user would have to press a button or move the stick. There's no way around this on the PC.
     
  49. daven8989

    daven8989

    Joined:
    Jan 25, 2014
    Posts:
    19
    Ok , thank you very much!
     
  50. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    18
    We've been using the ControlMapper in our game, and I think we found a bug with conflict checking assignments.

    If "Show Split Axis Input Fields" is enabled, you can make an infinite amount of assignments to a split-axis by clicking on the full-axis & pressing a button. (Please see the gif below)

    For now, I simply changed the source to work in our case by changing IsAllowedAssignment() to not use the "_showSplitAxisInputFields" check, forcing players to only assign an axis to the "full" axis range, while still allowing them to set a split axis as well.