Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    i am working on a game that uses keyboard + mouse, and can also use controllers. I've wired up the controller's horizontal/vertical axis so that it works with my mouselook script, but the sensitivity is much different. controller needs a lower sensitivity, while mouse needs higher sensitivity.

    Do you have any suggestions as far as a proper way of implementing mouse sensitivity vs controller sensitivity?

    Is there a way I can determine the source of the input? For example, whether input is coming from the mouse or a controller?
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No because Player input is a combination of all input from all controller types. Once the water is in the bucket there's no way to tell which cup(s) it came from.

    The solution every time when you need to treat input for various controller types differently is to create multiple Actions, one for each controller type you need to process individually. I may add a controller/joystick sensitivity setting to InputBehavior at some point like exists for the mouse. But this question comes up a lot in relation to many other controller-type specific issues. In all those cases, creating multiple Actions is the best approach.
     
    Last edited: Jan 2, 2015
  3. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Sorry if I over looked this question some where else in this thread, but with the Rewired Standalone Input Module you posted, how do we control how the input navigates our UI? I assume its with how the UI components are laid out, but for some reason when I'm pushing up to go through the UI it skips over one of the UI elements. Any thought on what I'm doing wrong?
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Unfortunately, I'm not an expert with Unity's new UI system. The Rewired Standalone Input Module is just a very slightly modified version of Unity's open-source Standalone Input Module with no changes other than that input in retrieved from Rewired instead of UnityEngine.Input. You might be able to get better help in the Unity UI forum.
     
  5. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    ok ill try there, thaks Guavaman
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.21 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.21 release notes:
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @philwinkel

    The latest update I mentioned in the previous post might be useful to you. Now you can set Joystick and Custom Controller sensitivity in an Input Behavior (runtime modifiable, save/load via XML).
     
    p87 likes this.
  8. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Wow, sweet. I hacked this together manually, but built-in support is pretty awesome!
     
    guavaman likes this.
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.22 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.22 release notes:
    The UFPS integration pack reroutes all input from vp_Input to Rewired. It does so without making any modifications to the UFPS source code so you don't have to worry about updating UFPS and breaking the integration. All you have to do is install it from the menu and add a Rewired UFPS Input Manager to the scene from the menu (which will give you default control mappings for mouse, keyboard, and dual analog gamepads). For usage instructions, see this page of the docs.
     
    Karearea likes this.
  10. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is great news on the UFPS integration. Thanks again.
     
    Last edited: Jan 7, 2015
    guavaman likes this.
  11. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Great work! I'm actually interested in how you managed to do that, as I had to do a bit of extra work to get them to play nicely. Any insight? It might clean up my custom input manager significantly.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The source code for the integration pack is visible so you can just look at it and see how it was done. It basically amounts to overwriting the mInstance variable in vp_Input on Awake and substituting a reference to a new class that inherits from vp_Input (and hence has access to the protected mInstance variable). The instance methods in vp_Input are all declared virtual, so it's just a matter of overriding those. All calls to vp_Input.GetButton, GetAxis, etc. can be rerouted. The other methods for changing button assignments through UFPS don't work, however.
     
  13. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Ah, alright. Clever solution! I would have checked the source myself, but I was unable to today, so thanks for the rundown.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.23 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.23 release notes:
     
  16. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318

    guavaman, thanks so much for the updates! This will be very helpful! Also, btw - thank you for nvidia shield controller mappings! Really appreciate the top notch support!
     
    guavaman likes this.
  17. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    http://docs.unity3d.com/Manual/script-SelectableNavigation.html
     
  18. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Is it possible to get the inputs associated with an Action? I'm trying to get something akin to KeyCodes for my Actions (so I can display the name of a key, etc.) but I can't quite figure it out. I'm sure it's something dumb I'm doing (or not doing) so any advice is much appreciated.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi,

    See this post on that topic a couple of pages back. It can be a bit complicated because you can have any number of controllers with any number of elements assigned to the same Action.
     
  20. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Wow, I can't believe I missed that. Thanks! I knew that Rewired had to have something for this. :)
     
  21. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I've successfully implemented code to show onscreen prompts for inputs of the last used input device (thanks to that post). I can share what I did if it's helpful.
     
  22. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Very kind of you, @Steve Tack! More code is never a bad thing -- it'd be interesting to see. I was just going to get the ActionElementMaps from the Controller/Keyboard/MouseMaps, but if you're willing to share that'd be pretty awesome of you. :)
     
    Last edited: Jan 13, 2015
  23. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Please post your code. Thanks Steve. As @electroflame said the more code the better.
     
  24. Hyper-Luminal-Games

    Hyper-Luminal-Games

    Joined:
    Jun 24, 2014
    Posts:
    108
    Hi, thought I'd ask this here for everyone's benefit.

    Is it possible to use Rewired in connection with NGUI for menu navigation? NGUI provides an Axes and Keys input section which references the Unity Input names. By using Rewired the Unity Input system is no longer used resulting in no connection to the NGUI input system. Is there some trick to enabling this? without having to rewrite NGUI's input to use Rewired (which I'm planning on beginning shortly if needed haha)
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi,

    I've never used nGUI, but if they just grab input from UnityEngine.Input directly, then there is no trick that's going to change that input source to Rewired. You will either have to modify the nGUI scripts that get input, or, if the nGUI scripts are structured in such a way that allows this, create a bridge like I did for UFPS using inheritance and overriding to change those input source after the fact. There may also be other ways to achieve this like, if they store the input values in public variables, you could just overwrite those every frame with Rewired, etc. It really all depends on how nGUI's scripts are structured.

    Another option is to do like I did with the uGUI input module. If nGUI has a special component that handles the input, make a copy of that script, change the source to Rewired, and replace that component on the object in the scene.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.23 is now live on the Unity Asset Store.

    Release Notes:
     
  27. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Ok, here's the info on how I display input "glyph" icons for Rewired controls. In a particular component's Update, I call the method CheckForControllerTypeChange() listed below. The timer is set to do its thing once per second or so.

    I have a class called InputGlyph that contains pointers to a background sprite, foreground sprite, and a foreground label. Each one represents a particular input prompt in the game's UI. The idea is that I construct input prompts by combining a generic background with a specific foreground. So an "A" button on 360 is a round background sprite with an "A" label on top. A triangle button on PS4 is a triangle on a circle. And "F1" on keyboard is a square background with an "F1" label on top. If you wanted controller-specific images, you'd have to go further and look at specific device GUID's that Rewired assigns. I don't need to get that specific in my game though.

    The basic idea is you attach an InputGlyph to any GameObject that contains the background sprite, with specific names for a foreground sprite and foreground label as children of that GameObject. InputGlyph has two public properties you can set, Action and AxisContribution. "Action" is the name of the Rewired action and AxisContribution is an optional value for when you need to show one half of an axis. Like my map zoom in and out controls are on one axis, but I want to show separate controls for + and -.

    In that case, I fill the values like this:



    If it's just a simple button, Axis Contribution is blank.

    An array of InputGlyph's is generated up front for all of them within each particular UI hierarchy. I extended a screen manager I wrote to incorporate that. The CheckForControllerTypeChange() method scans through all of those InputGlyph elements and tries to find the specific input names for each Rewired "Action." I have two separate UI's: one is an in-game "ship computer" and the other is a "helmet HUD." I know that I'll never have axis controls on the helmet HUD, so I don't even bother looking for AxisContribution on that one. The input names that Rewired returns have values like "Button 1", "A", "Square", "F1" and so on.

    I'm using NGUI, so I save references to UISprite and UILabel, but the idea would work with any type of sprites or text objects (Unity sprites/Unity UI, TextMeshPro, 2D Toolkit, etc).

    So here's the method that gets called regularly:

    Code (csharp):
    1.  
    2.     private void CheckForControllerTypeChange()
    3.     {
    4.         _checkForControllerTypeTimer -= Time.deltaTime;
    5.         if (_checkForControllerTypeTimer > 0)
    6.         {
    7.             return;
    8.         }
    9.  
    10.         // Start timer over
    11.         _checkForControllerTypeTimer = _checkForControllerTypeDelay;
    12.  
    13.         Rewired.Player player = ReInput.players.GetPlayer(0);
    14.  
    15.         if (player == null) return;
    16.  
    17.         Controller controller = player.controllers.GetLastActiveController();
    18.  
    19.         if (controller == null) return;
    20.  
    21.         // We got mouse input or we got keyboard input and are already showing keyboard glyphs, so get out
    22.         if ((controller.type == Rewired.ControllerType.Mouse) ||
    23.             (controller.type == Rewired.ControllerType.Custom) ||
    24.             (controller.type == _currentControllerType))
    25.         {
    26.             return;
    27.         }
    28.  
    29.         _currentControllerType = controller.type;
    30.  
    31.         // Switch input glyphs on helmet HUD UI
    32.         foreach (InputGlyph inputGlyph in ScreenManager.Instances[Strings.ManagerHelmetHUD].InputGlyphArray)
    33.         {
    34.             // For the input glyph action name, find the input
    35.             ActionElementMap actionElementMap = player.controllers.maps.GetFirstElementMapWithAction(controller.type, inputGlyph.Action, false);
    36.  
    37.             // Get the background and foreground elements to set
    38.             _glyphInfo = InputToGlyphMap.Instance.GetGlyph(
    39.                 (controller.type == Rewired.ControllerType.Keyboard) ? GlyphControllerType.Keyboard : GlyphControllerType.Joystick,
    40.                 actionElementMap.elementIdentifierName);
    41.  
    42.             inputGlyph.BackgroundSprite.spriteName = _glyphInfo.BackgroundSpriteName;
    43.             inputGlyph.ForegroundSprite.spriteName = _glyphInfo.ForegroundSpriteName;
    44.             inputGlyph.ForegroundLabel.text = _glyphInfo.ForegroundText;
    45.  
    46.         }
    47.  
    48.         // Switch input glyphs on main "ship computer" UI
    49.         foreach (InputGlyph inputGlyph in ScreenManager.Current.InputGlyphArray)
    50.         {
    51.             string elementIdentifierName = string.Empty;
    52.  
    53.             if (inputGlyph.AxisContribution == string.Empty)
    54.             {
    55.                 // No axis contribution was specified, so just grab the first control for the action (typical for buttons)
    56.                 ActionElementMap actionElementMap = player.controllers.maps.GetFirstElementMapWithAction(controller.type, inputGlyph.Action, false);
    57.  
    58.                 if (actionElementMap == null)
    59.                 {
    60.                     Debug.LogWarning("Could not find an ActionElementMap for action: " + inputGlyph.Action);
    61.                     continue;
    62.                 }
    63.  
    64.                 elementIdentifierName = actionElementMap.elementIdentifierName;
    65.             }
    66.             else
    67.             {
    68.                 // An AxisContribution value was given, so grab the full list of controls for the action.  Spin through to find
    69.                 // the matching axis.  There will typically just two items on the list: a Positive and Negative axis contribution.
    70.                 var actionElementMapList = player.controllers.maps.ElementMapsWithAction(controller.type, inputGlyph.Action, false);
    71.  
    72.                 if (actionElementMapList == null)
    73.                 {
    74.                     Debug.LogWarning("Could not find ActionElementMap items for action: " + inputGlyph.Action);
    75.                     continue;
    76.                 }
    77.  
    78.                 foreach (var item in actionElementMapList)
    79.                 {
    80.                     // Get a match for the axis contribution
    81.                     if (item.axisContribution.ToString() == inputGlyph.AxisContribution)
    82.                     {
    83.                         // Found it
    84.                         elementIdentifierName = item.elementIdentifierName;
    85.                         break;
    86.                     }
    87.                 }
    88.  
    89.                 if (elementIdentifierName == string.Empty)
    90.                 {
    91.                     Debug.LogWarning("Could not find a match for action: " + inputGlyph.Action + " and axis contribution: " + inputGlyph.AxisContribution);
    92.                     continue;
    93.                 }
    94.             }
    95.  
    96.             // Get the background and foreground elements to set
    97.             _glyphInfo = InputToGlyphMap.Instance.GetGlyph(
    98.                 (controller.type == Rewired.ControllerType.Keyboard) ? GlyphControllerType.Keyboard : GlyphControllerType.Joystick,
    99.                 elementIdentifierName);
    100.  
    101.             inputGlyph.BackgroundSprite.spriteName = _glyphInfo.BackgroundSpriteName;
    102.             inputGlyph.ForegroundSprite.spriteName = _glyphInfo.ForegroundSpriteName;
    103.             inputGlyph.ForegroundLabel.text = _glyphInfo.ForegroundText;
    104.         }
    105.  
    106.     }
    107.  
    Here's an example of it in action:

     
    Wortex17, Badin and guavaman like this.
  28. Hyper-Luminal-Games

    Hyper-Luminal-Games

    Joined:
    Jun 24, 2014
    Posts:
    108
    Hi Guavaman,

    Thanks for the reply, I ended up just rewriting a small section of the NGUI Input class to use Rewired instead of Unity Input. No big hassle :)
     
    guavaman and BTStone like this.
  29. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    @Hyper Luminal Games
    Uh, could you post it here or sent me the snippet via message? I'm trying to get it right with nGUI and Rewired but can't get it to work.
     
  30. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Awesome solution! I actually ended up doing something similar (minus the GlyphInfo solution, but I'll probably end up doing something like that as well).

    The only thing I could possibly add is that I also have a Dictionary set up to convert certain element names to something more concise. For example, Left Trigger to LT, etc.

    Nice work, by the way.
     
  31. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Yes, I have something like that. My GetGlyph method looks at a list of specific cases like that first, and if it can't find one, it goes with the control name from Rewired, which covers several cases, especially for the keyboard. It also handles what sprite to use for "Triangle" and those funky Sony things.

    I may need to look at specific devices by GUID to handle cases like a thumbstick click or even a "touchpad" click on PS4. I could go with a circle background with "L3" text on top for something like a left thumbstick click, but that isn't what you call it on non-Sony controllers. Actually, I'm not sure what you call that on Xbox or Logitech, etc. Then you've got weird stuff like those Xbox One "back" and "select" equivalents with lines and boxes that I suppose you'd want to get more specific with.
     
  32. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    My plan down the line is to have all of this set up in a config files that are user-editable (on PC, obviously). That way if someone has a controller I don't, or they find an edge case, etc. they can create or edit a config file to suit their controller.

    Also, my dictionary method works exactly like yours. :) Great minds think alike, I suppose. ;)
     
  33. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    Hey guavaman, just bought Rewired to integrate into our fighting game Beast's Fury :D Looks promising to fix all our controller issues :D Great price too if it delivers the goods!
     
    guavaman likes this.
  34. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I had thought about providing an options screen where a player could choose a background and foreground image to create their own custom glyphs, but honestly that seems like too much work. For the generic case that dumps the Rewired control name text onto a background, I do limit it to three characters. So hopefully that'd be good enough. NGUI has a feature where it can shrink the text to fit. Though I do have some special cases for "Button 1", "Fire 1", etc so they'll display as just "1".
     
  35. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I'm rather curious how others are managing their action names. I've gotten to the point where I have quite a few actions spread over a few categories, and I'm just imagining the headache later if I change some action names, or forget action names.

    I'm thinking of setting up a static class that has constant string declarations for each action. Yeah, quite a bit of work up front (and I have to maintain it...) but I'm thinking it'll lead to much less fragile code as it's all centralized if I need to make major changes later.

    Is this a good idea? A bad idea? Has anyone tackled anything similar?

    For reference, this is what I mean, in semi-pseudo code:

    Code (CSharp):
    1. Player.GetButton("MyActionName") //The current way
    2.  
    3. Player.GetButton(ActionNames.MyActionName) //The possible new way
     
  36. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    For what it's worth, I have all actions defined as string constants. I've got quite a few of them. I reference some actions multiple times (in different contexts), so I'd go insane otherwise. I put many of my string constants in a class called "Strings" so that I don't have to hunt around for them. I have a naming convention where I start actions with "Action" like GetButton(Strings.ActionFireEnergyWeapon).
     
  37. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    This is essentially the reason I'm doing this as well. I've got multiple categories and maps now, and it's getting kind of crazy just using action names as I need them. I think having everything centralized in a class as constant strings is probably the way to go (and this is another instance where we thought along the same lines!).

    I'm still curious if anyone is doing anything differently, though. If you've got something that you feel is a better alternative feel free to share! ;)
     
  38. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    That's what I'm doing as well, don't see any other way to go about it, it's a mess otherwise.
     
  39. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    I don't have that many actions (& categories) so I have no trouble organizing them etc.
    But what one could do is create an auto-generator of action constants - is there any way to get all actions when not in play mode?
     
  40. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I toyed with that idea as well, but I'm unsure of whether that would be a good or bad thing. It would surely be easier to manage, as it would auto-update everything when you add or remove actions, but the downside is that there wouldn't be a consistent human-crafted naming scheme, as it'd have to pull everything from what you put into Rewired. You could, for example, have something like "MenuHorizontalAxis" tied to "MenuLeftStickX" or something.

    Unless I'm being dumb. I've only scratched the surface of constants generators, so there may be something that I'm not aware of to handle stuff like this.
     
  41. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    If you generated your own .cs file based on what actions are defined, you could take it a step further and generate enums. You could assign each enum the action ID value. Then with stuff like my InputGlyph thing, you could use the enum for a nice drop-down in the inspector instead of having to put text in a public string field. The Rewired methods like GetButton have overloads that take the action ID int value instead of a string, though I suppose you'd have to cast to int all the time. Or you could create a dictionary of actions by that enum that contained each action's ID value.

    Or maybe the simple approach is better. :)
     
  42. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Heh, I was doing this to regain my sanity, not make things even more insane! I'm doing most of my input-related stuff in scripts, so a dropdown in the inspector doesn't really help me that much.

    I'm thinking the manual way is probably the way to go. Yeah, it sucks that it has to be maintained, but it seems like every solution has it's drawbacks. ;)
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It would be nice if there were a way to dynamically create enums so that all the Actions could be handled that way from the editor, but alas.

    If you're going to be using your own consts anyway, you might as well use the Action ID instead of the string. You can find it in the editor.

    They are stored in the Rewired Input Manager as serialized data under _userData.actions as a List<InputAction>. There aren't any public methods available to work with the data in the Input Manager and the fields are private, so you'd have to use reflection to read the data.

    I like this approach the best of all those mentioned. I like working with enums because they're human readable, you get the benefit of auto-complete, the errors can be caught at compile time, and you don't have to create a billion variables. Yes, you would have to cast to int when getting input, but that's free. I don't see that this approach is any more complicated than any of the other approaches.
     
    Last edited: Jan 26, 2015
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi Evil-Dog,

    Great, glad to hear it! Your game looks quite impressive! Let me know if you need anything.
     
  45. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    I'd say most of those benefits apply to constants as well, and you don't have to int cast. But yes, I like enums as well.

    You couldn't make some way of gaining access to the Input Actions when not in play mode without relying on serialization?
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I don't know of any way that could be done.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.24 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.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.
    ------------

    As always, you can see the ever-growing list of controllers with extended support here.
     
  48. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is great. Nice to see more HOTAS systems being supported. The Saitek X-55 can be good for Helicopter simulations too if you do not have Rudder Pedals.

    I was playing with the Arcade Guns (Light Gun) today in UFPS's skycity and it works very well. That UPFS integration in Rewired is great.

    I did notice a simple shooting gallery example in the asset store (it is a group of 5 examples in C#) but it will work well with a light gun. https://www.assetstore.unity3d.com/en/#!/content/116. This asset is free too which is nice.
     
    guavaman likes this.
  49. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    This asset looks awesome, but I'm not completely clear on one feature; How exactly do you handle assigning a particular controller to a particular player?

    I ask because I'd like to automatically assign an input device to a player when a "join game" action is preformed (e.g pressing the start button or mouse clicking). And also remove that assignment if the player leaves ("leave game" action). No other player would be able to use that particular input while it's assigned. Would this be very hard to do with your system?
     
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    There are various settings for auto-assignment of joysticks to players as seen here:
    http://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    By default, a joystick will be automatically assigned to a player when the joystick is connected. Which player it gets assigned to depends on your settings you define here.

    If you don't want Rewired to automatically assign joysticks, you can always manage assignment yourself through scripting:

    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_Player_ControllerHelper.htm
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_ControllerHelper.htm
    http://guavaman.com/projects/rewire..._Rewired_ReInput_ControllerConnectedEvent.htm
    http://guavaman.com/projects/rewire...wired_ReInput_ControllerDisconnectedEvent.htm

    There is also a field in the Player class called isPlaying which you can use to tell Rewired whether a player is playing and should or should not be assigned controllers when one is found (again, depending on your chosen settings):
    http://guavaman.com/projects/rewired/docs/api-reference/html/P_Rewired_Player_isPlaying.htm

    Rewired will assign the controllers to players initially in the order that it finds them based on the USB port id. When disconnecting and reconnecting a controller, it will try to match that controller back up to its previous owner.

    But it sounds like you want to automatically assign whatever controller has a "Start" button pressed on it to the next available player slot. If that's the case, you're going to have to manage this yourself. Here is a post in this thread about how to detect a "Start" Action on any controller, which would be an Action assigned to a particular controller element rather than an actual "Start" button (as not all controllers have that). You could also just detect any button press on the controller to allow the player to join in fairly easily.

    The best way to find out if Rewired will work for you is to get a free trial. Contact me with your email address on my support form here and I'll email you a trial.
     
    Last edited: Jan 26, 2015
    IsaiahKelly likes this.