Search Unity

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

Feature Request Keyboard WASD and DPAD

Discussion in 'Input System' started by X3doll, Nov 3, 2022.

  1. X3doll

    X3doll

    Joined:
    Apr 15, 2020
    Posts:
    34
    How there is "Gamepad.current.dpad" and there isn't "Keyboard.current.wasd" and "Keyboard.current.dpad"?
     
  2. X3doll

    X3doll

    Joined:
    Apr 15, 2020
    Posts:
    34
    It's super sad that i have to this way.

    Code (CSharp):
    1.  
    2.                 var wasdDirection = new Vector2(
    3.                     keyboard.wKey.ReadValue() - keyboard.sKey.ReadValue(),
    4.                     keyboard.dKey.ReadValue() - keyboard.aKey.ReadValue()
    5.                 );
    6.                
    7.                 var dpadDirection = new Vector2(
    8.                     keyboard.upArrowKey.ReadValue() - keyboard.downArrowKey.ReadValue(),
    9.                     keyboard.rightArrowKey.ReadValue() - keyboard.leftArrowKey.ReadValue()
    10.                 );
     
  3. ManuelRauber

    ManuelRauber

    Joined:
    Apr 3, 2015
    Posts:
    122
    Why should it be there?
    DPad, aka Digital Pad is a distinct physical control on a game pad.

    That you use WSAD for moving a character on the keyboard, is not "one physical" control but for that form a direction. If that would be there, there must also be .leftRightUpDownArrow thing or for local coop games maybe a .ijkl thing.
    Does not make sense.

    You can simply compose whatever you need from your physical keys, either set it up via code like you did or the visual approach.
     
    Ryiah likes this.
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,966
    Because these shortcuts are based off of the physical controls on the device.

    Outside of prototyping you shouldn't be doing it this way either as you risk getting negative reviews from people who want to use other keys or have keyboards with alternative layouts.
     
    Last edited: Nov 3, 2022
  5. X3doll

    X3doll

    Joined:
    Apr 15, 2020
    Posts:
    34
    Ah i didn't know that directional pad was a unique block of physical controls.

    I was thinking the API was made to make it simple as common feature (Yeah i know that you cannot physically move the keys, but either other common configuration you cannot), and that's because i was complaining about that there isn't WASD and KDPAD.

    Thanks for the responses.

    Anyway, yes i was prototyping. Btw if i don't want to support rebinding or alternative layouts in the final product, it is too problematic to do this way? Anyway that's good to know, sure it's on list.
     
  6. X3doll

    X3doll

    Joined:
    Apr 15, 2020
    Posts:
    34
    I was not talking about "character", whatever. I was talking about "why" gamepad has API physically mapped such as
    Gamepad.Dpad
    and Keyboard not have a API such as
    Keyboard.Wasd
    , this was my sentence. For me make sense to exists, and is quite useful only when is mapped using some sort of internal localization, using keyboard layouts (EN, IT, FR. etc..). Example: Gamepad Arrows remains as is whatever gamepad you use, ps4, ps3, xbox, switch.. etc..., but keyboard is pretty disposed in a way that change based on the keyboard layout, that's why you cannot rely on "Use whatever key you want and build your own" that's why you cannot and why Gamepad in way more reliable then the keyboard.