Rewired - Advanced Input for Unity

It’s been many years since I had the Farm Simulator controller, but some things that stand out to me on the Aerosoft:

  • Force feedback
  • Clutch pedal
  • Indicator and retarder stalks with all the various controls (cool!)
  • Large diameter wheel
  • Eaton Fuller 18 speed transmission

I haven’t tried it in any games, but it feels really substantial. The sitting behind the enormous wheel gives me the sensation of being behind the wheel of an 18-wheeler or bus.

The Farm Simulator controller’s side panel definitely has more functionality.

Hi !

I started using Glyphs recently and might be misunderstanding something.

My initial state :

I have a rebind menu (which currently works fine) that displays all game inputs (action name + binded key name) from all my maps.

My goal state :

Replace keys names with glyphs.

My current state :

I only get glyphs from enabled maps.
So, when I’m in my rebind menu I only have my “UI” map enabled, which mean that I only have glyphs related to “UI” map inputs. All others inputs have an empty glyph (no error).

Could you please tell me what I’m misunderstanding ?

Thanks for your help !

How have you chosen to display these glyphs? There are 3 different components provided by Rewired for glyph display, plus you could create your own if you so choose.

If you are using either Unity UI Player Controller Element Glyph or Unity UI Text Mesh Pro Glyph Helper, they are not the right components to use to display a list of bindings for remapping. The purpose of these components is to display only the first applicable glyph for the element bound to an Action in a Player, and optionally for the last active controller. These components are for displaying UI help text to show the user which elements to press to perform some Action. Bindings in a disabled Controller Map will not be displayed when showing the user what they need to press to perform an Action because disabled bindings will not contribute to any Action value.

The only suitable included glyph component for a control remapping menu is Unity UI Controller Element Glyph. The purpose of this component is to display a glyph for a specific element on a controller. This component is used by Control Mapper to display glyphs for the controller elements bound to Actions.

From the documentation:

Unity UI Controller Element Glyph

This component displays glyphs / text for a specific Action Element Map or Controller Element Identifier using Unity UI.

This component cannot be used alone. It requires a script to set either the actionElementMap property or the controllerElementIdentifier and axisRange properties. This is mainly useful if you need to display a glyph for a specific controller element, such as when showing a list of glyphs for controller elements in a controller or when showing glyphs for controller elements currently contributing to an Action value. If you want to display a glyph for a controller element bound to an Action for a Player, use Unity UI Player Controller Element Glyph instead.

Thank you so much !

I’m now using “Unity UI Controller Element Glyph” and everything works perfectly.

Regards.

1 Like

I have updated my project to Unity 6. If I update the Rewired-Version to 1.1.57.3 I get by importing the error message with Rewired_WindowsGamingInput.dll

after that I get the error
Failed to copy package file to Assets/Rewired/Internal/Libraries/Runtime/Native/WindowsStandalone/x64/Rewired_WindowsGamingInput.dll

The file is probably being locked by the operating system for some reason (virus scanner, file in use, etc.).

The only thing I can tell you is to do a clean install:
https://guavaman.com/projects/rewired/docs/Troubleshooting.html#clean-reinstall

If the file cannot be deleted with the editor open, delete the Rewired folder in a file explorer with Unity closed. The DLL could be being locked because Unity is using it as it is a native library for Windows, and the Unity Editor on Windows will load that file, probably locking it and preventing it from being deleted. This is the same thing that would happen with any other native Windows DLL on the Windows platform. This is not unique to Rewired, nor can I do anything to prevent it because Unitypackage extraction is handled by Unity and file permissions is handled by Windows.

1 Like

Thanks, I got it to work.

An other point, I get the warning (have nothing to do with the update, this warning I have long time):

I have deleted the UserDataStore_PlayerPrefs in the Rewired Input Manager see picutre. Is this just generally information which I can ignore?

*Rewired: UserDataStore_PlayerPrefs loaded all user data from XML. *
IMPORTANT: Changes made to the Rewired Input Manager configuration after the last time XML data was saved WILL NOT be used because the loaded old saved data has overwritten these values. If you change something in the Rewired Input Manager such as a Joystick Map or Input Behavior settings, you will not see these changes reflected in the current configuration. Clear PlayerPrefs using the inspector option on the UserDataStore_PlayerPrefs component.
UnityEngine.Debug:LogWarning (object)
Rewired.Data.UserDataStore_PlayerPrefs:Load () (at Assets/Rewired/Internal/Scripts/DataStorage/UserDataStore_PlayerPrefs.cs:253)
Rewired.Data.UserDataStore_PlayerPrefs:OnInitialize () (at Assets/Rewired/Internal/Scripts/DataStorage/UserDataStore_PlayerPrefs.cs:339)
Rewired.Data.UserDataStore:Initialize ()
Rewired.ReInput:YCRUigEzyVGSykoSYRlRyLJreWUY (Rewired.InputManager_Base,System.Func2<Rewired.Data.ConfigVars, object>,Rewired.Data.ConfigVars,Rewired.Data.ControllerDataFiles,Rewired.Data.UserData,Rewired.Utils.UnityTools/ZoyUFZuWgIYtoMtaLYhhtgTPBOhh,System.Action1<Rewired.Platforms.Platform>)
Rewired.InputManager_Base:IzQlgepxZVKRXLhTAcPPKUxCjvUm ()
Rewired.InputManager_Base:Awake ()
UnityEngine.Object:Instantiate (UnityEngine.Object)
Rewired.Utils.UnityTools:Instantiate<UnityEngine.GameObject> (UnityEngine.Object,UnityEngine.Vector3,UnityEngine.Quaternion,UnityEngine.Transform,bool)
Rewired.Utils.UnityTools:Instantiate<UnityEngine.GameObject> (UnityEngine.Object,UnityEngine.Transform,bool)
Rewired.Initializer:Initialize ()
Rewired.Initializer:Awake ()

Hi @guavaman

I still have the bug, that the player character continue to shoot even if I don’t press/held anymore the fire-button. When I press the fire-button again the wrong shooting stops. I can’t find any bug in my own code, I tried with a static bool variable too.

The wrong shooting happens mostly by left mouse button in the editor. But very rare it happens in Built version with gamepad too. But mostly time with the mouse in the editor.

You can see it in the video at 1:18: the flame is still shooting even the “eligibleForClick:” say “false” (buttonID: -1)

        private Player playerRewired;
        public static bool inputShooting;

        private void Awake()
        {
            playerRewired = ReInput.players.GetPlayer(playerId);
        }
        private void Update()
    	{
            //inputShooting = false;
            //inputShooting = Fire();
            Fire();
            if (inputShooting)
            {
                Debug.Log("Rewired found " + ReInput.controllers.joystickCount + " joysticks attached.");
                for (int i = 0; i < ReInput.controllers.joystickCount; i++)
                {
                    Joystick j = ReInput.controllers.Joysticks[i];
                    Debug.Log(
                        "[" + i + "] Joystick: " + j.name + "\n" +
                        "Hardware Name: " + j.hardwareName + "\n" +
                        "Is Recognized: " + (j.hardwareTypeGuid != System.Guid.Empty ? "Yes" : "No") + "\n" +
                        "Is Assigned: " + (ReInput.controllers.IsControllerAssigned(j.type, j) ? "Yes" : "No")
                    );
                }

                // Log assigned Joystick information for each Player
                foreach (var p in ReInput.players.Players)
                {
                    Debug.Log("PlayerId = " + p.id + " is assigned " + p.controllers.joystickCount + " joysticks.");

                    // Log information for each Joystick assigned to this Player
                    foreach (var j in p.controllers.Joysticks)
                    {
                        Debug.Log(
                          "Joystick: " + j.name + "\n" +
                          "Is Recognized: " + (j.hardwareTypeGuid != System.Guid.Empty ? "Yes" : "No")
                        );

                        // Log information for each Controller Map for this Joystick
                        foreach (var map in p.controllers.maps.GetMaps(j.type, j.id))
                        {
                            Debug.Log("Controller Map:\n" +
                                "Category = " +
                                ReInput.mapping.GetMapCategory(map.categoryId).name + "\n" +
                                "Layout = " +
                                ReInput.mapping.GetJoystickLayout(map.layoutId).name + "\n" +
                                "enabled = " + map.enabled
                            );
                            foreach (var aem in map.GetElementMaps())
                            {
                                var action = ReInput.mapping.GetAction(aem.actionId);
                                if (action == null) continue; // invalid Action
                                Debug.Log("Action \"" + action.name + "\" is bound to \"" +
                                    aem.elementIdentifierName + "\""
                                );
                            }
                        }
                    }
                }

                //Debug.Log("inputShooting");
      }


        public void Fire()
        {
            inputShooting = playerRewired.GetButton(RewiredConsts.Action.Fire);
            if(pressedPause)
                inputShooting = false;
            //return inputButton;
        }

Unity version >> 6.000.0.24f1
Rewired version >> 1.1.57.3
Platform >> Windows
Build / Editor / Both? >> Both.
Primary Input Source and optional additional input sources in use: https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings
Is Steam initialized? >> no
What controller(s) are being used? 

Rewired found 1 joysticks attached.
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:934)

[0] Joystick: Xbox 360 Controller
Hardware Name: Xbox 360-Controller für Windows
Is Recognized: Yes
Is Assigned: Yes
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:938)

PlayerId = 0 is assigned 1 joysticks.
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:949)

Joystick: Xbox 360 Controller
Is Recognized: Yes
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:954)

Controller Map:
Category = Default
Layout = Default
enabled = True
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:962)

Action “Jump” is bound to “A”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “Seek” is bound to “B”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “Fire” is bound to “X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “Seek” is bound to “Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “SwitchLeft” is bound to “Left Shoulder”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “SwitchRight” is bound to “Right Shoulder”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “Pause” is bound to “Back”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “Pause” is bound to “Start”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveVertical” is bound to “D-Pad Up”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveHorizontal” is bound to “D-Pad Right”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveVertical” is bound to “D-Pad Down”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveHorizontal” is bound to “D-Pad Left”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_Submit” is bound to “X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_Submit” is bound to “A”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveVertical” is bound to “D-Pad Up”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveVertical” is bound to “D-Pad Down”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveHorizontal” is bound to “D-Pad Right”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveHorizontal” is bound to “D-Pad Left”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_Cancel” is bound to “B”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_Cancel” is bound to “Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveHorizontal” is bound to “Left Stick X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveVertical” is bound to “Left Stick Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveHorizontal” is bound to “Right Stick X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “MoveVertical” is bound to “Right Stick Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “SwitchLeft” is bound to “Left Trigger”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “SwitchRight” is bound to “Right Trigger”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveHorizontal” is bound to “Left Stick X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveVertical” is bound to “Left Stick Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveHorizontal” is bound to “Right Stick X”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

Action “UI_MoveVertical” is bound to “Right Stick Y”
UnityEngine.Debug:Log (object)
SupanthaPaul.PlayerController:Update () (at Assets/!MyGame/Scripts/PlayerController.cs:973)

more pics

All other buttons works well with “GetButtonDown”, the Fire-action is the only with “GetButton”

That warning is displayed every single time Play mode is entered if you are using the UserDataStore_PlayerPrefs component and it loads saved XML data. That warning is shown because of how many times people ask me for support because changes they have made to the input configuration data in the Rewired Input Manager are not reflected at runtime because they are using UserDataStore_PlayerPrefs and have previously saved data which overrides the defaults defined in the Rewired Input Manager. It is not logged in a build.

1 Like

You should be monitoring input values using Debug Information, not the Event System. Event System is used by Unity UI, not for game input.

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

The single most important tool for debugging issues in Rewired is Debug Information. It is always where you should start.

There is a checklist to follow which takes you through every step of the input stack to identify where problems are happening:

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

For the issue of a stuck button, I would check the following things in this order:

  1. The Action’s Button Held and Button Down values:

Debug Information → Players → [Player #] → Actions → [Action Category] → [Action]

If in the Unity editor, Click back into the game window before testing, otherwise input may be ignored because the game window is out of focus.

  1. If the Action’s button value is stuck on, next check the Controller Button’s values:

Debug Information → Controllers → [Controller Type] → [The Controller] → Buttons

If the Controller’s Button is stuck on when it should not be, there is some kind of problem at the low level that you cannot fix and I am going to have to look into it. If this is the case, I will ask you to provide information that I will need to investigate.

If the Action’s button value is stuck on but the Controller’s button value is not stuck on, then you can be certain there is another controller element on some controller contributing to this Action’s value. Check all the bindings in the Player at runtime using Debug Information or log all the contributing input sources to that Action:

https://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources

If neither the Action’s value is stuck on nor the Controller’s button value is stuck on, that would indicate the problem is in your code.

1 Like

The debug info tells me that the left mouse button is pressed. Where could I look for fixing this?

You can’t fix this. This can only happen if Raw Input is reporting a button Down event and not then reporting an Up event when the button is released. This is at the very lowest possible level of input – the operating system’s input API. This should not be possible.

  1. What mouse are you using?
  2. You have also said this happens with a gamepad in a build. Which gamepad were you testing with?
  3. Is Steam initialized in this project? Steam is a very important factor because it gets in between the OS input APIs (Raw Input) and the application.
  4. What is your Unity “Active Input Handling” set to? (Player Settings → Active Input Handling)

It is remotely possible that something else is stealing this event from the Windows event queue and processing this input event before Rewired is able to process it. This very thing happened in the past (Unity 2021.2) when Unity made changes to their Raw Input event handling code. I worked with Unity to create a way to resolve this. Since I’ve had 3 people report something similar in the last few months, I suspect it is possible that Unity (or perhaps Steam) has made some change recently that is responsible for this. I had no reports of this before the last few months.

1 Like

My mouse is Logitech G403 Hero. It happens without Steam too.

In the last times it only happened by the mouse. On the gamepad it happened very rare in past times and in the last times never. But I changed some things between the time.

I tried to uncheck “Native Mouse handling” in the Rewired Editor at the Windows settings. Since then the bug didn’t occurred. But I can’t tell for sure because it happens randomly. I will tell you in the future if the bug happens again by longer testing time. Thank you.

Unchecking Native Mouse Handling makes it use UnityEngine.Input for mouse input, which in turn uses the WM_KEY_UP / WM_KEY_DOWN Windows API underneath. It’s different than Raw Input and would not have the same issues as Raw Input. Unity’s new input system uses Raw Input for mouse input, however. It would be useful to know if their new input system’s mouse buttons are getting stuck on on your system.

I have been unable to get enough information from any of the 3 people who have reported this to determine where the problem lies. Because this is a new problem that just started occurring with no changes to the Rewired code, and due to the fact that I have gone over the code in detail and can find no code path that could lead to this other than Raw Input not sending the Up event, and because I have spent hours on multiple systems running different versions of Unity and Windows and with a bunch of different mice trying to reproduce the problem, I have to assume the issue is outside Rewired and due to something specific to the systems in question. What specifically, I cannot say. It could be software (drivers, memory resident programs that modify input, Steam, drivers, etc.) or even hardware. I am at a loss to determine any cause for this.

I suspect the only way I will ever track this down is if I can somehow manage reproduce it or have someone who can reproduce the problem spend a great deal of time running test builds that log extensive information at the low level so I can analyze it.

I will look into getting the Logitech G403.

1 Like

I haven’t tested it very long time but the bug didn’t occurred since I have uncheck “Native Mouse handling” in the Rewired Editor at the Windows settings.

Rewired 1.1.58.0 is available on the Unity Asset Store.

1.1.58.0:

Changes:

  • Windows Standalone, Native Mouse Handling: Handle possible edge case of a Raw Input mouse event reporting both up and down events for a button in the same Raw Input event. (It is unclear if this can even occur, but this is an attempt to address a few recent reports of mouse buttons getting stuck on.)

API Changes:

  • Added UserDataStore_File class.
  • Added UserDataStore_KeyValue class.

Bug Fixes:

  • Unity Editor: Fixed OnGUIHelper component being permanently added to Rewired Input Manager GameObject if OnGUI update loop enabled and Run in Edit Mode is enabled.
  • Unity Editor: Fixed static object pool not cleared manually on initialization causing exception to be thrown when Domain Reloading is disabled in Unity Editor preferences and entering Play mode multiple times with different Rewired Input Managers which have different Update Loops enabled.
  • Unity Editor, Windows, Native Keyboard Handling / Native Mouse Handling: Fixed keyboard and mouse input events buffering up when clicking outside the Unity Editor window when Application.runInBackground disabled and Ignore Input When App Not In Focus enabled.

Rewired 1.1.58.1 is available on the Unity Asset Store.

1.1.58.1:

  • Bug Fixes: Fixed compiler error in UserDataStore_KeyValue on Nintendo Swtich, Playstation 4, and Xbox One (XDK) build targets.

I’m trying to create a quick controls tutorial for a game and have the main mapping for movement (WASD) showing, but I don’t know how to get the alternate mapping (Arrow keys) to display.

using Rewired;
using Rewired.Glyphs.UnityUI;
using UnityEngine;

namespace MyNamespace {
    
    public class MyUnityUIPlayerControllerElementGlyph : UnityUIPlayerControllerElementGlyphBase {

        [SerializeField]
        [PlayerIdProperty(typeof(MyRewiredConsts.Player))]
        private int _playerId;

        [SerializeField]
        [ActionIdProperty(typeof(MyRewiredConsts.Action))]
        private int _actionId;

        public override int playerId { get { return _playerId; } set { _playerId = value; } }
        public override int actionId { get { return _actionId; } set { _actionId = value; } }
    }
}

I am using that sample code to display the glyph to an action, but what would I need to add to get the secondary mapping glyphs? I see the Control Mapper can display secondary glyphs, so I know it is possible, I’m just not sure what to search on your documentation because I tried secondary and alternate on the glyph page but did not find anything.