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

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

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

Post 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.
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+.
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: TLbind - making professional control schemes easy

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

Re: TLbind - making professional control schemes easy

Post 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
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+.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: TLbind - making professional control schemes easy

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

Re: TLbind - making professional control schemes easy

Post 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.
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+.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: TLbind - making professional control schemes easy

Post by Robin »

Which also means one key can activate multiple actions. :roll:
Help us help you: attach a .love.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: TLbind - making professional control schemes easy

Post 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).
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

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

Re: TLbind - making professional control schemes easy

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

Re: TLbind - making professional control schemes easy

Post 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)
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+.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests