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. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Yes. Rewired and Unity's new input system cannot both work together without issues in Windows in any version of Unity prior to Unity 2021.2.0f1 as it says in that first link I posted.
     
    PROTOFACTOR_Inc likes this.
  2. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,039
    All right, then i read all that correctly then. Just wanted confirmation I wasn't crazy or read something wrong. Thanks for your time
     
  3. DR_Studio

    DR_Studio

    Joined:
    Aug 4, 2018
    Posts:
    6
    Can we still use this with unity 2019.4.40f?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Rewired works with all versions of Unity 4.3 and greater. The Unity Asset store provides versions for Unity 2019+. Anything earlier has to be downloaded from the website.
     
  5. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    34
    Hi, I'm using rewired for steering wheel and pedal inputs. I'm having some issues with axis mappings. For example, I map the throttle and set no dead zone and use the calibration tool in the control mapper example. On screen it goes from 0-1 fine (the raw data seems to go -1 to 0.25). But when I do player.getAxis, about 75% of the pedal travel and the value is 1 for the last 25% of pedal travel. The steering does similarly, after about one turn, the value reaches 1 and just sits there.

    Here's a picture of the calibrator showing it reaching 100% so it calibrates fine. but getaxis doesn't show these same values.
    upload_2023-12-10_21-31-12.png

    Example of the code I'm using to get the axis:

    sldThrottle.value = rewiredPlayer.GetAxis("Throttle");

    Example code of setting the default values:


    AxisCalibration joystickcal = currentPlayer.controllers.Joysticks[controllerid].calibrationMap.GetAxis(j);
    joystickcal.Reset();
    AxisCalibrationData acd = joystickcal.GetData();
    acd.deadZone = 0f;
    acd.min = ffMin.value;
    acd.max = ffMax.value;
    if (mappingtype == buttonType.Steering)
    {
    acd.zero = 0f;
    }
    else
    {
    acd.zero = -1f;
    }
    acd.sensitivity = 1f;
    acd.applyRangeCalibration = true;
    joystickcal.SetData(acd);


    (1) What racing wheel setup are you using? (Name/Version) Simagif alpha mini wheel. Fanatec club sport v2 pedals
    (2) Does you racing wheel setup have the latest firmware installed? yes to both
    (3) What operating system are you using (Windows/MAC/LINUX)? Windows
    (4) Have you calibrated your racing wheel for the operating system you are using? Usually the racing wheel setup has specific guidance (in the racing wheel setup documentation) on how to calibrate your device for a specific operating system. (I am guessing it is Windows). Yes. It works fine in all other games.
    (5) What Unity version are you using? 2022.3.7f1
    (6) Are you using the latest Rewired version available in the asset store? 2.0.50727
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Why are you showing both Control Mapper's calibration screen and your own custom calibration code? Which is being used here? And which is resulting in a value that doesn't reach 1.0 when the pedal is fully depressed?

    Calibrate the pedal using the Control Mapper interface:
    1. Press Calibrate.
    2. Wait for the timer to run out with no pressure on the pedal.
    3. Fully depress the pedal multiple times and release it so it can record the full range of motion, then wait for the timer to run out.
    4. Test.

    Monitor the calibrated and raw values of the Controller Axis using Debug Information:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Monitor the raw and final values of the Action using Debug Information.

    A discrepancy between the Controller Axis value and the Action value can only be accounted for by an Input Behavior value modifying the Controller value. A Joystick Axis Sensitivity of anything but 1.0 would definitely cause this:
    https://guavaman.com/projects/rewired/docs/InputBehaviors.html
     
    Last edited: Dec 11, 2023
  7. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    34
    Thanks for the reply. I'm using both just for testing purposes. I want to use my own and I cant' tell if my code is bad or the mapper is bad. I think both calibration systems work fine. Here's a screen shot after a calibration using the default control mapper calibration (sensitivity 1 on every ss below). The debug values are correct but my slider using rewiredPlayer.GetAxis("Throttle") is already at 1.
    upload_2023-12-12_6-58-56.png
    Here's the same pedal placement, no settings changed, just with the control mapper calibration
    upload_2023-12-12_7-4-23.png

    Basically, I think everythign is fine, it's just GetAxis is giving me the wrong value.
     
    Last edited: Dec 11, 2023
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    There is nothing that can possibly transform a underlying Controller Axis value from 0.233 to an Action value of 1.0 besides the Input Behavior. There is no other processing happening between the final Controller Axis value and the Action value apart from compiling input values from all contributing input sources and applying the input behavior processing to it.

    Did you clear Player Prefs?
    https://guavaman.com/projects/rewired/docs/UserDataStore.html#saved-xml-not-synced

    Input Behavior values are saved and loaded. If a non-zero value was ever saved, it will be loaded even if you change the value in the Rewired Input Manager. Input Behavior values can be seen in real time in Debug Information under the Player section.

    Make sure there are no other input sources besides the single pedal axis contributing to the Action value:
    https://guavaman.com/projects/rewired/docs/HowTos.html#get-contributing-input-sources

    And make sure there aren't multiple bindings to the Action from that same pedal axis using Debug Information to view all the Controller Maps and Action Element Map bindings to that Action at runtime.
     
  9. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    34
    Thanks! Cleraning the player prefs fixed it. Although I'm still very confused how it got so far in the first place. The min value was -1 (zero was -1 as well). Max wound up being 0.25. Weird how the fanatec pedals are -1 to 0.25 but ok!
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    An Input Behavior Joystick Axis Sensitivity scale of 2.0 would cause the pedal to reach 1.0 twice as fast as it should. It's scaling linearly. You must have had a Joystick Axis Sensitivity of like 4 or 5 in at some point which was saved to XML. Control Mapper does have an optional slider for Joystick Axis Sensitivity.

    Glad it works now.
     
  11. marspot

    marspot

    Joined:
    May 22, 2020
    Posts:
    7
    Hello Guavaman! First off thanks for all your hard work in supporting this asset over the years. It's fantastic and very versatile.

    I'm using the SimpleControl example for remapping. For two buttons, the default controller map is set up so that the UI actions and in-game Player actions both share the same button and I end up just switching between the two depending on what situation the player is in. For example, "Fire" and "UICancel" both sharing the "B" button on an xbox controller. When I try to test and remap an action to one of these buttons, the remapping script stops listening for input and reverts back to the menu without remapping anything, as if I had cancelled the operation completely. I cannot map to those buttons for any actions through the remapping screen. The listening operation also cancels if I use any other UI controls while it's listening for input, for example if I use the DPAD or analog stick to navigate UI.

    I've tried looking through the options in the rewired input manager and couldn't find anything to prevent this from happening. I have UI controls and player controls on separate maps to protect the UI controls from getting remapped inadvertently.

    Do you have any thoughts on how to allow remapping of these buttons for the player controls map, but protect the UI map from being remapped?

    I have done my best to find anything in the documentation and/or forums that points to this but so far haven't found any help yet.

    Thanks in advance!
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I'm glad to hear Rewired has been useful.

    Right here:
    https://guavaman.com/projects/rewired/docs/HowTos.html#conflict-checking
     
  13. marspot

    marspot

    Joined:
    May 22, 2020
    Posts:
    7
  14. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Im receving this error on play for 3 different actions:

    Code (CSharp):
    1. [Warning] [17:28:14.606] Rewired: No Action exists for Action Id 24. You can create Actions in the editor.
    2. [Warning] [17:28:14.606] Rewired: No Action exists for Action Id 26. You can create Actions in the editor.
    3. [Warning] [17:28:14.606] Rewired: No Action exists for Action Id 27. You can create Actions in the editor.
    4.  
    And I cant find the cause. Those were actions that I deleted from rewired (and confirmed on my RewiredConsts.cs that there are no action with this id). After I deleted them, those message started poping, and the log doesnt hint where / why

    Strack:
    Code (CSharp):
    1. [Warning] Rewired: No Action exists for Action Id 27. You can create Actions in the editor.
    2. Logger.LogWarningNow()
    3. Logger.LogWarning()
    4. Logger.LogWarning()
    5. eHHEMxcgIXacZfzIFlzCvJaOYUkqB.lckhtUweqUHVKGCvbrAMJdlhQEpU()
    6. eHHEMxcgIXacZfzIFlzCvJaOYUkqB.wcVHTOjdYwfoEvnpgnYdRBETHmVy()
    7. ccaCWOJvbydViizXKbdwnnBQxBIS.JFGCfFiLPUOKQOjLugTbayBfDDVxA()
    8. Player.GetAxis()
    9. PlayerController/MouseWheelAxis.rCKFxBBMhgoRJzsEosHfgbMXWJLt()
    10. PlayerController/MouseWheelAxis.iGfvQIxknXEztLRlEexIhzhdQxrcA()
    11. PlayerController.Update()
    12. PlayerMouse.Update()
    13. PlayerController.GsPbmiacXgfGPHcAKrbwsXsBbuahe()
    14. ReInput.iGfvQIxknXEztLRlEexIhzhdQxrcA()
    15. InputManager_Base.DoUpdate()
    16. InputManager_Base.Update()
    17.  
    Any hints how to fix it? I dont seem to be able to add them again, as new Ids are created, right?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Your stack trace tells you where the problem is:
    PlayerMouse.Update()

    You created a PlayerMouse and you have left the deleted Actions assigned to the PlayerMouse.
     
    Fira-Soft likes this.
  16. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    How to use Rewired to bind keys in CorgiEngine?
    Why do my key bindings have no effect?

    My setup is as follows;

    I used CorgiEngine as the core gameplay system of the game, DialogueSystem for plot and mission settings, and I used PixelCrusher’s DialogueSystemMenuFrameWork as the main menu of the first scene.

    1. Added an object to the scene containing the Rewired Input Manager (1-Player for Corgi Engine) component and a UserDataStore_PlayerPrefs component to save key binding data.

    2. Replace EventSystem with Rewired Event System+Rewired Standalone Input Module.

    3. Replace the input system of CorgiEngine's UICamera with RewiredCorgiEngineInputManager.

    4. Copy the UI component ControlMapper of ControlMapperDemo to the Option interface for functional testing, and try to change the horizontal movement of the character from AD to the left and right ← → direction keys in the keyboard key binding, but the character cannot move after entering the game.

    Please tell me what I'm missing? Thank you so much
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      176.4 KB
      Views:
      21
  17. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Thx for the direction. I didnt recognized PlayerMouse as a MonoBehaviour when looking at the stack. Assumed it was only a step on the stack that I couldnt access.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    1. Does character input work before you try remapping it? (Clear Player Prefs to start over.)
    2. Does the character still move when you press A/D after remapping it?
    3. Did you use Debug Information to view the bindings in the Controller Map live at runtime after you changed the bindings? https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    Event System and Rewired Standalone Input Module have no effect on character movement. They are only used for Unity UI navigation.
     
  19. chilly-15

    chilly-15

    Joined:
    Nov 7, 2013
    Posts:
    2
    Hi all! :)
    I just updated Rewired in my project from 1.1.44.0 to 1.1.49.1.
    I'm getting an error when I play my project which seems to be related to DualShock controllers.
    It is causing Rewired to not initialise if I startup with my PS4 controller plugged in.
    (I've included the exception call stack at the bottom of this message)

    For context, my project is in Unity 2023.3.18f1, I'm using a Macbook Pro with Apple Silicon (M1 Max), running Ventura 13.5.

    Looking at the ReleaseNotes.txt, it looks like the issue might be caused from a change in 1.1.47.0:
    - MacOS Game Controller Framework: Added DualSense trigger effect support.

    Code (CSharp):
    1. EntryPointNotFoundException: RWController_GetDualSenseAdaptiveTrigger assembly:<unknown assembly> type:<unknown type> member:(null)
    2. MFnSqJHiCldiQwjCMDpSURJFGbQd..ctor (System.IntPtr , Rewired.Config.UpdateLoopSetting ) (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    3. VNCXXoQmgxpZEhNEkpZrRAUfwNNQ.aJaVTVVoRdBZqkhotVRXfpCTBswGA (System.IntPtr ) (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    4. VNCXXoQmgxpZEhNEkpZrRAUfwNNQ.YXpyHsoxRbOrFjMsaPJWvXmcRnfU (System.IntPtr ) (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    5. (wrapper native-to-managed) VNCXXoQmgxpZEhNEkpZrRAUfwNNQ.YXpyHsoxRbOrFjMsaPJWvXmcRnfU(intptr)
    6. VNCXXoQmgxpZEhNEkpZrRAUfwNNQ.Update () (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    7. FZKxCsLLoxeXqmeTkSMojfvcbnxq.Update (Rewired.UpdateLoopType updateLoop) (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    8. wrBkCgYCtFiCORaKIUdAXbZckJOp.Update (Rewired.UpdateLoopType currentUpdateLoop) (at <f393b1d9b3974ab6a5ec46e9e925de35>:0)
    9. Rewired.ReInput.sCrFsINbYXMZGKRQoueIoixtaVUW (Rewired.UpdateLoopType ) (at <0bb07e336b974148b8a339062f9b8312>:0)
    10. Rewired.InputManager_Base.DoUpdate (Rewired.UpdateLoopType updateLoopType, Rewired.Config.UpdateLoopSetting updateLoopSettingBit) (at <0bb07e336b974148b8a339062f9b8312>:0)
    11. UnityEngine.Logger:LogException(Exception)
    12. Rewired.Logger:LogExceptionNow(Exception, Object, Boolean)
    13. Rewired.Logger:LogException(Exception, Object, Boolean)
    14. Rewired.Logger:LogException(Exception, Object)
    15. Rewired.InputManager_Base:lGckuCZvGnVteNGRgERHkTmzVWgY(fIFfEUjWVzRmwcMcVLgVOpREBWdsA, String, Exception)
    16. Rewired.InputManager_Base:DoUpdate(UpdateLoopType, UpdateLoopSetting)
    17. Rewired.InputManager_Base:Update()

    I'm thinking I will downgrade to 1.1.46.0 for now.
    Anyone have any other ideas or thoughts?

    Thanks!

    ========== UPDATE ==========

    The error goes away if I disable the OSX Platform Setting: "Use Game Controller Framework".
    So I've decided not to downgrade for now.
     
    Last edited: Dec 18, 2023
  20. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    1.RewiredCorgiEngineInputManager works normally in a single scene and seems to be no different from the InputManager that comes with CorgiEngine. However, the character cannot be controlled after the Rewired Input Manager (1-Player) is added. In the Action of the Debug page, the input of the keys can be detected, but the character cannot be controlled.

    2.The character not move when i press the keys after remapping it.

    3.In the Action of the Debug page, the input of the keys(Includes new keys that have been bound) can be detected, but the character cannot be controlled.

    4.I just noticed a strange phenomenon; I originally added the RewiredCorgiEngineInputManager to the camera in the second scene (tutorial level), and the first scene is the main interface scene that contains the Rewired Input Manager (1-Player) and button settings. . When I jump to the second scene, the RewiredCorgiEngineInputManager component disappears
     

    Attached Files:

    • 2.jpg
      2.jpg
      File size:
      93 KB
      Views:
      20
  21. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Thanks to the developer for the reply and long-term support, this should be a minor issue.

    I think I've solved it, I opened the script and found this comment //This persistent singleton handles the inputs and sends commands to the player.

    Before that, I put this RewiredCorgiEngineInputManager in the camera prefab which exists in every scene and that's why the script disappears.

    The script RewiredCorgiEngineInputManager should be placed together with the Rewired Input Manager (1-Player) component, so that it will work. After a short test, the keys are bound normally.

    Another small question is, is this error report normal?Can I ignore this?

    Rewired: Unity Input Manager mouse entries are missing.
    Rewired was not installed properly or was canceled during installation, preventing it from installing the necessary Unity Input Manager entries for mouse input or the input manager entries may have been overwritten by another package installed in your project .
    Mouse input will not function if native mouse input is disabled or is unavailable on this platform.
    ------- Rewired System Info -------
    Unity version: 2020.3.23f1c1
    Rewired version: 1.1.49.1.U2020
    Platform: Windows
    Editor Platform: Windows
    Using Unity input: False
    Primary input source: RawInput
    Use XInput: True
    Native mouse handling: True
    Enhanced device support: True

    UnityEngine.Logger:LogError (string,object)
    Rewired.Logger:LogErrorNow (object,bool)
    Rewired.Logger:LogError (object,bool)
    Rewired.Logger:LogError(object)
    Rewired.ThreadSafeUnityInput/Mouse:Update ()
    Rewired.ThreadSafeUnityInput/Mouse: PostInitialize ()
    Rewired.ThreadSafeUnityInput: PostInitialize ()
    Rewired.ReInput:TsGxKDrXtsYfTRmMAvEnIiJFHNXT (Rewired.InputManager_Base,System.Func`2<Rewired.Data.ConfigVars, object>,Rewired.Data.ConfigVars,Rewired.Data.ControllerDataFiles,Rewired.Data.UserData,Rewired.Utils.UnityTools/SgiFtBjoQ SnoQtlhFIsKXENLVPzmA ,System.Action`1<Rewired.Platforms.Platform>) Rewired.InputManager_Base:TsGxKDrXtsYfTRmMAvEnIiJFHNXT ()
    Rewired.InputManager_Base:Awake ()
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    An EntryPointNotFoundException indicates that Rewired_MacOS.bundle is an outdated version. This is included in the distribution, but it is possible that it is not being overwritten when you upgrade because the Unity editor already has a lock on the file.

    Assets/Rewired/Internal/Libraries/Runtime/Native/MacOS/Rewired_MacOS.bundle should have a modified timestamp of 9/28/2023 5:45 PM. If it is older, then the file was not overwritten when you installed the update. Close the editor, open it again, and install the Unitypackage over it, making sure this file is checked.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    That error message should not be ignored. See this for how to fix this and the explanation for why it happened:
    https://guavaman.com/projects/rewir...tml#exception-input-manager-entries-not-setup
     
  24. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
  25. Zarpyk

    Zarpyk

    Joined:
    Mar 17, 2019
    Posts:
    7
    Hi, I have a question about getting the inputs, is there a way to avoid using strings like in the new input system that generates the code automatically? Or is string (or int) the only way to use the asset?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Yes. The documentation advises you to always use the integer constants. Strings are slow.

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

    "You can also get input based on the Action id instead. The Action id is displayed in the Rewired Editor under Actions. You can export a list of Action Id constants which adds the convenience of letting you use your IDE's auto-complete to find Actions when coding. Looking up Actions by id is significantly faster than by name and is the recommended method."
     
  27. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    Hi there!

    A couple of years ago i tried rewired with an XBox or PS4 Controller on iOS and the triggers were not functioning properly. (Just acting as buttons basically). (It was working correctly on PC and Android devices tho)

    Now we are almost in 2024, still having the issue on my iPhone 14.

    Is there any hacks for making this work? anything i can do on XCode side to help with that issue?
    Thanks a lot, any idea would be appreciated!

    Regards
     
  28. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Hi! I got the following error while submitting my build to appstore for Mac, any clues how to fix this?

     
    Last edited: Dec 21, 2023
    dirty-rectangle likes this.
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    This is the reason:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    Rewired is 100% dependent on UnityEngine.Input for input on the iOS platform. This is Unity's documentation on iOS input:
    https://docs.unity3d.com/Manual/ios-handle-game-controller-input.html

    Apple's original iOS controller standard, MFI, used buttons for triggers, not analog triggers. Apple only added new API in iOS 13 to support Xbox and Sony controllers, and have added more features to this API in later releases. Unity's Input Manager does not expose these trigger values as far as I know as they are not documented.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    First, let me state that I am not a Mac App Store developer. I do not have any experience with publishing applications on the Mac App Store. I only provide a library that runs on Mac. That library can work on the Mac App Store, provided you follow all the submission guidelines. I am not the one to authoritatively answer this question. What follows is simply what information I have been able to gather trying to research this error and how libraries are supposed to be handled by Mac App Store submissions.

    As best I can understand the error, it sounds like it is telling you two things:
    1. The library needs to be signed with the same signature as the main application.
    2. The library has an invalid identity tag. This identity was generated by Xcode and doesn't appear to be settable for a dylib (this library is actually a .dylib file with the extension changed to .bundle as per Unity's recommendation to make it able to be loaded by older versions of the Unity Editor.)

    The solution appears to be to re-sign the library and set the application identity tag at the same time using codesign in a terminal:
    Code (csharp):
    1. codesign -s "YOUR ORGANIZATION'S SIGNING IDENTITY" -f -i "YOUR BUNDLE IDENTIFIER" Rewired_MacOS.bundle
    To see your signing identities:
    Code (csharp):
    1. security find-identity -v -p codesigning
    More information about signing libraries:
    https://stackoverflow.com/questions/7936624/signing-libraries-in-mac-app-store-app

    This Unity documentation on Mac code signing appears to recommend running codesign on the project with the --deep flag enabled, which would presumably cause it to sign all the binaries inside the project which would include Rewired_MacOS.bundle:
    https://docs.unity3d.com/2022.1/Documentation/Manual/macos-building-notarization.html

    I do not know if it would still throw an error about the "application identifier" of Rewired_MacOS.bundle after running the codesign --deep command. It is unclear to me whether I should be manually overwriting this application identifier tag to something other than the default generated value when building or not. As mentioned before, it doesn't appear to be settable in Xcode when building a dylib.

    FYI, Rewired_MacOS.bundle was a recent addition to Rewired, added in version 1.1.43.0, in order to support Apple Game Controller Framework.

    See this for the discussion I had about requirements for native library signing:
    https://forum.unity.com/threads/code-signing-requirements-for-native-plugin.1236583/
     
    Last edited: Dec 21, 2023
  31. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    I really appreciate your time for answering and support!
    So, no hack to be found to go around that limitation?
    Does the new Input System from Unity could solve the issue?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I don't see how there could possibly be a hack to add features that are unavailable except through the native API. That would be adding native support for the platform through a native library. I wouldn't consider that a hack.

    I don't know much about Unity's new Input System. I would ask on their forum. I would bet it does support the newer input APIs, but I have not used it.

    It is possible Unity added these axis values without documenting it. Build and run Rewired/DevTools/UnityJoystickElementIdentifier on the device and see if those return axis values through Unity's input system. If it does, it would be dependent on the Unity version in use.
     
  33. chilly-15

    chilly-15

    Joined:
    Nov 7, 2013
    Posts:
    2
    Looks like you're right! My Rewired_MacOS.bundle was last created AND modified on 12/20/2020.
    After restarting Unity and checking the changed files while importing the package, Unity didn't realise that the file had changed and it didn't let me select it to modify it. I deleted the file manually and reimported it, now I have a much more recent modified date: 11/21/2023.

    Thank you so much!
     
  34. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Hello, I use i2 Localization to perform multi-language localization translation for the game.
    Now I can translate the UI interface in ControlMapper by modifying the LanguageData script, like this:

    using I2.Loc;
    //other codes..
    public override string restoreDefaultsButtonLabel { get { return LocalizationManager.GetTranslation(_restoreDefaultsButtonLabel); } }

    If I want to translate the Action's DescriptiveName customized by developers in RewiredEditor, what should I do? Can you provide some guidance?
     
  35. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    68
    Hi,

    I'm almost sure this is not an issue in ReWired, but I hope someone has already met with this and could give me some hint, or a workaround for the issue.
    I'm stuck with a given, older unity version (2021.1.28f), but at the same time I have to support the latest macOS Sonoma version as well
    It seems one of the latest Sonoma updates changed something, the same unity-generated game standalone binary stopped processing input at all (or can do some, but with a huge timeout, extremely slowly) in windowed mode on the latest Sonoma version (earlier versions are not affected)
    If the game starts in full-screen mode the problem occurs with a smaller chance, but it can happen too. (or switching back and forth between full-screen and windowed mode)
    I'm using the latest possible ReWired version for input handling.

    Have any of you met with this, is there any workaround, or fix?

    Thank you in advance!

    EDIT: I narrowed down the issue a bit meanwhile. The problem is in the mouse handling somewhere. In windowed mode, if the mouse is inside the app window it stops responding to the keyboard events, after a while the mouse pointer is removed from the window, the keyboard handling starts working again. As a quick workaround, I tried multiple ways to disable mouse support at all, but no success so far...
     
    Last edited: Dec 28, 2023
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I would say there are only two potential sources for this:

    1. Issues in UnityEngine.Input. Rewired is dependent on UnityEngine.Input on MacOS for keyboard and mouse input. If some update to MacOS somehow broke Unity's ability to handle input and/or track windows focus, which would affects the input it returns, it would definitely affect Rewired. The same is not necessarily true for controller input (see below). You did not mention how controllers behave in this scenario.

    2. If the change in behavior is due to MacOS making some kind of change that affects Unity's ability to detect window focus or application pause, it could affect all input including controller input. Rewired relies on MonoBehaviour.OnApplicationFocus and MonoBehaviour.OnApplicationPause. Broken functionality with either of these will lead to broken functionality in Rewired. Exactly what the symptoms would be would depend on the Rewired setting "Ignore Input When App Not in Focus" and the Unity Player setting "Run in Background."

    Either way, because of the dependency on Unity for focus and pause reporting and for mouse and keyboard input, there isn't a fix possible on the Rewired side. Making sure "Run in Background" is enabled and "Ignore Input When App Not in Focus" is disabled MAY provide a workaround for controllers only, but could also result in other undesirable side effects.
     
    Last edited: Dec 28, 2023
  37. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    HI there, Im doing some button swaps ( like the Interact action now has the Cancel action button and vice versa). I was already able to do the swap using ReplaceElementMap.
    I'm having trouble in how should I identify if a controller has already done the swap or not. This is the use case:

    1) A new joystick is connected
    2) Check the user swap option is active
    3) Swap buttons
    4) Later controller is disconnected
    5) Another controller ( that might be the same) is connected

    From my tests, if I reconnect the same controller, I don't need to swap the buttons again, but I'm assuming if this is another controller (and maybe using another template), or if a 2nd joystick is connected, I need to perform the swap only on the 2nd controller.

    My game is a single player game, so I'm much more worried about consistency, than needing to handle multiples players and options.

    I'm thinking of some options, but would like direction on what you recommend, or is the right way of doing it:
    1) When a controller is connected, reset the controllerMap and then do the swap. (don't know how to "reset" a controller map to it's default values from the template used)
    2) Save a controller id (It doesn't need to be persistent between plays, but I change scenes and my Rewired prefab is not "Don't destroy on load". What id should I use? )
    3) Serialize the action and elementIdentifierId that I want and check if they're swapped or not. I'm not sure how to serialize ElementIdendifierId ( is there an attribute to show a list of them? what about other controllers templates? I would need to do this for each template that I define?)
    4) Reset all Rewired when a controller is connected. (doesn't seem to be a good option, I'm in the middle of a connection, I have listeners in other places listening to changes, etc.)

    Thx for the help

    EDIT:
    After more testing, it seems that using the
    controller.deviceInstanceGuid
    is the way to go
     
    Last edited: Dec 28, 2023
  38. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    68
    Thank you for the explanation!

    Unfortunately, these are exactly the settings (Run in Background, Show in Background, and Ignore Input When App Not in Focus) I played with a lot meanwhile, and nothing has helped.

    I will double-check the latest macOS Sonoma changes, and release notes, by a good chance there was a change like you mentioned (last time, after a decade, they changed NSView clipsToBounds behavior, which broke a bunch of drawing functionality, I guess that affected almost all developers works somehow)

    I cannot see any other way to fix this now (If I find something related) than for a release build I will generate the IL2CPP source that I could patch if needed.

    We will see, I'll check back later with the result.
    Thanks for your reply!
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    There is so much here it's hard to know where to begin.

    1. Why would you want the Rewired Input Manager to be destroyed and reinstantiated on level load? This causes a host of issues that you will have to work around, and there's almost never a reason to do this.

    2. Are you trying to enforce a single layout across multiple controllers? Does this include swapping the same keys on the keyboard? And can the user manually remap their controls, or is this swap just something equivalent to swapping A and B on Nintendo controllers? If the latter and the user can't make other control mapping changes, I suggest using Layouts instead of doing this manually. Have a normal and swapped layout. If the user is able to remap controls and you're trying to make their mappings be mirrored across multiple controllers simultaneously, you should implement saving/loading Controller Template mappings. Then you can force a load of controller maps from saved data on every controller after making your changes (see next item).

    3. Because you are destroying and reinstantiating the Rewired Input Manager, what you are doing is no different than persisting data between game sessions. A new Rewired Input Manager is exactly equivalent to a new game session as the Rewired Input Manager memory is cleared and discarded when the Rewired Input Manager is destroyed. Functionality was provided to handle saving/loading user data for exactly this purpose. Add a UserDataStore_PlayerPrefs component to the Rewired Input Manager and call ReInput.userDataStore.Save() after making changes to the Controller Maps.

    4. Restoring a controller map to default is equal to loading the controller map from the Rewired Input Manager. That is to load a single Controller Map, but to load all Controller Maps in the Player can be loaded from defaults with this function. If you want to get a specific controller map from the saved user data, see this function. If instead you are trying to load all last saved user data, see the IUserDataStore interface.

    5. If it makes sense for your use case, the absolute easiest way to globally swap functionality of two Actions across all controllers and controller types is simply to execute different code based on a flag when you process input. Note that this approach could complicate UI help text/glyphs depending on how they're implemented.

    Code (csharp):
    1. int actionA = 12;
    2. int actionB = 13;
    3.  
    4. if(swap) {
    5.     int tmp = actionA;
    6.     actionA = actionB;
    7.     actionB = actionA;
    8. }
    9.  
    10. if(player.GetButtonDown(ActionA)) {
    11.     // do something
    12. }
    13.  
    14. if(player.GetButtonDown(ActionB)) {
    15.     // do something else
    16. }
     
    Last edited: Dec 29, 2023
  40. mulesmasters

    mulesmasters

    Joined:
    Dec 29, 2023
    Posts:
    1
    In Unity, a recurring issue has been identified with joysticks, wherein a joystick intermittently registers "TRUE" for all possible buttons on all Unity joysticks and the Unity mouse when any button on the joystick is pressed. It's important to note that this problem is not associated with Rewired; instead, it appears to be a bug within Unity itself.

    This issue becomes particularly problematic when Unity is employed as the mouse input source. Even after thorough testing, no workaround has been discovered when using Unity as the mouse input provider. It's worth mentioning that Rewired, when utilizing Direct Input or Raw Input, bypasses Unity's Joystick data, thus avoiding complications arising from this bug. However, when the mouse input is managed through Unity's mouse input system, the bug can inadvertently trigger joystick button values, subsequently activating all mouse buttons. This unintended activation can lead to the firing of actions mapped to the mouse.

    To address this challenge, native mouse support through Raw Input has been incorporated. When using Direct Input or Raw Input with Native Mouse Handling enabled in the Unity editor, mouse data is processed through Raw Input. This integration has been implemented to mitigate the aforementioned bug, ensuring that joystick presses no longer unintentionally activate all mouse buttons, thereby preserving the intended functionality of actions mapped to the mouse.
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    This is the reason I added Native Mouse Handling and Native Keyboard Handling in Windows and made them enabled by default. This Unity bug to which you are referring is many, many, many years old. What version of Unity are you using? I would be surprised if it hasn't been fixed by now in newer versions.
     
  42. Why485

    Why485

    Joined:
    Jun 30, 2013
    Posts:
    45
    Hello, I have a player saying that they cannot see more than 12 devices plugged in. I already have joysticks auto assigned at 100 as per best practices. Is there anything obvious I might be missing?

    upload_2023-12-29_23-20-8.png

    Their wording verbatim:
    Is there a way to use more than 12 devices? I have a bit more than that connected and the game doesn't see the Thrustmaster Combined.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    I don't have enough information to answer this question.

    1. What build platform are you referring to?
    2. What is the Primary Input Source set to for this platform?
    3. How is the user determining whether the game doesn't detect the device? For all I know, he could be talking about seeing it in a UI.

    As to your question, there is no evidence this has anything to do with controller assignment at this point. You need to have this person clarify what exactly the symptoms are an in what context he can't see the controller.

    "Thrustmaster Combined" is not a supported controller, therefore it has to be mapped through some kind of control mapping system in your game. I need information about this system, for example, are you using Control Mapper?

    Further clarification on what "Thrustmaster Combined" refers to would also be helpful. Best information I can find seems to imply this is some kind of virtual device created by a driver or other tool. Assuming this is the Windows Standalone platform and the Primary Input Source is Raw Input, only HID devices that identify themselves as a HID Joystick, Gamepad, Consumer Control Device, or Multi-Axis Controller. Anything else will not be detected. If this is a virtual joystick created by a driver as it seems, it would not be supported if it does not expose itself as a device type that Rewired's Raw Input implementation supports.

    Direct Input and Raw Input are not the same thing, and some drivers may create devices that only work correctly through Direct Input. As is frequently noted in cases like this, the device shows up in Windows USB Game Controllers, but not in some games. That is usually because Windows USB Game Controllers is based on Direct Input, but the game in question is using some other input API. Before changing to Direct Input, see this. In addition to the information there, Enhanced Device Support (DS4, DualSense, Nintendo Pro Controller special features) can only be used with Raw Input as the Primary Input Source on Windows. See this for information on changing configuration settings at runtime.
     
    Last edited: Dec 30, 2023
  44. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Thanks for the help, after writing this I realized ( and as you said) that using layouts was the way to go. Redid it with a alternative layout ( to handle nintendo switch case) and it was a lot simpler. A least it was good to have a better grip of the Rewired system.

    About destroying Rewired when scene changes, this isnt a decision specific to Rewired, but we avoid things moving from scene to scene as much as possible, as this adds a complexity layer, as you can have instances when a scene has a singleton prefab because it changed from another, or not, depending on the flow. Other than that, I agree that it's simpler to have it with dont destroy on load
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    Maybe Rewired Initializer could solve the problem:
    https://guavaman.com/projects/rewired/docs/InputManager.html#rewired-initializer

    If one is included in the scene prefab but a Rewired Input Manager has already been instantiated, by the opening scene of the game for example, it won't instantiate another when you open a prefab with a Rewired Initializer in it.
     
    Fira-Soft likes this.
  46. kael558

    kael558

    Joined:
    Sep 27, 2022
    Posts:
    2
    Hi Guavaman,

    Thanks for making Rewired first of all. I'm trying to use it for supporting keyboard actions even when the Unity application is in the background (p.s. I know it sounds like a keylogger but it's not I swear!). I've got it working on Windows but I'm having an issue on MacOS. It works as soon as the app is opened but as soon as it goes into background, the events stop and when it comes back into focus, it stops taking inputs completely.

    I've enabled app to run in background, disabled 'Ignore Input when App not in Focus' and mapped the relevant keys to actions.

    What other information can I provide or look into to solve this problem?
    Cheers,
    Kael
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    That functionality will not work for keyboard or mouse on MacOS because Rewired uses UnityEngine.Input.GetKey for keyboard input on MacOS:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    In fact, the only platform it will work for keyboards is Windows Standalone because Windows Standalone is the only platform where Rewired optionally implements native keyboard handling.

    From https://guavaman.com/projects/rewired/docs/RewiredEditor.html:

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

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

    banjolasse

    Joined:
    Feb 13, 2016
    Posts:
    11
    Hi Guava,

    I'm implementing remapping and it's working wonderfully. However, I'm showing glyphs that correspond to an action in RewiredConsts.cs, and it doesn't seem to export axis negative and positive sub-actions, only the axis action itself. I'm using an axis action to move the player and I'm stumped at how I'm supposed to show for instance Move Left and Move Right glyphs when there is only a single move axis action with a single glyph.
    I suppose there could be a unified move glyph (eg. generic left stick glyph) but that would break if the player were to remap movement to dpad left/right, or A/D, or any other strange button combo. I need to show both glyphs.

    Any guidance is greatly appreciated!
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,579
    See the documentation on this topic. It contains a link to a complete, functional example.

    In short, all the information about the mapping is available from the ActionElementMap. Further details on implementation can be found in the above example.
     
  50. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    436
    Just a quick note that in 1.1.41.1 we are still seeing the lockup on tabbing back to the game on PC with PS4 controllers connected via USB. Unplugging and reconnecting the controller unsticks the game.

    If it would help, I can provide our Rewired configuration, see if we've screwned something up :)
     
    Last edited: Jan 8, 2024