Search Unity

  1. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  2. Unity 2017.1 is now released.
    Dismiss Notice
  3. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  4. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Joystick detection and direct axis detection

Discussion in 'Scripting' started by guavaman, Dec 9, 2011.

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I'm writing an Input Manager of my own to replace Unity's that will allow my players to customize their controls in-game as well as allow me more fine grained control of how they customize things. I've got it working pretty well, but ran in to some problems because I can't find any way to access input functions at a lower level than through the basic stuff available in Input.

    1.) Joysticks are not ever detected when plugged in while game is running. (Tested in editor and build.) Is there any way to re-poll for joysticks while the player is running in case they a) forget to plug a controller in before or b) remove a controller mid game or c) add a 2nd controller in mid game to join in.

    2.) There seems to be no way to get an axis directly without first setting it up in Unity's Input Manager. I can access all keyboard, joystick, and mouse buttons through Input.GetKey, but there's no equivalent for axes as Input.GetAxis just takes a string which matches whatever axis you set up in Input Manager.

    3.) There's very little available for managing joysticks. The only way I can even detect how many controllers are connected is with Input.GetJoystickNames. I'm wondering if there are any undocumented features for input management that I might get access to to help me get the most out of input.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Can anyone give me guidance on how to use reflection to find out if there are any undocumented methods/properties in Input?
     
  3. ufo_driver

    ufo_driver

    Joined:
    Jul 6, 2011
    Posts:
    93
    Well, you can find tool that is named ILSpy and watch source code of .NET libraries (still I don't know if I am allowed to say this on official forum :) ) .If libraries are not obfuscated you can see some useful things but I strongly don't recomend you to use undocumented features as they can disappear in next version or even work improperly.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    UPDATE: ufo_driver, ILSpy looks like it's what I needed. Thanks again!.
    UPDATE2: Well there's a whole lot to see in there, but I don't see any way to get more control over the controllers. :(

    Thanks for the tip! I'll see what I can find using that. I realize using undocumented features isn't the greatest idea, but I would seriously like to find a way to make Unity re-poll the controllers when hotplugged. This is a big drawback IMO, and I seriously doubt the Xbox 360 and PS3 versions would have this same problem as all games on those systems can detect controller removal. It seems the PC version should be able to do that somehow. It's an even bigger issue for wireless controllers.

    Since I'm nearing the completion of my game, I don't think worrying about future support for undocumented functions is really a big deal for me. (It's a standalone ver, not webplayer so I shouldn't need to worry about the player getting updated either.)

    My approach to reflection was going like this:
    Code (csharp):
    1.  
    2.  
    3. var refl : Reflector = new Reflector();
    4. var propertyInfo : System.Reflection.PropertyInfo[] =  Reflector.GetProperties(System.Reflection.BindingFlags.Default);
    5.  
    6. class Reflector extends Input implements System.Reflection.IReflect {
    7. }
    8.  
    However I get the error "Cannot extend final type 'UnityEngine.Input'."
     
    Last edited: Dec 11, 2011
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I've run into another problem... I've got my entire input manager built, but I'm having trouble identifying joysticks by id. The only function I've found for determining anything about connected joysticks is Input.GetJoystickNames which returns a string of joysticks connected since run. I was using this returned string to get names of controllers for the config screen to let users choose which player is using which controller. I also use this name list to determine which joysticks are in which positions (joy 0 - joy 3) and map to players accordingly. (I'm also planning on having default joystick config profiles based on the joystick name so I can set up decent defaults for more popular game controllers.)

    PROBLEM: My entire house of cards just came falling down because I've determined the order of joysticks returned by Input.GetJoystickName DOES NOT relate to the order the joysticks are handled by unity. For example, a joystick in the returned name array in position [0] does not always equal the unity mapped Joystick1 (Input.GetKey(Joystick1Button0)). SOMETIMES it does, but sometimes it doesn't. (Try connecting 3 or 4 different model controllers, doing a Input.GetJoystickNames to see your list of controllers, then poll all the joysticks while pressing buttons on various controllers and see how the mapping doesn't always match.)

    Is there any other way to determine what controllers are connected and what their respective unity joystick number is?

    Example of how joystick names do not always match joystick ids:

    Code (csharp):
    1. // Slap this code onto an object in the scene then press buttons
    2. // I recommend you test with 3-4 controllers (different models) for best effect
    3. function Awake() {
    4.     var names : String[] = Input.GetJoystickNames();
    5.     Debug.Log("Connected Joysticks:");
    6.     for(var i : int = 0; i < names.length; i++) {
    7.         Debug.Log("Joystick" + (i + 1) + " = " + names[i]);
    8.     }
    9. }
    10.  
    11. function Update() {
    12.     DebugLogJoystickButtonPresses();
    13. }
    14.  
    15. private function DebugLogJoystickButtonPresses() : void {
    16.     var joyNum : int = 1; // start at 1 because unity calls them joystick 1 - 4
    17.     var buttonNum : int = 0;
    18.     var keyCode : int = 350; // start at joy 1 keycode
    19.    
    20.     // log button presses on 3 joysticks (20 button inputs per joystick)
    21.         // NOTE THAT joystick 4 is not supported via keycodes for some reason, so only polling 1-3
    22.     for(var i : int = 0; i < 60; i++) {
    23.        
    24.         // Log any key press
    25.         if(Input.GetKeyDown(keyCode+i)) Debug.Log("Pressed! Joystick " + joyNum + " Button " + buttonNum + " @ " + Time.time);
    26.        
    27.         buttonNum++; // Increment
    28.        
    29.         // Reset button count when we get to last joy button
    30.         if(buttonNum == 20) {
    31.             buttonNum = 0;
    32.             joyNum++; // next joystick
    33.         }
    34.     }
    35. }
    Unity Script Reference - Input.GetJoystickNames states:

    Because the joystick id does not always map to the corresponding entry in the GetJoystickNames array, this statement in the Unity docs appears to be incorrect. I can see no way to use the names returned by this array as there's no way to relate them to an individual controller.

    The above test was done with all controllers connected to the system from program start, nothing removed. Therefore I'm confident it's a bug and I've reported it. However, even if that bug is fixed in the future, there will still be a case of id mismatching if a controller is ever removed while the program is running. Ex: 3 controllers connected, controller id 1 is unplugged. Now GetJoystickNames() returns a 2 element array, 0 = id 0, 1 = id 2. Again, no way to associate a name with a joystick. There MUST be a way to access joysticks by id, THEN get name from that.

    Update: Controller order seems to change depending on which USB controller the joysticks are plugged into. (In the off chance one of the dev team reads this, that may be somewhere to start testing.)

    All these limitations with the Input class are seriously messing up my plans to have a good input experience for multiple players on one system.

    Another example of the problems with Unity's input handling:
    I mentioned in my posts above that I was searching for a way to hot-plug controllers during the game and never found any way to do it. Here's a real-world scenario that WILL cause big headaches for players, even in a single player game -- Player is using Xbox 360 wireless controller or another wireless controller. Player pauses game and gets up to do something for 20 minutes. Controller shuts off. Unity drops controller from list. Player comes back and reconnects. Unity ignores the new controller. Player cannot control game anymore and is forced to quit with mouse/keyboard and re-run the game.

    I've been working with unity for almost 2 years now and have found it to be all around great, but the Input class is just sorely lacking.
     
    Last edited: Dec 14, 2011
    StridingDragon likes this.
  6. Batman187

    Batman187

    Joined:
    May 25, 2009
    Posts:
    11
    guavaman, I share your frustration with the way Unity handles joystick inputs. Unfortunately, I don't have a solution, only solidarity. Here is a thread I just posted to describe the problems I am running into.

    How do I map joystick buttons beyond 20 and axes beyond 8?

    Aside from the issues with Input (and source control management) I am the biggest Unity fanboy on the planet. Let's hope the Unity Devs take notice and fix their insufficient code!
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
  8. Batman187

    Batman187

    Joined:
    May 25, 2009
    Posts:
    11
    I posted my support on the feedback page you linked to. So sad, I gave similar feedback when the current version was 2.x. Does anyone at Unity ever listen? I would at least appreciate an explanation as to why this is difficult or impossible for them to do. If there are good reasons why this can't be done I would be sympathetic.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I think you need to add your votes. Click the vote button near the top. It will allow you to add 1 or more votes depending on how many you have left. (Of course, if you want to add a new topic about more axes/buttons and use your votes there instead, you should do that. EDIT: There's one already:http://feedback.unity3d.com/forums/15792-unity/suggestions/940687-increase-joystick-button-limit but it doesn't mention Axes)

    I don't feel like this is a difficult problem at all to solve. I already sent them a detailed bug report and outlined a simple to implement solution that wouldn't take a lot of time. In my view, the devs are just too busy adding the latest, greatest whiz-bang features and systems that everyone wants and have no time to go back and fix small bugs that most of their users don't care about. Lets face it, how many PC gamers actually use controllers compared to those that use mouse/keyboard? It's sad, but you can see by the paltry 19 votes for the joystick fix that not a lot of people use multiple joysticks on the PC. New feature requests far outshadow bug fixes.

    I would appreciate it if they'd at least acknowledge the problem in an email or something after my thorough bug report. Looks like PC controller support is going to be broken past my release date. I guess I'll have to include some kind of controller disconnection disclaimer telling players that the engine's support for controllers is broken and if you unplug a controller or your wireless controller times out, you MUST quit the game and restart for the new changes to take effect. As for your problem with not enough buttons/axes, I don't see any solution within Unity. It would be a big headache, but maybe you can completely replace the Input system using some kind of plugin DLL. (Not sure of the details but I have seen some Xinput project where you could add a DLL and get access to inputs outside of Unity's handling. I may do some research in this area later as I've kind of moved on from controllers for now.)
     
    Last edited: Feb 23, 2012
  10. lockbox

    lockbox

    Joined:
    Feb 10, 2012
    Posts:
    506
    And this is probably the real reason why the fixes are not making their way to the top of the list.

    PC driving and flying games are about the only games I can think of off the top of my head that people might be included to buy specialized hardware for. Flying games are pretty much dead - and only die hard racing monkeys actually buy a wheel for their PC to play already established games, like iRacing vesus some kind of arcade style game, like the NFS series, which plays perfectly fine with a keyboard.
     
  11. Neeko

    Neeko

    Joined:
    Mar 9, 2012
    Posts:
    24
    I've been dealing with the exact issue as of late. I've been trying to figure out a possible solution, and it seems that you can use XInputDotNet instead of the built-in Unity InputManager which I can attest fixes the issue. Problem with that, it uses DirectX which means Windows only.'

    There's also XboxCtrlrInput which attempts to create a more multi-platform solution, using XInputDotNet on Windows and seemingly falling back to Unity's built-in InputManager for all other platforms.

    Sad that this issue has remained in Unity for so long (well over two years, I'm sure!)
     
    Last edited: Dec 23, 2013
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I'm saddened and a bit suprised (though I shouldn't be) to hear that this issue is still unresolved. See this post from a Unity staff member over a year ago. I hadn't checked back on this issue myself, but assuming you're using 4.3, I guess we're never going to see working controllers in Unity.

    I really don't like the idea of resorting to external plugins to solve the problem because like you said its not cross-platform. That means essentially you have to find external solutions and rewrite your controller management code for every platform you intend to publish on. That said, thanks for posting your workaround. I will probably have to dig into this because I simply can't wait forever.

    Unity really does not support game controllers. That's about the size of it.
     
    Last edited: Dec 29, 2013
  13. tamberlain

    tamberlain

    Joined:
    Jun 16, 2013
    Posts:
    19
    Same issues here. Saying "not many people use joysticks" is not an excuse for Unity to ignore these bizarre problems. Though I'm not sure they've ever given that as an excuse. We've just been ignored. If you are making a flight sim or space sim like I am, then joysticks and game controllers are a standard requirement. Modern joysticks and controllers have a wide variety of axes and buttons so the limitations of 20 buttons and a handful of axes is just foolish.

    I see people have been discussing this issue for up to 3 years and nothing has changed. I might go look at Unreal or other engines now as this is a showstopper/dealbreaking issue for any flightsim developer.
     
  14. KOKOStern

    KOKOStern

    Joined:
    Dec 22, 2013
    Posts:
    11
    Looking up this exact issue and pretty sad to see there's no proper solution.

    I have a game where it's highly encouraged to play with a controller and when people find that out they are forced to restart it in order to have the game recognize the controller (web game).

    This really sucks =\
     
  15. Neeko

    Neeko

    Joined:
    Mar 9, 2012
    Posts:
    24
    Look into InControl, http://www.gallantgames.com/pages/incontrol-introduction. It's a fantastic input library for Unity that abstracts away a lot of the issues with InputManager and provides numerous out-of-the-box support for a lot of controllers.

    However, there's not going to be a guaranteed way to ensure controller order unless you use XInput. This is a Windows driver issue more than anything, so I don't think Unity can be blamed entirely (if at all).

    So to get around this, if you end up using InControl, you'll need to create some type of character selection screen and listen to all of the attached controllers. When a player selects a character, capture reference to the InputDevice (an InControl class that represents controller state) that made the selection and use that to represent the player going forward.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I'm currently working on a complete controller input system to replace Unity's. I'm hoping to release it within the next week or two. But it has a number of features that will make working with joysticks (and other controllers) far better than Unity's input system or any plugin that wraps Unity's system. For starters, it will fully support hot-plugging on Windows, Windows Store, and OSX games (Linux and Android planned if there's enough interest.) However, unfortunately, it is not possible to support hot-plugging in web players. Apart from hot plugging, it features a player-centric input system (player.GetAxis("Walk") gets all the player's joystick, mouse, and keyboard inputs that have the "Walk" action mapped), auto re-assignment of controllers to players on controller disconnect/reconnect (if hot-plugging is supported on that platform), connect/disconnect events, frame-rate independent input (get input in Update or Fixed Update), customizable (and saveable) controller mappings, multiple mapping layouts per joystick, joystick calibration, multiple controllers per player, an editor GUI for creating actions and controller/keyboard/mouse maps, named buttons and controller elements per-joystick (for help messages and config screens), and much more. In addition, it does not abstract all controllers into a gamepad-style layout, so it will work with any controller type. However, to save time and effort, you can map a controller template such as Dual Axis Gamepad if you don't feel like configuring all the supported controllers for your game and any controller that uses that template will work.

    It's not a Windows driver issue. I've solved the problem on both Windows and OSX. Unity hasn't touched input in probably 8 years. It was just half implemented and forgotten. But I did see in another thread that they will be revamping input for some upcoming 5.x release, though not the initial release.
     
    Last edited: Jul 3, 2014
  17. Neeko

    Neeko

    Joined:
    Mar 9, 2012
    Posts:
    24
    Could you explain this further? Everything I've ever read has always faulted the actual drivers and Microsoft, so I'm curious as to how you solved the 360 gamepad numbering issue.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    XInput numbers the pads itself, as you know. So if you choose to use XInput (my prog has that option) for 360 pads, the numbers will be stable.

    For other devices (or if you disable XInput), I'm using DirectInput. While the hardware ids can change occasionally on Windows when disconnecting and reconnecting, for the most part they stay fixed for the duration of the Windows session unless forced out of place by another device that had the id before it. Anyway, I remap the controller ids based on identifying information from the controller and map that back to a player. On connect, the device is assigned to the last player to own that controller (if you choose to use auto-reassignment). There is still the possibility of mix up if multiple identical controllers are used, but its minimized because of identifying information which usually stays fixed as long as the controller remains attached. So as long as one controller is removed then attached at a time and all of them aren't removed together, everything should be fine. And if they do remove all of them together, they'll just be reassigned to players as intelligently as possible. Even in the worst case, the identical controllers could be crossed, but it would be an easy matter for players to go into the option screen and switch controllers back. This issue is better on OSX because you can get more USB information than through DirectInput to keep the controller id in place. I may try adding a lower level layer in Widows to try to get even more hardware data on the device to make it more solid, but that will wait until after my initial release.

    In my system, you will be getting input from the Player 99% of the time instead of controllers directly (you can, but there's no real benefit and you lose out on all the goodies of player-based action mapping by hitting the controller directly). So you don't even have to care whether a controller is at the same id as long as it's mapped back to the player properly.

    By the way, actions are player-based as well. So any controllers assigned to that player can return input for the action in question. You don't have to create duplicate actions for multiple players anymore. All of this works for keyboard mapping as well -- the keyboard can be partially mapped to as many players as you want, and will return input to the player for the actions being queried.
     
    Last edited: Jul 4, 2014
  19. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    97
    Any updates on your input manager replacement? I've recently ran in to a situation very similar to yours, and find it kind of silly that Unity can't accurately determine which controllers are which. A solution would be much appreciated
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Hi Terabyte. I'm polishing up the last bits and will have it out very soon. All that's left to do is some testing, documentation, demos, and a website. Probably a few more days. I'm a bit behind my originally planned release date because I ended up expanding the scope a bit and added a number of goodies. Exciting! :)
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I thought I'd post a feature list here since I've added some things over the last month. There are probably a few things I missed as I hastily typed this up just now, but here's the first rundown:

    Features:
    • Works in Unity free and Pro.
    • Full hot-plugging support on Windows, Windows Store, and OSX (Linux and Android planned if there's enough interest.)
    • Optional XInput support for Windows (mandatory for Windows 8 Store).
    • Fallback on Unity input for all other platforms. All features work except for hot-plugging.
    • Player-centric input system.
    • (Optional) Auto re-assignment of controllers to players on controller disconnect/reconnect with configurable options to tune the reassignment to your needs.
    • Connect, pre-disconnect, and disconnect events.
    • True frame-rate independent input for Windows, Windows Store, and OSX
    • Get input in Update, Fixed Update, and OnGUI -- you choose which loops update runs in, one or multiple as needed.
    • Customizable and saveable controller maps -- export mappings to XML and save how you choose (example included using PlayerPrefs, but save however you like.)
    • Unlimited mapping layouts per controller.
    • Controller Templates (see Controllers section).
    • Editor GUI for creating Actions, Input Behaviors, Joystick/Keyboard/Mouse maps, categories, etc.
    • Editor GUI for creating and editing Joystick Hardware Maps (for adding new fully-supported joysticks).
    • Editor GUI for creating and editing Controller Templates (for adding new templates or adding new joysticks to a template).
    • Extremely versatile -- can be used for simple 1-player games all the way to highly complex multi-player games with complex mapping requirements. Gives the developer a high level of control and doesn't try to force you into a specific one-size-fits-all mold.
    Controllers:
    • Functional support for any USB controller (see below).
    • Extended support for 7 game controllers (I just ordered 3 more which are coming soon and will add those. Or mail me your controller and I'll add it and mail it back! : ).
    • Supported controllers are recognized on each platform and are fully mapable by element name and have standardized axis directions.
    • For any controller not included, you can map an Unknown controller which includes all possible buttons/axes on the platform (Windows 128 buttons & 32 axes, etc.) Regardless of whether you define a map for this, users will always be able to manually map every element on the controller. This means support for virtually every USB controller.
    • Controller template system so you can either choose to create default maps for every controller you wish to explicitly support, or save time and just map the template. All controllers that use that template will be mapped automatically. (Comes with a Dual Axis Gamepad template that works for the 7 included controllers.) User can always map any remaining controller elements even if they're not defined on the template.
    • Named buttons and controller elements for supported controllers (for help messages and config screens).
    • Vibration (XInput only currently)
    Mapping:
    • Unlimited, stackable, maps per controller.
    • Maps stack so you can have as many maps for each controller as you need. For example: If you have multiple game modes such as Infantry, Tank, Airplane, you can have shared controls on one map, and mode-specific controls each on its own map. You can have even more maps as needed: A Menu map for when you're in the menus, a system map for controls like Save/Load and Quit, multiple maps for different players on the keyboard, etc.
    • Enable / disable maps as needed, for example, when changing game modes.
    • A shared controller (the keyboard for example) can be mapped by any number of players with any number of maps.
    • All maps are owned by the player, so changes you make to one player's maps don't affect the others even if it's on the same controller.
    • Map axes to buttons and buttons to axes if you choose.
    • Split axes - allows you to map one pole of an axis to an action and the other pole to another action if you want.
    • Axis Contribution - you can choose how your button or axis affects the final Action's value. A button can generate positive or negative values on an Action's final axis value.
    • Save maps to XML.
    Input:
    • Standard Unity lingo: GetButton, GetButtonDown, GetAxis.
    • Most input handled by calls through Player -- player.GetAxis("actionName").
    • Get input directly from elements by index if necessary.
    • Get Action input by action name or action id.
    • Positive and negative buttons.
    • Double-press/click support with customizable timing.
    • GetButtonDown buffer -- allows you to make GetButtonDown respond for longer than a single frame to help with timing issues when user is pressing the button rapidly.
    • Keyboard modifier support - Map keyboard controls with up to 3 modifiers - Control, Alt, Shift, and Command (mac).
    • Axis calibration (min, max, zero, deadzone)
    Players:
    • Unlimited number of players.
    • Multiple controllers per player (optional).
    • Convenient System player for handling system actions - Save, Load, etc.
    • Define starting maps for joystick, keyboard, and mouse per-player.
    Actions:
    • Define actions in the editor.
    • Action categories for organizational convenience.
    • Set user-assignable flag on an Action or Action Category to allow or prevent certain actions from showing up in lists (useful for mapping screens.)
    Input Behaviors:
    • Input Behaviors are similar to Unity's Axes where you set options for digital axis simulation options (sensitivity, gravity, etc.), how to handle mouse axes, a GetButtonDown buffer, button double press speed, button dead zone, and more.
    • Each Action is assigned an Input Behavior, so if you have many actions that need to behave the same way, you don't have to duplicate the information, just set them to use the same Input Behavior.
    • Per-player, and run-time modifiable.
    • Save to XML.
    Map categories:
    • Categorize your maps by any criteria you choose. For example: System, Menu, Gameplay Shared, Infantry, Vehicle, Airplane.
    • Set user-assignable flag on a category to allow or prevent user-assignment of certain controls (system controls should be protected from change, for example).
    • Category selective conflict checking - choose to conflict check some categories with other categories, but not necessarily in both directions. (Useful for complex stacked map setups).
    Map Layouts:
    • Multiple layouts per category. Allows you to have optional controller layouts.
    Other:
    • Input Manager is self-contained so you can actually have separate input managers for different levels if you choose with entirely different mappings, etc. (Not necessary but interesting!)
    • Functions for mapping conflict checking
    • Identify joysticks by button press in Unity Fallback mode.
    • Included example of mapping screen using Unity GUI (will update when new GUI system comes out) including saving and loading of maps per-player.
    Performance:
    • ZERO bytes of memory allocated per-frame in gameplay situations means no garbage collection overhead. (Some allocations required during remapping).
    • Fallback platforms have periodic allocations as it polls Input.GetJoystickNames() every second or two to find changes for event.
     
    Last edited: Aug 9, 2014
    Shkarface-Noori likes this.
  22. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    97
    Very interesting, how does it handle joysticks on OSX? Does it utilize something like the Tattie Boggle plugin, or does it have native support?
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Edit: To be clear, the Tattie Bogle driver is required for Xbox controllers on OSX.

    It accesses Apple's HID system through a native plugin. Unity free can't use native plugins in the normal way, but its super easy to make it work in the editor and a build with just one extra manual step. If you don't want to do that, it will fall back to use Unity's input system, but wrapped up nicely so it will be functional.

    Sorry about how long its taking to get this out. I'm very nearly done. I'm trying to get the plugin structured for easy installation and use. Lots of issues dealing with webplayer and Windows 8 Store publishing which are now resolved. And I had quite a few issues to tackle with fallback support on Linux. (I seriously, seriously can't believe how bad the existing joystick support is on all platforms... I knew it was bad, but before doing this I only saw the tip of the iceberg...)
     
    Last edited: Aug 23, 2014
  24. andiCR

    andiCR

    Joined:
    Sep 6, 2012
    Posts:
    17
    Thanks for the hard work guavaman. This is something that I've been looking into for some time now and can't believe I found this today that its close to being released. Do you have an estimated delivery date for this aesome work?
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Hi andi! Thanks! I've been thinking about doing this for 5 years myself. I'm really close to done, but because of the delays that came up I've still got to do docs, website, logo, and submit to the store. The store review process is at least a week. If you're interested in trying something sooner, let me know and I can send you a beta.
     
  26. aitchest-of-dees

    aitchest-of-dees

    Joined:
    Dec 28, 2013
    Posts:
    37
    Great work guavaman! It looks like you've really taken it to the next level. Let me know if you want help with mappings, I got a pile of USB controllers and various adapters here.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Hi aitchest,

    Thanks! I'm trying to. Anyway, I'm going to put together some videos today. Got the website up here

    Rewired Website
    Documentation site
    Rewired API Reference

    Let me know if you have any comments or suggestions.

    I'm going to publish it with the 9 controllers I've created profiles for and add more in subsequent releases, though it's important to mention that you don't need a profile for it to work -- in the case of an unknown controller, you just have to allow the user to map his own controller, and it should work with any. As for controller mapping screens, I've included one sample screen (using Unity's GUI), but I will be including more sample screens using the new uGUI in subsequent updates. (I'm planning to include a number of pre-configured control sets for various game types with mapping screens that you can use as-is or modify for you needs in the future.) I'd love to create profiles for what you've got, but you have to be able to get the element data in Windows, OSX, and Linux at this point, so if you're not set up do to that, it may be easier if I just did it. If anyone has controllers they want to add profiles for, they can mail me their controllers, I'll add them and then mail them back.
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    I'm happy to announce my new input system Rewired is finally ready to roll!

    Rewired is now live on the Unity Asset Store. I put a ton of work into this over the past 4 months, so I hope it helps a bunch of people finally get a handle on input and make great games!

    Rewired is an advanced input system that completely redefines how you work with input, giving you an unprecedented level of control over one of the most important components of your game. It is cross-platform, player-centric input system with many advanced features such as Intelligent Hot-Plugging, frame-rate independent input, controller maps, a full editor GUI, saving/loading data via XML, named controller elements, support for 32 axes and 128 buttons (on Windows and OSX), and much more.
     
    Last edited: Sep 26, 2014
  29. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi, I'm looking at this and wondering if your nice looking asset might help solve my question, see here
    Can I use your asset to see which axis my controller is using and map those to unity's input ?
    Is there a video of how your asset works?
    I see I could request a trial, is that still possible?
     
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,195
    Guavman does have a evaluation version available. See this web page for specifics http://guavaman.com/projects/rewired/ There is a section at the bottom of the page for requesting the evaluation version.

    Does the RC controller show up as joystick or game controller under Windows? Can you use this controller to fly an aircraft in Microsoft Flight Simulator? If it does it should work fine with Rewired. Rewired supports (DirectInput, Raw Input and XInput) under windows.

    You should post in the Rewired thread so more people can see your question too.

    http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-6
     
    guavaman likes this.
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Rewired won't map anything to Unity's inputs. It works in the opposite way mapping Unity inputs to Rewired inputs on platforms that use Unity input as the source of input. On Windows, you will probably want to use Raw Input as the source. If, like your question shows, that they show up as joysticks, then yes, they should show up fine in Rewired. The trick is, if you want to be able to just start the game and have those controllers "just work" (predefined maps for controlling your game), you will have to create controller profiless first so Rewired can recognize the devices and have a element mappings so it knows which button/axis goes where. Creating a controller definition can be a bit complex. You can see the docs on it here: http://guavaman.com/projects/rewired/docs/HowTos.html#new-controller-definitions

    Alternately, you can mail me the controllers and I will create the definitions and mail it back.

    To get a trial, please request it through the contact form on the rewired website here: http://guavaman.com/rewired#support
     
  32. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Thanks for the reply, I managed to sort my issue out, thanks anyway.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Okay, glad you got it working!
     
  34. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    290
  35. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    358
    Sorry for not reading it all, I'm sure it was already answered here or in your docs, but since a bump on your tread should do no harm ;)

    1. Do you have some example UI for setting up controls on runtime. For example, if a player wants to change keyboard bindings from arrows to "wasd"?

    2. If "no" is the answer to the first question. Is there a way to read input changes? For example the user clicks on "Reassign Left Axis" and the system detects the next joystick movement, which the user does (maybe even filtering joystick noise)?

    [EDIT:] By the way you should add a link to the asset store in your first post :rolleyes:
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    2,620
    Hi,

    This actually isn't the forum thread for Rewired. That's here: http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/ (Linked a few posts above when I released Rewired.)

    As to your question, yes:
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    There's also info on the upcoming uGUI drop-in remapping system here:
    http://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-14#post-2081967
     
    Last edited: Jun 12, 2015
    FreebordMAD likes this.
  37. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    358
    Thanks you just sold it one more time! ;)
     
    guavaman likes this.