Some love features I think would be useful

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Shadowblitz16
Citizen
Posts: 73
Joined: Wed Oct 28, 2015 11:18 pm

Some love features I think would be useful

Post by Shadowblitz16 »

I just had a suggestion for love2d to make input easier to manage
adding these functions would make life a lot easier and I think could speed up development time for people.

- Love.keyboard.isDownPrevious()
- Love.mouse.isDownPrevious()
- Love.joystick.isDownPrevious()
- Love.joystick.GetAxisPrevious()

- Love.keyboard.GetKeysDown()
- Love.keyboard.GetKeysDownPrevious()
- Love.mouse.GetButtonsDown()
- Love.mouse.GetButtonsDownPrevious()
- Love.joystick.GetButtonsDown()
- Love.joystick.GetButtonsDownPrevious()
- Love.joystick.GetAxesDown()
- Love.joystick.GetAxesDownPrevious()

not only this but you could make a input manager without a update function because you have access to all the inputs that is needed to check if something was just pressed, something is pressed, or something is released for example..

Code: Select all

local joystickAxesCurr               = joystick:GetAxesButtonsDown(1)
local joystickAxesPrev               = joystick:GetAxesButtonsDownPrevious(1)
local joystickAxisJustChangedFrom0   = joystick:GetAxis(joystickAxesCurr ) == 0 and joystick:GetAxisPrevious(joystickAxesPrev) ~= 0;
local joystickAxisJustChangedTo0     = joystick:GetAxis(joystickAxesCurr ) ~= 0 and joystick:GetAxisPrevious(joystickAxesPrev) == 0;
it also supports people making their own input managers because you don't have access to pressed and release functions directly but just the current and previous inputs.

also we can now easily check for if anything was pressed by just passing in the one of the new constant getting functions.

what do you guys think?
User avatar
4vZEROv
Party member
Posts: 126
Joined: Wed Jan 02, 2019 8:44 pm

Re: Some love features I think would be useful

Post by 4vZEROv »

I don't understand how this would be usefull, just use a variable to stock the previous key and voila ?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Some love features I think would be useful

Post by raidho36 »

My input library does exactly this, by a popular request. I'm convinced though that the framework itself doesn't need this functionality.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Some love features I think would be useful

Post by zorg »

People usually should detect whether something was pressed or released at the current frame (if using the callbacks) or detect whether something is still held down (if using methods in update); Anything else can be implemented using your own code, by storing such state, and querying that state, giving the "classic" 4-state input model of "de-pressed", "pressed", "held", "released".

Or as raidho said, use a library that implements such a thing.

To me, all those function duplications scream bad news; what do the Previous functions return? The same as the regular ones?
So now i have to manually truth-table-combine both results into all 4 possibilities; Why not just return that state itself? And by then, again, you'd use a library.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Shadowblitz16
Citizen
Posts: 73
Joined: Wed Oct 28, 2015 11:18 pm

Re: Some love features I think would be useful

Post by Shadowblitz16 »

you would still be able to implement a library you would just be able to do it easier.

the previous functions return the previous frames value.

if duplication is a problem then there could be a constant that you could pass that would edit the return value to the current frame or previous frame with the current frame being the default.

I think making input manager easier to make would be a good thing since they are already very complicated.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Some love features I think would be useful

Post by raidho36 »

That's what libraries are for. The engine itself doens't need to be any more complicated than to do the bare minimum it's supposed to do.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Some love features I think would be useful

Post by zorg »

What löve provides itself is already capable of making implementing such a -stateful- input system possible; hence, it's a perfect candidate for a library.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Some love features I think would be useful

Post by pgimeno »

The values in the previous frame are not so useful, because several events (e.g. a key down and up) can occur within one frame.

Best to leave that up to a library, which knows what to do with them. If the programmer doesn't want to miss any single press, they would use the events rather than the isDown() functions.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 8 guests