Search Unity

Rewired - Advanced Input for Unity

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

  1. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have a rather silly question and I am likely to feel stupid but.... I am using the ControlMapper from ControlMapperDemo sample and have changed the theme colours but just don't seem to be able to find where to change the theme colour for Knob used for the Calibration sliders. Could someone possibly point me in right direction for this?
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The Calibration arrows are under the "Calibration Value Marker" and "Calibration Raw Value Marker" fields. Sliders are all under the "Slider Settings" field.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I went through and tested everything and found there is an issue with Sliders in the source code.

    Change Rewired/Extras/ControlMapper/Scripts/ThemeSettings.cs, Line 271 to:
    Code (csharp):
    1. base.Apply(item);
    2. Apply(item as Slider);
    If you are having a problem with something not working, please be explicit and say that the feature is not working so I can go test it and make sure it's working properly.
     
  4. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Thanks for that. For you information, I did not know it was not working otherwise I would have said so. I asked based on what I knew at the time thinking I was just missing something obvious.
    I actually had just put together an image to say that there seems to be an issue showing the runtime values being out of kilter with the settings. I came here to post it and see that you had already addressed it. Thanks again for your time.
     
    guavaman likes this.
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I figured you must have seen and tried the Slider settings entry already because you had themed everything else without issue. I'll be including the fix in the next update.
     
  6. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Thanks @guavaman , I think I was half way between thinking I was just missing something stupid and thinking maybe there was a problem because I could not see what I was missing. I was assuming it was me, which at the moment had a greater probability of being correct. Anyway, thanks again. It is a phenomenal piece of work you have done here and solves a massive use case for people. Appreciated by all I'm sure.
     
    guavaman likes this.
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    :) I understand and glad I could help. Thanks for the kind words and I'm glad Rewired has been helpful to you!
     
  8. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Hi, first of all, thank you for the wonderful plugin!

    I have a small issue I can't quite figure out. I am toggling showing the mouse cursor based on the following snippet I got from your documentation:

    Code (csharp):
    1. if (Rewired.ReInput.players.GetPlayer(0).controllers.GetLastActiveController().type == Rewired.ControllerType.Joystick)
    However, it seems that if I call that if statement from an Update() function, until I pass any actual input I get Null Reference exceptions:

    NullReferenceException: Object reference not set to an instance of an object

    I am using the UnityInputOverride script. Is there a way I can force Rewired to initialize/wake up in order to not get these errors? I tried to return early based on this conditional:

    Code (csharp):
    1. if (!Rewired.ReInput.isReady)
    2.             return false;
    But that also throws a null reference exception. I need to move the mouse, press a key, gamepad button, anything in order to get the "Rewired: Currently overriding Unity input..." message (and the errors stop).

    Thanks!
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    GetLastActiveController() is returning null because no controller has ever been active in this Player and therefore the returned value is null.

    Code (csharp):
    1. Controller c = Rewired.ReInput.players.GetPlayer(0).controllers.GetLastActiveController();
    2. if(c != null) {
    3.     // do something
    4. }
     
    f0ff886f likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Hi @astroblastro,

    I have another user trying to make a UI like yours with individual virtual cursors. I was wondering, does your game use Unity UI or something else? If Unity UI, could you give a brief rundown of the steps involved to make the cursors work as they do in your game? If you're not using Unity UI, then nm.
     
  11. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Thank you, that nailed it.
     
  12. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    332
    Hello!

    I would like to get a custom controller map in runtime. How can I do it?

    What I really need is to see the relationship between a element identifier in the custom controller and the action Id.

    We have a NetCustomController. When one side press a button, a net message is sent. We are sending a pair (int action id, bool value). When we recieved the message, we would like to do something like customController.SetButtonValueById(int elementId, bool value) in the other side.

    To do that, we need to know what elementId correspond with the actionId, and with this we can do the SetButtonValueById.

    Thank you very much.

    Edit:

    I have done this and It is working. Thank you any way
    Code (CSharp):
    1.     private ControllerMap GetMap(CustomController controller)
    2.     {
    3.         IEnumerable<ControllerMap> allCustomMaps =
    4.             ReInput.players.GetPlayer(GetPlayerName()).controllers.maps.GetAllMaps(ControllerType.Custom);
    5.         return allCustomMaps.FirstOrDefault(map => map.controllerId == controller.id);
    6.     }
     
    Last edited: Aug 2, 2016
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You can do it more directly:

    Code (csharp):
    1. foreach(p.controllers.maps.GetMaps<CustomControllerMap>(controllerId)) {
    2.    // do something
    3. }
     
    Maeslezo likes this.
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.0.0.94 is available for registered users to download on the website. If you would like to register to receive early access to updates, please contact me here. The Unity Asset Store should have the update in 2-10 business days.

    Be sure to read the documentation on Updating Rewired before updating.

    1.0.0.94:

    Changes:
    - Windows Standalone Raw Input + XInput, Direct Input + XInput, Windows UWP: Made modifications to prevent Xbox One S controller from showing up as two Joysticks.
    - Windows Standalone XInput, Windows UWP: Xbox One controllers no longer become unresponsive to vibration changes when sending vibration commands every frame.
    - Added preprocessor if to eliminate warning about RuntimePlatform.OSXWebPlayer on Unity 5.4+ in ControlRemappingDemo1.cs.
    - Added preprocessor conditional for disabling Unity Input Override script.
    - Added new SDL2 gamepad mappings.
    - UFPS Integration: Added Set Weapon 1 - 10, Teleport Actions with default keyboard mappings to Rewired UFPS Input Manager prefab.

    Modified Controller Definitions:
    - Microsoft Xbox One Controller:
    - Added Xbox One S mappings for:
    - Windows Standalone: Raw Input, Direct Input, Fallback
    - OSX Standalone: Native, Fallback
    - Android

    Bug Fixes:
    - Fixed bug in Control Mapper theme settings causing Slider components to not reflect theme Slider settings.
    - Windows Standalone Raw Input: Fixed handling of HID report arrays.
    - OSX Standalone Native: Fixed sporadic editor crash when exiting Play mode when using the JoystickElementIdentifier too with Enhanced Device Support enabled and a DualShock 4 controller attached.
     
  15. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    332
    Hi Guavaman,

    I have an exception sometimes when I unsubscribe from a button. The problem is when I unsubscribe at OnDisable when the application quits

    I have:
    But neither player nor rewiredEvent nor actionEventType nor actionId is null, so the nullReferenceException should come from inside.

    I have Updated rewired because I have seen in the Changelog 1.0.0.83 this:
    Bug Fixes:
    - Fixed issue causing input event delegate removal to fail in Player.RemoveInputEventDelegate functions.

    But the exception problem remains.

    Maybe inside there is a helper class that is destroyed before.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The issue here is destruction of objects by Unity comes in an unpredictable order. There's no way to control this. It seems to depend on the order in which the objects were created in the scene. When OnDestroy is called on the Rewired Input Manager, the entire Rewired structure disposes. All helper objects in ReInput including the controllers, mapping, configuration, etc. are nulled and no longer valid. This includes many internal objects which manage various components of the system.

    If your object is disposed before Rewired, you don't get an exception when you unsubscribe in OnDestroy. If your object disposes after Rewired, when you try to unsubscribe, an exception is thrown by Player because core internal objects have already been disposed and nulled and no longer exist. At that point, the Player is an invalid orphaned object with references only existing in your scripts.

    I can think of no solution except to wrap the unsubscribe in a try/catch block or check ReInput. isReady before you try to unsubscribe. The only thing I can do on my end is to do the same internally to all public methods in Player. There is no way to control the order of object destruction by Unity.

    Code (csharp):
    1. void OnDestroy() {
    2.     if(ReInput.IsReady) {
    3.         player.RemoveInputEventDelegate(...);
    4.     }
    5. }
    6.  
    7. // or
    8.  
    9. void OnDestroy() {
    10.     try {
    11.         player.RemoveInputEventDelegate(...);
    12.     } catch {
    13.     }
    14. }
    15.  
     
    Last edited: Aug 3, 2016
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Notice: Two new issues with Windows 10 Anniversary Update when using XBox One controllers with Raw Input or Direct Input without XInput

    Edit: New information (see bottom of post)

    1. Microsoft has back peddled on a driver change they made in an update about 1 year ago for Xbox One controllers on Windows 10. This driver change modified the L/R trigger assignments Xbox One controllers when using Raw Input or Direct Input without XInput. The driver change made it so that the L/R triggers could be used simultaneously without XInput on Windows 10. The new Windows 10 Anniversary update has reverted that driver change so the L/R triggers are no longer separated anymore, but the other unique identifying information in the device was not reverted.
    2. Changes to the Xbox One driver in the new Anniversary Update also affected Raw Input's ability to see the Xbox One controller. This makes the Xbox One controller not appear when using Raw Input without XInput.

    The result is:
    • If your game uses Direct Input without XInput, the L/R triggers on the Xbox One controller will not work properly.
    • If your game uses Raw Input without XInput, Xbox One controllers are unusable.

    This affects Windows Standalone builds running on Windows 10 with the Anniversary update. I am working to find workarounds to both issues and will release an update as soon as possible.

    This issue does not affect you if you are using XInput.

    Edit: New information

    I have found workarounds to both issues. The Raw Input "workaround" isn't so much a workaround but a complete replacement for Raw Input. This will take some time to implement and test.
     
    Last edited: Aug 5, 2016
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Following up to the previous post, having done a bunch of testing, I can safely conclude that Xbox One controllers do not work with Raw Input anymore in Windows 10 after the Anniversary Update. The device does not get returned by Raw Input and Raw Input events are never sent, therefore there is no workaround to this issue.

    If your game does not use XInput (because you need to support more than 4 Xbox controllers) and uses Raw Input, you will have to inform your users that the Xbox One controller is not supported post Windows 10 Anniversary Update due to Microsoft driver issues.

    As for the L/R trigger issue in Direct Input, I am certain I can come up with a workaround for that.
     
    Last edited: Aug 4, 2016
  19. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    332
    I have checked and Reinput.IsReady is false when the exception is throwed, so I am going to check this param. The weird thing is I unsubscribe at OnDisable and you say that is at OnDestroy when all the Rewired objects are destroyed, so at OnDisable it should work because is before OnDestroy.

    Anyway, I will check ReInput.IsReady, thank you

     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I didn't catch that you were calling it in OnDisable. I read that as OnDestroy. So that does make it interesting... Rewired is never destroyed except in OnDestroy. According to this page https://docs.unity3d.com/Manual/ExecutionOrder.html OnDestroy should run after OnDisable, but that does not seem to be the case because Rewired would never report ReInput.isReady = false unless it has been destroyed. Perhaps the documentation is wrong then.
     
    Maeslezo likes this.
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    @Maeslezo

    This is probably what's happening:
    When Unity shuts down, for each object, OnDisable is called, then OnDestroy is called immediately after.

    That would make sense and not go against what the docs say. If your object was Disabled then Destroyed before Rewired, no issues. If your object was Disabled then Destroyed after Rewired, ReInput = false and the objects are invalid.

    I don't think OnDisable would be called on every object first, then OnDestroy called on everything after. That wouldn't make much sense.
     
    Maeslezo likes this.
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Acissathar likes this.
  23. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  24. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @guavaman I was going crazy, I literally spent a couple hours trying to find the reason why the controller wouldnt work.

    Glad to know it is a known issue and I look forward to the update. Thanks!
     
    guavaman likes this.
  25. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Hi Guavaman -

    I'm having an odd issue with my customer controller. I set the Right Stick X and Right Stick Y so calibrate is false. In the OnInputUpdate on that controller, I set values of how many pixels the user has moved on the screen. The range can be roughly (-400 to 400) depending on how fast you swipe. When I go to retrieve the value from that axis, it returns -1 to 1. Shouldn't Calibrate set to false just allow my input values to be retrieved without any scaling? Can you tell what I'm doing wrong?
    Screen Shot 2016-08-05 at 9.21.28 AM.png Screen Shot 2016-08-05 at 9.10.20 AM.png
     
  26. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    One more question... how to I hide and lock the mouse cursor?
     
  27. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Oh... I do it the same way as before using the Unity Cursor object.
     
  28. rrazcueta

    rrazcueta

    Joined:
    Dec 16, 2015
    Posts:
    2
    I've been having a similar crash with ntdll.dll and ReWired. I use DS4s on Win10 and it happens to new projects with ReWired. The same crash happens when I try to run the last project we made on a different computer.

    Old setup: Thinkpad X230 with Win 7. New setup: Thinkpad T460p with Win10. I'm using DS4s on both. The file runs on my partner's Mac machine.

    I don't use InputMapper. ReWired base config crashes in addition to our specific config for our game.

    Every once in a while it runs fine, but most of the time it does not. I've figured out I can run a debug and then ignore the first error, but I'm not exactly sure how safe that is.
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    It's bugged. I don't know when it broke, but I will fix it in the next update.

    If you know the exact range the value should be, you can scale it before it goes into the Axis to a -1 to 1 range. If you don't know the complete range, you can scale it smaller based on a much larger range such as +/-800 and then apply the opposite to unscale it after you get the value of the Action.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I need information to be able to look into this:
    1. Rewired Version
    2. Unity Version
    3. Settings in Rewired Input Manager:
    4. Windows Standalone Input Source?
    5. Use XInput?
    6. Enhanced Device Support?
    7. Native Mouse Handling?
    8. Steam Raw Input Fix?
    9. When does the error occur? On start?
    Every one of those options changes what could possibly be wrong because different systems are involved with each. These questions are up front on the support form on my website. Unfortunately I cannot put a form to fill out on this forum. This kind of support question which is going to involve a lot of back and forth and probably debug builds is much better handled by using email.

    What do you mean by "Every once in a while it runs fine, but most of the time it does not. I've figured out I can run a debug and then ignore the first error, but I'm not exactly sure how safe that is."

    What is "the first error"? Is it an exception?

    Without knowing the answers to any of the above, the most obvious thing to try is to disable Enhanced Device Support which disables special features of DS4.
     
    Last edited: Aug 5, 2016
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Additionally, is the DS4 connected on USB or Bluetooth and do you have a non-Microsoft Bluetooth stack installed?
     
  33. SecondShadow17

    SecondShadow17

    Joined:
    Oct 15, 2012
    Posts:
    2
    Hey @guavaman I've been running into a problem using this plugin. It all started when my coding leader told my to update my version of unity from 5.2.2 to 5.3.2, now whenever I play in the editor the character can not move and the fps drops considerably. This problem seems to only affect me as other members of the team have been able to update with little issue and even after reinstalling unity, re-branching our depot, and even getting a full copy of my lead's files the problem continues to persist.

    I'd appreciate any help you can provide.

    Here is the error I get:

    Rewired: Error creating Axis2D from hardware map! Invalid axis index!
    UnityEngine.Debug:LogError(Object)
    Rewired.ControllerWithAxes:.ctor(Int32, InputSource, String, String, String, ControllerType, Int32, Int32, HardwareControllerMap_Game, Extension, ControllerDataUpdater)
    Rewired.Joystick:.ctor(Int32, InputSource, String, String, String, Int32, Int32, HardwareControllerMap_Game, Extension, ControllerDataUpdater)
    Rewired.Joystick:.ctor(BridgedController)
    swIEDHjPklnDfRvDaGDdGGfDoVPB:AsLaoDEnMFHwHeAOMYmbJVPeYXBF(BridgedController)
    swIEDHjPklnDfRvDaGDdGGfDoVPB:eRRFiXesytUhdtYYNkVJvsRZUmv(BridgedController)
    Rewired.ReInput:fEBobiPpyvFImBCRcHiHqWUxfxOS(BridgedController)
    MxIfkOIfmRdUUMtZymctnfhfLdxg:TWltWtCTquZgTFmImeFOKgugYWC(qCGanVbckUcfuMEaRfvehuuxIzjH, Boolean)
    MxIfkOIfmRdUUMtZymctnfhfLdxg:rVXEkXMzfeANSsnZJARLkusZpjG(List`1, List`1, Boolean)
    MxIfkOIfmRdUUMtZymctnfhfLdxg:kyZFRWhTswqMrijVZsEdJRsJTVX(String[])
    MxIfkOIfmRdUUMtZymctnfhfLdxg:kyZFRWhTswqMrijVZsEdJRsJTVX()
    MxIfkOIfmRdUUMtZymctnfhfLdxg:Initialize()
    Rewired.ReInput:quzfrowiONiecEKBHMvoWzllmxRI()
    Rewired.ReInput:cvpTFPxuQJMlfhVhPCfDxgMVBQI(InputManager_Base, Func`2, ConfigVars, ControllerDataFiles, UserData, UserDataStore)
    Rewired.InputManager_Base:Initialize()
    Rewired.InputManager_Base:Awake()
    UnityEngine.Object:Instantiate(GameObject)
    PixelNoir:_InitializeInput() (at Assets/scripts/Game/PixelNoir.cs:491)
    PixelNoir:_Initialize() (at Assets/scripts/Game/PixelNoir.cs:461)
    PixelNoir:Start() (at Assets/scripts/Game/PixelNoir.cs:408)
     
  34. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    What version of Rewired are you using? What operating system are you using? Is your operating system 32-bit or 64-bit?
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    1. Your framerate drop could only be due to log spam. Enable console log warnings.
    2. Very likely your serialized data was corrupted. See this: Serialized data corruption after upgrading Unity
    3. Rewired: Error creating Axis2D from hardware map! Invalid axis index! - This is either due to corrupted serialized data or you have a controller attached that has a corrupted or bugged hardware definition. What controllers are attached? What platform is this? What input sources are chosen in the Rewired Input Manager?
    4. What version of Rewired are you using? (I'm guessing very old because there's no system info logged after the error which was added quite a number of releases ago.) If Windows, Unity Fallback, a bug like this with unknown controllers was fixed in 1.0.0.83, and if OSX Unity Fallback, one like it was fixed in 1.0.0.83 for the DS4.
    5. If you've updated Rewired recently, did you follow this guide?
    6. If none of the above apply, unplug your controllers. That will definitely stop it. Then figure out which one it was by plugging them in one at a time.
     
    Last edited: Aug 7, 2016
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.0.0.95 is now available for download for registered users. If you'd like to register to receive early access to updates, please contact me here. The Unity Asset Store should have the update in 3-10 business days.

    This update is focused on smoothing over the Xbox One Controller Windows 10 driver mess. I've done my best to make everything work, but there are still persisting bugs in this driver which are impossible for me to cover over.

    Just a couple of the new issues introduced with the Windows 10 Anniversary update:
    http://guavaman.com/projects/rewire...box-one-controller-stops-working-after-unplug
    http://guavaman.com/projects/rewire...ows-xbox-one-controller-game-center-popup-bug

    A couple more:
    Unity will very often throw exceptions when the controller is unplugged stating the HID device cannot be accessed. If using Unity Fallback input, this usually causes other Xbox One Controllers that are attached to stop working until the other controller is plugged back in.

    Also, Bluetooth Xbox One Controller pairing is very flaky. If you plug the controller in via USB, pairing information will be lost and you'll have to re-pair, which it seems usually requires a reboot.

    And some others that I was able to find workarounds for.

    1.0.0.95:

    Changes:
    - Windows Standalone Raw Input: Implemented workaround to make Xbox One Controller work again after Windows 10 Anniversary Update caused the device to stop functioning when using Raw Input without XInput.
    - Windows Standalone Direct Input, Raw Input: Updated Xbox One Controller definition for new driver changes in Windows 10 Anniversary Update that broke trigger mappings. Now triggers will work properly with any version of the driver.
    - Windows Standalone Direct Input: Improved Bluetooth device detection. Now more Bluetooth controllers are recognized when using Direct Input.
    - Windows Standalone Direct Input: Improved controller hot-plugging assignment accuracy in certain scenarios.

    New Controller Definitions:
    - ThrustMaster T3PA Pedals

    Modified Controller Definitions:
    - Windows Fallback: Improved L/R trigger handling to accomodate both split axis and combined axis element sources because of source inconsistencies on Xbox 360 Controller, Xbox One Controller, Logitech F310 (X), Logitech F710 (X), Zidong V+ (X).

    Bug Fixes:
    - Non-calibrated CustomController values are no longer clamped -1 to 1.
     
    Last edited: Aug 8, 2016
  37. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Great update. Hope the unity asset store can release this today since it is so critical.

    Nice to have standalone USB T3PA pedals also so we can support windows/mac/Linux easily.

    Keep up the great work!
     
    guavaman likes this.
  38. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Hi,
    I would like to feed recorded input data back to Unity. I wanted to ask if there is a way how to do it through Rewired.
    (I would like to do it for recording short sessions for Helios, simply recording input for offline rendering)

    Or you would recommend to use user32.dll methods like SendInput and SetCursorPos

    I know Unity is not 100% deterministic but it could be still precise enough for short videos.

    Thanks
    Peter
     
  39. MatiasJP

    MatiasJP

    Joined:
    Nov 4, 2013
    Posts:
    16
    Hi guavaman!

    I'm testing the steam controller, and when I plug in I recieve the Connected joystick event, and then the disconnected joystick event. Do you know why that could happend?

    Rewired version: 88
    Plataform Windows : Windows 7
    Input source: RawInput
    Using XInput.
    Steam open.
    Steam controller connected via USB.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired does not have this feature. If you wanted to do it while using Rewired, you would have to set input values at the OS level before Rewired updates. How difficult this would be and what would be required to do so would depend on the input source(s) chosen.
     
    camel82106 likes this.
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Steam Controller is handled by XInput. There is no steam-controller specific code. Rewired relies on Steam's ability to accurately emulate an XInput controller. If you are getting multiple events, Steam would have to be doing something very strange with XInput like Creating 2 controllers and then the 2nd disappearing in the next frame. Every version of Steam is different and I do not keep a running tally of all the changes or bugs that are introduced in each version. Rewired works perfectly with real XInput controllers so this isn't an issue with Rewired but a weird Steam behavior that would have to have special case code added to somehow work around it if it's possible. I don't think this is necessary, especially since the behavior is likely to change in future versions of Steam.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Just to add more information to the situation:

    In the past, it had been reported that Steam Controller did not send system controller disconnect events and the joystick would still appear even after it was unplugged or turned off. At that time I implemented an auto-disconnect whenever communication with the XInput controlller object is lost. This was a workaround I had to implement because Steam did not properly send events to the system when the device was disconnected. The alternative was to poll for the connected state every single frame, which I chose not to do because it is a very expensive call.

    The Steam Controller has a history of not functioning as a normal XInput device should. This sounds like they've made another change that isn't to spec.
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
  44. SecondShadow17

    SecondShadow17

    Joined:
    Oct 15, 2012
    Posts:
    2
    Thanks for the help, turns out I still had a flight controller connected silly me.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Which flight controller was causing the Axis2D error? I need to check and make sure there isn't an error in the definition.
     
  46. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    We are using the following to get the corresponding keycode for an action which works great:
    ActionElementMap map = controllerMap.GetFirstButtonMapWithAction(action);

    Problem is we want to sometimes reset a controller or allow the player to, so we use the following which does reset it, but when you go into the game and use the above call it still pops up the old key until you restart the game.
    UIManager.Instance.playerInput.controllers.maps.LoadDefaultMaps(Rewired.ControllerType.Keyboard);

    Are there any other init methods or things we need to call?

    Edit: The same is true if you use the prefab controlmapper and change a key when in game, it still pulls the old key.

    Just noticed it does actually "use" the new key that you assign, but it is displaying the incorrect letter in the UI we are using.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Are you are storing the ActionElementMap object somewhere and using that to display your UI? The ActionElementMap is no longer valid when you remap a key or load defaults. It creates a new ActionElementMap with a different ActionElementMap.id whenever you call any of the methods that create or change a mapping. In addition, calling LoadDefaultMaps will discard all the ControllerMaps and create them anew as well.
     
    Last edited: Aug 15, 2016
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.0.0.96 is available for registered users to download immediately. If you would like to register to receive early access to updates, please contact me here. The Unity Asset Store should have the update in 3-10 business days.
    The new Debug Information displayed in the Rewired Input Manager inspector is a very useful tool to help debug input problems. It allows you to see your Players, joystick assignments, Controller Maps, and more in real-time so you can easily solve many issues without having to add debug code.

    inputmanager_inspector_debug_info.png

    1.0.0.96:

    Changes:
    - Windows Standalone Direct Input and XInput: Improved accuracy of button down detection when frame rate is extremely low and a button is pressed and released quickly.
    - ReInput.ControllerHelper.GetLastActiveController is now based on controller element value changes instead of absolute element values to exclude uncalibrated non-zero-at-rest axes and always-on buttons.
    - ReInput.ControllerHelper.GetLastActiveController() now returns Keyboard if no last active controller is found.
    - Added Debug Information to Rewired Input Manager inspector. This shows a ton of useful information allowing you to visualize most objects in the system during runtime.
    - Minor performance optimizations.

    API Changes:
    - Added Controller.GetButtonChanged method.
    - Added Controller.GetAnyButtonChanged method.
    - Added Controller.GetLastTimeAnyButtonChanged method.
    - Added Controller.GetLastTimeAnyElementChanged method.
    - Added Controller.Button.lastTimeStateChanged property.
    - Added Controller.Button.justChangedState property.
    - Added Controller.Axis.lastTimeValueChanged property.
    - Added Controller.Axis.lastTimeValueChangedRaw property.
    - Added ControllerWithAxes.GetLastTimeAnyAxisChanged method.
    - Added ReInput.ControllerHelper.GetAnyButtonChanged method.
    - Added ReInput.ControllerHelper.GetLastActiveControllerType method.
    - Removed obsolete ActionElementMap.actionCategoryId property.
     
    Last edited: Aug 16, 2016
  49. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That debug info will be extremely useful in the inspector. Looking forward to another great release.
     
  50. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    Thanks for the quick reply, indeed had ControllerMap cached and simply updating it using GetMap on the player's controller updates the UI correctly.