1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

[Released] cInput 2 - Unitys custom inputmanager got improved !

Discussion in 'Assets and Asset Store' started by Roidz99, Apr 4, 2012.

  1. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    176
    Hi Roidz,

    This plugin looks absolutely amazing. I've been wanting this for forever and can't believe it's not a standard Unity feature. I am not wanting to store anything in PlayerPrefs, however, and am wondering if I can easily rig this to save using EasySave2 (Basically just saving to a file, encrypted) rather than in PlayerPrefs? I assume I can edit the save sections to where it saves and loads from, but ideally I'd like to not edit your scripts to allow for future updates. Any ideas?

    Additionally (This may already be in the documentation, I apologise) but if you want to use the mouse as input is this available? For example, if I wanted a joystick's axis as the left/right input and moving the mouse left/right as the secondary, is this available?

    Finally, I just loaded up the JS demo and tried to set my Xbox controller as some of the buttons. However I'm getting errors saying 'input axis joy1 axis1 has not been setup' etc. I can't seem to find documentation to say what I need to set up to get gamepads etc. working, are you able to point me in the right direction?
     
    Last edited: Jul 17, 2012
  2. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,604
    I'm with gumboots, I think. Is this safe to use with a webplayer?

    From the Unity documentation:

    1MB doesn't sound like a whole lot if there's for instance thousands of players playing your game and customizing their controls. I currently store highscores etc. with MySQL, would be nice if the controls could be stored there as well. That is if I'm not worrying needlessly and this isn't actually a problem. :)
     
  3. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    This is a good idea, Deozaan and me will discuss this to see if we can give the dev a choice to save to the playerprefs or to an external file. We will get back at this

    Yes this is available, check the docs :)

    You can use the Keys class for this ,this should be explained in the docs also, we also have a list at the end with inputs that work with cinput2. If i'm understanding this wrong or you can't figure it out, please let us know and we work it out. :)
     
  4. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    1MB is quiet a lot for playerprefs - the cinput2 controlls are kept local, so the player will have its controlls saved to his playerprefs. This will take only a few kilobytes tops. But as i said in the previous post,we are gona look into saving the inputs to an external format. This is a decision i would like to make with Deozaan tho', and there he is on vacation, don't expect it to be done this week...
    But keep an eye on upcomming updates for this !

    EDIT: and yes it's save to use with a webplayer
     
    Last edited: Jul 18, 2012
  5. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    176
    Hi Roidz,

    Ideally a way to plug in to the save/load method would be great, so I can use EasySave 2 which I'm currently already utilising.. hehe.
     
  6. goodhustle

    goodhustle

    Joined:
    Jun 4, 2009
    Posts:
    310
    Hey guys! A couple quick things:

    1) The public scanning property is great! But it should preferably be static like everything else.

    The underlying property is static, and this should be static too.

    2) The static methods / behind-the-scenes instance creation is sorta driving my code into contortions right now.

    There's no way to call the createcObject method publicly, which means if I do an integration that needs access to cInput values within Start of another monobehaviour, it seems like I have to call something like cInput.length, then yield a frame because the initialization doesn't happen until the newly created cInput GameObject gets to call its own Start function at the very end of the current frame (not immediately!).

    This happens when I need to run GetKey to configure a enter/cancel key for NGUI's camera. I tried doing this in the Start method of another monobehaviour, but it throws errors if I just run cInput.GetText()/GetKey immediately.

    Instead, I need to do a weird-looking workaround like
    Code (csharp):
    1.  
    2. IEnumerator Start() {
    3. Debug.Log("Ignore: " + cInput.length); // Schedule initialization routines for Start() in the next frame when newly instantiated GO's are handled.
    4. yield return null;
    5. sceneCamera.submitKey0 = cInput.convertString2Key(cInput.GetText(submitKeyName, 1));
    6. }
    7.  
    This might be nicer:
    Code (csharp):
    1.  
    2. void Start() {
    3. cInput.createcObject(); // Do initialization routines
    4. sceneCamera.submitKey0 = cInput.convertString2Key(cInput.GetText(submitKeyName, 1));
    5. }
    6.  
    Anyway, open to comments or suggestions, as always.
     
  7. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Hi goodhustle,

    1) That was an oversight. Thanks for pointing it out. It will be made static in the next release.

    2) We tried to make it so that cInput would create the game object automatically for you, but apparently we didn't cover all scenarios. It should be simple enough to provide a public method to initialize the game object, but I'll need to discuss it with Roidz first to make sure there's no specific reason for not having it.

    Thanks again for your feedback.
     
  8. DoTheEyeThing

    DoTheEyeThing

    Joined:
    May 25, 2011
    Posts:
    4
    I'm having some problems getting cInput to work with any axis inputs (xbox OR ps3 joysticks). I created a new project with nothing but your example project - loaded the c# version, and when I click play I'm already getting a Unity Exception - UnityException: Input Axis Joy1 Axis 1 is not setup. To Change the input settings use: Edit -> Project Settcings -> Input

    If I then try to hit escape and open the gui to change inputs during runtime, as soon as I click one the Unity Exception changes to - UnityException: Input Axis Mouse Wheel is not setup. To Change the input settings use: Edit -> Project Settings -> Input. And when I try to use anything axis based it won't accept the input, but it will accept buttons on either controller.

    Strangely, your webdemo of the same project DOES accept my axis inputs correctly.

    I'm using Unity 3.5.3

    Any ideas what could be going wrong?
     
    Last edited: Jul 29, 2012
  9. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    I think you just need to copy over the InputManager.asset file into your ProjectSettings folder (overwriting the existing file).

    If that's not the problem, can you zip up the entire project so I can take a look at it?
     
    Last edited: Jul 30, 2012
  10. DoTheEyeThing

    DoTheEyeThing

    Joined:
    May 25, 2011
    Posts:
    4
    Ah yep that was it. I feel silly now :p Thanks!
     
  11. goodhustle

    goodhustle

    Joined:
    Jun 4, 2009
    Posts:
    310
    Possible bug: If Clear() is called, it wipes out the _defaults array and doesn't re-save it. Because I work in the editor a lot, and have cInput setup only on my splash screen, this can cause a crash if Clear() is called and I try to restart the scene, which calls LoadInputs and assumes that _defaults is populated. Why does Clear() delete all the keys? And since it already re-saves the inputs and axes, why not re-save the defaults?
     
  12. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Clear() is intended to completely wipe out all the values stored in PlayerPrefs by cInput. This is working as intended.

    However, it does look like the ResetInputs() function which resets the inputs to the defaults and then calls Clear() does not re-save the defaults as it should. The fix for this will be in the next update. But until then, you can simply put _SaveDefaults(); in the ResetInputs() function under the line where it calls Clear().

    Thanks!
     
  13. goodhustle

    goodhustle

    Joined:
    Jun 4, 2009
    Posts:
    310
    No prob!

    Got another request - since I built my own control settings GUI in NGUI and outside of the UnityGUI system, having the OnGUI functions inside the cInput object really slows things down unnecessarily. I can always rip them out whenever I download a new build, but I think it's a good idea to suggest that you separate the cInput GUI into its own class. That, and it will also ensure that you have all the necessary public methods available for everyone to implement their own control setup GUI. Thanks!
     
  14. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    this is a interesting tought and we will discuss this , we gotta make sure cInput stays backwards compatible. We will see what our options are on this.
     
  15. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Hi folks,

    An update to cInput has been submitted to the Asset Store and the cInput website. If you bought cInput from the Asset Store then the update should be available within 24 (business) hours. If you bought it from the website then the update is available right now.

    @goodhustle: As for separating the GUI from the main cInput class, Roidz and I both think that is a good idea, but we're still working out how to do that without breaking backward compatibility, so that didn't make it into this update.

    cInput changes:

    v 2.4.1

    • Added public Init() to manually create the cInput object. (Thanks goodustle)
    • cInput now supports saving/loading inputs to/from sources other than PlayerPrefs. (Thanks gumboots)
    • Made "scanning" property static. (Thanks goodhustle)
    • Fixed a bug with allowDuplicates.
    • ResetInputs() now re-saves defaults to PlayerPrefs. (Thanks goodhustle)
    • Fixed ChangeKey() to properly (dis)allow certain inputs. (Thanks Adrian)
    • Fixed certain debug messages showing when they shouldn't.
     
  16. GS Kiwibird

    GS Kiwibird

    Joined:
    Jan 27, 2012
    Posts:
    7
    I seem to be receiving an error for all of Joystick 5's buttons. cInput.SetKey("Special_5", "Joystick5Button0") results in the error: "cInput error: Joystick5Button0 is not a valid input." Setting the Axes seems to work fine though. cInput.SetKey("Special_1", "Joystick1Button0") works fine, as well as 2, 3, and 4. Anything past 4 results in that error. Any idea what's wrong?
     
  17. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    It appears as though Unity itself only supports up to 4 joysticks/gamepads. That is to say that it only has KeyCodes to accept the button input for the first four joysticks.

    Scroll down this list of KeyCodes and see for yourself.

    The strange thing is that the Input Manager in the Editor allows you to define inputs for up to 11 Joysticks. I'm not sure why the folks at Unity think you might want to use 11 joysticks' axes but not be able to press the buttons on more than half of those joysticks.

    I'm stumped on this one.
     
  18. GS Kiwibird

    GS Kiwibird

    Joined:
    Jan 27, 2012
    Posts:
    7
    What's interesting is I had 5+ joysticks working before just using Unity's input manager. It was horrible to set up the bindings in the standalone executable though, which is why I switched to cInput. Anyway, I think the reason it worked is because of this:

    The number of input devices is 17. The maximum number of inputs Unity will allow is 80 inputs. (4 joysticks, each with 20 buttons).

    I had 5 or 6 joysticks, each with only 5 buttons, not 20. I wish Unity had better support for joysticks... I'm curious, how did you get cInput to scan for joystick inputs during run-time?
     
    Last edited: Aug 31, 2012
  19. GS Kiwibird

    GS Kiwibird

    Joined:
    Jan 27, 2012
    Posts:
    7
    Ah, this makes sense. Unity does support more than 4 controllers, BUT it does not support the keycode events past Joystick 4. Don't know why... So any controller that is 5+ would have to be set up before hand... Now I know why I had 5+ controllers "working" before.
     
  20. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    First of all, sorry for my delayed response. I was hoping to be able to talk to Roidz about this before responding but I haven't gotten a hold of him yet.

    I'm still confused by this. How would you go about setting up the keycode events before hand? Maybe we could get cInput to support 5+ controllers again if I understood that.
     
  21. GS Kiwibird

    GS Kiwibird

    Joined:
    Jan 27, 2012
    Posts:
    7
    As I understand it, Unity only allows the binding 5+ controllers through the use of the Input Manager, and through the use of the Input tab of the stand-alone.

    The Input Manager allows you to type out "Joystick 5( or 6, 7, etc) Button 0" as a valid button while the Input tab of the stand-alone allows you to press the button for detection on "Joystick 5(or 6, 7, etc) Button 0".

    Unity does not allow for detection of Joystick 5+ during run-time through the use of Event.keyCode in user created scripts. It only supports KeyCode events for Joysticks 1-4.
     
  22. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    We initially designed cInput to support 5 controllers, but we recently made some changes to it to speed it up which caused it to no longer support more than 4 controllers. Since Roidz was the one who made those changes, I wasn't sure what exactly the problem was. But I think I know what it is now that you've explained it, so maybe we can get support for 5 controllers back into cInput in the next update.

    Thanks again!
     
  23. vorce67

    vorce67

    Joined:
    Sep 11, 2012
    Posts:
    3
    Is it possible to delete all current Default keys so they can be reassigned? I would like to be able to assign default keys for a keyboard a mouse then on the fly delete the default keys and assign different default keys for an Xbox controller?

    I also appear to be in a situation where I have messed up the saved controls. In a Start function I call SetKey() for all my default keys. However when the game starts none of the keys are assigned and I have to call ResetInputs to get them back to the default keys. I cannot seem to get it to save the default keys as my starting keys. Also Calling ResetInputs() from a Start routine does not seem to work as something is overriding it. I only seems to work if it is called later on after the game starts running
     
  24. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Try calling cInput.Clear(); which clears all data stored by cInput from the PlayerPrefs.

    If I understand you correctly, that should solve both of your problems.
     
  25. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    304
    How would I prevent the using from binding a certain key? Specifically the left and right mouse buttons.
     
    Last edited: Sep 21, 2012
  26. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    This is explained in the documentation. There are, essentially, two ways this could be done:

    One way is that when you use ChangeKey() you can specifically not accept input from the mouse buttons, among other things. Just pass in false for the "mouseBut" parameter from the definition of ChangeKey() below.

    Code (csharp):
    1. ChangeKey(name: string, [input: int], [mouseAx: bool], [mouseBut: bool], [joyAx: bool], [joyBut: bool], [keyb: bool]) : void
    Another way is to use ForbidKey() to forbid cInput from allowing specific keys to be bound, like so:

    Code (csharp):
    1. cInput.ForbidKey(Keys.Mouse0);
    2. cInput.ForbidKey(Keys.Mouse1);
     
  27. Ghisallo

    Ghisallo

    Joined:
    Sep 27, 2012
    Posts:
    10
    Can cInput be used to make a workaround for allowing text input on a Flash player? Specifically I need users to be able input their user names somehow. It doesn't have to be in a typical GUI box. The text characters could just appear on the screen. Then I'd need to be able to store the text in a variable. Thanks.

    Edit:
    Upon further investigation, I really only need to map the Backspace and maybe the Enter keys to commands. Is that possible? Thanks.
     
    Last edited: Oct 5, 2012
  28. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    cInput can detect ENTER or BACKSPACE but i'm not sure you need to use cInput for this.
    I think you can detect it also if the user pressed bakcspace or enter.
     
  29. Ghisallo

    Ghisallo

    Joined:
    Sep 27, 2012
    Posts:
    10
    The problem is that a Flash player will not register a backspace in a GUI.TextField. But you're right that Input.GetKeyDown(KeyCode.Backspace) will work. I'll pursue this. Thanks.
     
  30. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    happy to help :)
     
  31. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    99
    1) How about a ClearKey function on right-click of a button that isn't in "change mode" to set it to None?

    2) If my intent is to allow player to create "macros" or somesuch, they'll need to be able to add new entries with a name (for the label), the keys to assign, and some means to define what this new thing does (i.e. text box to type in commands). In such a case, do I need to pre-define some fixed number of "Keys" entries, with most of them blank for the player to define, or can it be open-ended to let the player add/remove them as they see fit?

    3) What about Comination keys, i.e. Shift+G or Alt+G or Shift+Ctrl+G?

    4) The Windows key comes up as LeftApple...is that a Unity bug or in your code?
     
    Last edited: Oct 6, 2012
  32. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    This could be a good idea. I'll discuss it with Roidz and see what he thinks about implementing this into cInput. In the meantime, you can click on a button to set it to "change mode" and then press Escape to set it to None.

    cInput can add/remove Inputs as you see fit. Though you may need to manually reset to defaults or clear out the cInput settings which are saved in PlayerPrefs (with cInput.Clear()) to prevent conflicts with changing numbers of inputs.

    For something like this you would simply check if both the modifier key(s) and the main key(s) are all being pressed down. For example:

    Code (csharp):
    1.  
    2. cInput.SetKey("Shift", Keys.LeftShift, Keys.RightShift);
    3. cInput.SetKey("Jump", Keys.G);
    4.  
    5. if (cInput.GetKeyDown("Shift")  cInput.GetKeyDown("Jump")) {
    6.     //Shift+G has been pushed
    7. }
    8.  
    I just tested this in the Editor in Windows using the built-in Input functions, and Unity seems to recognize my Windows key as the LeftApple key, and doesn't recognize it as the LeftWindows key, so it seems to be a Unity bug.
     
  33. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    99
    While this does work to "clear" a key assignment, Escape cancels the GUI entirely, even in "change mode".

    As for combinations, I'm not sure how this fits with the "ChangeKey" feature in terms of the player being able to assign a combination to a predefined or player-defined action or macro. In your demo and reference manual, the next single input is assigned, so it would be the Shift key alone, ignoring whatever else was pressed with it. Since I've no way to know (at design time) what assignments the player will choose, I can't hard code the handlers. I will need to evaluate the key(s) being pressed each frame for a matching assignment item in your Keys() collection and go from there.
     
  34. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    To fix this, you simply need to check to see if cInput.scanning is true, and if so, don't allow Escape to cancel the GUI. Assuming you're using the built-in GUI to display/change inputs, that would look something like this:

    Code (csharp):
    1.  
    2. if (Input.GetKeyDown("escape")  !cInput.scanning) {
    3.     menu = !menu;
    4.     cInput.ShowMenu(menu);
    5. }
    6.  
    Sorry, I misunderstood you before. I didn't realize that you wanted the player to be able to define the key combinations. I thought you just wanted the player to customize the letter or number, but not the modifier (shift, control, alt, etc.). In this case, you are correct that cInput doesn't have a simple way to do this built in.
     
  35. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    Howdy !

    Another update to cInput has been submitted to the Asset Store and the cInput website.
    Like always,if you bought cInput from the Asset Store then the update should be available within 24 (business) hours. If you bought it from the website then the update is available right now.

    This time its mainly a perfomance boost - we would like to hear everyones results !

    cInput changes:

    v 2.4.2

    • cInput now caches joystick axis strings. (Thanks goodhustle)
    • Escape doesn't close GUI menu in demo if scanning for new inputs. (Thanks MrG)
     
  36. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    we've updated cinput again for a small bugfix...

    cInput changes:

    v 2.4.3

    • Fixed a out of range null-reference exception related to number of gamepads. (Thanks Julian)
     
  37. Neurological

    Neurological

    Joined:
    Jun 25, 2012
    Posts:
    310
    Hello, just bought cInput a moment ago. Just wanted to ask a thing, every time you update the asset I should follow the same link you provided for download to download the new version? As I bought it from your site as it was cheaper.

    By the way glad this asset exist, I was really scared to think about releasing a pc game without key bindings.
     
  38. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    hey ! Thanks for buying cinput !

    The price on the asset store and the website should normally be the same.
    What price did you pay on the website and what price do you see on the asset store ?

    As you said, keep the download link you received for future updates, the link should automatic update when there is a new release.
    We always post new updates here on the forum and on our website.

    Hope you enjoy using cinput :)
     
  39. Neurological

    Neurological

    Joined:
    Jun 25, 2012
    Posts:
    310
    The price is the same, is the conversion that is not. Unity asset store converted the 20 $ to 19 euro, instead from your site with the paypal tax and all it was only 16 euro, which is the right conversion.

    But anyway, already digging into cinput and starting to make a menu for it.
     
  40. Neurological

    Neurological

    Joined:
    Jun 25, 2012
    Posts:
    310
    Sorry for double post but want to report a small problem with cInput.

    I can't seem to make a button or axis of the same name with more than 2 keys. I know cInput support two button for each input, but this is about keyboard and pad, here an example:


    cInput.allowDuplicates = true;

    cInput.SetAxis("Horizontal", "Left", "Right", 10f);
    cInput.SetAxis("Horizontal", "Right X360", "Left X360", 10f);

    When run the scene only the keyboard inputs works, the pad ones are totally ignored, So in order to make it work I have to rename the pad horizontal axis to something else. I know that with the vanilla input menager of unity is doable to use the same axis name for both keyboard and pad, maybe is possible to add this on cInput too?
     
    Last edited: Dec 8, 2012
  41. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    I think perhaps you are misunderstanding the use of allowDuplicates. What it does is allow you to assign the same input to multiple keys. For example:

    Code (csharp):
    1. cInput.allowDuplicates = true;
    2.  
    3. cInput.SetKey("Jump", Keys.Space);
    4. cInput.SetKey("Fire", Keys.Space);
    This way pressing the spacebar will trigger both the "Jump" key and the "Fire" key.

    The name of the Key or Axis must be unique in cInput. If you want to have arrow keys and gamepad axis control the game, you would make different axes and then have them both call the function to control it. e.g.:

    Code (csharp):
    1.  
    2. // assuming you already have "Left" "Right" "Left X360" and "Right X360" defined previously
    3. cInput.SetAxis("Horizontal", "Left", "Right", 10f);
    4. cInput.SetAxis("GamePadHorizontal", "Right X360", "Left X360", 10f);
    5.  
    6. // somewhere in your main game loop
    7. if (cInput.GetAxis("Horizontal") != 0 || cInput.GetAxis("GamePadHorizontal") != 0) {
    8.     // we've got input from either the arrow keys or the X360 joystick! Handle movement here!
    9. }
    I hope this helps.
     
  42. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    So I feel kind of like an idiot for missing this... But here's an easier way to do what you want if you just need to use two "inputs" per key/axis in cInput:

    Code (csharp):
    1.  
    2. // note that I don't have an Xbox 360 gamepad so I'm guessing what axis it uses
    3. cInput.SetKey("Left", Keys.LeftArrow, Keys.Joy1Axis1Negative);
    4. cInput.SetKey("Right", Keys.RightArrow, Keys.Joy1Axis1Positive);
    5. // this creates a single axis that uses both the keyboard keys and the joystick axis.
    6. cInput.SetAxis("Horizontal", "Left", "Right");
    7.  
    If you need more than two inputs per key/axis then you'll need to do it the way I previously described it. e.g., if you need to use WASD and the arrow keys, and the joystick, then you'll need to do it the way I described in my previous post.
     
  43. Neurological

    Neurological

    Joined:
    Jun 25, 2012
    Posts:
    310
    Thanks for the hints.
     
  44. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    176
    Hey Roidz,

    Question about Input.mousePosition. If I'm using this as well as cInput, am I loading two different input modules, effectively doubling usage? Or are they two separate entities (Mouse positioning, and key/button inputs)?

    I'm not hugely worried about performance, though if I can save some I will. It's mainly for understanding.

    Also I'm not quite sure I understand saving to external sources, is there a way to say when it's initialized where to load/save the preferences to? Or do I have to do it each time a key is changed?

    Thank in advance for any help!
     
  45. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    cInput uses the input class internal so it won't make any difference.


    cInput will generate 'cInput.externalInputs' (a string) everytime a change has been made internal.
    It's up to you how you save this string to an external solution.
    This can be done when the players exits the 'change inputs screen' or you can decide to add a 'save button'.


    I hope this answers your questions :)
     
  46. Distant-Temples

    Distant-Temples

    Joined:
    Apr 14, 2012
    Posts:
    112
    I just got cInput. I like the way it is set up. It's nice to be able to set the keys and stuff while the game is running. I was wondering if you had any plans to add other adjustable settings like for graphics and audio. Would be nice to be able to pull those up too.
     
  47. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Roidz and I have indeed discussed plans for tools for other adjustable settings such as graphics and audio. Can't really say what those plans are or give you any sort of ETA on those, though. It's a bit too early for that.

    Thanks!
     
  48. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    119
    Hi,

    I just sent you an email but afterwards found this thread (I'm a fool), the question may sound stupid but my problem that led me to cInput was I want to allow users to use either the mouse or gamepad, to do this you need to change 'Mouse Y', 'Mouse X' from Mouse to Joystick, in cInput is there a way to do this or can you use either the mouse or the sticks when using cInput.

    Not sure I'm explaining this very well in Unity if you change 'Mouse X, Y' to joystick you can't use the mouse and when mouse input is selected the gamepad sticks don't work so the question is, is the a setting in your asset to swap between the Axis Type or by using your system do they both work at the sometime.

    Thank you !
     
  49. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    189
    i'm not 100% sure i understand correctly but let me try to answer . If im missing it please clarify more.

    You want the player to be able to use the mouse AND a joystick/joypad.
    This can be done easely in cinput. Every action can have 2 differend inputs bound to it.

    Example:

    Action 1: player move left
    binding 1 : mouse X-
    binding 2: joystick X-

    Action 2: player move right
    binding 1: mouse X+
    binding 2: joystick x+

    this allows the player to move left/right with the mouse and/or the joystick.

    If you want to make this an axis then you can combine action 1 and action 2 into an axis. This is done with code using cinput.
    The axis will always work in your script even if the player changes keybounds to other keys/mouse/joysticks.

    So cinput handles mouse,joypads,keyboards,etc all at once without the need to change anything.


    I hope this answered your question
     
  50. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    119
    Ahh, I see you can you can have both inputs bound thats even better.

    I wanted to offer the user to either use the mouse or the gamepad and was struggling to find a smooth way to offer the choice and then swap, I seemed to be writing far too much code, but this way is so much easier !!

    Thanks for the reply I'm off to the asset store right now !


    **UPDATE** Bought, reading manual (well sort of !) ;-)
     
    Last edited: Jan 20, 2013