Search Unity

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

Rewired - Advanced Input for Unity

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

  1. emredesu

    emredesu

    Joined:
    Aug 12, 2021
    Posts:
    55
    While messing around with output files, I found out that the massive Unity hotshot - Genshin Impact uses rewired... Now I'm regretting using Input System for my own game... :p

    upload_2023-10-16_20-30-30.png
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I have never heard about any problem using PS4 or PS5 controllers over bluetooth. The only issue I've ever had with them is when Windows itself does not connect to the device properly and has to be re-paired over and over until it works. This has been an issue for years and there is no solution at the application-level that can fix it. I use both DualShock 4 and Dual Sense over Bluetooth all the time and have no issues.
    • What exactly is happening?
    • Is the device visible to Unity and not Rewired?
    • Assuming you're talking about Windows Standalone, is the Primary Input Source set to Raw Input and is Enhanced Device Support enabled?
    • What do you see if you open Rewired/DevTools/JoystickElementIdentifier and press Play?
    • Is Steam involved?
    • Have you tried a different computer and/or a different Bluetooth adapter?
    • Is anything logged?
    • Is any software or driver installed that would affect these devices (DS4Win, etc.)?
    The Unity Asset store no longer allows any updates to assets built with Unity versions before 2019.4. All older version updates can only be downloaded from my website. Use the support form to request access.
     
    Last edited: Oct 16, 2023
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Yes. I'm aware. It's super cool. :D
     
    Last edited: Oct 16, 2023
    emredesu likes this.
  4. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    a couple of questions. can't i just the "gamepad" template you have here to take care of the xbox, ps4, switch, etc" instead of having to configure buttons for all the controllers? some pc users use xbox or ps4 controllers and i want to make sure this works for them.

    also the playmaker action doesnt seem to be working for me. i don't see an action to get axis / button by NAME. just element? is there a tutorial for this?
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    This is answered in the documentation:
    https://guavaman.com/projects/rewired/docs/ControllerTemplates.html

    A Controller Template represents a generalized controller layout that applies to all compatible controllers providing a common interface to work with these controllers. When you create a map for a Controller Template, any controller that implements the template will inherit that map automatically without the need for you to create a map specifically for that controller. For example, Rewired comes with a Gamepad Template. When you create a map for this Gamepad Template, you do not need to create individual maps specifically for any of the gamepads listed on this page because they are all covered by the Gamepad Template. This makes is much quicker to create pre-defined controller maps for a huge variety of controllers. Additionally, as more controllers are added to the Template in the future, the map you've already created will work with these new controllers as well.

    If you have created a map for a Controller Template but still want to make a map for a specific controller that is covered by the Controller Template, just create the map for the specific controller and it will override the map defined in the Template.

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

    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

    All PlayMaker Actions that require an Action argument take a string in the Action Name field.
     
  6. BasicallyGames

    BasicallyGames

    Joined:
    Aug 31, 2018
    Posts:
    91
    Gonna post the cause of an ancient issue I've had with Rewired that I finally figured out today. Partly so that anyone else who might encounter the issue can find out what's going on, and partly because it's just funny lol.

    Years ago I noticed an issue where my game would stutter when using Rewired to rumble a controller. I eventually realized it wasn't a big issue as it didn't occur when the controller was being used, only when a controller was connected but I was using some other control scheme, like the mouse and keyboard. Today I finally discovered what's actually happening. The game isn't actually stuttering, rather, when the controller (In this case, an Xbox One controller) vibrates, it shakes the sticks enough to send input through Rewired! This interrupted other inputs and so it made it appear that the game was stuttering if I was moving in-game when this happened. This drove me crazy back when I first encountered it so it's funny to me how simple the issue actually was.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    D'oh! That is pretty funny. What symptoms this would cause would be dependent on how the game uses input. If the vibration cause an axis value to be produced that is greater than the dead zone, tor most games, it would probably just lead to some slight drift in movement or camera look.

    It never occurred to me that it could have that affect on sticks, but the same is true for anything that has a gyro / accelerometer. Vibration can really throw those values off.
     
  8. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222


    yes i read all those before posting and clearly im doing something wrong lol. i need to figure it out. i even watched your video and followed through. ill have to try again. at this point im not sure if i even need to use rewired for this current project since i have figured out all the (xbox only) controllers by my self and chat gpt using unity's input system. but im sure there are some benefits to using rewired. i don't even know if my game will work with a ps4 controller. i have to test it out.

    however i have a question. i currently use xinput module to make my xbox controller vibrate, but would it work without it if i use rewired?
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
  10. h0neyfr0g

    h0neyfr0g

    Joined:
    Jul 13, 2019
    Posts:
    35
    Hi Guavaman!

    Hope you are well.

    I have looked through this thread for all PS5 controller related posts, but I am not sure what the current state of the issue is. I was hoping you could help me :)

    I am looking to use my PS5 controller and I cant seem to figure out how.

    Im using Unity v. 2020.3.27f1
    and
    ReWired 1.1.37.0.U2020

    I've tried creating a Custom Controller, but it still doesnt seem to be recognizing any inputs.

    Ive tested the controller with other programs, like Steam and it is seen there.

    Any guidance would be greatly appreciated!

    All the best

    :)
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    This version is 3 years old update Rewired.

    It does not make any sense to create a Custom Controller for trying to make a controller work. That's not the purpose of Custom Controllers as explained in the documentation:

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

    Custom Controllers are a type of virtual controller that you can customize, adding as many axes and buttons as you need. A Custom Controller allows you to set your own sources for axis and button input. This could be any type of physical or virtual controller. Anything that can return a float or a boolean value can be used as an element source. Custom Controllers can be used for on-screeen touch controllers and more. (See the example in the Rewired/Examples folder.)

    IMPORTANT NOTE: Custom Controllers are NOT meant to be used to create new HID joystick definitions for controllers that Rewired doesn't automatically recognize and map for you. They are virtual controllers that know nothing but what axis and button data is fed into them by your script. They are entirely separate from the Joystick system, are not auto-assigned, don't generate connect or disconnect events, etc. If you are planning to use a Custom Controller to add support for controller that Rewired can detect but doesn't recognize and automatically map for you, don't -- it's the wrong tool for the job. Instead you want to create a new controller definition for that or else define a Joystick Map for Unknown Controller instead. Custom Controllers can however be used to support devices that do not show up as joysticks such as special controllers that require the use of an SDK (most VR controllers).
     
  12. h0neyfr0g

    h0neyfr0g

    Joined:
    Jul 13, 2019
    Posts:
    35
    Thanks very much for the clarification Guava!

    Do you suspect the PS5 Controller would become recognized after updating?
    Ill be sure to make a separate git branch to test, as I'd hate for the update to unexpectedly break something I have done on my end.

    Again, thanks for the help, really appreciate it
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Support for the DualSense was not added until 1.1.38.0.

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

    1.1.38.0:

    Changes:
    - Added support for Game Core Xbox platforms through additional plugin.
    - Added Enhanced Device Support for Sony DualSense controller (Windows and MacOS).
    - Changed display name of Nintendo Switch handheld controller to meet Nintendo's new naming requirements.

    API Changes:
    - Added ControllerExtensions.DualSenseExtension class.
    - Added ControllerExtensions.DualSenseMicrophoneLightMode enum.
    - Added ControllerExtensions.DualSenseOtherLightBrightness enum.
    - Added ControllerExtensions.DualSensePlayerLightFlags enum.

    New Controller Definitions:
    - Sony DualSense

    Bug Fixes:
    - Fixed broken ReInput.MappingHelper.GetActionElementMap function.
     
    h0neyfr0g likes this.
  14. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    117
    Hello!
    What is the correct way to get what Input key is mapped to Action that is Axis type?(Even in case where that type of controller is not connected)


    I've used code like this:
    Code (CSharp):
    1. Rewired.Player _Player = Rewired.ReInput.players.GetPlayer(_PlayerID);
    2. Rewired.InputAction _Action = Rewired.ReInput.mapping.GetAction(_ActionID);
    3. Rewired.ActionElementMap _ActionElementMap = _Player.controllers.maps.GetFirstElementMapWithAction(Rewired.ControllerType.Joystick, _Action.id, true);
    But the ActionElementMap returned is null if I call it on axis type action.

    I have two cases of how I use this axis, on the gamepad it has a full axis contribution, and on the keyboard, buttons give a +/- contribution.
     
    Last edited: Oct 27, 2023
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    1) There is no reason to call Rewired.ReInput.mapping.GetAction(_ActionID) if you already have the Action Id. Pass the id directly to Player.controllers.maps.GetFirstElementMapWithAction instead of getting the Action and then passing Action.id.

    2) As to why GetFirstEelementMapWithAction it is returning null, that would only happen if one of the parameters you are passing to the function is wrong or the Player does not contain any bindings matching the parameters you've passed (Must be a Joystick Map with Action Id and the Controller Map and ActionElementMap must be currently Enabled). Use Debug Information to view live at runtime which Controller Maps exist in the Player at the time of the function call. It will definitely return Axis bindings, full or partial.

    3) You cannot use GetFirstEelementMapWithAction if there are multiple bindings to an Action. As the name of the function states, it will only get the first it finds. In the case of D-Pad or Keyboard bindings to an Axis-type Action (Move Down, Move Up), that is by definition two bindings and GetFirst will never give you both bindings, and the GetFirst functions do not allow you to specify other matching criteria for the search such as an axis pole. Player.controllers.maps.GetFirstElementMapWithAction is simply a convenience function. You have full access to all bindings in all Controller Maps in a Player and can iterate and search them by whatever means you want to find the information you want. This shows you many different ways of working with element bindings including how to iterate over all matching elements. Additionally, this topic links to a complete glyph displaying script that includes handling of keyboard and mouse bindings and takes into account modifier keys and the possibility of having multiple bindings to an Action (split-axis).
     
    Hellwaiker likes this.
  16. guavaman

    guavaman

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

    See Updating Rewired before updating.

    Release Notes:

    1.1.47.0:

    Changes:
    - Windows Standalone: Added support for Windows.Gaming.Input input source (Requires Windows 10, October 2018 Update version 1809 (10.0.17763.0) or greater. Will fall back to other input sources on older versions of Windows.) Note: This option is now enabled by default on newly created Rewired Input Managers, but existing instances are not modified and the option must be manually enabled in Rewired Editor -> Settings -> Windows.
    - Added Rewired_WindowsGamingInput.dll native library.
    - Windows Standalone Raw Input, MacOS Native, Enhanced Device Support: Added DualSense trigger effect support.
    - MacOS Game Controller Framework: Added DualSense trigger effect support.
    - MacOS Game Controller Framework: Excluded Nintendo Switch Joy-Cons due to devices not functioning correctly through Game Controller Framework.
    - Added DualSense Edge support (not tested).
    - Android: Improved keyfile detection of Dual Shock 4 and Dual Sense controllers due to problems caused by Android fragementation.
    - Windows UWP, Native: Improved filtering of non-XInput compatible HID controllers that are supported by Windows.Gaming.Input.Gamepad to prevent duplicate devices from appearing when both Gamepad API and HID API are enabled.
    - Windows UWP, Native: Xbox 360 and Xbox One Controllers and now recognized as distinct controller types instead of being identified as "XInput Gamepad" with limited.
    - Windows UWP, Native: Added device type and HID product name to joystick.HardwareIdentifier string.
    - Windows UWP, Native: Updated minimum supported windows version to Windows 10, Fall Creators Update version 1709 (10.0.16299.0).
    - Rewired Editor: Changed some terminology under Settings -> Windows UWP.
    - Windows Standalone Raw Input, OSX Native, Enhanced Device Support: Added internal drivers for Nintendo Switch Pro Controller and Joy-Cons to support vibration and certain special controller features.
    - Windows Standalone Raw Input, OSX Native, Enhanced Device Support: Added workaround for lack of perceptible vibration ramp on Dual Sense.
    - Added more information to Debug Information.

    API Changes:
    - Added ReInput.ConfigHelper.useWindowsGamingInput property.
    - Added Rewired.ControllerExtensions.IDualSenseExtension interface.
    - Added Rewired.ControllerExtensions.IDualSenseGamepadTriggerEffect interface.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerType enum.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectType enum.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectState enum.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectPositionValueSet struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectOff struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectFeedback struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectWeapon struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectVibration struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectMultiplePositionFeedback struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectSlopeFeedback struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadTriggerEffectMultiplePositionVibration struct.
    - Added Rewired.ControllerExtensions.DualSenseGamepadExtension.SetTriggerEffect function.
    - Added Rewired.ControllerExtensions.IHIDControllerExtension interface.
    - Added Rewired.ControllerExtensions.NintendoSwitchGamepadExtension class.
    - Added Rewired.ControllerExtensions.NintendoSwitchProControllerExtension class.
    - Added Rewired.ControllerExtensions.NintendoSwitchJoyConExtension class.
    - Added Rewired.ControllerExtensions.NintendoSwitchGamepadVibration struct.
    - Added Rewired.ControllerExtensions.NintendoSwitchJoyConType enum.
    - Added Rewired.ControllerExtensions.NintendoSwitchJoyConGripStyle enum.
    - Added Rewired.Platforms.Apple.GameController.GCControllerDualSenseExtension.SetTriggerEffect function.
    - Added Rewired.Platforms.Windows.RawInput.RawInputControllerExtension class.
    - Added Rewired.Platforms.Windows.DirectInput.DirectInputControllerExtension class.
    - Added ReInput.ConfigHelper.windowsUWPSupportGamepads property.
    - Added ReInput.ConfigHelper.useAppleGameControllerFramework property.
    - Added Rewired.ControllerExtensions.IHIDControllerExtension interface to Rewired.ControllerExtensions.DualSenseExtension, Rewired.ControllerExtensions.DualShock4Extension, and Rewired.ControllerExtensions.RailDriverExtension.

    Controller Definitions:
    - Nintendo Switch Pro Controlller, Apple Game Controller Framework: Added definition.
    - Windows, Windows Gaming Input: Added Steam-configured variants to Xbox 360 Controller, Xbox One Controller, Sony DualShock 4, Sony DualSense, Nintendo Pro Controller, Nintendo Joy-Con (L), Nintendo Joy-Con (R), Steam Controller.

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

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    Hi Rewired Support team,
    We've met an unexpected behaviour that doesn't match the documentation when calling the API
    Player.ControllerHelper.MapHelper.LoadDefaultMaps;

    as the doc says, "For Joysticks that have been previously assigned to this Player but are no longer assigned at the time this method is called, the Joystick Map history for these Joysticks will be cleared so the next time the Joystick is assigned to this Player, the default Joystick Maps will be loaded instead of Joystick Maps stored in the history".

    What happended to us is that we left the joystick disconnected, and start the game, load default maps for ControllerType.Joystick, reconnect the joystick, the previously customized map for this joystick stays without been overridden by the default map.

    Could you please confirm if this is a bug or there is something wrong with my steps.
    Thanks
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I think you are misunderstanding what the documentation means by "history."

    It is not referring to saved XML/JSON user data -- persistent save data. Assuming you are using something like Control Mapper which uses the UserDataStore_PlayerPrefs component, user data is saved to PlayerPrefs and is reloaded the next time the application is launched or the next time a joystick is connected. This is what is happening in your case. Saved user data is being loaded for the joystick.

    The "history" that documentation refers to means a runtime memory cache of Controller Maps for a particular joystick. This does not persist after quitting the application, and exists so that even if the user is not using persistent data storage of any kind, if they unplug and re-plug a controller, their binding customizations are not lost. This is the history that is cleared when the LoadDefaultMaps function is called.

    If you want to clear saved user data, that's entirely separate and has to be done at the data storage level. In the case of UserDataStore_PlayerPrefs, because of the limitations of the PlayerPrefs system, the only way to clear user data is to clear PlayerPrefs entirely.

    https://guavaman.com/projects/rewired/docs/UserDataStore.html#playerprefs

    If using persistent data storage, the LoadDefaultMaps can only reset maps for controllers that are currently connected.
     
    Last edited: Nov 2, 2023
  19. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    Thanks for you explanation, so the only way to clear the saved data for unpluged controllers is clearing the saved data, we have an custom userdata class called UserDataStore_Json which is similar to UserDataStore_PlayerPrefs but wirte json data to the file, so we can delete it without affecting other settings stored within PlayerPrefs.

    Again, thanks for your rapid reply and it helped me a lot.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    If you've written your own UserDataStore implementation, you could certainly delete saved controller map data for anything that's not currently connected. Since you have the complete JSON data, you can parse it and modify it. You can't do that with PlayerPrefs because there is no way to get data from PlayerPrefs without knowing the key. The main reason to do that over wiping the whole file would be if you want to keep other configuration information such as calibration.
     
    Last edited: Nov 5, 2023
  21. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    yes, the json file is well structured and we can manipulate it easily.
     
  22. sjyooon

    sjyooon

    Joined:
    Feb 6, 2016
    Posts:
    3
    Hi! I have follow problem with xbox elite controller on silicon mac.
    How can I solve this problem?


    Rewired: Error opening HID device! This device will not function.
    ------- Rewired System Info -------
    Unity version: 2023.1.19f1
    Rewired version: 1.1.47.0.U2023
    Platform: OSX
    Editor Platform: OSX
    Using Unity input: False
    Primary input source: Native
    Native mouse handling: False
    Enhanced device support: True
    UnityEngine.Logger:LogError (string,object)
    Rewired.Logger:LogErrorNow (object,bool)
    Rewired.Logger:LogError (object,bool)
    Rewired.Logger:LogError (object)
    JVDdrRIEEwlpZtUXeuFjRqEIfKJfA:.ctor (intptr)
    JVDdrRIEEwlpZtUXeuFjRqEIfKJfA:RnGkEPMLXrTWDHMNObHWTzFaBJWN (intptr)
    nOHkpfYpzCoELGCxhVhXOjZZWotP:yvJCmMBRHohlYvoYfOfnbnpUlNNaA (intptr,bool)
    nOHkpfYpzCoELGCxhVhXOjZZWotP:AJOgtYgpCNVDSvIXeUDLdWqJkYCOA ()
    KXaDpHJSZPlTjGPWGmeHWAyRjzvdc:pFRXTESEuTgIDTQwbfrbENVIrsztA ()
    EPiSRTSbgjMkrZcbHLKWgboARcRy:NlpzVhscdTsKHyMbGSMrfbGgifjq ()
    EPiSRTSbgjMkrZcbHLKWgboARcRy:tzFKBeYXJKHzyRUyXHxdcYLKPkXf ()
    EPiSRTSbgjMkrZcbHLKWgboARcRy:Update (Rewired.UpdateLoopType)
    apzMbHULjogSraBHFRrpKbwXJUgO:Update (Rewired.UpdateLoopType)
    Rewired.ReInput:WHQeRCrgfKDJeMXaAxKmAQJkPWjm (Rewired.UpdateLoopType)
    Rewired.InputManager_Base:DoUpdate (Rewired.UpdateLoopType,Rewired.Config.UpdateLoopSetting)
    Rewired.InputManager_Base:Update ()
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    If a HID device refuses to open when attempted to open through I/O Kit, there's no way to make it open. The only thing you can do is use a different input source for the device. Enable Game Controller Framework support:
    Rewired Input Manager -> Settings -> OSX -> Use Game Controller Framework.
     
  24. ironfiftynine

    ironfiftynine

    Joined:
    Jan 22, 2013
    Posts:
    71
    Good day. I have a question about getting the name of the plugged controller. I've seen the sample code using the joystick name property for choosing the right glyphs. I was expecting the name or hardwareName property of the Controller class to return the same name as the one Unity displays in its editor when plugging the controller or values returned by Input.GetJoystickNames. However, when I tried to log the name of my XBOX 360 Wired controller, it logged in Rewired as XInput Gamepad. I checked with Input.GetJoystickNames and it returns XBOX 360 as part of its name. Is there any way that I can get the joystick name that syncs with the registered name in Unity? If not, do you have like a preliminary list of the names of the popular joysticks? Thank you very much.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    The example code does not use string names for choosing glyphs. The documentation never tells you to match anything on strings. Very little is consistent across platforms or input sources. The glyph documentation uses Guids for identifying controllers. That's the only reliable way to do it. All the information you need to build a complete glyph system is in that link. For a more detailed example, see the link within the topic: A more complete example that shows handling Joystick, Keyboard (including modifier keys), and Mouse glyphs can be downloaded here. Links to CSV files of all recognized controllers and controller element ids are included in that topic as well, as well as the list of important controllers.

    The strings you're seeing from UnityEngine.GetJoystickNames are from the Windows HID API. They are not even necessarily the same as the string returned by the hardware (HID Product Name) and are modified by drivers. They will not necessarily match what you see on any other platform even when using UnityEngine.GetJoystickNames. Using strings as keys is guaranteed to fail under many circumstances.
     
    Last edited: Nov 10, 2023
    ironfiftynine likes this.
  26. guavaman

    guavaman

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

    See Updating Rewired before updating.

    Release Notes:

    1.1.48.0:

    Changes:
    - Linux Standalone, Native: Added Enhanced Device Support option. Special device features such as Sony DualSense vibration, IMU, and trigger haptics now work on Linux. (See documentation for Linux permissions issues.)
    - Linux Standalone, Native: Modified format of joystick.HardwareIdentifier string.
    - Windows Standalone, Raw Input: Modified format of joystick.HardwareIdentifier string for consistency.
    - Windows Standalone, Direct Input: Modified format of joystick.HardwareIdentifier string for consistency.
    - MacOS, Native: Modified format of joystick.HardwareIdentifier string for consistency.
    - Enhanced Device Support, Sony DualSense: Changed to vibration compatibility mode v2 for proper vibration intensity ramp, removed workaround.
    - MacOS Standalone, Native, Enhanced Device Support: Sony DualSense special features now work when connected via Bluetooth.
    - MacOS Standalone, Native, Enhanced Device Support: Sony DualShock 4 special features now work when connected via Bluetooth.

    Controller Definitions:
    - Sony DualSense, Linux Native: Added more device identifiers for matching.
    - Nintendo Pro Controller, Linux Native: Added variant for newer versions of Ubuntu.
    - Nintendo Left Joy-Con, Linux Native: Added variant for newer versions of Ubuntu.
    - Nintendo Right Joy-Con, Linux Native: Added variant for newer versions of Ubuntu.

    Bug Fixes:
    - Windows Standalone, Raw Input + Enhanced Device Support: Fixed possible issue with cleanup of resources for devices supported by Enhanced Device Support.
    - Windows Standalone, Raw Input + Enhanced Device Support: Fixed Sony DualShock 4 special features no longer working via Bluetooth (bug introduced in 1.1.47.0).
     
  27. ironfiftynine

    ironfiftynine

    Joined:
    Jan 22, 2013
    Posts:
    71
    Thank you for your response and providing me with the needed reference. I probably misunderstood the section that I found. Sorry about that.
     
  28. Christopher337

    Christopher337

    Joined:
    Apr 7, 2018
    Posts:
    2
    This is likely an uncommon request, but before I purchase ReWired I wanted to know if something like this would be feasible using this plugin. I am by no means a Unity input expert so apologies if this is obvious. What I would like to do is attach an FPV drone controller (specifically the DJI FPV Remote Controller 2) which, along with several other drone radios, can actually already be currently be used via USB connection in several popular drone simulators today. I am interested in creating my own simulator and custom tracks in Unity and I was hoping to find a solution that allows me to use a controller like this; something like a traditional XBox or PS gamepad is not sufficient for acrobatic drone flight. Thanks!
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I don't know. You would have to test it and try it. That's why there's a free trial. I don't have any information on how that device works, whether it's a standard HID device that identifies itself as a Joystick / Gamepad, or whether it needs some kind of special HID input/output report driver.
     
    Christopher337 likes this.
  30. juanborgesv

    juanborgesv

    Joined:
    Jul 15, 2017
    Posts:
    8
    Hello @guavaman,

    I want to address the case in which the player had some input controller maps saved, but some time after we added a new Action and Element Action Map to the default controller maps. The problem is, as you might imagine, that the saved mappings aren't updated with the new changes.

    The solution I'm trying is to use the ReplaceOrCreateElementMap method to do so, but it's not updating it correctly. During my tests the Action exists but with the wrong/test Element I initially set. However, regardless if the Action exists or not I'd like to add it to the saved controller maps data.

    Solution tried:

    private ControllerMap KeyboardControllerMap => ReInput.players.GetPlayer(_playerID).controllers.maps.GetMap(ControllerType.Keyboard, ReInput.controllers.Keyboard.id, _categoryName, "Default");

    public void Validate()
    {
    var controllerMap = KeyboardControllerMap;

    #region Keyboard
    // Generate element assignment.
    int kElementId = ReInput.controllers.Keyboard.GetElementIdentifierByKeyCode(KeyCode.Z).id;
    int kActionId = ReInput.mapping.GetActionId("Skip Area");
    ElementAssignment ea = new(kElementId, kActionId, Pole.Positive);

    // Reassign.
    if (controllerMap.ReplaceOrCreateElementMap(ea))
    Debug.Log("Assignment successful");
    else
    Debug.Log("Assignment failed.");
    #endregion
    }


    The results I got are the following: https://gyazo.com/1a8c8146c7100dffa9981db1b85d64d4

    The assignment change, but it didn't assigned the letter Z to that action as I was hoping.

    Do you know if I'm using the wrong method, or maybe there is a better method I could use, or something wrong in the code shared, or what could be the reason why ReplaceOrCreateElementMap is returning false?

    Thank you in advance.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Because you're creating an ElementAssignment for a button and not a keyboard key. See the constructors here:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ElementAssignment.htm

    Keyboard key assignments require a KeyCode and a ModifierKeyFlags value.

    Additionally, nothing will ever be replaced unless you pass in an id for elementMapId, which is the unique id of the ActionElementMap to be replaced.
     
    juanborgesv likes this.
  32. guavaman

    guavaman

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

    See this for more information about the Unity Physical Keys setting issue introduced in Unity 2021.2 and enabled by default in Unity 2022.0.

    See Updating Rewired before updating.

    Release Notes:

    1.1.49.0:

    Changes:
    - Added Use Physical Keys (Unity) option in Rewired Input Manager to detect Unity Physical Keys setting and to display warning to users about implications of using this setting. (Unity 2021.2+)
    - Native Keyboard Handling is disabled if Unity Physical Keys setting is enabled.

    API Changes:
    - Added Rewired.Platforms.MacOS.IOKit.IOKitControllerExtension class.
    - Added Rewired.Platforms.Linux.UDev.UdevControllerExtension class.
    - Added Rewired.Platforms.Windows.XInput.XInputControllerExtension class.
    - Added Rewired.Platforms.Windows.XInput.CapabilityFlags enum.
    - Added Rewired.Platforms.Windows.XInput.DeviceType enum.
    - Added Rewired.Platforms.Windows.XInput.DeviceSubType enum.
    - Added Rewired.Platforms.Microsoft.WindowsGamingInput.WindowsGamingInputControllerExtension class.
    - Added Rewired.Platforms.Microsoft.WindowsGamingInput.DeviceType enum.
    - Added Rewired.Platforms.UWP.HID.HIDControllerExtension class.
     
    Last edited: Nov 17, 2023
    juanborgesv likes this.
  33. InfiniteMonkey

    InfiniteMonkey

    Joined:
    Oct 8, 2016
    Posts:
    19
    Hey, I'm looking at building our controller remapping options menu, and there's something I can't work out how to do. I've got multiple different Map Categories that map the same input (e.g. Left Mouse Click) to different actions. This is similar to in the examples with Infantry / Vehicle / Airplane maps. The difference I'm struggling with is I only want to show the player one of these inputs to edit, and have that then alter all the different ActionElementMaps.

    A more concrete example:

    Left Mouse Click will - depending on which map is active - fire the Submit action or the SelectObject action. I don't want the player to edit those two independently (as they would if I used something like the ControlRemapping1 example) - I want them both to always be bound to the same input - but using InputMapper etc I can't see an obvious way to do that.

    I'm *guessing* that what I'd need to do is only present the player one "row", say for the Submit action, and then hook into the InputMappedEvent to then update the ActionElementMap for the SelectObject action and save the data with ReInput.userDataStore.Save(). Does that sound about right?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    What you are trying to do is not a something that the system was designed to do. Therefore, at that point, it is up to you to sync bindings across different controller maps manually. There is nothing in the system that will make this process any easier or more straightforward than simply iterating through the bindings, finding the one you want to replace, and manually replacing it. Controller Map and its subclasses contain a ton of different functions for getting at that information, iterating through it, and replacing bindings.

    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ControllerMap.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ControllerMapWithAxes.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_JoystickMap.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_MouseMap.htm
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_KeyboardMap.htm

    Input Mapper listens to input and writes the results to only a single Controller Map. Technically, it is possible to run multiple InputMapper instances simultaneously, but this can get messy.

    UserDataStore.Save would need to be called if you want these changes saved, yes.
     
  35. guavaman

    guavaman

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

    See Updating Rewired before updating.

    Release Notes:

    1.1.49.1:

    Bug Fixes:
    - MacOS Standalone, Native, Enhanced Device Support: Fixed bug causing controllers using Enhanced Device Support to stop working after editor pause, long level loading time, or application out of focus with Unity Player -> Run in Background disabled.
     
  36. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    Hi guavaman,
    After steam updates on Nov 21, 2023 Steam News Hub (steampowered.com) Sony PS4 & PS5 controllers are recognized as XBOX 360, does rewired new version 1.1.49.1 fixe this issue in advance? or we could wait for a later rewired release to have this issue fixed? or rewired could do nothing with this issue?
     
  37. guidaye

    guidaye

    Joined:
    May 20, 2022
    Posts:
    15
    By the way, we could disable steam input in the game input settings to make it works as before
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Please read these three topics on Steam and controllers in their entirety. They will explain exactly what is happening. This isn't a new issue:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-controller
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-configured-controllers

    And the section entitled "Special Considerations for XInput-compatible gamepads on Windows Standalone and Windows App Store":
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows

    What a controller appears as to the application is entirely determined by Steam. What information can be gleaned from the controller it exposes to the application is entirely determined by the input API currently being used for that device. What ultimately a device appears as to Rewired is determined by those two factors. There is no way to tell a Steam-configured controller is anything but an XInput gamepad (treated as Xbox 360 Controller) using any input source except Windows Gaming Input.

    The application cannot "fix" what Steam is chooses to expose to the application when it is placed in charge of controller configuration. That is by design.
     
    Last edited: Nov 21, 2023
  39. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    436
    Hello again :)

    We've been having the same issue that we were having with PS4 controllers on PC (lockup on resume of game) on the Switch after waking it from sleep (PC version is now perfectly fine after your recent changes). I've tried updating to the latest Switch plugin but to no avail. Is it possible that something similar to the PC problems is responsible? Thanks.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    It's not possible it's related. Nintendo Switch input happens on the main thread via polling. It's not possible for a buffer to grow out of control while the application is not in focus because there is no thread running in the background collecting input messages.

    Nintendo Switch issues and all issues for all platforms covered by NDAs should always be handled via email through the support form on the website.
     
  41. Necronopticous

    Necronopticous

    Joined:
    Jul 23, 2020
    Posts:
    4
    Hello!

    Last night I decided to take the plunge and swap out the input layer of the RPG project we have been working on for the last 3 years to use Rewired instead of the Unity Input System. I'm very happy with how much this has cleaned up our input handling code generally, but sadly it did not solve one of our oldest problems which I posted about a couple years ago on the Unity discord server, and few weeks ago in the Input System forum here:

    Bug - USB controller has dupe button Display Names and improperly registers input thusly - Unity Forum

    I'm at the point with this where I just want to understand and solve it purely for my own mental health! I don't really expect anyone to actually have this SNES controller adapter (though it shockingly looks like it is still available...it's this one here: USB Super RetroPort - retroUSB)

    The most baffling part about this to me is that in Unity's Input Debugger I was able to see that Unity is absolutely able to distinguish between all of the different inputs on the controller, but seems to compress the input handling in a lossy way, seemingly due to the "Display Name" of the input, before it gets to what I have access to in the game code.

    This is probably my last-ditch effort to get help with this before I just move on with my life and try to purge it from my memory forever. Any help or response is greatly appreciated, and thanks for your hard work on this great tool!
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    You need to describe the problem you're seeing in Rewired if I am to look into it. What you are describing in that link is very specific to how Unity's input system works with their display names, bits, etc. It is not clear to me what you are actually describing is happening to the inputs.

    This is the best guess I can make based on one sentence in your post:
    "If I press the B button for example, both value bits for button2 and button5 will be set, like so:"

    Are you saying that when you press the B button, both Button 2 and Button 5 activate and return non-zero value? And you are saying this happens with both Unity's new input system and Rewired? If this is what is happening, then the only possible explanations are:
    1. The device is providing a bad HID report descriptor that defines the data format of the input report.
    2. The device's HID report descriptor is somehow incompatible with Raw Input and errors in it are resulting in Windows' HID report parser functions to return incorrect values when called on the Raw Input event returned by Windows for the device.

    The fact that other games may work may simply be due to the fact that those other games don't use Raw Input and use the old outdated Direct Input, which can and does get different results with some devices, but is not necessarily "better" or more accurate across all devices, with many that exhibit problems that can be fixed through implementing Raw Input correctly as Rewired does. Those other games may also be directly reading the HID input reports from the HID device and parsing that input report instead of using Raw Input to deliver this data. The two APIs are not equivalent and Windows' processing of data can make a difference.

    #2 could be ruled in/out by using the legacy UnityEngine.Input system to read the device. UnityEngine.Input uses (used?) the direct HID reading method to read controller input as opposed to Raw Input. Open Assets/Rewired/UnityJoystickElementIdentifier scene and press buttons. You MAY want to try this in an older version of Unity (2019?) to rule out any possibility of changes to how the legacy system worked. If the buttons are independent using the legacy system, then that would indicate the problem is Raw Input.

    Either way, the problem is at an extremely low level, the HID descriptor provided by the device and/or the input API. Bad report descriptors and other errors and oversights in HID data are not uncommon, especially on cheap, no-name controllers, but sometimes even on name-brand devices like 3D Connexion Space Mouse. I've seen stuff like this plenty of times in the wild.
     
    Necronopticous likes this.
  43. Necronopticous

    Necronopticous

    Joined:
    Jul 23, 2020
    Posts:
    4
    The UnityJoystickElementIdentifier was able to uniquely identify each button press! This is what I see in the text area there (I put the SNES input in parentheses I observed flagging each button input in the scene)

    Code (CSharp):
    1. Unity Joystick Element Identifier:
    2.  
    3. Connected joysticks:
    4. [0] ""
    5. [1] ""
    6.  
    7. Current Unity Joystick Id: 1
    8. (Press + or - to change monitored joystick id.)
    9.  
    10. Axis 0 = 0
    11. Axis 1 = 0
    12. Axis 2 = 0
    13. Axis 3 = 0
    14. Axis 4 = 0
    15. Axis 5 = 0
    16. Axis 6 = 0
    17. Axis 7 = 0
    18. Axis 8 = 0
    19. Axis 9 = 0
    20. Axis 10 = 0
    21. Axis 11 = 0
    22. Axis 12 = 0
    23. Axis 13 = 0
    24. Axis 14 = 0
    25. Axis 15 = 0
    26. Axis 16 = 0
    27. Axis 17 = 0
    28. Axis 18 = 0
    29. Axis 19 = 0
    30. Axis 20 = 0
    31. Axis 21 = 0
    32. Axis 22 = 0
    33. Axis 23 = 0
    34. Axis 24 = 0
    35. Axis 25 = 0
    36. Axis 26 = 0
    37. Axis 27 = 0
    38. Axis 28 = 0
    39. Button 0 = False (Y)
    40. Button 1 = False (B)
    41. Button 2 = False (select)
    42. Button 3 = False (start)
    43. Button 4 = False (X)
    44. Button 5 = False (A)
    45. Button 6 = False (L)
    46. Button 7 = False (R)
    47. Button 8 = False
    48. Button 9 = False
    49. Button 10 = False
    50. Button 11 = False
    51. Button 12 = False
    52. Button 13 = False
    53. Button 14 = False
    54. Button 15 = False
    55. Button 16 = False
    56. Button 17 = False
    57. Button 18 = False
    58. Button 19 = False
    I also ran the JoystickElementIdentifier scene and noticed the dupe input behavior:

    Code (CSharp):
    1. Raw Input Joystick Element Identifier
    2.  
    3. 1 connected devices:
    4. Unknown
    5.  
    6. Current RI device 0: "Unknown"
    7. (Press + or - to change monitored device id.)
    8.  
    9. Product Name = "Unknown"
    10. Is Bluetooth Device = False
    11. Device Type = Gamepad
    12. Identifier = 00f1f000
    13. Product Id = 241
    14. Vendor Id = 61440
    15.  
    16. Axis Count = 2
    17. Button Count = 8
    18. Hat Count = 0
    19.  
    20. X = 257 (0.003921569)
    21. Y = 257 (0.003921569)
    22. Z = 0 (0)
    23. RotationX = 0 (0)
    24. RotationY = 0 (0)
    25. RotationZ = 0 (0)
    26. Slider0 = 0 (0)
    27. Slider1 = 0 (0)
    28. VelocityX = 0 (0)
    29. VelocityY = 0 (0)
    30. VelocityZ = 0 (0)
    31. Buttons  = (X, Y both show 0) (A, B both show 1) (L & select both show 2) (R & start both show 3)
    32.  
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    That confirms that the problem is the device's HID descriptor is somehow broken and incompatible with Raw Input.
     
    Necronopticous likes this.
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    You could change the Primary Input Source in Rewired to Direct Input just to see what happens. I don't recommend this as a permanent change though. You will lost a ton of features.
     
    Necronopticous likes this.
  46. Necronopticous

    Necronopticous

    Joined:
    Jul 23, 2020
    Posts:
    4
    Makes sense. Thanks for your help! I suppose the best thing to do if I want to play & demo my game with an SNES controller is to get a better adapter. Not the end of the world if so--like I said, this is less about me being concerned that players are going to have this specific thing and more that I wanted to understand why it seemed that it was possible to read the values distinctly but not process them properly in game, which I feel that I adequately understand now with the Direct vs Raw input explanation.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Just to clarify for others reading this, there are at least 3 ways to read HID device input in Windows:
    1. Raw Input (wrapper of Windows HID API).
    2. Direct Input (wrapper of Windows HID API).
    3. Reading HID input reports using the Windows HID API.
    • Rewired can be set to use Raw Input or Direct Input, and uses the HID API directly only in the case of Xbox One controllers due to an old Windows 10 bug.
    • Unity's old input system (Input Manager) reads HID input reports using the Windows HID API for all game controllers.
    • Unity's new input system uses Raw Input for all game controllers except those supported by Windows Gaming Input.
    Then there are other higher-level APIs such as XInput and Windows Gaming Input for specific devices.

    The problem with this specific device appears to be due to Raw Input's parsing of the HID descriptor which determines the data format and layout of the data in the input report returned by Raw Input.
     
  48. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,039
    Hi there and thanks for the continued updates on that asset! :)

    I'm in a little bit of a pickle here. We're on unity 2020.3.48. In our project we have both input enabled (old and new input system). the reason is that we use Invector 3Rd Person Shooter Controller which uses the old Input system and my dev is using the new one to handle all the navigation and stuff like that in the menu scene. In order to use Rewired and specifically that awesome looking UnityInputOverride tool, Can it be done? Will Rewired work properly with both Input system inside the same project? Could that lead to potential issues (on top of your head). Will the UnityInputOverride tool be our savior in our case? Thanks in advance for your time. :)
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    See this in the documentation:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#not-compatible-unity-new-input-system

    Unity 2020 predates the new Unity API to make it possible for Rewired and the new Unity input system work simultaneously in Windows. There are a number of problems that may occur due to how Raw Input works. In the best case scenario, UnityEngine.Input's mouse X and Y input will not work, and neither mouse nor controllers will work in the new input system. In the worst case, if Unity has patched Unity 2020 somewhere along the line to mirror the changes they made in Unity 2021, neither Rewired nor Unity input will work correctly.

    UnityInputOverride will only work for scripts that reference Unity's Input class without using the fully-qualified name of UnityEngine.Input. It will only make scripts that use the legacy Input Manager get input from Rewired instead. Unity Input Override won't fix anything involving the new input system, but it would allow scripts that call Input.GetButton or Input.GetAxis to use Rewired's Actions instead.
     
    PROTOFACTOR_Inc likes this.
  50. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,039
    So you're basically saying that i would need to update to 2021 in order for Rewired to work properly if the "both" (input option) is used? Am I reading you right (and the known issues as well)?
    Thanks