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. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

InControl - input and cross platform controller support for Unity, made easy!

Discussion in 'Assets and Asset Store' started by pbhogan, Jul 18, 2014.

  1. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186


    InControl is an input manager for Unity3D that standardizes input mappings across platforms for common controllers. It is written in C# and strives to make it a snap to add controller support to your game with a simple, powerful API. All the heavy lifting of mappings are handled for you with dozens of controllers handled cross-platform, and more being added continually. Add virtual touch controls, or keyboard mappings to your game with just a few clicks, and have it feed right into the API you're already using as a virtual controller.

    Links
    Supports:
    Requires Unity 4.5+



    Version 1.2 has just been released introducing touch controls. InControl has been on the Asset Store for around six months now and the feedback and support from users has been fantastic. Several have asked me to start a topic on the forums to post feature requests, spread the word and discuss the asset more openly, so here it is!
     
    rakkarage likes this.
  2. bilke

    bilke

    Joined:
    Jul 13, 2012
    Posts:
    54
    InControl is highly recommended! You can even implement your own devices. I used it to abstract Virtual Reality devices (I am using MiddleVR) and to simply switch between an Xbox Gamepad for input when testing on a normal pc and a virtual environment interaction devices (like Flysticks).

    Keep up the good work!
     
  3. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,231
    I just imported the latest version (1.2.0) into a new project, and I seem to be missing the Header attribute class, which is used in TouchStickControl.cs, TouchSwipeControl.cs, and TouchTrackControl.cs. Getting errors about missing "Header" and "HeaderAttribute." I guess for now I can comment out that stuff, since I don't need touch control right away. Any chance of getting the missing classes in the mean time?

    UPDATE: I also had to comment out the line [Space(10)] in TouchManager.cs to get everything to compile.
     
    Last edited: Jul 19, 2014
  4. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,231
    On a happier note, I was able to get all of the controls working on Vita/PSM, which is just too cool. At first I was grumbling about the statement in the InControl docs about not supporting the Start button, but then I discovered the MenuWasPressed feature. Perfect!
     
    Marc-Uberstein likes this.
  5. HansBernd

    HansBernd

    Joined:
    Nov 3, 2012
    Posts:
    39
    Would love to buy, but with Vita development iam currently stuck with a custom build of unity 4.3.4. Therefore I cannot buy/download your plugin from the asset store, as the store claims : "Requires Unity 4.5.1 or higher".

    Will this run anyway with unity 4.3.4?

    Best Regards
     
    Last edited: Jul 19, 2014
  6. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,231
    Yeah, I'm in the same boat, but was able to upgrade to the latest version. Other than taking out the new touch features, it works fine. So I imagine he'll be able to remove that restriction from the asset store. I don't think it uses anything 4.5 specific as far as I can tell.
     
  7. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    730
    I don't suppose v 1.2 will be coming to the GitHub page at any point?
     
  8. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @HansBernd It will run under 4.3.4, except that you'll need to comment out a few attributes that are 4.5 only, and also a few controllers may not work quite right (the PS4 controller on Mac comes to mind). Unity tends to update controller support even in very minor point updates, which is why I keep InControl on the latest official release of Unity.

    @TheValar New versions are typically on GitHub before I submit to Unity, although the touch features are Asset Store only. Most major new features will be Asset Store only too.

    @Steve Tack If you want direct access to a non-standard mapped control for a particular device you can always do inputDevice.GetControl( InputControlType.Start ); Just be aware that many controllers may not have that button, which is why I added the more generalized MenuWasPressed which just maps to any of those menu-y buttons.

    I'm considering adding a page on the website where users can register with their Asset Store invoice number and get downloads along with early access to new versions. Let me know if you would find this useful. :)
     
  9. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,231
    Yeah, I saw that. I really dig the MenuWasPressed solution as opposed to specifically checking for Start, since I may port my Vita game to other platforms.

    It is kind of a pain to have the Unity 4.5 attributes in the code, since with Vita PSM we don't yet have the option to go beyond 4.3.4.
     
  10. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @Steve Tack I will find a way to deal with the attributes, either wrapping them in a preprocessor or leave them out entirely since they're just aesthetic.
     
  11. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,024
    Just for clarification:

    When developing for an actual (major) console like XBOX One, WiiU or PS4, InControl can be used without any problems? Or does the package aim for a game which is made for PC/Mac/Linux with support for the Console-Controllers?
     
  12. warance

    warance

    Joined:
    May 4, 2014
    Posts:
    11
    Question:

    I am doing a local multiplayer console game and I am trying to resolve disconnected controllers problem. So when a player disconnect and reconnect his controller, the order of the controllers in InputManager.Devices will be scrambled. So is there a proper solution to map the players back to their controller cause now InputManager.Device[0] might no longer be player1's controller anymore.
     
  13. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @BTStone InControl does not currently have console profiles, so it's mainly used for desktop/mobile development, however, I know of at least one game (http://aztez.com/) using InControl on consoles. They created their own profiles using the SDKs / devkits for each console. I hope to add official console support at some point, but since I don't have access to the SDKs myself, I'll need assistance from someone who does.
     
  14. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @warance For single player, the solution is simple: use InputManager.ActiveDevice and you're done. For multiplayer... well, it's not pretty.

    Controllers have no virtually no standardization and HID (the protocol desktops use to talk to input devices) does not require devices to provide any kind of unique ID and thus they don't have one. That makes it impossible to know that the same device has been reattached, or keep the order identical. We are at the mercy of hardware, OS and Unity limitations here.

    Consoles are an exception because they implement their own proprietary hardware, OS and drivers, which is also why they can have nice features like player lights, touch pads and colored LED bars and rumble. Desktops are like the wild, wild west by comparison.

    This presents us with a tough challenge: design for maximum flexibility. Your users may have 3 controllers attached, or they may have 7 attached, or whatever. Some controllers are attached, and show connected, but aren't OS compatible. The wireless Xbox 360 receiver often reports phantom controllers. I've even heard of a webcam that reports itself as a controller. Some controllers require an app restart if you do certain things (toggling between X and D mode on Logitech controllers, for example).

    You will need a way for players to indicate which controller(s) they want to use, and you will need a way for them to re-select their player if controller changes are detected. This may be an options menu. This may be a player select menu where a button press on each controller add a player. The best way will be specific to your game, of course.

    It seems like many games these days require everything set up before the game starts and if someone disconnects during the game, they just stop working. Often you event have to make sure all controllers are connected before you launch the game or it's tough bananas. There are some interesting approaches out there—one that comes to mind is how Jamestown has you map your controller right before play with a few quick button presses. I think it takes some creativity.

    This is hands down the most infuriating part of working with controllers, but it is, unfortunately, the reality we have to deal with. :(
     
    Mobaiou likes this.
  15. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    InControl v1.2.1 has been submitted to the Asset Store with the following updates:
    • Better support for scene switching.
    • Added space, header and range property attributes for Unity 4.3 compatibility.
    • Fix for building Windows Store apps.
    • Fix to Xbox One profile for split axes triggers.
    • Improved Logitech F310 / Dual Action support.
    • Added PlayStation 3 Android profile.
    • Map Xbox back button to InputControlType.Back instead of InputControlType.Select
    • Add InputControlType.View for Xbox One controller.
    • Create system compatible newlines when generating profile list.
    • Disable Xbox One profile if XInput is used.
    If anyone needs early access to the update, just e-mail me your invoice number and I'll send you the package.
     
  16. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Hey pbHogan,

    I bought InControl today and began implementing it with my GAC System Asset. I have a question, I want to get the direction of a stick/analog say UpLeft, how do I go about doing this?

    Thanks,
    jrDev
     
  17. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @jrDev there's a number of ways to go about querying an analog. You can use InputDevice.LeftStickX and LeftStickY, or you can use InputDevice.LeftStickVector (which gives a Vector2), or you can use InputDevice.LeftStick which gives an object that lets you query directions like InputDevice.LeftStick.Up.IsPressed. There are similar queries for the right stick and d-pad. You can also query InputDevice.Direction which combines the left stick with the d-pad. There is no specific query for UpLeft... but you can combine Up and Left, or figure out what you need from the x and y vector components. http://www.gallantgames.com/pages/incontrol-getting-started
     
  18. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Perfect! I found the StickVector a few minutes ago but was wondering if there were any set vectors anyone uses. It should be easy though. Are the Vector values normalized?

    Edit: nvm, they are so UpLeft would be (-1,1).

    Thanks,
    jrDev
     
  19. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @jrDev Yes—the vectors are always normalized for controllers.
     
  20. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Hey pbhogan,

    Could you explain to me what a Stick Button is? I am not familiar with it.

    Thanks,
    jrDev
     
  21. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @jrDev On most major controllers, if you press on an analog stick, it clicks and acts as a button.
     
  22. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Just like on the PS3 controller.
    EDIT: InControl is fantastic BTW!
    Thanks,
    jrDev
     
    Last edited: Jul 29, 2014
  23. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Hey pbhogan,

    I have another question. How do I go about getting the Vector2 of an Unsupported Analog?

    Thanks,
    jrDev
     
  24. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    So I realized there are no Vector2 for Analogs because each Analog consist of 1 Value if I am understanding correctly?
    So Analog0 corresponds to Horizontal of a set control stick and Analog1 corresponds with Vertical of that stick. So Analog0 and Analog1 must be grouped together to create a Unique stick?

    pbhogan, let me know if I am on the right track please.

    Thanks,
    jrDev
     
  25. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @jrDev LeftStickX, LeftStickY, RightStickX and RightStickY are the individual axes, but you can also access them together as LeftStick or RightStick, which has a Vector property and can also be implicitly cast to Vector2 and Vector3. If you're having to access things as Analog0 and Analog1, then it sounds like you have an unknown controller not mapped by InControl and will need to create a device profile for it.

    Also, it may be better to e-mail me with support questions so we don't clog up the forum thread going back and forth—thanks! Contact info here: http://www.gallantgames.com/contact
     
  26. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Hey pbHogan,

    Email Sent!

    Thanks,
    jrDev
     
  27. S-0-L-0

    S-0-L-0

    Joined:
    Nov 9, 2012
    Posts:
    163
    How to setup inControl with NoesisGUI? Calls like .KeyDown from this script:
    http://www.noesisengine.com/forums/viewtopic.php?f=3&t=483

    Don't seem to be working. How can these scripts be made compatible with inControl?

    P.S. It would be nice to have NoesisGUI integration on the support site.
     
    Last edited: Aug 8, 2014
  28. Garth-Smith

    Garth-Smith

    Joined:
    Apr 26, 2012
    Posts:
    1,237
    InControl is great!

    A question, is there a way to figure out if an Xbox or a PlayStation controller is attached? I got InControl so I don't have to care about which controller the player is using, but now I want to know which controller is attached so I know which icons to display.
     
  29. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    @Garth Smith Naturally, I don’t really recommend checking for a specific device, but if you need to, you can take any given instance of InputDevice, try to cast it to UnityInputDevice, and assuming that succeeds (is not null) check its Profile property. This will give you an instance of UnityInputDeviceProfile which has a Name (string) property you can check.
     
  30. Garth-Smith

    Garth-Smith

    Joined:
    Apr 26, 2012
    Posts:
    1,237
    I'll check that out. Yeah I know it's not a perfect solution, especially since I have no idea what 3rd party controllers might have for a name, but I'm guessing I can at least id the PlayStation controllers then fall back to Xbox otherwise. Thanks!
     
  31. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    Assets/InControl/Source/GUI/InControlInputModule.cs(348,60): error CS0426: The nested type `MouseButtonEventData' does not exist in the type `UnityEngine.EventSystems.PointerInputModule'

    can you help please...

    im using unity 4.6 beta
     
  32. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    186
    Which version of 4.6 beta are you using? The latest version of InControl (1.3.7) is compatible with 4.6 beta 20. Since it's in beta, Unity is making breaking changes to the event system internals every release, so it takes a week or two after Unity releases a beta update for a fix to make it into the Asset Store allowing for me developing a fix and getting the update approved (which is taking quite a while currently).

    I see they've just released beta 21 which I haven't had a chance to test with yet. You can send me an e-mail and I'll send you the updated file as soon as I have it. Or you can roll back to beta 20 until InControl's next update lands with the fix.

    Of course, if you're not using InControl with the new UI, you can just delete InControlInputModule.cs ;)
     
  33. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    oh wow that was quick :)

    I'm using b18.. i didnt know they had a recent release. I'll download b20 for now.

    Thanks for helping.
     
  34. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    222
    EDIT: Fixed! its a problem with the naming being different in the betas.
    FIX: go to InControl/Source/Unity/DeviceProfiles find LogitechF310ModeXWinProfile and add "Gamepad F310 (Controller)" to the JoystickNames. so far this has fixed all the problems.
    BTW: thanks to creator for the fix!

    I'm running into an issue where my gamepad is coming up as unrecognized. its a logitech F310 which is listed as supported and yet it gives me this error:

    Device 1 with name "Gamepad F310 (Controller)" does not match any known profiles.
    UnityEngine.Debug:LogWarning(Object)
    InControl.InControlManager:HandleOnLogMessage(LogMessage) (at Assets/InControl/Source/Components/InControlManager.cs:122)
    InControl.Logger:LogWarning(String) (at Assets/InControl/Source/Debug/Logger.cs:43)
    InControl.UnityInputDeviceManager:DetectAttachedJoystickDevice(Int32, String) (at Assets/InControl/Source/Unity/UnityInputDeviceManager.cs:173)
    InControl.UnityInputDeviceManager:DetectAttachedJoystickDevices() (at Assets/InControl/Source/Unity/UnityInputDeviceManager.cs:94)
    InControl.UnityInputDeviceManager:RefreshDevices() (at Assets/InControl/Source/Unity/UnityInputDeviceManager.cs:46)
    InControl.UnityInputDeviceManager:.ctor() (at Assets/InControl/Source/Unity/UnityInputDeviceManager.cs:23)
    System.Activator:CreateInstance()
    InControl.InputManager:AddDeviceManager() (at Assets/InControl/Source/InputManager.cs:239)
    InControl.InputManager:SetupInternal() (at Assets/InControl/Source/InputManager.cs:95)
    InControl.InControlManager:OnEnable() (at Assets/InControl/Source/Components/InControlManager.cs:30)

    P.S. i tried it with both the 4.6 beta and 5 beta and both had the same issue.
     
    Last edited: Oct 30, 2014
  35. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    77
    Any way to get the non-normalized input for each stick? Slowing down horizontal movement because someone is aiming diagonally is making things difficult today.

    EDIT: Woops. Looks like I can use magnitude and sign. Mah bad

    EDIT EDIT: Nope that didnt fix it. Any way to get raw values?
     
    Last edited: Nov 2, 2014
  36. inafield

    inafield

    Joined:
    Feb 26, 2013
    Posts:
    281
    4.6 RC1 has around 53 errors. Currently downloading RC2 to see if the errors change at all. Not holding my breath.
     
  37. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,107
    RC1 changed the interface used for the custom modules. The open source standalone input module from Unity up on Git which we had based our code on broke as well. Unity is supposedly working on making the new source available on a new repository, but last I heard they did not know when it would be available. That is most likely the reason InControl breaks as well.

    Is this still being actively maintained btw...? It's been a while since answers in the thread....?

    My question is whether there is any full documentation available? I have seen the Get Started resources on the website but is there anything more in depth?

    TIA!
     
  38. inafield

    inafield

    Joined:
    Feb 26, 2013
    Posts:
    281
    @Foxxis the developer responds very quickly. I emailed in regards to the 4.6 RC1 errors at night and received a reply the following morning.

    See this page for more information: http://www.gallantgames.com/pages/incontrol-new-unity-gui

    It doesn't appear that there is more documentation, but I've been playing around with it and it's quite intuitive. I have a self-made demo running on my Surface RT and I think I'm just 1 or 2 lines of code away from having my game running properly with the touch controls as well as PS3 controller.
     
  39. inafield

    inafield

    Joined:
    Feb 26, 2013
    Posts:
    281
    1.3.8 is out with official fixes for 4.6
     
  40. kurotatsu

    kurotatsu

    Joined:
    May 10, 2012
    Posts:
    589
  41. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,209
    Nice tool so far! Trying to figure out identifying players at the moment, the info on the site was helpful. I have a few questions about various things..

    How do I identify which device fired a submit/click on a button, for instance, when using the new UI? Use case would be character selection, I would need to obtain the device that chose that character. I could do this one by one, but would prefer to do it with all devices at the same time (fighting games) which leads to...

    Is there a way to have each device navigate the menu individually? I could do this with some work, making custom control for a UI element which is controlled by a specific device (and in turn solve the issue behind the previous question) but I'm curious if this is possible within the UI system natively. Additionally...

    Is there a way to specify which device is in control of UI navigation?

    Thanks,
    Lane
     
  42. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    238
    Loving this so far, excellent work. Saved me weeks of effort.

    Double on LaneFox's question. I have multiple players on the same client. The device assigned to player 1 shouldn't be able to send events to a menu that is serving player 2 (character selection for example). This is really a question for the new UI and event system, but getting that question answered would be a step in the right direction.

    Edit: Taking a closer look at InControlInputModule.cs:
    Code (CSharp):
    1.     InputDevice Device
    2.         {
    3.             set
    4.             {
    5.                 inputDevice = value;
    6.             }
    7.  
    8.             get
    9.             {
    10.                 return inputDevice ?? InputManager.ActiveDevice;
    11.             }
    12.         }
    I'm sure you could add/extend this class for handling of multiple controllers. Have it watch all the devices and fire events in different directions. However, Unity does not allow for multiple event systems, so you likely have to write your own event handling solution for currently selected and button navigation.
     
    Last edited: Dec 16, 2014
  43. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,209
    Thats what I was starting to wonder. I'm not familiar with doing that, has anyone looked into that sort of thing yet? The UI system is relatively new, so this may be a dot release feature or a totally ignored point altogether.

    Thoughts?
     
  44. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    238
    Yes LaneFox, crack open the InControlInputModule.cs and use it as a template for writing your own system.

    If it's beyond your skill as a programmer (not trying to be condescending) then you may be in trouble. Someone else could tackle the problem for you.

    I may have to do this myself at some point depending on the scope of the project. If so, I'll post my solution here, but that wont be for weeks if not months.
     
    LaneFox likes this.
  45. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,604
    Hey pbhogan,

    Can you tell me how to register a button being held down? I tried IsPressed but it doesn't seem to work like units GetKey type events.

    EDIT: NVM, it works the way it should, the problem was on my end.

    Thanks,
    jrDev
     
    Last edited: Jan 8, 2015
  46. ForrestX

    ForrestX

    Joined:
    Apr 17, 2010
    Posts:
    94
    Windows 7 64bit or Windows 8 64bit
    Unity 4.5.4

    With two original Xbox360 controllers attached, in Editor triggers work perfectly.
    When I build, only triggers seem to be inverted (pad1 <-> pad2) and they don't respond correctly (mainly they don't work at all).
    Tried the "TestInputManager" scene.

    What's the problem?

    (And why Unity recompiles each time I press play in the editor?)
    EDIT: found this post: http://www.gallantgames.com/posts/27/details-on-the-xbox-360-controller-bug-in-unity
    EDIT: I tried with two xBox one controllers (wired) simultanely using this driver:
    http://majornelson.com/2014/06/05/pc-drivers-for-the-xbox-one-controller-available-now/
    Same bug.
    I guess then that is not related to 360 drivers but it happens when two or more identical controllers are plugged in, infact using a 360 controller and a ONE controller together works perfectly. (although it find a phantom device on one of two PCs).


    Unity support sleeps as usual and this is of course a serious problem. Bah...
     
    Last edited: Feb 5, 2015
  47. Aedous

    Aedous

    Joined:
    Jun 20, 2009
    Posts:
    232
    Hey there! first of all great plugin! wish Unity just came with it's own default :(.

    I've been using your plugin since the Unity 4.6 beta came about, and everything was working fine. I updated to Unity 4.6.1f which I believe is the latest release, however I've now run into a few problems, I'm also not using any GUI functionality just in case you think that may be the problem.

    - The Playstation 4 pad no longer works, but is recognised and shown by Incontrol in the console window.
    - Xbox 360 pad is absolutely fine, but for some reason the triggers do not work on a different laptop ( used an Xbox 360 program to test triggers and windows is picking it up, but not Unity ) - EDIT: Just installed Xbox 360 drivers which seemed to fix it.

    Just to make sure I wasn't going crazy, I opened up one of your examples and tried it with the Xbox 360 pad ( works fine ), but the PS4 pad just doesn't bring up any input.

    I also redownloaded Incontrol from github v1.3.9, and still the same problem, Xbox 360 pad works on my laptop ( but not my second one ) and PS4 pad just doesn't work at all.

    I did another test with my old builds, and both pads where working fine (still the same issue with triggers not working on a different laptop but at least both pads where working fine on one), so I'm assuming it's something to do with Unity.

    If anyone could share any light on this issue, would be really greatful :)

    EDIT: Looks like all I had to was download the Xbox 360 drivers in order for things to start working correctly. Seems to have fixed the Xbox 360 trigger and Ps4 pad issues.
     
    Last edited: Feb 7, 2015
  48. ottolb

    ottolb

    Joined:
    Jul 1, 2009
    Posts:
    42
    Hey Patrick,
    how to check if an Input Device is a joystick?

    Currently I'm doing:

    Code (CSharp):
    1. InputDevice inputDevice = InputManager.ActiveDevice;      
    2. UnityInputDevice uid = inputDevice as UnityInputDevice;
    3. uid.Profile.IsJoystick
    thanks
     
    Last edited: Mar 4, 2015
  49. Mistale

    Mistale

    Joined:
    Apr 18, 2012
    Posts:
    173
    Just bought this, excellent addon! Never thought it could be this easy to add keyboard/mouse + different controllers to my project!

    However, I'm having problems getting touch controls to work.
    It seems like the virtual buttons and sticks only report their status when the user moves his finger (or mouse).
    Even in the touch example provided, if I move the virtual joystick using the mouse in the editor, the cube will only spin for a moment until I move the mouse again. Not like a joystick. And the buttons don't work except perhaps once every 10th press or something like that.

    If it's any help, I'm using Unity 5. And when starting the example scene, incontrol always reports an Ouya device as the active device (is that normal? It seems like mouse input is received through the touchpad of this virtual Ouya device).
     
  50. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    111
    Love the InControl! One small issue is it gc allocs 16B of garbage every couple of frames or so. I think I traced it to this call :

    Input.GetJoystickNames();

    Since that's a Unity call I'm not sure anything can be done about it, but thought I'd ask.