Search Unity

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,624
    You don't need to do this in code if you assign it in the Rewired Input Manager. It is already assigned to all Players by default.

    Is your console showing and do you have warnings enabled? http://guavaman.com/projects/rewired/docs/Troubleshooting.html#something-isnt-working
    • What controller are you using?
    • Did you create Actions called "Move Horizontal" and "Move Vertical"? Please send a screenshot.
    • Did you map these Actions to a Controller Map for the controller you are currently using? (Keyboard, mouse, or Dual Analog Gamepad Template?) Please send a screen shot.
    • Did you set these maps to be assigned to your Player and enabled on start? (Players page of the Rewired Input Manager)
    This link I sent before will always help you find the cause of problems like this:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    You get real-time visualization of every single object in Rewired. You can see at a glance the Controller Maps loaded in your Player and what is mapped to what. You can also see a real-time display of the values of every Action in a Player and what controllers are assigned to that Player. (When viewing values of axes/buttons//actions, always click back into the main window before moving the axes or pressing the buttons or they will be ignored because the inspector window has focus.)
     
  2. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Thank you kind sir, newbie head up his arse syndrome here.. typo error on the Axis name.
    Thank you for taking the time to get me sort, very much appreciated!

    Cheers
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No problem. Glad it's fixed.
     
  4. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    You can still write a custom driver for the HID device if it's too easy for you out of the box. :D
     
    guavaman likes this.
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired 1.1.7.0 is now available for registered users to download on the Rewired website. If you'd like to receive early access to updates, please contact me here. The Unity Asset Store is currently experiencing extremely long approval times for updates. I have no ETA on when this update will be available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    Release Notes:

    1.1.7.0:

    Changes:
    - Modified Action system to determine button states from underlying contributing Controllers instead of calculating button states based on previous and current frame values. This changes some behavior of ButtonUp and ButtonDown events. ButtonDown events are no longer reported when a Controller is assigned to a Player while the button is already held down. ButtonUp events are no longer reported when un-assigning a Controller, or disabling a Controller or Controller Map while a button is held down. This was done to eliminated the need for frame skipping when assigning or un-assigning Controllers or enabling/disabling Controller Maps using a button on that same Controller.
    - Rewired Editor: Added "Defer Controller Connect Events On Start" option to Settings.
    - Rewired Editor: Added "Joystick Refresh Rate" option to Settings -> Windows.
    - Rewired Editor: Added "Coordinate Mode" option to Custom Controller Axis properties.
    - Rewired Editor: Changed "All" Platform Settings controls function more intuitively.
    - Control Mapper: Added new events for when a popup window is opened or closed and when input polling starts and stops.
    - Control Mapper: Added Unity events for each event and exposed them in the inspector.
    - Controller Templates now support mapping the same template element to multiple controller elements.
    - Added "Reverse Gear" to Racing Wheel template.
    - Added "Reverse Gear" mappings to Racing Wheel template for Logitech G25, Logitech G27, Logitech G29, Logitech G920, and Thrustmaster TH8A Shifter.
    - Added Rex Engine integration.
    - Added Ultimate Survival integration.

    API Changes:
    - Added AxisCoordinateMode enum.
    - Added Player.GetAxisCoordinateMode method.
    - Added Player.GetAxisRawCoordinateMode method.
    - Added Player.GetAxisCoordinateModePrev method.
    - Added Player.GetAxisRawCoordinateModePrev method.
    - Added InputActionEventData.GetAxisCoordinateMode method.
    - Added InputActionEventData.GetAxisRawCoordinateMode method.
    - Added InputActionEventData.GetAxisCoordinateModePrev method.
    - Added InputActionEventData.GetAxisRawCoordinateModePrev method.
    - Added ReInput.ConfigHelper.deferControllerConnectedEventsOnStart property.
    - Added ReInput.ConfigHelper.joystickRefreshRate property.
    - Added ControlMapper.PopupWindowClosedEvent event.
    - Added ControlMapper.PopupWindowOpenedEvent event.
    - Added ControlMapper.onScreenClosed event.
    - Added ControlMapper.onScreenOpened event.
    - Added ControlMapper.onPopupWindowClosed event.
    - Added ControlMapper.onPopupWindowOpened event.
    - Added ControlMapper.InputPollingStarted event.
    - Added ControlMapper.InputPollingEnded event.
    - Added ControlMapper.onInputPollingStarted event.
    - Added ControlMapper.onInputPollingEnded event.

    New Controller Definitions:
    - Logitech Driving Force GT
    - Thrustmaster Freestyler Bike

    Modified Controller Definitions:
    - Changed CH FlightStick Pro "Dial" name to "Throttle."
    - Reverted Saitek X45 "Stick Rotate" name to "Rudder."
    - Sony DualShock 2: Added mapping for Super Dual Box Pro adapter with default HID driver, Linux Native and OSX Native mappings.
    - Sony DualShock 3, Linux Native: Added mapping for Ubuntu 17.04 driver, fixed button mapping issues on Gasia Co.,Ltd PS3 Adapter mapping.

    Bug Fixes:
    - Windows Standalone, XInput: Joysticks disconnected and reconnected no longer report button values from before disconnection during the first frame after reconnection.
    - Windows Standalone, Direct Input: Joysticks with hats no longer return a hat value of up for few frames when plugged in at runtime.
    - Windows Standalone, Raw Input: Fixed memory leak when Headsoft VJoy is installed on the system.
    - Windows Standalone: Added workaround for Steam issue preventing Control, Shift, and Alt keys from working when using Steam Streaming.
    - Rewired Editor: Fixed issue preventing disabling Native Keyboard Handling in Settings -> Windows.
    - OSX, Native: Fixed rare issue causing some Xbox controller vibration messages to not be sent to the device.
    - PS4, Native: Fixed bug introduced in 1.1.6.0 causing gamepads to not be recognized.
     
  6. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Another great update. Every time I think you have run out of controllers to add a few new ones appear. :) @Steve-Tack will like the X-45 change too.

    Looking to try out the new reverse gear in the racing wheel template too.

    Thanks for Ultimate Survival integration too.

    The Ultimate Survival 0.14 was recently submitted (I suspect after Rewired) and it is approved already on Sep 13, 2017. Not sure why Rewired 1.1.6.0 is taking so long to get approved on the asset store.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Indeed. They just keep coming out of the woodwork. :p

    I saw the 0.14 update also. There were basically no changes and nothing that affects input.
     
  8. MarkcusD

    MarkcusD

    Joined:
    Jul 12, 2011
    Posts:
    40
    Do you have a demo exe of a simple game using this? I want to verify that vibration and triggers on xbox 1 controllers works. Thanks.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I don't publish any game demos using Rewired. If you want to try Rewired, get the free trial.

    Add a Rewired Input Manager to the scene and put this script on some game object. Press V to vibrate.

    Code (csharp):
    1. public class RewiredVibrateTest : UnityEngine.MonoBehaviour {
    2.     void Update() {
    3.         if(!Rewired.ReInput.isReady) return;
    4.         if(UnityEngine.Input.GetKey(UnityEngine.KeyCode.V)) {
    5.             foreach(var j in Rewired.ReInput.controllers.Joysticks) {
    6.                 j.SetVibration(1f, 1f, 0.5f, 0.5f);
    7.             }
    8.         }
    9.     }
    10. }
     
    Last edited: Sep 17, 2017
  10. Vonsnake

    Vonsnake

    Joined:
    Mar 3, 2015
    Posts:
    3
    Hey there

    Recently bought Rewired and have just finished getting it fully implemented, everything is working perfectly except for one issue - when the built game exits (Alt + F4 or through an Application.Quit call) it will hang indefinitely until the user kills the process manually or clicks on the hung window to trigger the Windows dialogue to popup. I've been able to narrow it down to Rewired, as long as an input manager is never present to initialize anything then quitting works perfectly fine.

    All players on my game's beta branch have been able to reproduce this and I'm wondering if it's another issue on Unity's end. I'm building for Windows x86 with the experimental .net 4.6 backend with Rewired setup to use Raw Input, just updated from 2017.1p5 to 2017.1.1p2 as well to make sure there wasn't anything else Unity might have fixed.

    Any help would be greatly appreciated, thanks!
     
  11. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    767
    Hi @guavaman, I'm wondering of I implemented my controller mappings the right way for my user case.
    I've setup one Map Category with Actions within different Action Categories. For those action I create one Map so that in my case one button (for instance for a joystick the B button) can have multiple actions for the action categories (fi jump in action category Gameplay and Close in the category UI, ...)
    Now depending on where I am in the game (UI or Gameplay) I want to enable/disable the mappings using the action category so if I press B for jump, the UI doesn't popup. What would be the best approach? Redo my setup and create different map categories in stead or is there a way do enable my mappings as they are defined now?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I just tested it and see the same issue. Because there are zero differences in Rewired between the two .NET modes, the only conclusion is that this is another .NET 4.6 backend bug. I will report it to Unity.

    As a general rule, I don't support betas (or "experimental" parts of Unity) because they're almost always buggy and coming up with an adding workarounds for bugs that are later fixed is a big time killer.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    You do not use Action Categories for enabling and disabling maps in Rewired. Action Categories are only used for organizing Actions in the editor and displaying lists of Actions to the user in a UI.

    You enable and disable Controller Maps by Map Category to switch on and off different sets of controls as shown here:
    http://guavaman.com/projects/rewired/docs/HowTos.html#enabling-disabling-controller-maps

    If you have one Controller Map in a Map Category with all your Actions on it, you cannot disable that Controller Map because everything will be disabled.

    See the ControlRemapping1 example included with Rewired or the Control Mapper example (if you've installed Control Mapper) to see complex configurations with many Map Categories.

    See the documentation on Map Categories.
     
  14. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    767
    Thanks, that exactly what I thought when looking at the API but was wondering if I missed something. Will redo my mappings in the editor then.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    @Vonsnake

    Further testing shows Rewired successfully logs through the entire shutdown process, meaning all parts of Rewired were stopped and shut down successfully.

    Other testing shows that this only happens when XInput is enabled. However, XInput shuts down completely as well, therefore, as I concluded before, this must be a bug in the .NET 4.6 Experimental backend.

    There's nothing further I can do to pinpoint the problem because everything that happens in Unity after Rewired shuts down is beyond its control. I've reported this bug to Unity.
     
  16. fatality674

    fatality674

    Joined:
    Nov 1, 2012
    Posts:
    24
    I'm currently having an issue and i'm not sure if it is Rewired or Unity related. My guess is the latter but i've not ruled Rewired out.

    I'm making a multi window project, i have created an input scene which is used for calibration and takes input from any joystick i throw at it. I also have another "game" scene which takes input over a network.

    The problem comes from when the input scene doesn't have context in windows. The only time input is detected/fired is when the input scene is the current window.

    Run in background is enabled but its as if input is not taking this into account.

    Any Ideas what it could be?
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Disable this:
    Rewired Editor - Settings: Ignore Input When App Not in Focus
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    For those of you using the .NET 4.6 experimental backend, there are still major issues even in Unity 2017.1.1f1. This time in OSX. See this for more information.

    My advice: Do not use the .NET 4.6 backend until it is stabilized and no longer experimental.

    I wouldn't be at all surprised to see bug reports in Linux that end up being caused by this next...
     
    Last edited: Sep 20, 2017
  19. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    I'm writing a first person shooter and want to convert mouse movement inches to radians. Specifically, a 2 * PI rotation should be achieved by moving the mouse 6.3015 inches.

    I looked through the manual and searched the forum but didn't see any way to get this.

    How would I read the actual inches moved for the mouse?
     
  20. Vonsnake

    Vonsnake

    Joined:
    Mar 3, 2015
    Posts:
    3
    Thanks for taking the time to test, much appreciated. I'm taking advantage of .net 4.6 right now so I'll wait it out for Unity to patch it.

    Cheers for the excellent input library!
     
    guavaman likes this.
  21. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    Modifiers keys don't update correctly.

    You can see in my setup I have WADS for walk, and shift + WADS for run.

    Press W: Walk (OK)
    Press W then shift: Walk (BAD)
    Press shift then W: Run (OK)
    Press shift, then W, then release shift: No movement (BAD)


    Code (CSharp):
    1. player.AddInputEventDelegate(UIHook_WalkZ, UpdateLoopType.Update, InputActionEventType.AxisActive, RewiredConsts2.Action.AvatarWalkZ);
    2. player.AddInputEventDelegate(UIHook_WalkX, UpdateLoopType.Update, InputActionEventType.AxisActive, RewiredConsts2.Action.AvatarWalkX);
    3. player.AddInputEventDelegate(UIHook_RunZ, UpdateLoopType.Update, InputActionEventType.AxisActive, RewiredConsts2.Action.AvatarRunZ);
    4. player.AddInputEventDelegate(UIHook_RunX, UpdateLoopType.Update, InputActionEventType.AxisActive, RewiredConsts2.Action.AvatarRunX);

    upload_2017-9-21_12-25-59.png

    upload_2017-9-21_12-27-5.png
     
    Last edited: Sep 21, 2017
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    The operating system returns data in the format of pixels moved since the last update. The value is then multiplied * 0.5 to match what Unity normally returns. If you want to convert that to inches, you will have to do it. However, to do that, you need to know the DPI of the screen. This information is rarely available on PC's. Unity's Screen.dpi is the only way to get this information, but it will usually just return 0 on PC's so you will have to assume a default value like 72 or 96.

    var inches = mouseValue * 2 / (Screen.dpi != 0 ? Screen.dpi : 96);
     
    Last edited: Sep 21, 2017
    RakNet likes this.
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This is the expected behavior. Modifier keys act exactly as they do in any other circumstance in Windows or any other operating system. To copy text, you have to hold Control first and then press C. You cannot hold C and then press Control. This is by design. The 2nd case (Press shift, then W, then release shift: No movement ) is also by design and is a result of key blocking. If you map, say, "Throw Grenade" to G, then you map "Group Command" to Control + G, you wouldn't want "Throw Grenade" to activate if you release Control while still holding G. This allows you to layer commands to keys as well as to keys + modifiers and Actions are only fired for the modified key and not the underlying keys just as it happens in any other case with OS key modifiers.

    What you are trying to do would qualify as a multi-button Action and would have to be handled this way.
     
    Last edited: Sep 22, 2017
  24. jloehr

    jloehr

    Joined:
    Jan 24, 2014
    Posts:
    1
    Hi, i am the developer of HID Wiimote, a Windows Device Driver for the Nintendo Wii Remotes.
    For some reason Rewired in Raw Input mode is incompatible with my driver.

    I did my tests with Unity 5.6.0f3 and Rewired 1.1.7.0 trial. I set up a new empty project and used the Rewired Input Managers Debug Information. When using DirectInput everything runs fine, Rewired is picking up the device and i can see the input being received. However when using Raw Input the Debug Information won't even show any controller connected. I also tried an Logitech Controller in Raw Input and that was working fine.

    My current release version does not implement/report any Product, Manufacturer and Serial string. Though for a development version i implemented those and it still wasn't working. Unity's Input System is working fine with my driver and i am able to read inputs. I also build some test application (Win32 C++) following Microsofts "Using RawInput" documentation. GetRawInputDeviceList is correctly enumerating the controller and doing a standard read of RawInput yields reports as well.

    Do you do any additional filtering for RawInput devices?
     
    Arkade likes this.
  25. MaxPirat

    MaxPirat

    Joined:
    Sep 7, 2015
    Posts:
    12
    Hello! I just got Rewired and I'm SUPER satisfied with it as of now. Convert my game with UI in a matter of half an hour. I have A few questions I can't find answers to:

    1) Can I set default axis dead zone? This seems like the only thing I cant configure without using code. Right now I do this in Start:
    Code (CSharp):
    1.  
    2.         foreach (var j in Rewired.ReInput.controllers.Joysticks)
    3.         {
    4.             foreach (var a in j.calibrationMap.Axes)
    5.             {
    6.                 a.deadZone = .5f;
    7.            }
    8.         }
    9.  
    And I should probably listen to joystick connect event to do it again but It just doesn't feels right to set such a basic thing like that. Am I missing it somewhere?

    2) In my other game, I'm trying to make mouse cursor which will be controlled by the joystick (simple sprite, not hardware cursor). There is a lot of trouble to make every UI event work with it. Can Rewire help me with it somehow? Probably not, but Rewired seems so advance that I decided to ask anyway ;)
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Yes. If you have Use XInput enabled, all XInput-compatible devices will be filtered out. Rewired only treats joysticks and gamepads as Joysticks (Usage 1, Usage Page 4/5). There are also quite a few other scenarios that will cause the device to fail and not be reported. Please PM if you want to dig deeper.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I'm glad you're happy with Rewired! That's great you got it implemented so quickly.

    No, you can't do this in the editor. The editor is primarily for defining Controller Maps and related things like Actions, not for overriding default hardware settings. The FAQ addresses this:
    http://guavaman.com/projects/rewired/docs/FAQ.html#default-dead-zone

    Rewired includes default dead zones for every recognized joystick. They are built into the hardware definition for each joystick and specified per-platform, per-input source. These defaults should not be changed because they will be overwritten when you update Rewired. There is not currently a means of non-destructively overriding default hardware definition settings per-device.

    Controller dead zones are very individualized to each physical joystick and can vary due to manufacturing, wear and tear, etc. As such, you should not simply set an extremely large default dead zone if your joystick drifts. Instead, you need to allow your users to set their own dead zone specific to their joystick. Rewired allows you set all kinds of calibration information for joysticks through scripting. See How To's - Calibrating controller axes for more information. You can see this implemented in both the ControlRemappingDemo1 and Control Mapper.

    Using Control Mapper in your game will give users the option to remap and calibrate their controllers.


    ---

    The way you are doing it is the only way. And, yes, you need to also do it on the controller connected event. However, realize that your default dead zone of 0.5 will feel probably ridiculously large on many joysticks even if it feels right on yours. Many joysticks don't even need dead zones because the hardware has one built-in already. Racing wheels and throttles should never have dead zones. This will also affect triggers, pedals, and other things you may not intend for it to be applied to.

    No, Rewired does not provide anything for this. The Rewired Standalone Input Module is the only UI-related feature Rewired includes.
     
    MaxPirat likes this.
  28. MaxPirat

    MaxPirat

    Joined:
    Sep 7, 2015
    Posts:
    12
    Maybe you will tell me a better way: I'm trying to simulate 4-way arcade stick. So after I got Vec2 position of the analog stick I snap it to the nearest direction out of four (vec2(1,0), vec2(0,1), etc). And If dead zone is not big it sometimes feels like direction jump around near diagonals on a start of the analog stick movement.
    Like if dead zone feels like 0.1 or smaller, I have to be dead straight in moving my stick down or I can get left or right direction in the beginning of a movement. Hope I explained it good enough ;)

    Ok, this package has insane value for its price already ;D Strange no one made an asset for joystick cursor with UI support, seems like a typical task. Oh well.

    Thanks for replying so fast, Rewired totally blew me away!
     
    Last edited: Sep 25, 2017
    guavaman likes this.
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I think this method would work for your purposes:

    Code (csharp):
    1. Vector2 stickValue = new Vector2(
    2.     player.GetButton(horizontalAction) ? 1f : player.GetNegativeButton(horizontalAction) ? -1f : 0;
    3.     player.GetButton(verticalAction) ? 1f : player.GetNegativeButton(verticalAction) ? -1f : 0;
    4. );
    Player.GetButton when used on an axis-type Action will use the Button Dead Zone setting on the Input Behavior assigned to that Action to determine what axis value is required to activate the button on state. Disable Digital Axis Simulation in the Input Behavior assigned to this Action as well.

    You may also want to change the default joystick dead zone type to Axial if you don't expect to also need to use analog sticks for anything that would require a radial dead zone.

    Thanks!

    To do it you would have to replace the PointerInputModule which is the base class of StandaloneInputModule, so you'd have to replace both changing the source of the cursor position to your own value instead. Maintaining branched code from Unity's UI system can be challenging because they're always changing things.

    Another thing I am also asked about is multiplayer UI cursor support. That's an even bigger issue because Unity's entire UI system only allows for one active Selectable object. Making this work would require essentially replacing the Selectable component and all UI elements that depend on it (Button, ScrollBar, etc.).
     
  30. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    Why does the player.GetAxis2D(string, string) can't use one action name as its parameter?
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Because an Axis is by definition a single float value. An Axis 2D is 2 float values returned as a Vector2.
     
  32. HittmanA

    HittmanA

    Joined:
    Jul 27, 2016
    Posts:
    45
    Hey there @guavaman , I am trying to make a virtual cursor for my game similar to the cursor found in the game Destiny ( ).
    The problem is all the virtual cursor scripts I have found only work with a mouse and keyboard, not with controllers. How would I make a virtual mouse that is moved by one of the controller's sticks and is "pressed" by one of the controller's buttons as well as sending pointerEnter and pointerExit events? Thanks in advance!
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    If the script works with keyboard, all you would do is substitute player.GetAxis for however they are getting keyboard input and it will automatically work. Otherwise, you would have to generate the pointer events yourself as is done in the StandaloneInputModule. You'd have to replace this module because it will generate events for the actual system cursor. If you just make another module that also generates pointer events, you'll get events for both your virtual cursor and the actual OS cursor. You also have to replace the PointerInputModule which is the base class for StandaloneInputModule because this class is responsible for creating the PointerEventData which is used in the StandaloneInputModule. The PointerInputModule is coded to use Input.mousePosition for the pointer position. You would have to change this to the position of your software cursor. The only role Rewired plays here is to provide the X and Y axis values to move the software cursor through player.GetAxis and the click state through player.GetButton, otherwise this is entirely a Unity UI issue.

    Alternately, you could disable mouse input on the RewiredStandaloneInputModule (if you're using that) and make an entirely new custom Input Module which handles all the pointer events.
     
    Last edited: Sep 27, 2017
    Arkade likes this.
  34. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    hi Sir! I'm wondering how I can show the input key to a UI, like I have a hoover over ui thats says PRESS 'which ever keycode i'm referencing is" will show the keycode.
    so for eg.
    Code (CSharp):
    1. Text.text = "PRESS " + SOMECODEHERE TO SHOW KEYCODE.tostring();
    Thank you hopefully you understand my jibber :D

    I'm using UFPS integration too.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Displaying a button/axis/key name to the user for an Action
     
    llJIMBOBll likes this.
  36. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Appreciate it, was just gonna comment back to say I looked thru past posts and you've posted a few times about how to. I'm sorry XD and Thank you :D
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No problem!
     
  38. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    I try to detect whether an XBOX 360 or Xbox One Controller is connected (Windows 10, Unity 2017.1.1p3). When I connect both Controllers, I see in the Unity Debug Console:
    When I drop the DebugInformation Prefab in a Scene, I see Rewired 1.1.5.3.U2017 detected two Joysticks.

    However, both Joysticks have the Hardware Type Guid d74a350e-fe8b-4e9e-bbcd-efff16d34115, which is the Guid found in MicrosoftXbox360.asset.

    Rewired seems to detect the Xbox One Controller as an XBOX 360 Controller, according to the Hardware Type Guid.

    How can I differentiate an XBOX 360 from an Xbox One Controller?
     

    Attached Files:

  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This is covered in the documentation here:
    http://guavaman.com/projects/rewired/docs/ControllerMaps.html#xinput-devices-windows
    http://guavaman.com/projects/rewired/docs/KnownIssues.html#xinput-device-name

    There is no possible way to differentiate XInput device types from each other except to disable XInput. You will lose all the features XInput provides when you do so.
     
    Peter77 likes this.
  40. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    How do you get touch pad's input of the controller like DualShock4?
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired 1.1.7.5 is FINALLY live on the Unity Asset Store. It's been over a month since the last update appeared on the Asset Store and quite a few versions have gone by since then. The release notes to all the changes since 1.1.5.3 are below:

    1.1.7.5:

    Bug Fixes:
    - Windows Standalone, Direct Input: Joysticks button held down when another joystick is disconnected now retain the pressed value.

    1.1.7.4:

    Modified Controller Definitions:
    - Sony DualShock 3, Windows, Raw Input & Direct Input: Fixed incorrect button and D-Pad mappings for Gasia Co.,Ltd PS3 Adapter.

    1.1.7.3:

    Changes:
    - Added silent install option for headless installation.
    - Windows, Raw Input: Bluetooth devices without a valid serial number are no longer ignored.

    1.1.7.2:

    Bug Fixes:
    - Fixed bug causing GetAxisRaw to return an incorrect +1 value for one frame when a physical button is mapped to an axis-type action and the button is released.

    1.1.7.1:

    Bug Fixes:
    - Windows Standalone: Eliminated 120 byte per frame memory allocation added in 1.1.7.0.

    1.1.7.0:

    Changes:
    - Modified Action system to determine button states from underlying contributing Controllers instead of calculating button states based on previous and current frame values. This changes some behavior of ButtonUp and ButtonDown events. ButtonDown events are no longer reported when a Controller is assigned to a Player while the button is already held down. ButtonUp events are no longer reported when un-assigning a Controller, or disabling a Controller or Controller Map while a button is held down. This was done to eliminated the need for frame skipping when assigning or un-assigning Controllers or enabling/disabling Controller Maps using a button on that same Controller.
    - Rewired Editor: Added "Defer Controller Connect Events On Start" option to Settings.
    - Rewired Editor: Added "Joystick Refresh Rate" option to Settings -> Windows.
    - Rewired Editor: Added "Coordinate Mode" option to Custom Controller Axis properties.
    - Rewired Editor: Changed "All" Platform Settings controls function more intuitively.
    - Control Mapper: Added new events for when a popup window is opened or closed and when input polling starts and stops.
    - Control Mapper: Added Unity events for each event and exposed them in the inspector.
    - Controller Templates now support mapping the same template element to multiple controller elements.
    - Added "Reverse Gear" to Racing Wheel template.
    - Added "Reverse Gear" mappings to Racing Wheel template for Logitech G25, Logitech G27, Logitech G29, Logitech G920, and Thrustmaster TH8A Shifter.
    - Added Rex Engine integration.
    - Added Ultimate Survival integration.

    API Changes:
    - Added AxisCoordinateMode enum.
    - Added Player.GetAxisCoordinateMode method.
    - Added Player.GetAxisRawCoordinateMode method.
    - Added Player.GetAxisCoordinateModePrev method.
    - Added Player.GetAxisRawCoordinateModePrev method.
    - Added InputActionEventData.GetAxisCoordinateMode method.
    - Added InputActionEventData.GetAxisRawCoordinateMode method.
    - Added InputActionEventData.GetAxisCoordinateModePrev method.
    - Added InputActionEventData.GetAxisRawCoordinateModePrev method.
    - Added ReInput.ConfigHelper.deferControllerConnectedEventsOnStart property.
    - Added ReInput.ConfigHelper.joystickRefreshRate property.
    - Added ControlMapper.PopupWindowClosedEvent event.
    - Added ControlMapper.PopupWindowOpenedEvent event.
    - Added ControlMapper.onScreenClosed event.
    - Added ControlMapper.onScreenOpened event.
    - Added ControlMapper.onPopupWindowClosed event.
    - Added ControlMapper.onPopupWindowOpened event.
    - Added ControlMapper.InputPollingStarted event.
    - Added ControlMapper.InputPollingEnded event.
    - Added ControlMapper.onInputPollingStarted event.
    - Added ControlMapper.onInputPollingEnded event.

    New Controller Definitions:
    - Logitech Driving Force GT
    - Thrustmaster Freestyler Bike

    Modified Controller Definitions:
    - Changed CH FlightStick Pro "Dial" name to "Throttle."
    - Reverted Saitek X45 "Stick Rotate" name to "Rudder."
    - Sony DualShock 2: Added mapping for Super Dual Box Pro adapter with default HID driver, Linux Native and OSX Native mappings.
    - Sony DualShock 3, Linux Native: Added mapping for Ubuntu 17.04 driver, fixed button mapping issues on Gasia Co.,Ltd PS3 Adapter mapping.

    Bug Fixes:
    - Windows Standalone, XInput: Joysticks disconnected and reconnected no longer report button values from before disconnection during the first frame after reconnection.
    - Windows Standalone, Direct Input: Joysticks with hats no longer return a hat value of up for few frames when plugged in at runtime.
    - Windows Standalone, Raw Input: Fixed memory leak when Headsoft VJoy is installed on the system.
    - Windows Standalone: Added workaround for Steam issue preventing Control, Shift, and Alt keys from working when using Steam Streaming.
    - Rewired Editor: Fixed issue preventing disabling Native Keyboard Handling in Settings -> Windows.
    - OSX, Native: Fixed rare issue causing some Xbox controller vibration messages to not be sent to the device.
    - PS4, Native: Fixed bug introduced in 1.1.6.0 causing gamepads to not be recognized.

    1.1.6.0:

    Changes:
    - Changed Sony DualShock 4 controller display name and element identifier names on PS4 platform to conform to Sony's required standards.
    - Added Positive Name and Negative Name fields to Controller Element Identifier in Hardware Joystick Map editor.
    - Changed mouse axis positive/negative axis names to Mouse Left, Mouse Right, etc.
    - Updated Control Mapper to use positive/negative name fields.
    - Added FirstNonZeroValue Custom Calculation type.
    - Added default UI controls to Corgi Engine integration.
    - Corgi Engine integration: Added inventory system integration.
    - Corgi Engine integration: Minimum required Unity version changed to Unity 5.6.3f1.
    - Special platform inspector settings for Rewired_Core.dll are now checked more often that just when the build platform is changed to account for installing Rewired and/or special platform plugins with the build target already set to a special platform that is not supported by the base Unity editor.

    New Controller Definitions:
    - Logitech MOMO Racing Wheel

    Modified Controller Definitions:
    - Sony DualShock 3: Added WebGL mappings for OSX and Linux.
    - Microsoft Xbox One: Added OSX Native mapping for Xbox One S controller firmware 3.1.1221.0.
    - Added positive/negative axis names to most recognized controller axes.
    - Changed CH CombatStick "Dial" name to "Throttle."
    - Changed CH FighterStick "Dial" name to "Throttle."
    - Changed Saitek Heavy Equipment panel "Stick Z (Blue)" name to "Stick Rotate (Blue)."
    - Changed Saitek Heavy Equipment panel "Stick Z (Red)" name to "Stick Rotate (Red)."
    - Changed Saitek X45 "Rudder" name to "Stick Rotate."
    - Changed Saitek X-56 Rhino Throttle "MiniStick X", "MiniStick Y", and "MiniStick Button" to "Mini Stick X", "Mini Stick Y", and "Mini Stick Button."
    - Changed Thrustmaster T.16000M "Slider" name to "Throttle."

    API Changes:
    - Added ControllerElementIdentifier.positiveName property.
    - Added ControllerElementIdentifier.negativeName property.
    - Added ControllerPollingInfo.controller property.
    - Added ControllerPollingInfo.player property.
    - Added ControllerPollingInfo.elementIdentifier property.

    Bug Fixes:
    - Disabling "Ignore Input When App Not In Focus" in the Rewired Input Manager works again in the Unity editor even when "Run Application in Background" is disabled in the Unity Player settings.
    - Fixed missing class and method exceptions thrown during build time on Windows 8.0 Store and 8.1 Universal platforms.
    - Windows Standalone, Raw Input: Fixed issue preventing Microsoft Xbox One controller from working when used with "Use XInput" disabled.
     
  43. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @guavaman
    Our game allows 6 players. For the past few weeks we've been testing with 4 wireless xbox one controllers connected to a xbox one PC dongle and 2 ps4 controllers connect by USB to the PC and this has worked fine.

    However, this last weekend we've tried using 6 xbox one controllers connected wirelessly to the USB dongle on PC and rewired will not recognize more than 4 of the controllers. All 6 have steady lights indicating they are connected to Windows 10, but in the Rewired debug manager it only shows 4 joysticks, and if I plug in the PS4 controllers it will then show 6.

    Does rewired have any kind of restriction with only allowing 4 xbox one controllers? From what I've read online, the xbox one PC dongle can connect 8 xbox one controllers...

    Or any other thoughts of what I might be doing wrong?
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Rewired does not. XInput does:
    http://guavaman.com/projects/rewired/docs/KnownIssues.html#more-than-4-xbox-controllers

    More than 4 XBox controllers cannot be used at the same time
    Windows Standalone
    XInput has a hard limit of 4 devices. This is not a Rewired limitation, it is a limitation in Microsoft's XInput system.

    You can mix and match non-XInput devices with XInput devices for a total of more than 4, but you cannot use more than 4 XInput compatible devices simultaneously if XInput is enabled. If you need to support more than 4 XInput controllers, you must disable XInput in the Rewired Editor - Settings page.

    Be advised that by disabling "Use XInput" in the Rewired Input Manager, you introduce these new issues/limitations:

    1. L/R triggers are treated as 1 combined axis and both cannot be pressed simultaneously without canceling each other out.
    2. You lose universal XInput controller support because each XInput controller now must be specifically recognized and mapped. Any unrecognized XInput devices will be treated as Unknown Controllers.
    3. Vibration is not supported without XInput enabled.
    4. The Steam Controller as well as Steam Streaming and Steam Link can no longer be supported.
    OSX Standalone
    XBox 360 controllers on OSX require this XBox 360 driver. This driver also imposes the 4-device limit just like XInput. It is currently not possible to use more than 4 XInput devices simultaneously on OSX. Again, you can mix and match non-XInput controllers to achieve a total count greater than 4. Because the driver is required for the controller to be detected, there is no way to disable the use of this driver and get around this issue.[/user]
     
  45. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @guavaman

    Thank you for the detailed response. That's rather unfortunate, but I understand. Dang you XInput! =P
     
    guavaman likes this.
  46. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Sorry, one more question I meant to ask... Is there any chance that Unity / Rewired can use Direct Input rather than XInput? I'm a noob when it comes to this stuff so I assume I don't understand, but thought I'd ask. I've seen posts saying that Direct Input can handle any number of controllers. Is DirectInput the same as just disabling XInput?
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    My post before this told you how to do it:
    "If you need to support more than 4 XInput controllers, you must disable XInput in the Rewired Editor - Settings page."

    Disable "Use XInput". This is controlled by the Windows settings in the Rewired Input Manager -> Settings page: http://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    You cannot change Unity's input system in any way. Rewired is written to use native libraries on many platforms and default to Native on Windows, not Unity Input. It was written to support all these different libraries on Windows: Raw Input, Direct Input, XInput, SDL2, Unity Input. Each is different and has different limitations. Raw is always preferred over Direct.
     
  48. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for another great set of Rewired updates all in one package. :)
     
    guavaman likes this.
  49. thatscraigz

    thatscraigz

    Joined:
    Mar 27, 2015
    Posts:
    100
    Hiya! :D

    Just had a quick question! How would I go about Restoring the player's default controls without needing them to go into the Input Mapper menu? (so I can manually have them confirm doing it in a poppup window when I release a new version of my game that I've had to remap over their custom keys)

    Thanks again for the awesome product! :D

    -craigz
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I think you mean Control Mapper. The source code is there so you can look at it to see how everything is done. It calls player.controllers.maps.LoadDefaultMaps on all players.

    Thanks!