-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Even more Input Idea's #69
Comments
sorry for late to reply. i think there may be multiple buttons pressed at the same time. so, it As for and Anyway, I try to give you a class: copy the code https://gist.github.com/endlesstravel/db0f9f6f93b89a23cc8f56b44b70396c into your project. class ISSUE69 : Scene
{
public override void Update(float dt)
{
Input.Update();
}
public override void Draw()
{
Graphics.Print(string.Join("\n",
$"mouse down {string.Join(",", Input.GetMouseDown())}",
$"Input.IsMouseDown(Input.MouseButton.LeftButton)) {Input.IsMouseDown(Input.MouseButton.LeftButton)}",
$"key down {string.Join(",", Input.GetKeyboardDown())}",
$"Input.IsKeyboardDown(KeyConstant.Space) {Input.IsKeyboardDown(KeyConstant.Space)}",
$"joy key {string.Join(",", Joystick.GetJoysticks().Select(joy => string.Join(",", Input.GetGamepadDown(joy).Select(name => joy.GetGUID() + ":" + name))))}",
$"joy axis {string.Join(",", Joystick.GetJoysticks().Select(joy => string.Join(",", Input.GetGamepadAxis(joy).Select(name => joy.GetGUID() + ":" + name))))}"
));
}
} |
These could return arrays
as for they joystick axes they could be made to take array like everything else. as for the class you posted I really don't want to have to call a update function that's kinda why I suggested this so you could have a input manager that doesn't require a update function. |
If you have no problems with these functions, I will integrate them into the library. I provide class is mean in facilitate your testing and understanding of my intentions. I think the most controversial issue so far is the
public static AnxisValue GetGamepadAxis(this Joystick joy) The define of AxisVlaue here line 165
public static bool IsGamepadAxisChange(this Joystick joy, GamepadAxis axis) I'm not sure what your I want to add them to other namespaces(You don't need to call update manually either.). for example |
deadzone is the amount you need to press the joystick before it registers or return true. I think these could be very useful in the love library, as for the namespace I don't really know I think the the events should have been exposed in the original love2d as functions and things like getting input should have been easier maybe I need to start suggesting features for love2d instead of love2dcs this way they can be native. |
so you need a function to set the dead zone size ? |
no I just thought that if the user was able to pass a deadzone it could return a bool instead of a float. |
so, you want input a function as parameter, the public delegate bool DeadZoneFunc();
bool Joystick.IsAxisChange(GamepadAxis axis, DeadZoneFunc preparatoryFunction) ? |
basicly deadzone would just do |
ok,I'm still confused. .I don't recommend such a "complex" function, which is too confusing. On the one hand, it returns to the case of changing the axis, on the other hand, it demands to limit the dead zone. If these two conditions are combined, the situation may be different. |
don't worry about the deadzone parameter users can check it manually. so just do..
|
Why is the function return float, can you give some description? |
the float is how far you press the joystick axis. |
@endlesstravel so I had an idea to reduce the function count. you would pass these into the function optionally like so..
this would reduce the function count from 16 to 8 for mouse, keyboard, gamepadbutton, and gamepadaxis |
public static AnxisValue GetGamepadAxis(this Joystick joy);
public static AnxisValue GetGamepadAxisPrevious(this Joystick joy);
public static GamepadButton[] GetGamepadDown(this Joystick joystick);
public static GamepadButton[] GetGamepadDownPrevious(this Joystick joystick);
public static KeyConstant[] GetKeyboardDown();
public static KeyConstant[] GetKeyboardPrevious();
public static MouseButton[] GetMouseDown();
public static MouseButton[] GetMouseDownPrevious();
public static bool IsGamepadAxisChange(this Joystick joy, GamepadAxis axis);
public static bool IsGamepadDown(this Joystick joystick, GamepadButton gbtn);
public static bool IsGamepadDownPrevious(this Joystick joystick, GamepadButton gbtn);
public static bool IsKeyboardDown(KeyConstant key);
public static bool IsKeyboardPrevious(KeyConstant key);
public static bool IsMouseDown(MouseButton button);
public static bool IsMouseDownPrevious(MouseButton button);
|
@endlesstravel
|
ok bear with me I know there has already been alot of changes to input that love2d didn't have.
this should be my final suggestion for inputs so I will try to make sure I don't miss anything.
the following functions should be implemented for more control over your game
Mouse
MouseButton Mouse.GetDown()
MouseButton Mouse.GetDownPrevious()
bool Mouse.IsDown(MouseButton button)
bool Mouse.IsDownPrevious(MouseButton button)
Keyboard
KeyConst Keyboard.GetDown()
KeyConst Keyboard.GetDownPrevious()
bool Keyboard.IsDown(KeyConst key)
bool Keyboard.IsDownPrevious(KeyConst key)
GamepadButton
GamepadButton Joystick.GetDown()
GamepadButton Joystick.GetDownPrevious()
bool Joystick.IsDown(GamepadButton button)
bool Joystick.IsDownPrevious(GamepadButton button)
GamepadAxis
GamepadAxis Joystick.GetAxis()
GamepadAxis Joystick.GetAxisPrevious()
bool Joystick.IsAxisChange(GamepadAxis axis, bool deadzone)
bool Joystick.IsAxisChangePrevious(GamepadAxis axis, bool deadzone)
doing this makes the newer Pressed and Released functions pointless because now you can make your own class and do something like
which you could remove them or add pressed and released variants for JoyStickAxes as well so we can check if they just changed from 0 or just changed to 0
idk what do you think @endlesstravel?
The text was updated successfully, but these errors were encountered: