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
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: TLbind - making professional control schemes easy

Post by MarekkPie »

Put me on your small dingy of non-conformity.
User avatar
smrq
Prole
Posts: 2
Joined: Sun Feb 05, 2012 10:19 am

Re: TLbind - making professional control schemes easy

Post by smrq »

Awesome library! I was going to roll my own solution, but yours is a lot simpler.

I've found some really weird behavior that I think is related to having only keyboard or only joystick input enabled. I've thrown together a quick test LÖVE program to show what I'm talking about, as well as some fixes.

https://gist.github.com/1744602

The program basically just dumps input info to the screen. On control press, the relevant control text flashes green for one frame, and red on control release. I have it set up with one "player" who uses the keyboard, and one who uses a joystick, using two separate instances of TLbind.

The keyboard-only player does not have any analog inputs, but "left" and "right" are mapped to the "horizontal" analog, and same with up/down/vertical. With TLbind v1.07, releasing a direction does not actually register.

The joystick-only player has analog inputs and hats, which bring their own oddities. Up/down/left/right/horizontal/vertical do not trigger key presses or releases at all, though their values change. Also, up/down/left/right are set to nil instead of false on release.

I included a TLbind_custom.lua which solves the above problems*. See what you think!

*I also cleared out the default bindings, which shouldn't affect anything. Seems kind of weird to me to include game-specific example defaults straight in the middle of the library source, though... End users (like me!) shouldn't have to edit the library source imho.
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 »

smrq wrote:Awesome library! I was going to roll my own solution, but yours is a lot simpler.
Thank you! That's why I release my libraries.

I've reviewed your improvements, and they are good. You not only fixed these bugs which have somehow slipped past me (how they heck did they do that, I use this library all the time!?), but you even made everything behave the way I envisioned. Nicely done. I would be happy to add them to the official TLbind library, if you're amenable to this (you'd get credit, of course).
smrq wrote:*I also cleared out the default bindings, which shouldn't affect anything. Seems kind of weird to me to include game-specific example defaults straight in the middle of the library source, though... End users (like me!) shouldn't have to edit the library source imho.
I put that there for three reasons. First, they're decent defaults for most 2D games (the directional stuff, at least. The first two buttons mainly just needed names, so I chose generic, common ones). Two, they're a working example of how to set binds. Three, it's a handy reference for what axes and buttons enumerate to on an XBox 360 gamepad, the "official" Windows gamepad (and most all gamepad-capable games on PC cater to, both professional and indie).

That being said, you also have a point. So what if, as a compromise, I keep my default example there, but commented out?
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 »

Taehl wrote:
smrq wrote:*I also cleared out the default bindings, which shouldn't affect anything. Seems kind of weird to me to include game-specific example defaults straight in the middle of the library source, though... End users (like me!) shouldn't have to edit the library source imho.
I put that there for three reasons. First, they're decent defaults for most 2D games (the directional stuff, at least. The first two buttons mainly just needed names, so I chose generic, common ones). Two, they're a working example of how to set binds. Three, it's a handy reference for what axes and buttons enumerate to on an XBox 360 gamepad, the "official" Windows gamepad (and most all gamepad-capable games on PC cater to, both professional and indie).

That being said, you also have a point. So what if, as a compromise, I keep my default example there, but commented out?
Isn't that more something for in the documentation than in the library source, even if commented out?
Help us help you: attach a .love.
User avatar
smrq
Prole
Posts: 2
Joined: Sun Feb 05, 2012 10:19 am

Re: TLbind - making professional control schemes easy

Post by smrq »

Taehl wrote:I would be happy to add them to the official TLbind library, if you're amenable to this (you'd get credit, of course).
Cheers! I just don't want to have to maintain my own fork of the library :P Go right ahead!
Taehl wrote:So what if, as a compromise, I keep my default example there, but commented out?
Good enough for me, but...
Robin wrote:Isn't that more something for in the documentation than in the library source, even if commented out?
I agree with that sentiment. An end user isn't going to look into the library source unless something is wrong. It would be a lot more useful just to have that information in the docs, since that's what users are actually going to be reading when they get started with the library. Just my 2 cents.
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 »

Thanks, smrq. I added your improvements, a tiny bug fix, and a few minuscule optimizations (turns out that if statements are slightly faster than short-circuit evaluations of equal size. Who would have guessed?). Don't worry, it still passes your test just fine.

TLbind is now v1.1. Download link is still here.
Robin wrote:Isn't that more something for in the documentation than in the library source, even if commented out?
Maybe I'm biased by all my experiences of being cut off from the 'net...
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 »

Taehl wrote:Maybe I'm biased by all my experiences of being cut off from the 'net...
Fair enough. Though I was thinking more of a README file than a website for documentation.
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: TLbind - making professional control schemes easy

Post by kikito »

I hope you don't mind if I intrude on this conversation.

I believe the best option is a README and, when needed, a small sample app. Lately I have been adding a "demo" app to all my libs on github just for this.
When I write def I mean function.
User avatar
hughes
Prole
Posts: 21
Joined: Fri Oct 28, 2011 3:10 am

Re: TLbind - making professional control schemes easy

Post by hughes »

This is really cool :)

Any plans to allow multiple controllers for local multiplayer games?
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 »

kikito wrote:I hope you don't mind if I intrude on this conversation.

I believe the best option is a README and, when needed, a small sample app. Lately I have been adding a "demo" app to all my libs on github just for this.
Not at all. That's not a bad idea, actually. I think I'd do that if I wasn't in the middle of a bunch of other things right now.
hughes wrote:This is really cool :)

Any plans to allow multiple controllers for local multiplayer games?
Thanks!

That capability is already there. If you like programming in procedural style, then you just assign some controls for things like "p1left", "p2left", and so forth, and have your game logic do stuff with that. In OO style, you can give each player object its own TLbind object. Smrq's test shows one way to do it (don't use the version of TLbind in there, though, it's outdated). Check out the TLbind documentation on the wiki (all of my libraries are documented there).
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 14 guests