Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    Thanks guavaman, I do have two questions.

    I add an event delegate to receive inputs from my player.
    m_Player.AddInputEventDelegate(OnPositiveButtonDown, UpdateLoopType.Update, InputActionEventType.ButtonJustPressed);
    m_Player is set to the player using his player name "Player1" but I also get the inputs from Player 2, is that normal? Do I have to parse using the player id?

    My second question is do I have to setup the joystick map for each of the supported controllers to have default controls for each of them? I'd think yes but I'm not sure, enlightement please? :)
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    No, that's not normal. It's a bug and I just fixed it. (Had an extra loop that shouldn't have been there...) Please contact me on the support form here with your email address and I'll send you a link where you can download 1.0.0.25 right now with the fix.

    For all the controllers that are dual analog gamepads, they are covered by the Dual Analog Gamepad template. You make a map for that template, you're making a map that's compatible with all the dual analog gamepads that Rewired comes with extended support for. (Everything under "Gamepads" here, plus more as they're added.) If you make a map for the template, you can optionally also make a map for an individual controller and that will override the template map for that controller. Otherwise, for the other controllers like flight sticks, steering wheels, light guns, etc. that do not currently have templates, yes you have to create a map for each you want supported out of the box (meaning you don't want the user to manually have to map them before playing). If you don't create a map and you want the user to be able to use that controller, you'll have to make a remapping screen where the user can map his controls manually. For unrecognized controllers, Rewired will use the Unknown Controller map (whether you define a map for this or not). This is a list of 32 axes and 128 buttons. You can create a map for Unknown Controller if you like, but there's no way for you to know what axis or button corresponds to what, so it's generally better just to leave it without a map and provide the user with a remapping screen where they can set up their unknown controllers how they see fit.

    I will add something to the docs to make all this more clear.
     
    Last edited: Jan 26, 2015
    Karearea likes this.
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Rewired 1.0.0.25 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address.

    ------------
    1.0.0.25 release notes:

    Bug Fixes:
    - Fixed issue with event-based input causing a Player's events to fire for every Player.
    ------------
     
  4. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    246
    Thank you very much for the detailed response. I knew the documentation must contain this information, but I wasn't exactly sure where to look. However, all the great solutions you've provided only seem to relate to joysticks and I guess I'm going for something a little more abstract.

    In my current game project I want to give up to 4 local players the ability to jump-in/jump-out of the game using whatever control scheme they want. I say “control scheme” because this would include more than just joysticks, and the input devices could be grouped together (mouse + keyboard).

    Essentially, one player in the game could be using the mouse & keyboard, while the other 3 players could be using xbox controllers, etc. This could also be in any particular order. Meaning the player using the mouse & keyboard could be player 1 - 4 depending on when they joined, and no one else could use that control scheme while it was in use.

    From what I understand, Rewired requires you to define all possible players upfront, and assign each all possible control mappings before the game even starts. This sounds way too inflexible for what I want.

    Ideally, I would like a system that would allow me to simply define a maximum number of players and a set of control schemes. When an input device related to one of these control schemes is triggered (mouse click, button pressed). A new player is created and assigned that control scheme (mouse & keyboard, Xbox controller, etc.).

    Map categories sound very similar to the control scheme concept I'm going for here. But I'm not exactly sure if that can be made to work the way I want it to?
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    It is entirely possible to do all of this with Rewired. However, because of your special case of assigning controllers in the order they pressed a button/key, you are going to have to do some manual management of control assignment instead of letting Rewired auto-assign them for you (which isn't that hard.)

    If that's the impression you have of Rewired, then I've totally failed in explaining its capabilities.

    Rewired is ridiculously flexible. It comes with a sample control remapping screen demo that you can use to learn how to make a remapping system for your players. It makes it possible to completely reconfigure keyboard, mouse, joysticks, and even multiple joysticks per player. It handles conflict checking, saving and loading, etc. It was designed specifically to be extremely flexible for any style of single or multi-player game. It's all up to you how you use it.

    In the Rewired editor, you (optionally) define STARTING control maps for each Player. Those maps will be loaded on start for each player for Keyboard, Mouse, Joystick (if any are found and assigned), and Custom Controllers. If a joystick is plugged in and assigned to a player, it will load the appropriate map for that joystick. But all maps and control assignments are modifiable at runtime. The only things set in stone before runtime are the Actions and the max number of Players. You don't even have to assign any maps on start at all. You could manage that all yourself if you choose to by assigning mouse, keyboard maps, and joysticks to players completely manually.

    1) Rewired's Players are exactly that -- a maximum number of players. They don't all have to be in use at all times.
    2) Rewired Players are created at runtime, not dynamically. They exist perpetually, but that doesn't mean your actual game players have to. Your concept of a game player exists totally separately from a Rewired Player, therefore you are totally free to assign any Rewired player to be the input source for your game player1 and change that assignment to a different Rewired player at will if need be.
    3) There is no concept of "control schemes" or "control sets" in Rewired, as in combinations of multiple controllers that all get assigned at once. That doesn't mean you can't manage this yourself though. You can easily assign/deassign one or more joysticks, the mouse, keyboard maps, etc., from one or all Players.

    The way Rewired generally works in the most basic straightforward way is this:

    1) You are using joystick auto-assignment set to assign each joystick to each player consecutively as they become available. The first joystick plugged in goes to player 1, the next to player 2, etc.
    2) You have created a series of keyboard maps, one for each of your 4 players. You assign player 1 keyboard map to player 1 on start, player 2 keyboard map to player 2 on start, and so on.
    3) One player should get the mouse. You can assign this on start with a checkbox, or assign it via scripting.
    4) You can change and and all of these assignments of controllers and maps during runtime.

    However, this is nothing more than the basic use case. It's just how it works out of the box using auto-assignment. You can manage it however you like and there is a huge API to help you achieve just about anything you want to.

    The absolute only extra step I see in what you want to do is the fact that you will have to detect which controller (be it a joystick, mouse, or specific map on the keyboard) has been pressed and assign that manually to a Player. You will then assign that Rewired Player id to your game player (again, which may or may not correspond to the same ID as the Rewired player.)
     
    Last edited: Jan 26, 2015
  6. HiVE-interactive

    HiVE-interactive

    Joined:
    Oct 11, 2013
    Posts:
    14
    Guavaman, first I'd like to say thanks for what looks like a great project, I'm looking forward to getting the most out of Rewired. Secondly, I'd like to ask for some help ;)

    I Purchased and imported Rewired today to start doing some tests using Xbox 360 controllers with both Windows and OSX - made a simple scene and followed the 'Getting Started' guide to configure the input manager for 4 controllers with all action buttons as "Test". Made a simple code to detect button presses using mostly default setup and I had success with this in the editor on Windows - 4 players detected presses correctly.

    I cannot get the same scene to reproduce these results on OSX. No button presses are detected using the same script which is successful on Windows. With Tattiebogle installed, my Mac detects and correctly displays connected controllers - button presses are also detected in the Tattiebogle pref pane. Using your 'OSXJoystickElementIdentifier' and also the 'ControlRemapping1' scene - I can also see that all of my controllers are registering correctly through Rewired - so I am at a loss as to why my code is not detecting button presses.

    Is there something in the 'Getting Started' setup that needs something Mac specific? or something else I am missing... for my mac builds, how can I go about correctly reading input from these connected controllers in a simple fashion?

    For the scene, here is the script I attached to 4 cubes:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Rewired;
    4.  
    5. public class CubeController : MonoBehaviour
    6. {
    7.     public int playerId = 0;
    8.     private Player player;
    9.  
    10.     private Renderer cubeRenderer;
    11.     private bool testSuccess;
    12.  
    13.     void Awake()
    14.     {
    15.         player = ReInput.players.GetPlayer(playerId);
    16.         cubeRenderer = transform.renderer;
    17.     }
    18.  
    19.     void Update ()
    20.     {
    21.         GetInput();
    22.         ProcessInput();
    23.     }
    24.  
    25.     private void GetInput()
    26.     {
    27.         testSuccess = player.GetButton("Test");
    28.     }
    29.  
    30.     private void ProcessInput()
    31.     {
    32.         if(testSuccess)
    33.         {
    34.             Debug.Log ("Player_" + playerId + " is pressing buttons!");
    35.             if (cubeRenderer.material.color != Color.red)
    36.             {
    37.                 cubeRenderer.material.color = Color.red;
    38.             }
    39.         }
    40.         else
    41.         {
    42.             Debug.Log ("Player_" + playerId + " is NOT pressing buttons!");
    43.             if (cubeRenderer.material.color != Color.white)
    44.             {
    45.                 cubeRenderer.material.color = Color.white;
    46.             }
    47.         }
    48.     }
    49. }
    50.  
     
    Last edited: Jan 27, 2015
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    @BS_Dev

    Thanks! I hope you get a lot of use out of it!

    There's nothing Mac specific you have to do to get an Xbox 360 controller working apart from using the Tattie Bogle drive as you have done.

    Here's a question: Are these actual Microsoft Xbox 360 controllers or another brand? This can make a difference on OSX because non-MS controllers may identify themselves with different Product Id and Vendor Id making Rewired not recognize the controllers. This wouldn't happen on Windows if you're using XInput because Product Id and Vendor Id are not used by XInput. (If you were to disable XInput in Windows this may also happen.)

    Please run the 'OSXJoystickElementIdentifier' again and tell me what you get for these fields:
    • Product Name
    • Manufacturer
    • Product Id
    • Vendor Id
    • Axis Count
    • Button Count
    • Hat Count
    Another thing you can try is to open the ControlRemappingDemo1 scene and press ESC. Then check what names the controllers are showing up as (and tell me). Then you can select a player, select the controller, then click Calibrate and see how many Axes show up. If you see 32 axes, it's loading the Unknown Controller map because it can't recognize the controller based on the matching criteria it finds.
     
  8. HiVE-interactive

    HiVE-interactive

    Joined:
    Oct 11, 2013
    Posts:
    14
    @guavaman

    Thanks for getting back so quickly :) greatly appreciated.
    You are correct in guessing that they are actually non-MS controllers, they are RockCandy controllers. Also - after running the RemappingDemo I have confirmed that the Unknown Controller map is being loaded because 32 axes are displayed when calibrating.

    Running ElementIdentifier here are the details:
    • Product Name: Rock Candy Gamepad for Xbox 360
    • Manufacturer: Performance Designed Products
    • Product ID: 287
    • Vendor ID: 3695
    • Axis Count: 6
    • Button Count: 15
    • Hat Count: 0
    I am a bit confused as to how to correctly setup an Unknown Controller map for correct use - excuse me for being a Rewired noob, but what steps should I take now?

    once again, thanks for the help :)
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    @BS_Dev

    Ahh, as I suspected.

    You don't want to make an Unknown Controller map because that applies to ALL unknown controllers, not just this Rock Candy controller. You can read about Unknown Controller maps and how they're useful here: http://guavaman.com/projects/rewired/docs/ControllerMaps.html

    So there are a couple of ways to deal with this:

    1) Create a new controller definition for this controller specifically. (Instructions: 1, 2)
    2) Add the relevant information to the HardwareJoystickMap for the Xbox 360 controller, assuming all the button assignments are identical which is probably a safe bet.

    I would probably go with #2. Since you're not the first to ask about Rock Candy Xbox 360 controllers on OSX, I will probably add this myself to the Xbox 360 controller profile in the next release. But in the mean time, you can do this:

    1) Go to the Rewired/Internal/Data/Controllers/HardwareMaps/Joysticks folder and locate the MicrosoftXBox360 file. Click it, and in the inspector click "Launch Hardware Joystick Map Editor."
    2) Go to the OSX Native page.
    3) On the Matching Criteria tab, add an entry under Manufacturer and in that field enter "Performance Designed Products" (without the quotes).
    4) Add an entry under Product Name and in that new field, enter "Rock Candy Gamepad for Xbox 360" (without the quotes).
    5) Add an entry under Product Id and in that new field enter "287" (without the quotes).
    6) Add an entry under Vendor Id and in that new field enter "3695" (without the quotes).

    If you have any interest in supporting Webplayer, you'll also want to do the same for the OSX Fallback tab. The difference here is the only identifying information for matching criteria is the joystick name, which you can find by using the UnityJoystickElementIdentifier.

    Be aware that if you update Rewired and this new Rock Candy controller isn't added (for example, you download the latest 1.0.0.25 update from the asset store once it goes live in a few days), your changes to this file will be undone (unless you untick the box on this file when doing the update).

    In order for me to add this to the next release, I'd need to get also the same identifying information from the other DevTools:
    UnityJoystickElementIdentifier in OSX
    UnityJoystickElementIdentifier in Windows
    RawInputJoystickElementIdentifier in Windows (including the Product GUID but not the instance GUID)
    DirectInputJoystickElementIdentifier in Windows (including the Product GUID but not the instance GUID)

    If you don't mind getting me this info, that would be great. Otherwise, I'll order one.
     
  10. HiVE-interactive

    HiVE-interactive

    Joined:
    Oct 11, 2013
    Posts:
    14
    @guavaman

    Will read about unknown maps and try work through editing the current maps to allow use of my current controllers. I will get back to you soon to let you know if I have any more issues :)

    In the meantime, here is the information you requested (I think it's all there!). Thanks dude!

    Product Name (UnityJoystickElementIdentifier in OSX
    ):
    Performance Designed Products Rock Candy Gamepad for Xbox 360

    Product Name (UnityJoystickElementIdentifier in Windows):
    Rock Candy Gamepad for Xbox 360 (Controller)

    Joy Details (RawInputJoystickElementIdentifier in Windows):
    • Product Name: Rock Candy Gamepad for Xbox 360 (Controller)
    • Product GUID: 011f0e6f-0000-0000-0000-504944564944
    • Product Id: 287
    • Vendor Id: 3695
    • Axis Count: 5
    • Button Count: 10
    • Hat Count: 1
    Joy Details (DirectInputJoystickElementIdentifier in Windows):
    • Product Name: Rock Candy Gamepad for Xbox 360 (Controller)
    • Product GUID: 011f0e6f-0000-0000-0000-504944564944
    • Product Id: 287
    • Axis Count: 5
    • Button Count: 10
    • Hat Count: 1
    EDIT:
    Adding those details to the mappings has fixed the issue - the controller's button presses are detecting fine.

    As I am intending on supporting many known controllers though, I will add mappings for a bunch of different controller types - along with an unknown mapping as our game is arcade style and small enough to ignore a mapping screen, a large blanket of controller support should be fine. Do you think this is enough.. or are there any other methodologies you would apply to achieve greatest support for controller variance?
     
    Last edited: Jan 28, 2015
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Thanks! I will use this to add support for the Rock Candy 360 controller. :)

    Rewired already includes direct support for a ton of controllers (I've bought dozens of them and have had a bunch loaned to me for mapping. I currently have about 20 more sitting here I am slowly mapping.) I think the out-of-the-box support already covers most controllers players are likely to use. For gamepads, just map the Dual Analog Gamepad Template and you will have created maps for all of the gamepads Rewired comes with support for and any that are added in the future.

    But the issue of off-branded Xbox 360 controllers on OSX is a possibility that is best remedied by having a remapping screen unless you're willing to buy every brand of Xbox 360 controller you can find and add their pid/vid/name/guid info. If you do that, please share the information so I can add them.

    However I do think I will need to slightly modify the Matching Criteria system before this will be foolproof. Right now on OSX it matches by: if any vendor id in the list matches and any product id in the list matches then it's a match. That allows for the possibility of a vendor id and a product id that don't belong together to match and could lead to problems. I'm going to have to modify it so that they match in corresponding pairs so that huge lists of prodid/vendorids won't cause inaccurate matches. Edit: Okay, this change will roll out in the next update. So if you have multiple PID's from the same VID, just duplicate the VIDS so they form pairs index to index.
     
    Last edited: Jan 28, 2015
  12. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    275
    Hey @guavaman. Would it be possible to make this plugin directory-agnostic? It currently breaks if you move it into a subfolder in Assets - which is kind of annoying. I personally like to group my plugins in subfolders so as to not crowd the heirarchy.
     
  13. Zionmoose

    Zionmoose

    Joined:
    Oct 17, 2012
    Posts:
    237
    +1 If this is true.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    It shouldn't. I went through great pains to make it so it would run in any subfolder provided you A) don't rename the main Rewired folder to something else and B) don't go moving any of the internal folders inside the Rewired folder around.

    What problems are you having and what platform and Unity version are you on? I just tested and have no problems moving it into even several subfolders deep.

    But nothing can be done about the fact that when I add new controller definitions or other files and you upgrade Rewired, if you've moved the Rewired folder, Unity is going to extract those new files into a root-level Rewired folder. That's Unity's Unitypackage format's issue.
     
    Last edited: Jan 28, 2015
  15. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    For what it's worth, I have Rewired in a sub-directory and it works fine.

    This does indeed suck, though. It's out of your hands, but this issue plus not being able to import an asset into a specific folder are the two biggest issues with Unity's .unitypackage handling, in my opinion.
     
    HiVE-interactive and guavaman like this.
  16. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    275
    Yup, my bad! Something strange was going on, I moved it back out and back in and now it seems to be working fine.
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Glad to hear it!
     
    HiVE-interactive likes this.
  18. HiVE-interactive

    HiVE-interactive

    Joined:
    Oct 11, 2013
    Posts:
    14
    no worries! Glad I could help :)

    I think I will rely on the template and also the fact that I doubt many will be using exotic controllers with their Mac anyways. If we do run into issues, then I will work on some in-game reconfiguration meta stuff. I think it will be fine. Will save me having to purchase bulk controllers... which seems strange anyhow, can't you access pid/vid/guid etc. online somewhere - or is this information that manufacturers are reluctant to release? Interesting :)

    Once again, @guavaman - thankyou for your help and a great asset, just gave you 5 star on the store (y)
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Sadly, no. Even sadder, many manufacturers just don't care and put useless or nonsensical information into these fields. One company I've run into a LOT when it comes to generic controllers is Dragon Rise, Inc. They use the exact same product name, manufacturer name, product id, vendor id, and all other identifying information on dozens and dozens of different controllers they manufacture for a ton of different companies (including surprisingly SteelSeries) regardless of the joystick layout, number of buttons, etc. What this means is these controllers simply cannot be mapped because there's no way to tell what's plugged in. In that case, there's no choice but to let the player map it themselves. I always love ordering a new gamepad only to plug it in an see Dragon Rise, Inc... >_<

    NP and thanks! :D
     
  20. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,391
    The USB Vendor ID has a licensing cost associated with it from the USB organization. For specifics see http://www.usb.org/developers/vendor. Which makes sense since the USB organization has to maintain the USB specification (which is good reading material), marketing, and so forth as you would expect.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    That's true. Many manufacturers don't seem to follow this. It can also be problematic when Bluetooth and WiFi control devices are thrown into the mix as they don't all provide this type of information since they're not USB.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Rewired 1.0.0.25 is now live on the Unity Asset Store.

    1.0.0.25 Release Notes:
    Bug Fixes: - Fixed issue with event-based input causing a Player's events to fire for every Player.

    1.0.0.24 Release Notes:
    Changes:
    - Changed the axis count formula for Raw Input to more closely match results from Direct Input.
    * IMPORTANT * If you've created your own controller definitions, be sure to verify and update the axis count value for Raw Input in the Matching Criteria as this update may cause the axis count to return more axes than before.

    New Controller Definitions:
    - Saitek X-55 Rhino Stick
    - Saitek X-55 Rhino Throttle
    - OUYA Gamepad
    - Sony DualShock 2 (requires Insten PS2 to PS3 USB converter)
    - Radio Shack PC Gaming Controller (2603666)

    Modified Controller Definitions:
    - Linux: Added DualShock 4 on Bluetooth
    - Windows, OSX, Linux: Added Red Samurai Wireless Controller mappings on Bluetooth

    Bug Fixes:
    - Fixed AOT compiler failure when building to WiiU platform.
    - Fixed problems with fallback joystick identification when a joystick has buttons that are always on.
    - Raw Input: Fixed detection of buttons on certain devices when button HID usages are not sequential.

    Other:
    - Minor speed improvements to HardwareJoystickMap editor.
     
    Last edited: Jan 29, 2015
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Hi @BS_Dev,

    In looking at your results I'm noticing something odd. Your Windows results are returning the specific name of the gamepad + (Controller) in parenthesis like this:
    Rock Candy Gamepad for Xbox 360 (Controller)

    However, other resources I find with this controller and the original MS Xbox 360 controller does it the opposite way:
    Controller (XBOX 360 For Windows)
    Controller (Xbox 360 Wireless Receiver for Windows)

    Including the Rock Candy controller:
    Controller (Rock Candy Gamepad for Xbox 360)

    I even find on this page that both variations were posted for the Rock Candy:
    https://forums.frontier.co.uk/archive/index.php/t-17280-p-11.html

    I'd like to figure out why. What versions of Windows and Unity are you using?
     
  24. HiVE-interactive

    HiVE-interactive

    Joined:
    Oct 11, 2013
    Posts:
    14
    @guavaman this is interesting! Strange that two different sets of results are coming up on that page...

    I just checked my results again and I can confirm -

    Product Name (UnityJoystickElementIdentifier in Windows):
    Rock Candy Gamepad for Xbox 360 (Controller)

    I am using Unity v4.6.1f1 (latest) with Windows 7 Professional.

    I'd like to help too - but I'm not sure how. One thing I have noticed though, which may be of use, is that we actually have different types of rock candy gamepads here - some with rumble motors and some without... the ones I am using atm and the ones I have replied results for are the controllers without rumble motors. I will try devtesting the other controllers and see if I get different results.

    EDIT:
    Details for the other RockCandy controllers with rumble packs are as follows:

    Product Name (UnityJoystickElementIdentifier in Windows):
    Rock Candy Gamepad for Xbox 360 (Controller)

    Joy Details (RawInputJoystickElementIdentifier in Windows):
    • Product Name: Rock Candy Gamepad for Xbox 360 (Controller)
    • Product GUID: 021f0e6f-0000-0000-0000-504944564944
    • Product Id: 543
    • Vendor Id: 3695
    • Axis Count: 5
    • Button Count: 10
    • Hat Count: 1
    Joy Details (DirectInputJoystickElementIdentifier in Windows):
    • Product Name: Rock Candy Gamepad for Xbox 360 (Controller)
    • Product GUID: 021f0e6f-0000-0000-0000-504944564944
    • Product Id: 543
    • Axis Count: 5
    • Button Count: 10
    • Hat Count: 1
    Hope this helps somehow..
     
    Last edited: Jan 29, 2015
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Okay, thanks! The more GUIDS the merrier! It's not critical because I can do some regex matching anyway should it not find the right GUID. I'm going to make the X360 profile as robust as I can to catch as many clone controllers on Windows non-XInput and OSX. It will be in the next release which will probably be in a day or two.
     
  26. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,391
    This is amazing to have all of the buttons available on the Saitek X-55 (HOTAS) Flight Simulation controller.
    They certainly have more than enough buttons to work with.

    Rewired_Saitek_X55_stick.JPG

    Rewired_Saitek_X55_throttle.JPG
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Rewired 1.0.0.26 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. 1.0.0.26 has been submitted to the Asset Store and should be available there in 3-10 days.

    ---------------
    1.0.0.26 Release Notes:


    New Controller Definitions:
    - Mad Catz C.T.R.L.R
    - Amazon Fire Game Controller
    - Amazon Fire TV Remote
    - Google Nexus Player Gamepad
    - Google Nexus Player Remote
    - GameStick Controller
    - idroid:con Snakebyte (Mode 1 & 2)
    - ípega Wireless GAMEPAD Controller
    - ípega BLUETOOTH Classic GamePad
    - CH Products Throttle Quadrant


    Modified Controller Definitions:
    - Improved generic controller detection in XBox 360 controller definition.
    - Added Back button functionality to Nvidia Shield Controller definition.


    Changes:
    - Added UnityUI RewiredStandaloneInputModule integration for Unity 4.6+.
    - Integration packages are now automatically updated when Rewired is updated.
    - OSX Native Matching Criteria changed to require Product Id and Vendor Id pairs in the corresponding array indices to match.
    - Added KeyCode source for joystick buttons/axes in HardwareJoystickMap.
    - Added Disable option to Matching Criteria in HardwareJoystickMap.
    - Added custom inspector to ControllerDataFiles.


    Modified Enums:
    - Added Rewired.Data.Mapping.HardwareElementSourceType.Key = 2
    - Added Rewired.Data.Mapping.HardwareElementSourceTypeWithHat.Key = 3


    ---------------


    The next controller update will include a bunch more flight controllers. They take a while to map, so stay tuned.
     
    Last edited: Jan 30, 2015
    HiVE-interactive likes this.
  28. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,391
    I almost missed the flight simulation controller (CH Products Throttle Quadrant) that you added in this update. The CH Products Throttle Quadrant is great for multi-engine flight simulations and a perfect compliment to the CH Products Eclipse Yoke.
     
    guavaman likes this.
  29. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    532
    Woa! Hang on. Ouya controller support!? Daymn, I missed you sneaking that in! A few questions before I start my mass port!
    1. Does that include Ouya controller support on Ouya ? (The compatibility table says it works on Android ... which Ouya is... so ... :) ?)
    2. Does it support the System Button (the central U button on Ouya controllers)?
    3. Is System Button uniformly handled on all platforms for all controllers? Especially the 2x4 matrix of combining...
      (Controller: Ouya or XBox 360)
      with
      (Platform: Ouya, PC, Mac, Linux)?
      Important ones for me being...
      1. Platform: Ouya + Controller: Ouya
      2. Platform: Ouya + Controller: XBox360
      3. Platform: PC + Controller: Ouya
      4. Platform: PC + Controller: XBox360
    Excited! Thanks!
    (EDIT: Formatting to switch "Platform:pC" to "Platform: PC" cuz, well, yeah, ok, maybe it is a bit :pC ;-) )
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    This is not what you're hoping for yet, sorry. This is simply mappings for the Ouya controller through Raw Input, Direct Input, OSX I/O kit, Unity Input on Windows, Unity Input on OSX, Unity Input on Linux, and Unity Input on Android. Quite a while ago, Ouya released the Ouya EverywhereSDK including a plugin for Unity which they advise to always use for Input on Ouya (presumably because Unity's built-in handling of multiple controllers is so bad).

    I do now have an Ouya sitting here, so hopefully I will get to incorporating that along with other native Android SDKs (Moga) in some time after the large number of other pending additions.

    It will probably work because it is Android, but again, you miss out on any benefits the Ouya Everywhere SDK provides, hot-plugging being a very important one I imagine.

    From that link I posted above:
    None of the above is happening through Unity's input manager. For real, proper Ouya controller support the Ouya Everywhere SDK will have to be implemented as a new input source for Rewired.

    It does, but it's very odd. The button only returns a press for one single frame on button release. It's not possible to detect a press and hold of it for some reason.

    Xbox 360 button is not mappable on any platforms including PC. On Android, it is not mappable because it's always detected as Home.
     
    Last edited: Jan 30, 2015
    Arkade likes this.
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Small but important bug fix update:

    Rewired 1.0.0.27 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The new version has been submitted to the Asset Store and should be available there in 3-10 days.

    ---------------
    1.0.0.27:
    Bug Fixes:
    - Unknown Controller map is now loaded correctly for unrecognized devices on Direct Input platform.
    ---------------

    This bug was introduced in 1.0.0.15. Most users are probably using Raw Input (as it's the default for Windows) which worked as intended.
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Okay, another really important bug fix update everyone on 1.0.0.24+ needs to get... Sorry about that!

    Rewired 1.0.0.28 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The new version has been submitted to the Asset Store and should be available there in 3-10 days.

    ---------------
    1.0.0.28:
    Bug Fixes:
    - Fixed bug introduced in 1.0.0.24 that broke mouse and CustomController axes.

    ---------------
     
  33. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    Hi there, I have a user for who the keyboard doesn't work with Rewired.
    He's got a USB Saitek cyborg keyboard v7 and I sent him the demo scene and Escape doesn't work when it asks to press escape before showing all the players, maps, controllers, etc.
    Any idea?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    If that's the case, then his I suspect keyboard isn't going to work with Unity at all. Rewired's keyboard handling is just passed through from Unity KeyCode input. There's no native keyboard handling on any platform at present.

    Here's a super simple script that shows what KeyCodes Unity reports when a key is pressed on the screen:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class KeyCodeTester : MonoBehaviour {
    5.  
    6.     private GUIText text;
    7.     private int[] values;
    8.  
    9.     void Awake () {
    10.         text = gameObject.AddComponent<GUIText>();
    11.         text.anchor = TextAnchor.LowerLeft;
    12.         text.alignment = TextAlignment.Left;
    13.         transform.position = Vector3.zero;
    14.  
    15.         values = (int[])System.Enum.GetValues(typeof(KeyCode));
    16.     }
    17.  
    18.     void Update () {
    19.         text.text = "KeyCode Tester:\n\n";
    20.  
    21.         for(int i = 0; i < values.Length; i++) {
    22.             if(Input.GetKey((KeyCode)values[i])) text.text += ((KeyCode)values[i]).ToString() + "\n";
    23.         }
    24.     }
    25. }
     
  35. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    But it did work before I integrated Rewired. That's what's weird about it.
    I will try to figure it out, do tell me if you have other hints on what could have gone wrong.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Okay, please give me some more information:
    User's OS
    Your Unity version used to build
    Rewired version

    When you say you "sent him the demo scene", do you mean the ControlRemappingDemo1 scene? That scene does incorporate PlayerPrefs for saving user mapping. PlayerPrefs is stored in the registry. Are you also using PlayerPrefs in your game to store mapping information in the same format as that example scene? Is the project file you sent your user built with the same project name as your game? (Registry entries for PlayerPrefs are stored under the Company/Project name.)

    When ControlRemappingDemo1 is loaded, it loads all the last saved maps from PlayerPrefs. If these were modified by your game or something else, then something could be getting loaded wrong.

    Also, does the log file from your user say anything unusual?

    Has anyone else besides this user had this problem?
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    @Evil-Dog

    Here's a version of the above keyboard key script that gets the keyboard values from Rewired. This will determine if Rewired is getting the key data at all.

    You need to have a Rewired Input Manager in the scene for this to work. It can just be a blank new one.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Rewired;
    4.  
    5. public class RewiredKeyTest : MonoBehaviour {
    6.  
    7.     private GUIText text;
    8.     private int[] values;
    9.     private Keyboard kb;
    10.  
    11.     void Awake() {
    12.         text = gameObject.AddComponent<GUIText>();
    13.         text.anchor = TextAnchor.LowerLeft;
    14.         text.alignment = TextAlignment.Left;
    15.         transform.position = Vector3.zero;
    16.  
    17.         values = (int[])System.Enum.GetValues(typeof(KeyboardKeyCode));
    18.         kb = ReInput.controllers.Keyboard;
    19.     }
    20.  
    21.     void Update() {
    22.         text.text = "Rewired KeyCode Tester:\n\n";
    23.  
    24.         for(int i = 0; i < values.Length; i++) {
    25.             if(kb.GetKey((KeyCode)values[i])) text.text += ((KeyCode)values[i]).ToString() + "\n";
    26.         }
    27.     }
    28. }
    A few other things to check:
    1. If you're using player.GetButtonDown("Menu") or some such in OnGUI or FixedUpdate, make sure those update loops are enabled in the Rewired editor or you could miss some down events.
    2. Check your Input Behavior's Digital Axis settings for the Action(s) in question.

    Another question:
    • Do ALL keys fail for this user or just certain keys?
     
  38. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    Ok thanks that's useful hints and handy piece of code, I will check all this out with the user and keep you updated with results, thank you for the quick support. Much appreciated.
    Escape doesn't work in the controller remap demo, and the WASD, Numpad keys either in my game's main menu.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Please do keep me posted on the results.

    In case this is a mapping problem, here is another script that will show you all the keyboard maps assigned to all players, the number of elements in the map, the enabled state, and the element names with their corresponding mapped actions. (If you have a lot of players and a lot of keys mapped this may not all fit on the screen.)

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Rewired;
    4.  
    5. public class ShowPlayerKeyboardMaps : MonoBehaviour {
    6.  
    7.     private GUIText text;
    8.     private const string indent = "    ";
    9.  
    10.     void Awake() {
    11.         text = gameObject.AddComponent<GUIText>();
    12.         text.anchor = TextAnchor.LowerLeft;
    13.         text.alignment = TextAlignment.Left;
    14.         transform.position = Vector3.zero;
    15.     }
    16.  
    17.     void Update () {
    18.         string log = "";
    19.  
    20.         foreach(Player p in ReInput.players.Players) {
    21.             log += "Player: " + p.descriptiveName + "\n";
    22.             int kbmCount = 0;
    23.             foreach(KeyboardMap km in p.controllers.maps.GetAllMaps<KeyboardMap>()) {
    24.                 log += indent + "Keyboard map " + kbmCount + ": Cat = \"" + ReInput.mapping.GetMapCategory(km.categoryId).name + "\", Layout = \"" + ReInput.mapping.GetKeyboardLayout(km.layoutId).name + "\", Element Count = " + km.elementMapCount + ", Map is " + (km.enabled ? "Enabled" : "Disabled") + "\n";
    25.                 foreach(ActionElementMap am in km.ButtonMaps) {
    26.                     log += indent + indent + am.elementIdentifierName + " = ";
    27.                     InputAction action = ReInput.mapping.GetAction(am.actionId);
    28.                     if(action == null) {
    29.                         log += "NULL\n";
    30.                         continue;
    31.                     }
    32.                     log += action.name + "\n";
    33.                 }
    34.                 kbmCount++;
    35.             }
    36.             log += "\n";
    37.         }
    38.         text.text = log;
    39.     }
    40. }
     
  40. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    532
    Darn :-\ ... but thanks for the detailed reply!

    Well, glad to hear it's coming. Guess I'll be sticking with my spaghetti for now :-\

    Yep, guess so. I wonder whether one of the libraries (Ouya/Moga/?) might provide sufficient global coverage?

    Hm, which platform are you talking about here? On Ouya, the System button has specific semantics for different presses so game developers only get the single press one (because double (and hold previously) meant system menu (as opposed to single press which means in-game menu)).
    If that behaviour is also on desktop, I'm not sure. Perhaps firmware reports it specifically for Ouya so desktop sees it as something else?

    Oh. Well that's a total pain. So what do people do for controller-based games' menus? One can't really put it on any of the regular buttons. On Ouya, I have System button for menus. Elsewhere I have it on OuyaA/XBoxB which is a total pain on desktop as player button mashing brings up the pause menu in the middle of fun!
    Any suggestions? Surely there's a solution we're missing (or I'm missing something?).

    Thanks as always!
     
  41. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    Awesome very useful, I'll let you know how that goes.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    No. Ouya is for Ouya, Moga is only for Moga devices. It mentions in the link I sent you "This input API is targeted at the OUYA Android Console and associated devices and is not maintained as a cross-platform input system." Additionally, they expose only specific named buttons like "OuyaController.BUTTON_O". Neither is designed to be a general purpose input library.

    Are you currently using the Ouya Everywhere SDK for input on Ouya?

    On Android 4.4, not on an Ouya console. It also behaves the same way on Windows, OSX, and Linux.

    Most of the time these "special" buttons like back, home, media keys, etc. return key codes on Android which seem to be intercepted by the system first. They're not usually configured as HID buttons, and therefore are not even detectable as joystick buttons.

    Since Android support happens through Unity input as the underlying source at present, what you get depends on their interpretation of the Android key events and how they map them to Unity inputs. In this case, no Unity KeyCodes show up for that button though.

    Select/Back and Start usually. The XBox button, PS button, NVidia button, Ouya button, etc. all have special system functions on their respective platforms usually and aren't meant for the developer to remap to anything.

    The only platform I know of where the Xbox button is actually detectable is OSX, but that's only because the 3rd party TattieBogle driver exposes it.

    I'm not sure why you aren't just using Start on the Xbox to bring up the menu. As for Ouya, you could map it to the center System button on any platform (haven't tested on actual Ouya console yet to see what it does). I'm not 100% sure you would catch the press every time though as input from it only appears for the tiniest fraction of a second and I'm not sure that's tied to Unity's update rate. (Edit: Testing shows that it does not sync with Unity's update. Whether you catch it or not will depend on your current frame rate it seems so it should not be relied upon until Ouya SDK is implemented.) Otherwise, I'd suggest a button press combination of some sort which would have to be done manually in code. On any system with a keyboard, you can always move the system buttons off to that (ESC, etc.).

    Maybe I'm not understanding the problem entirely. Are you using Rewired for this? You can always make separate maps for the different controllers if you need different Action layouts for each device instead of (or in addition to) using the Dual Analog Gamepad Template.
     
    Last edited: Jan 31, 2015
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Rewired 1.0.0.29 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address.

    1.0.0.29 will be submitted to the Asset Store after 1.0.0.28 is approved so as to not interrupt the approval process due to the important bug fix in that version, so it may be a significant delay before 1.0.0.29 is available on the Asset Store.

    Release Notes:

    1.0.0.29:
    New Controller Definitions:
    - 8Bitdo NES30 Gamepad

    Modified Controller Definitions:
    - Disabled definition for ípega Wireless GAMEPAD Controller in Direct Input and Windows Fallback due to identification conflicts. Raw Input now works for this controller due to Bluetooth enhancements.
    - Disabled definition for ípega BLUETOOTH Classic GamePad in Direct Input and Windows Fallback due to identification conflicts. Raw Input now works for this controller due to Bluetooth enhancements.
    - Fixed definition for Mad Catz C.T.R.L.R on Direct Input.
    - Added editor controller names to and refined public names of various controller definitions.

    Changes:
    - Made Bluetooth controller identification more robust in Windows Raw Input platform to be able to better identify certain Bluetooth controllers.
    - Added Editor Controller Name to HardwareJoystickMap to allow displaying a different controller name in the Rewired Editor for developer use.
    - Added Split Axis to HardwareJoystickTemplateMap to allow mapping an axis to two buttons through a template.

    API Changes:
    - Added ReInput.MappingHelper.GetLayout(ControllerType controllerType, int layoutId)
    - Added ReInput.MappingHelper.GetLayout(ControllerType controllerType, string name)
    - Added ReInput.MappingHelper.GetLayoutId(ControllerType controllerType, string name)
    - Deprecated Player.ControllerHelper.MapHelper.SetMapsEnabled(bool state, int categoryId, int layoutId)


    Bug Fixes:
    - ReInput.MappingHelper.MapLayouts(ControllerType controllerType) can now return CustomController layouts.
    - Player.ControllerHelper.MapHelper.SetMapsEnabled(bool state, string categoryName, string layoutName) now works correctly.
    - Player.ControllerHelper.MapHelper.SetMapsEnabled(bool state, ControllerType controllerType, string categoryName, string layoutName) now works correctly.
     
  44. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    275
    Hey guavaman. Just wondering if there's more examples out there that might be a bit simpler than the ones included in Rewired. I'm trying to get my head around some of the more advanced concepts, and the examples are just a bit too monolothic right now.

    Specifically, I'm looking for simple runtime mapping reassignment stuff.

    Edit: Also, I can't seem to find the RewiredStandaloneInputModule script anywhere. Where is it in the plugin?
     
    Last edited: Feb 2, 2015
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    Unfortunately, user mapping screens involve so many different parts of the API there’s no way to make a very very simple demo that will do all the things you’re expecting it to do. Specifically, a user mapping screen must do at least the following:
    • Assigning controllers
    • Assigning the mouse
    • Listing all user mappable actions
    • Assigning buttons and axes via polling for the next input on a per-controller basis
    • Removing, editing, and adding new assignments.
    • Modifying a keyboard map by detecting a key press, including up to 3 modifier keys
    • Modifying a mouse map by detecting mouse axis movements and mouse buttons
    • Modifying a joystick map by detecting joystick axis movements and joystick buttons
    • Must be able to distinguish between split axis assignments and whole axis assisgnments
    • Must be able to map axes to buttons and buttons to axes
    • Calibrating controller axes
    • Conflict checking among the same controller type across all players in different maps to make sure the player isn’t assigning something that conflicts with another assignment
    • Detect controller disconnect/connect events and update the GUI when necessary no matter what is currently happening
    • Handle fallback platform issues for platforms such as webplayer where it requires user interaction to identify the controllers on connect/disconnect (so Unity’s joystick Ids match the physical joysticks).
    Optional:
    • Doing all of the above for multiple players
    • Listing all Players and switching among them
    • Saving and loading Controller Map XML files after making changes so your users' data stays on the next play.
    • Saving and loading axis calibrations and Input Behaviors
    • Handle multiple categories of maps per device
    • Designating some categories as not-user-assignable so they are locked (for things like System type actions)
    • Action category selective conflict checking.
    To achieve all of this requires a lot of code, which is why the remapping demo is quite large. For this to be simple from a code-perspective would mean handling the majority of these things behind the scenes and just giving you a simple but limited one-size-fits-all interface like other packages out there. I chose to make Rewired open so you could tailor it to the needs of your game, from very simplistic single-player games to multiplayer games with very complex input requirements.

    Depending on your game, potentially certain things could be left out, for example, if your game is 1-player you could simply leave out the ability to choose your player and always assign everything to Player 0. If you decided you aren’t going to use map categorization and only have 1 map per controller, it could be simplified by removing the categorization system. You COULD leave off calibration, but I wouldn’t do it because the player may use an unknown device with axes that are stuck at –1 for instance and have no way to fix those axes. Regardless, were you to remove all of these, it wouldn’t greatly shorten the length of code required.

    The best way to learn about those topics is to look through the code. I can’t think of any other way to make it easier. I have planned to do some more user mapping screens using the new 4.6 GUI with different levels of complexity (1-player game, no categories, 1-player game with categories, 2 player game etc.) But that’s still not ready at the present time.

    It was added to Rewired in 10.0.0.28 which is not available on the Unity Asset store yet. Contact me with your email address and I'll give you access to download 10.0.0.29 right away. Or else you can find the script in the first page of this thread.
     
  46. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    275
    I mean I'd have to disagree with that first list. The vast majority of those things on it I have no need for. My game does not support joysticks, or custom controllers, or players, or modifier keys, or split axis/whole axis stuff, or calibration, or conflict checking, or anything like that. My use case is literally one keyboard map, with one assignable action that should be assignable to any normal, single key on the keyboard, and saving/loading that mapping.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    That is a very unusual and limited use case only supporting the keyboard and one single Action.
     
  48. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    275
    True, and both of those things are perfectly fine for my current project.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,363
    I don't know if this will help, but this is a completely stripped down version of the ControlRemappingDemo that only allows 1 player to remap keyboard keys for the Default Action category. The player must be assigned the Default keyboard map for it to work.

    You will see it's still 1,000 lines of code. You have to realize that 95% of that code is GUI related managing the modal boxes and such. Everything is well organized into regions. If you're on Windows and you're not using it, I suggest getting Visual Studio Community Edition so you can fold those regions and read the code easier.

    It was never the purpose of the demo to be a usable remapping screen. It was meant as a learning tool to show you the whole API in action.
     

    Attached Files:

    Last edited: Feb 3, 2015
  50. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,391
    Rewired 1.0.0.28 is available in the asset store now.