Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Ah I see! Thank you!! :D
     
  2. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Got it worked out. What I was reffering to above was like my fire is in one script, pause menu input is in another script, etc. Do I need to get public player id on every script? or can I do it on one, then skip the id since its already in that one script?

    Thank you!! :)
     
  3. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    Glad you enjoyed it. It is amazing. It would make a great helicopter simulation game (e.g. "The Saw Pilot") and perfect for Rewired with the Puma controller.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    It's up to you how you want to manage your variables. It's just C#. If you want to share a variable from some other class or component that contains the player id or the Rewired Player object, you can certainly do that. There's no requirement you use a public integer variable for the player id that you can set in the inspector -- that's just a suggestion. There's pretty much unlimited ways you can structure your code. The only important thing is that you pass the player id for the Player you want input from to Rewired when you get the Player object.
     
    Rockwall33 likes this.
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Indeed! Let me know when you get started. :D
     
  6. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Absolutely!!! Thank you sir!!
     
  7. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    109
    I'm using GetAxis to retrieve a Button value; this works great with a controller's analog trigger, but when activated with a mouse or keyboard button, the value is ramping in and out, rather than instantly on/off.

    Digital Axis Simulation is OFF in the input behavior settings. Am I missing another setting somewhere that could cause that?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    What you are describing is Digital Axis Simulation. There is no other setting but this that could possibly make an axis value for a button ramp up and down. Ensure you are changing the correct Input Behavior -- each Action is assigned its own Input Behavior. If you change the wrong one, the settings will not apply.

    You may also be loading the Input Behavior from XML without knowing it overriding whatever you are setting in the Rewired Input Manager in the editor. See UserDataStore for more information.

    Use Debug Information to see in real-time the values in the Input Behaviors.
     
  9. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    109
    Perfect, thanks! "Clear All Playerprefs Data" fixed it. I'm not entirely clear on why, since the Digital Axis Simulation setting isn't exposed in the control mapper (or is it, but I just haven't enabled it...?), but if it works, it works!

    -Scott
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    UserDataStore_PlayerPrefs.Save is called when you close Control Mapper. UserDataStore_PlayerPrefs.Save saves all user data including Input Behaviors for all Players.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Rewired 1.1.11.0 is now available for registered users to download immediately. If you'd like to get early access to updates, please contact me here. The update has been submitted to the Unity Asset Store and will be available when they approve it.

    Please see Updating Rewired before updating.

    Release notes:

    1.1.11.0:

    Changes:
    - Added Throttle Calibration Mode option to switch default throttle calibration between 0-1 output range and -1 to +1 output range.
    - Windows Raw Input, OSX Native, Enhanced Device Support: Sony DualShock4 headphone volume is now set to a default value instead of muted on initialization.
    - Added -1 to +1 throttle calibration for the following controllers:
    CH Combat Stick USB
    CH Fighter Stick USB
    CH Flight Stick Pro
    CH Eclipse Yoke
    CH Throttle Quadrant
    Logitech Extreme 3D Pro
    Logitech WingMan Attack 2
    Microsoft SideWinder 3D Pro
    Microsoft SideWinder Force Feedback Pro
    Microsoft SideWinder Joystick
    Microsoft SideWinder Precision 2
    Microsoft SideWinder Precision Pro
    Saitek Cyborg Evo
    Saitek JI3 Cyborg 3D Gold
    Saitek Pro Flight Cessna Trim Wheel
    Saitek Pro Flight Quadrant
    Saitek Pro Flight Yoke
    Saitek ST290 Pro
    Saitek X45
    Saitek X52
    Saitek X52 Pro
    Saitek X-55 Rhino Throttle
    Saitek X-56 Rhino Throttle
    Thrustmaster HOTAS Warthog Throttle
    Thrustmaster T.Flight Hotas 4
    Thrustmaster T.Flight Hotas X
    Thrustmaster T.Flight Stick X
    Thrustmaster TWCS Throttle
    Thrustmaster USB Joystick
    VKB-Sim Gladiator MKII
    - Added support for 8Bitdo N30 Pro and F30 Pro firmware update with product name change.

    API Changes:
    - Added Rewired.Config.ThrottleCalibrationMode enum.
    - Added ReInput.ConfigHelper.throttleCalibrationMode property.
    - Removed AxisCalibration() constructor.

    Bug Fixes:
    - All flight throttles re-calibrated for consistency across devices.
    - Saitek X-56 Rhino Throttle: Set default calibrated of throttles to return 0 to 1 range instead of -1 to 1 range.
    - CH Combat Stick USB: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - CH Fighter Stick USB: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - CH Fighter Stick Pro: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - CH Pro Throttle: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - Thrustmaster T-Flight HOTAS 4: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - Thrustmaster T-Flight HOTAS X: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - Thrustmaster T-Flight Stick X: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - Thrustmaster TWCS Throttle: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - VKB Sim Gladiator MK II: Set default calibrated of throttle to return 0 to 1 range instead of -1 to 1 range.
    - Control Mapper: Some UI buttons no longer stays disabled when changing theme button transition to modes other than Color Tint.
     
  12. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    This is a wonderful update. @Steve-Tack this is for you.
     
    Steve-Tack and guavaman like this.
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Steve-Tack likes this.
  14. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Indeed! For some reason, I read the throttle notes as the reverse at first and my reaction was: WTF? But yeah, those throttle values should be consistent with what my game expects. Cool! Thanks @guavaman!

    It's funny, I found my e-mail thread with @guavaman from November 2014 (!), where he showed me how to set up the first version of the X45 throttle map to map to 0-1 values. My how time flies.
     
    guavaman likes this.
  15. Verdemis

    Verdemis

    Joined:
    Apr 27, 2013
    Posts:
    88
    Hello everyone,

    first of all Rewired is really an awesome tool <3

    But I have one problem... when I deactivate a gameObject and enable it again, I can't controll it anymore.
    What am I missing?
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    What GameObject are you disabling? What is on this GameObject? How are you handling input? I need a to know a lot more about what you are doing to help.
     
  17. Verdemis

    Verdemis

    Joined:
    Apr 27, 2013
    Posts:
    88
    It's my player game object. It has a PlayerController attached, which handels the player input.... of course I'm using rewired here.


    Code (CSharp):
    1. private void Awake()
    2.         {
    3.             rewiredPlayer = ReInput.players.GetPlayer(playerID);
    4.         }

    Code (CSharp):
    1. // Update is called once per frame
    2.         void Update()
    3.         {
    4.             movementX = rewiredPlayer.GetAxisRaw("Move Horizontal");
    5.             movementY = rewiredPlayer.GetAxisRaw("Move Vertical");
    6.  
    7.             Fire();
    8.         }
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Disabling this GameObject and re-enabling it will work. There's nothing here that's not going to just continue working once re-enabled. Update will be called again by Unity and input will continue to be taken from Rewired. Only if you destroy the Rewired Input Manager and create a new one would there be a problem.

    Have you tried adding a Debug.Log in the Update to see that it's continuing to fire? I have a feeling your problem lies elsewhere and not with Rewired.
     
  19. Verdemis

    Verdemis

    Joined:
    Apr 27, 2013
    Posts:
    88
    I don't know why, but now it works... without changing anything oO
    But thank you for your support!
     
  20. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    This is funny since I am in the -1 to 1 side which is opposite of what you were interested in. :) But now we can switch as needed.

    This is really helpful especially when you using the flight controller templates (HOTAS,Yoke,etc.). Before you would get some subtle differences if you switched between different HOTAS systems on the fly during testing.

    Thanks again @guavaman!
     
    guavaman likes this.
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    Thanks @guavaman ... one Rewired release after another!

    Rewired 1.1.12.1 update is now live on the asset store.

    1.1.12.1: Controller Definitions:
    - 8Bitdo SN30 Pro: Added support for more connection modes on more platforms.

    1.1.12.0:
    Changes:
    - Added internal logging level settings.

    API Changes:
    - Added ReInput.ConfigHelper.logLevel property.
    - Added Rewired.Config.LogLevelFlags enum.
     
    Last edited: Apr 3, 2018
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    You're welcome! Yeah, I didn't feel this update was important enough to bother posting about. :p The ability to disable logging was added for someone who didn't want anything logged in their console even if it was just in the editor. I don't imagine this feature being very useful to many.
     
  23. FionaSarah

    FionaSarah

    Joined:
    Aug 26, 2015
    Posts:
    10
    Hi, I love Rewired, it takes a huge amount of work away from me, I've managed to do almost everything I want it to do, fantastic work. I just have a small question that I couldn't seem to find the answer to trawling through docs.

    I have a particular scenario where I would like to change the action behaviour assigned to an action and then change it back later. I know that I can change the individual settings for the behaviours of those actions, but this seems a little icky, and unless I alter all settings for all the actions in question, I might forget to add them later if I alter other settings down the line (instead of just the couple that are a problem in this case).

    So I wondered if I could just tell these actions "Use this behaviour now" and then later tell them to use the old behaviour.

    Thanks for the help :)
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Thanks! I'm glad you like Rewired.

    No. Actions and Input Behaviors are generated for each Player at initialization based on what you have defined in the editor. There is no code interface to change anything at all with regards to the list of Actions or an Action's properties at runtime. The design of Rewired is that all Actions are defined in the editor before initialization. This allows the static data to be loaded once on initialization and have the rest of the system rely on this data being constant throughout runtime, preventing a huge number of catastrophic scenarios that would happen with a fluid system. While changing the Input Behavior for an Action would actually work without much issue, there's no way to do that at the present time.

    Save the Input Behavior's data to an XML string, change the properties you want, then when you're done, reload it:
    http://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_InputBehavior_ToXmlString.htm
    http://guavaman.com/projects/rewire...l/M_Rewired_InputBehavior_ImportXmlString.htm
     
    Last edited: Apr 3, 2018
  25. FionaSarah

    FionaSarah

    Joined:
    Aug 26, 2015
    Posts:
    10
    Thank you for the detailed reply, I suspected that it was a design decision of sorts. The two methods you've linked to actually give me a particularly clean solution though, I'll dump the problem behaviour to XML, use ImportData to copy from the desired behaviour and then restore the properties afterwards. Thanks again! :)
     
  26. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    130
    Hey guavaman.

    Is there an easy way of getting a shortened version of the elementIdentifierName for the specific control input?

    I am getting the string result "Right Trigger" when I would prefer to use "RT".
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    No. There is only one string name for each element and only in English. Use the same system you'd use for glyphs to do this:
    http://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action
     
    IceBeamGames likes this.
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    How To's: Handling Button Presses of Various Types

    Tap / Press:

    To differentiate between a short tap and a longer press, simply use a combination of Player.GetButtonTimedPressUp and Player.GetButtonTimedPressDown. For example:

    Code (csharp):
    1. if(player.GetButtonTimedPressUp("Action", 0f, 0.7f)) { // button was released in 0.7 seconds or less
    2.    // This is a tap
    3. } else if(player.GetButtonTimedPressDown("Action", 0.7f)) { // button was pressed for 0.7 seconds
    4.    // This is a press
    5. }
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    There are many ways to do this. Look at the API reference for Player.ControllerHelper.MapHelper for available methods.

    The following contains 3 different approaches:
    1. Using Player.ControllerHelper.MapHelper to iterate all Action Element Maps that contain a particular Action across all Controllers at once.
    2. Using Player.ControllerHelper.MapHelper to iterate all Action Element Maps that contain a particular Action across each Controller individually.
    3. Directly iterating each Controller Map in each Controller and querying the Controller Map for bindings that contain the Action.

    Code (csharp):
    1. // Iterate all maps on all controllers
    2. foreach(var aem in player.controllers.maps.ElementMapsWithAction(actionId, skipDisabledMaps)) {
    3.     // Do something
    4. }
    5.  
    6. // By individual Controller
    7.  
    8. // Iterating Joysticks
    9. for(int i = 0; i < player.controllers.joystickCount; i++) {
    10.     Controller controller = player.controllers.Joysticks[0];
    11.     foreach(var aem in player.controllers.maps.ElementMapsWithAction(controller, actionId, skipDisabledMaps)) {
    12.         // Do something
    13.     }
    14. }
    15.  
    16. // Keyboard
    17. if(player.controllers.hasKeyboard) {
    18.     foreach(var aem in player.controllers.maps.ElementMapsWithAction(ReInput.controllers.Keyboard, actionId, skipDisabledMaps)) {
    19.         // Do something
    20.     }
    21. }
    22.  
    23. // Mouse
    24. if(player.controllers.hasMouse) {
    25.     foreach(var aem in player.controllers.maps.ElementMapsWithAction(ReInput.controllers.Mouse, actionId, skipDisabledMaps)) {
    26.         // Do something
    27.     }
    28. }
    29.  
    30. // Iterating Custom Controllers
    31. for(int i = 0; i < player.controllers.customControllerCount; i++) {
    32.     Controller controller = player.controllers.CustomControllers[0];
    33.     foreach(var aem in player.controllers.maps.ElementMapsWithAction(controller, actionId, skipDisabledMaps)) {
    34.         // Do something
    35.     }
    36. }
    37.  
    38. // By individual Controller Map
    39. // Iterate each Controller Map for each Controller and find bindings which bind the Action
    40.  
    41. // Iterating Joysticks
    42. for(int i = 0; i < player.controllers.joystickCount; i++) {
    43.     Controller controller = player.controllers.Joysticks[0];
    44.     IList<ControllerMap> maps = player.controllers.maps.GetMaps(controller);
    45.     for(int j = 0; j < maps.Count; j++) {
    46.         foreach(var aem in maps[j].ElementMapsWithAction(actionId)) {
    47.             // Do something
    48.         }
    49.     }
    50. }
    51.  
    52. // Keyboard
    53. if(player.controllers.hasKeyboard) {
    54.     Controller controller = player.controllers.Keyboard;
    55.     IList<ControllerMap> maps = player.controllers.maps.GetMaps(controller);
    56.     for(int i = 0; i < maps.Count; i++) {
    57.         foreach(var aem in maps[i].ElementMapsWithAction(actionId)) {
    58.             // Do something
    59.         }
    60.     }
    61. }
    62.  
    63. // Mouse
    64. if(player.controllers.hasMouse) {
    65.     Controller controller = player.controllers.Mouse;
    66.     IList<ControllerMap> maps = player.controllers.maps.GetMaps(controller);
    67.     for(int i = 0; i < maps.Count; i++) {
    68.         foreach(var aem in maps[i].ElementMapsWithAction(actionId)) {
    69.             // Do something
    70.         }
    71.     }
    72. }
    73.  
    74. // Iterating Custom Controllers
    75. for(int i = 0; i < player.controllers.customControllerCount; i++) {
    76.     Controller controller = player.controllers.CustomControllers[0];
    77.     IList<ControllerMap> maps = player.controllers.maps.GetMaps(controller);
    78.     for(int j = 0; j < maps.Count; j++) {
    79.         foreach(var aem in maps[j].ElementMapsWithAction(actionId)) {
    80.             // Do something
    81.         }
    82.     }
    83. }
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Rewired 1.1.12.2 is now available for registered users to download. Please contact me here to register to receive early updates. The Unity Asset Store will get the update when they approve it.

    Please read Updating Rewired before updating.

    1.1.12.2:

    Controller Definitions:
    - Added Thrustmaster Ferrari 458 (Xbox 360 model) definition.
    - Added XInput Wheel definition.

    Bug Fixes:
    - Fixed joystick axis calibration bug introduced in 1.1.11.0 that made certain joystick axes such as gamepad triggers not calibrate correctly.
     
  31. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    130
    Thanks for the reply guavaman!

    What is the best why to handle results from controllers that are not in the look up tables if you still want them translated? Is there a way of getting generic controller names back that you can localise?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    I'm not sure what you mean by "generic controllers." Controllers that are not recognized are always the "Unknown Controller" with a list of elements like Axis 0, 1, etc. You check the hardwareTypeGuid for Guid.Empty to determine if it's an Unknown Controller.

    Any recognized controller will have its own element list. If you don't add its elements to your table, you can't know what they are. Anything you want localized, add to the table.

    Unknown controllers and recognized controllers could be any type - gamepad, joystick, wheel, remote, HOTAS, gun, etc. Each controller has its own list of elements which you have to localize if you want to support it. There is no kind of system in Rewired that tags elements with a generic type like ElementType.LeftStickX. Elements are just elements. And elements names, even though the element may be similar, can be different on different controllers such as Left Should, LB, L1, etc. all referring to the same type of button based on the label on the controller.

    Most likely, you're asking whether you can get the Dual Analog Gamepad Template element names instead of the actual controller element names. No. This is not what the Dual Analog Gamepad Template is for. See the documentation on Controller Templates to understand their purpose and limitations. (Technically there is a very hacky way to misuse the template system to derive this information, but I don't recommend using it.) Because so many people expect to be able to use gamepads as a controller type class at runtime, I've been working on a new template system that will expose an object which will allow you to access the controller elements through one of its templates. This system is not finished.
     
  33. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    130
    Yeah, I want to be able to handle a situation where the user has plugged in a controller that doesn't exist in my lookup table.

    So, going from your example code, say the Element Identifier from the controller isn't matched to any entry and comes back as null, I can ask rewired what is considers the elementIdentifierId to be if mapped Dual Analog Gamepad Template.

    Its only for situations where they are playing in Spanish and are using something I haven't translated. Currently I am just displaying the elementIdentifierName, which is just in english.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    The only way you can get any kind of relationship with the Dual Analog Gamepad Template is through the hacky method I linked above. You send it the joystick and the elementIdentifierId in question and it returns a ControllerElementIdentifier object if there is one. What is returned is not guaranteed to be from the Dual Analog Gamepad Template if the controller supports more than one template and a different one comes first in the list. This method was added specifically because people wanted to get this information, but this was never what the mapping templates were intended for (acting as a "joystick type"). So if that's your use case, that's the only way to do it.

    Another approach would be to create a dictionary of general elements to translate and look up by string:
    Left Stick X = ...
    Left Stick Y = ...
    Left Stick Up = ...
    Left Stick Down = ...
    Left Stick Left = ...
    Left Stick Right = ...
    Right Stick X = ...
    Right Stick Y = ...
    Right Stick Up = ...
    Right Stick Down = ...
    Right Stick Left = ...
    Right Stick Right = ...
    Left Trigger = ...
    Left Shoulder = ...
    Left Bumper = ...
    Right Trigger = ...
    Right Shoulder = ...
    Right Bumper = ...
    Left Stick Button = ...
    Right Stick Button = ...
    D-Pad Up = ...
    D-Pad Right = ...
    D-Pad Down = ...
    D-Pad Left = ...
    Back = ...
    Select = ...
    Start = ...
    Option = ...
    Share = ...
    Guide = ...
    Accelerator = ...
    Brake = ...
    Clutch = ...
    Left Paddle = ...
    Right Paddle = ...
    Shifter Up = ...
    Shifter Down = ...
    Stick X = ...
    Stick Y = ...
    Stick Up = ...
    Stick Down = ...
    Stick Left = ...
    Stick Right = ...
    Throttle = ...
    Throttle Up = ...
    Throttle Down = ...
    Button 0 = ...
    Button 1 = ...
    ...
    Axis 0 = ...
    Axis 1 = ...
    ...

    Strings are not the best method to use, but it avoids the limitations of the template system.
     
    IceBeamGames likes this.
  35. Alexanderansoft

    Alexanderansoft

    Joined:
    Jan 5, 2015
    Posts:
    26
    Hi! How to configure the Control Mapper component so that the keyboard and mouse are configured in one column?



     
    Last edited: Apr 7, 2018
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    You can't. Rewired's system in based on Controller Maps per-controller. It is not a system with a static list of bindings like most other systems. While it would be possible to wrangle it to display as such, that is not advised. Combining controller types into a single column is not a feature of Control Mapper.
     
  37. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    130
    Thanks for the reply again guavaman. One last question (for now, I think).

    I am using your control mapper class to allow customised controls. I have set the "Universal Cancel Closes Screen" to true and am closing the screen and making the previous screen the EventSystem SelectedGameObject(). When I do this, the previous screen is receiving a ICancelHandler message and also closing that screen. Is there a way to configure the mapper to catch the ICancelHandler and not pass it down to the previous screen?
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Universal Cancel is not the same as ICancelHandler. ICancelHandler is fired any time whatever is mapped to Cancel in the Standalone Input Module is pressed. Universal cancel is a Rewired Action and does not pass through the Unity Event System. It sounds like you've configured Universal Cancel to be the same button that you also have mapped to Cancel in the Standalone Input Module, so it just so happens to be sending an ICancelHandler message also.

    The Control Mapper UI does not catch or use any of the Unity Event System events. The individual buttons do, but not the UI itself. I don't think there would be any reliable way for Control Mapper to catch this event anyway. Because you say your other window closes after Control Mapper opens it, this would indicate to me that the Unity event is being fired after Control Mapper has executed its Close command and your new window opened. There would be no way to catch this. Control Mapper cannot be given priority over your other MonoBehaviour to receive the Unity event before your other one does, so there's no way for Control Mapper to use the event. It would be random whether or not Control Mapper would receive it before your MonoBehaviour based on whatever method Unity uses to determine the order of event receivers.

    The only reliable thing I can think of would be to open your other window using a Coroutine and delay it by one frame.
     
  39. IceBeamGames

    IceBeamGames

    Joined:
    Feb 9, 2014
    Posts:
    130
    I made the control mapper close event select the control mapper object for a frame using EventSystem.current.SetSelectedGameObject(this.gameObject) which then catches the OnCancel() event which I then use the close the screen. A bit hacking, but it works...
     
  40. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    219
    Any official method to get rewired to work with cinemachine?
     
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
  42. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    219
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    There's quite literally nothing I can do differently than the tiny script snippet posted in that thread. An official method would end up being nothing more than this with probably a variable to choose the current Player to use. I don't have any plans to include this in Rewired.

    Code (csharp):
    1. public static class RewiredCinemamachineInputManager
    2. {
    3.     public static int playerId = 0;
    4.  
    5.     [RuntimeInitializeOnLoadMethod]
    6.     static void InitializeModule()
    7.     {
    8.         CinemachineCore.GetInputAxis = GetInput;
    9.     }
    10.  
    11.     static float GetInput(string name)
    12.     {
    13.         return Rewired.ReInput.players.GetPlayer(playerId).GetAxis(name);
    14.     }
    15. }
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    I assume you had to modify the ControlMapper class to implement ICancelHandler. It would be better to use some other MonoBehaviour to catch and use the event so you don't have to modify the ControlMapper source code (which will be overwritten when you update Rewired).

    Another approach would be to ignore input on your new UI for the first frame after it is opened. Something like:

    Code (csharp):
    1. int enabledFrame;
    2.  
    3. void OnEnable() {
    4.     enabledFrame = Time.frameCount;
    5. }
    6.  
    7. public void OnCancel(EventSystems.BaseEventData eventData) {
    8.     if(Time.frameCount == enabledFrame) return;
    9.     gameObject.SetActive(false);
    10. }
     
    IceBeamGames likes this.
  45. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    219
    Thanks that's fair. Am I wrong to suggest that you could perhaps in the asset documentation include a note about this along with the script. Thanks again
     
  46. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    219
    Also the little fact that I don't understand it or know how to implement it. Sorry :(
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Honestly, this would be a how-to on Cinemamachine, not Rewired. That delegate is how they designed for you to be able to use pluggable input of any kind. You could insert any input system in the blank there and it would identical. (The Rewired Player id is not required, just a nice feature should you decide you want a cinematic that can be controlled by one Player and not another by changing that id from a script.)

    Copy the code into a script somewhere in your project. (I assume there is somewhere in Cinemamachine to denote what axis string names you want to use for input. Probably somewhere in an inspector. Sorry, I've never used Cinemamachine.) You then create Actions in Rewired using identical string names as what Cinemachine expects, assign those per the normal Rewired practice to your Controller Maps, and it will work.

    The script just re-routes calls to UnityEngine.Input.GetAxis(string) to the Rewired player.GetAxis(string) equivalent.
     
    shotoutgames likes this.
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    I took a look at Cinemamachine and found where they denote what Actions control the camera. This is a Cinemamachine Free Look camera. The Axis Control shows what axis they use for the camera's X and Y axes. You enter a string name there. The defaults are Mouse X and Mouse Y. When you have the above script in the project, it will call player.GetAxis("Mouse X") and player.GetAxis("Mouse Y") instead of the UnityEngine.Input equivalents and get the input from Rewired. Either create two Actions in your Rewired Input Manager called "Mouse X" and "Mouse Y" and set them up for mouse input as usual or set up two Actions of your own naming choice and change these fields on the Cinemachine Free Look camera inspector.

    Cinemamachine.png
     
    shotoutgames likes this.
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,288
    Rewired 1.1.12.2 is available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    1.1.12.2:

    Controller Definitions:
    - Added Thrustmaster Ferrari 458 (Xbox 360 model) definition.
    - Added XInput Wheel definition.

    Bug Fixes:
    - Fixed joystick axis calibration bug introduced in 1.1.11.0 that made certain joystick axes such as gamepad triggers not calibrate correctly.
     
  50. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    289
    A quick question to help me decide if I should get rewired or not..... I have two identical joysticks, Thrustmaster 16000m, which are detected by Unity, but they are being assigned random IDs by the default Unity input manager. GetJoystickNames is returning identical strings for the joysticks. Will Rewired be able to detect a difference in these two sticks and keep the correct assignments? One stick has the bottom switch set to "Left" and the other "Right", but I don't see this making a difference outside of Thrustmasters own app.
     
unityunity