Page 1 of 2

[lib] CTRL - input handling

Posted: Wed Jun 28, 2017 8:26 pm
by raidho36
https://bitbucket.org/rcoaxil/ctrl

https://love2d.org/wiki/CTRL

Simple for basic usage and at the same time robust and advanced for extended use, this library provides all necessary facilities to handle user input, and with enough skill, can be extended to handle even the input devices not natively supported by the framework.

Code: Select all

local ctrl = require ( 'ctrl' ) ( )
function ctrl:inputpressed ( name, value ) print ( "pressed", name, value ) end
function ctrl:inputreleased ( name, value ) print ( "released", name, value ) end
function ctrl:inputmoved ( name, value ) print ( "moved", name, value ) end
ctrl:bind ( "fire", { "keyboard", "space" } )
ctrl:bind ( "fire", { "joystick", "default", "button", 1 } )
ctrl:bind ( "fire", { "mouse", "left" } )
ctrl:hookup ( )
Currently supports keyboard, mouse, gamepad, joystick input devices, input binding in many-to-many fashion, raw value mapping functions and clean value filtering functions, custom events and event triggers, and automatic grabbing of user input & autobind - for controls setup screens, and some more.

Re: [lib] CTRL - input handling

Posted: Thu Jun 29, 2017 6:41 pm
by Beelz
Looks nice and polished, I'll definitely be giving it a try. Keep up the good work!

Re: [lib] CTRL - input handling

Posted: Sat Jul 01, 2017 3:16 am
by raidho36
Fixed some bugs, added basic example program.

Re: [lib] CTRL - input handling

Posted: Fri Sep 08, 2017 6:56 am
by D0NM
raidho36 wrote: Sat Jul 01, 2017 3:16 am Fixed some bugs, added basic example program.
https://imgur.com/a/sRu2P
sorry for such a lazy bug report

Re: [lib] CTRL - input handling

Posted: Fri Sep 08, 2017 9:11 am
by raidho36
D0NM wrote: Fri Sep 08, 2017 6:56 am https://imgur.com/a/sRu2P
sorry for such a lazy bug report
Haha right I forgot to put an if guard in that branch in the demo program. I've updated the demo, now it works fine.

Thank you for reporting it!

Re: [lib] CTRL - input handling

Posted: Fri Sep 08, 2017 9:18 am
by Ulydev
Great job! This will prove useful for sure.

Re: [lib] CTRL - input handling

Posted: Wed Sep 27, 2017 1:20 pm
by georgeprosser
This looks really neat!

Would you consider adding a way to respond to key press/release events through function calls, rather than through callbacks? eg. ctrl:wasPressed()

Re: [lib] CTRL - input handling

Posted: Wed Sep 27, 2017 4:05 pm
by raidho36
getValue, isUp and isDown (equivalen to love's functions) exist, if that's what you're asking.

Re: [lib] CTRL - input handling

Posted: Wed Sep 27, 2017 4:34 pm
by georgeprosser
raidho36 wrote: Wed Sep 27, 2017 4:05 pm getValue, isUp and isDown (equivalen to love's functions) exist, if that's what you're asking.
I mean in addition to what love provides, so wasPressed(k) would return true if isDown(k) is true in this frame and was false last frame.

I just usually find it a hassle to do event handling or button press callbacks when all I want to check is that a key that wasn't down before is now down.

I've found myself wanting to write a library like yours for some time, partly just to add this functionality!

Re: [lib] CTRL - input handling

Posted: Wed Sep 27, 2017 5:15 pm
by raidho36
Not sure it's that necessary, but I've added it.