Page 1 of 4
TLbind 1.3 - professional controls made easy (now w/ mouse!)
Posted: Sun Oct 16, 2011 3:01 am
by Taehl
TLbind makes it easy to give a game professional-style configurable n sets of keys + joystick + mouse controls. It also makes it easier to code your game, since you don't have to worry about handling myriad inputs. You can use it to detect when a control is being held, tapped, or released (with or without callbacks). You can disable or enable keyboard, joystick, or mouse at any time, change bindings on the fly, all that good stuff. As a bonus, it can "circle-ize" 2D analogue inputs, preventing the time-honored "you move faster diagonally" bug. And as always, I've designed it to be as fast and easy to use as possible.
Full documentation, as usual, is
on the wiki, including a demonstration bindings scheme offering controls for "left", "right", "up", "down", "jump", "attack", and "menu" bound to two sets of keys (WASD and arrows) and an Xbox360 gamepad (it only takes nine lines of code for all this). Here's the
download link.
The latest improvement is the implementation of scaled radial deadzones instead of the old axis-bound deadzones. This requires specifying axis pairs in binds.deadzoneAxes. Since it has to normalize the axes for the math to work right, binds.circleAnalogue was rolled into it and depreciated.
Questions, comments, accolades, requests for help? Don't hold back.
Re: TLbind - making professional control schemes easy
Posted: Sun Oct 16, 2011 6:44 pm
by mike
This is totally awesome! I added it to my game and suddenly, as if by magic, I had gamepad support. You are a miracle worker!
Questions:
- Is there any way to modify the control bindings outside the TLbind.lua file?
- Why do you do?
Code: Select all
TLbind,control = love.filesystem.load("TLbind.lua")()
It breaks with the pattern in my lib.lua file which has a list of "require" commands and then this monstrosity.
- I was going to say something about the wiki page not having enough examples, but after looking at the code and the documentation I realized that it was unnecessary.
Again: this is totally tits. Thank you!
Re: TLbind - making professional control schemes easy
Posted: Sun Oct 16, 2011 8:27 pm
by Taehl
mike wrote:This is totally awesome! I added it to my game and suddenly, as if by magic, I had gamepad support. You are a miracle worker!
Thank you! That's exactly what I try to make my libraries do. I'm glad I could help.
mike wrote:Is there any way to modify the control bindings outside the TLbind.lua file?
Sure is. If you open TLbind, you'll see lines 10 through 19 define the default controls. You can add/remove/change these binds at any time, and TLbind will instantly work with it. So if you wanted to change the attack button, you could just say something like
EDIT) I've changed it to make more sense
TLbind.keys[1].x = "attack" (where x is the KeyConstant)
mike wrote:Why do you do?
Code: Select all
TLbind,control = love.filesystem.load("TLbind.lua")()
It breaks with the pattern in my lib.lua file which has a list of "require" commands and then this monstrosity.
I know it's odd, but this is needed to allow controls to be used in OO-style. It means you can give each player in a splitscreen game their own control object, for example. But if it really bothers you, you could use a regular require if you change the last line of TLbind.lua to this: TLbind, control = b, hold
Re: TLbind - making professional control schemes easy
Posted: Sun Oct 16, 2011 9:26 pm
by bartbes
Taehl wrote:you could just say something like TLbind.keys[1].attack = "x".
Does this mean an action can only have one (physical) key bound to it?
Re: TLbind - making professional control schemes easy
Posted: Sun Oct 16, 2011 11:19 pm
by Taehl
One control per input per keyset. But you can have as many keysets as you want (TLbind offers two by default (for WASD and arrows), but any number works). TLbind.keys[2].attack = "lctrl", TLbind.keys[3].attack = " "... As long as your game is checking for control.attack, then you're good - all keysets (and joystick things) bound to that control will trigger it.
Re: TLbind - making professional control schemes easy
Posted: Mon Oct 17, 2011 5:35 am
by Robin
Which also means one key can activate multiple actions.
Re: TLbind - making professional control schemes easy
Posted: Mon Oct 17, 2011 6:02 am
by Taehl
I guess that doesn't make much sense. Okay, switching the keys and values (and removing key sets). I'll update the wiki.
So, from now on, say something like TLbind.keys.z = "attack" (where z is the KeyConstant).
Re: TLbind - making professional control schemes easy
Posted: Thu Jan 19, 2012 11:15 pm
by gfreak
first: Thanks - saved me a lot time !
but i have a problem with your lib under 0.8.0 : short doesn't work any more (and yes i switch joystick from 0 to 1 )
any idea?
sorry: axis are +1 also....
fail - sorry!
Re: TLbind - making professional control schemes easy
Posted: Fri Jan 20, 2012 12:24 am
by Ensayia
I have not looked at the code, but it might have some issues with Joystick indexes starting at 0 in 0.7.2 and 1 in 0.8.0. I'm sure Taehl will update this when he's back online again.
Re: TLbind - making professional control schemes easy
Posted: Thu Jan 26, 2012 6:18 am
by Taehl
Could you tell me the error message? (I have a funny policy of not switching to the new version of Love until it's released. I know, I'm like the only one the whole forum who does that)