Love2dCS icon indicating copy to clipboard operation
Love2dCS copied to clipboard

Idea for better input mapping

Open Shadowblitz16 opened this issue 6 years ago • 6 comments

I had an idea for better input mapping. Idk if this is possible without majorly modifying love2d but if so you could allow something like this...

void SetInput()
{
    //note the any constants
    if (Keyboard.IsPressed(KeyConstant.Any)) // if any keyboard key is pressed
    {
       Keyboard.MapKey(Keyboard.GetKeyDown()) //Set binding to the first currently pressed key
    }
    else if (Joystick.IsPressed(GamepadButton.Any)); // If Joystick is Down
    {
       Joystick.MapButton(Joystick.GetButtonDown()) //Set binding to the first currently pressed button
    }
    else if (Joystick.IsAxisChanged(GamepadAxis.Any));
    {
      Joystick.MapAxis(Joystick.GetAxisChanged()); //Set binding to the first currently chnaged axis
    } 
}

this is just an idea to make input binding easier what do you think?

the bindings would have to be so they override the default button, axis, or key so for example X might not be X anymore but instead something else

Shadowblitz16 avatar Apr 18 '19 02:04 Shadowblitz16

emm, I believe it is no, it's look like a little "chicken rib" -- means "it‘s tasteless to eat but waste to throw away."

For junior developer, it was confuse. For advanced developers, they will customize their own input systems. so, i a think it was "chicken rib".

but i think the Keyboard.IsAnyKeyDown() is real useful

endlesstravel avatar Apr 19 '19 02:04 endlesstravel

well thats ok would a version of IsAnyKeyDown() be implemented for mouse and joystick as well?

mouse might be a little unnecessary but joystick would definitely be good

Shadowblitz16 avatar Apr 20 '19 02:04 Shadowblitz16

ok, not bad, I think that's the function you need :

bool Keyboard.AnyKeyDown()
bool Keyboard.AnyKeyDown(out KeyConstant key) // the output `key` is what you down
bool Mouse.AnyKeyDown()
bool Mouse.AnyKeyDown(out int button)
bool joystick.AnyKeyDown()
bool joystick.AnyKeyDown(out int button)
bool joystick.AnyGampadDown()
bool joystick.AnyGampadDown(out GamepadButton button)

endlesstravel avatar Apr 20 '19 08:04 endlesstravel

does gamepad treat axis as buttons? I was just wondering because it would be nice to map joystick directions

Shadowblitz16 avatar Apr 20 '19 18:04 Shadowblitz16

no , joystick.AnyGampadDown was any key down version of Joystick:isGamepadDown

Checks if a virtual gamepad button on the Joystick is pressed. If the Joystick is not recognized as a Gamepad or isn't connected, then this function will always return false.

endlesstravel avatar Apr 21 '19 02:04 endlesstravel

oh ok thats good to know

Shadowblitz16 avatar Apr 22 '19 17:04 Shadowblitz16