[lib] CTRL - input handling

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

[lib] CTRL - input handling

Post 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.
Attachments
example.love
1.0.3
(13.34 KiB) Downloaded 562 times
Last edited by raidho36 on Fri Sep 08, 2017 9:19 am, edited 6 times in total.
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: [lib] CTRL - input handling

Post by Beelz »

Looks nice and polished, I'll definitely be giving it a try. Keep up the good work!

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [lib] CTRL - input handling

Post by raidho36 »

Fixed some bugs, added basic example program.
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [lib] CTRL - input handling

Post 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
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [lib] CTRL - input handling

Post 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!
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: [lib] CTRL - input handling

Post by Ulydev »

Great job! This will prove useful for sure.
User avatar
georgeprosser
Citizen
Posts: 68
Joined: Fri Mar 28, 2014 5:55 pm

Re: [lib] CTRL - input handling

Post 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()
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [lib] CTRL - input handling

Post by raidho36 »

getValue, isUp and isDown (equivalen to love's functions) exist, if that's what you're asking.
User avatar
georgeprosser
Citizen
Posts: 68
Joined: Fri Mar 28, 2014 5:55 pm

Re: [lib] CTRL - input handling

Post 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!
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [lib] CTRL - input handling

Post by raidho36 »

Not sure it's that necessary, but I've added it.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 1 guest