Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bugreport & Request (or help request)

Discussion in 'Input System' started by rabirland, Apr 13, 2016.

  1. rabirland

    rabirland

    Joined:
    Nov 22, 2014
    Posts:
    29
    So I just tried out the new Input system, and I would have some suggestion...

    But first, the bug report:
    The ButtonInputControl.wasJustPressed and wasJustReleased aren't works... At least I couldnt make them, they always returned false. But they would be useful for my Android game.

    And feature suggestion:
    -Number One:
    Remapping in script... Well, I have no idea if it is possible or not right now, I couldnt find a way when I dig into the scripts... As I mentioned above i'm working on an Android game, but I also implementing both Keyboard and Gamepad support... And I'm planning that they would be re-mappable in-game just like any PC game.
    And that would require three vital feature:
    #1 That we can retrieve the active ActionMap, but we can do this now from querying the PlayerInput. So pass...
    #2 Editing this action map in runtime from a script. (Also adding save feature would be great, really)
    #3 Querying any input from any device AND / OR querying any input from specific device / device category...
    Something like the Input.anyKey... But with:
    NewInput.AnyInput(); returns the device and the key that is held down...
    NewInput.AnyInput(Devices.Gamepad); Returns the key that is currently held down on any Gamepad (or Axis [read below])
    NewInput.AnyInput(Devices.Gamepads.Joystick1); Returns the key that is currently held down on the first Joystick (or Axis like "Left Stick X- or X+ etc...)
    Well, most of the games does not query mouse movement but we are game devs and our imagine is endless, so it could also return with "Mouse X+ or Mouse Y- etc...)

    Number two: Events
    Adding event handling support for PlayerInput... Even for axises, buttons, mouse movement etc...

    Number Three: Active device
    Maybe if any one needs this, we should make a device "disabled" while it is binded to a character... So they can switch between Controller or Keyboard in the same ActionMap...


    Well, if any of these are already built-in, please let me know... Especially number one
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,877
    Hmm, we haven't reproduced this ourselves. If you could create a bug report with the project attached and write the bug case number here, I can take a look.

    It is possible but not very pretty right now. It's still in early stages. If in the single player demo you press R, you will get a simple remapping UI. See the example script RuntimeRebinding for an example.

    Right these should be possible already except for the saving part. It's on our todo list.

    Right, we'll have some kind of anyInput functionality eventually. For now you can iterate all the controls and check them, but this is of course less pretty.

    This can mean many different things. Can you tell me a bit about what you plan to do with it, so I can better understand which kind of event handling you mean?

    I'm not quite sure what you mean. You can switch between controller and keyboard in the same ActionMap already, but maybe you mean in a different way?
     
  3. rabirland

    rabirland

    Joined:
    Nov 22, 2014
    Posts:
    29
    Similar to InputSystem.ListerForBinding(...)... However that reads from all device, even those are outside of the action map... For example I had a Keyboard / Gamepad action map, and ListerForBinding retrieved even Mouse movement...

    Well, maybe it is active, but I ouldnt figure it out... When I have an action map with several devices inside, my character reacted to all of them... We should have a method to block each so like in the game settings menu we can switch between active devices... Now I guess we need different action maps...

    Also, I finished my rebinging method, but now I have a huge fault:
    I can not translate keyCode into Key name... So when I query my action map I can retrieve the code 273 which is the Up Arrow... But I can not transform it into a string to "UpArrow"... Is there any way to do this ?
     
  4. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,877
    We'll probably provide a way to only accept bindings from an existing control scheme, but we don't have that yet. For now you can look at the provider of the returned InputControl and see if it matches the type of device you want (for examples, the types that are already used in the current control scheme of the ActionMap). This might be a bit tricky, so I do understand the need for an easy way to do this.

    All right. When the checkbox "" is enabled on the PlayerInput component, it will be setup to listen to all devices via a global player handle. If you don't want that, you can uncheck that checkbox and use your own code to assign specific devices to the PlayerHandle. Then the ActionMapInput will only listen to those. (You don't need multiple ActionMaps for this.)

    The multiplayer example scene works this way (or similar anyway), but for multiple players.

    I'm not sure which keyCode you mean, but you can get the name of a control by using myControl.GetPrimarySourceName()
     
  5. rabirland

    rabirland

    Joined:
    Nov 22, 2014
    Posts:
    29
    I did, but its kind of hard to understand, you need many thing to set up just for a simple task to bind a device to a PlayerHandle... And I still trying to understand how it actually works...


    I mean, when I set a key to a specific action with InputSystem.ListenForBinding the Control instance can retrieve the key code's name for example, it retrieve the code "273" but I can also read the name "UpArrow" and etc...
    But I could not find any way to retrieve the name of the key from an exisiting action map, I colud get the code "273" but no class member contains it's name "UpArrow"...
    I talking something like:

    Code (CSharp):
    1. int keyCode = 273;
    2. KeyCode keyName = (KeyCode)keyCode;
    3. Debug.Log(keyName);
    4.  
    5. //Output: "UpArrow"