## TLbind 1.3 - professional controls made easy (now w/ mouse!)

Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### TLbind 1.3 - professional controls made easy (now w/ mouse!)

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.

Last edited by Taehl on Thu Apr 18, 2013 8:31 am, edited 3 times in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
mike
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

### Re: TLbind - making professional control schemes easy

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!
Now posting IN STEREO (where available)
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLbind - making professional control schemes easy

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
Last edited by Taehl on Mon Oct 17, 2011 6:56 am, edited 1 time in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: TLbind - making professional control schemes easy

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?
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLbind - making professional control schemes easy

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.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: TLbind - making professional control schemes easy

Which also means one key can activate multiple actions.
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLbind - making professional control schemes easy

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).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
gfreak
Prole
Posts: 29
Joined: Wed Jan 04, 2012 5:32 pm

### Re: TLbind - making professional control schemes easy

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!
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

### Re: TLbind - making professional control schemes easy

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.
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

### Re: TLbind - making professional control schemes easy

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)
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

### Who is online

Users browsing this forum: No registered users and 15 guests