[library] Tactile v2.0 pre-release

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

[library] Tactile v2.0 pre-release

Post by Tesselode »

So Kingdaro made this pull request, and it kind of spiraled into a whole new rewrite of Tactile. For those of you who don't know, Tactile is an input library for managing different input sources. In older versions of Tactile, axes and buttons were handled separately, and there were detectors that linked the two. In this version, axes and buttons are the same object! Control objects act as both axes and buttons.

It's a little unusual, but I think it works really well. Example:

Code: Select all

Control = {
  Horizontal = tactile.newControl()
    :addAxis(tactile.gamepadAxis(1, 'leftx'))
    :addButtonPair(tactile.keys('a', 'left'), tactile.keys('d', 'right')),
  Vertical = tactile.newControl()
    :addAxis(tactile.gamepadAxis(1, 'lefty'))
    :addButtonPair(tactile.keys('w', 'up'), tactile.keys('s', 'down')),
  Fire = tactile.newControl()
    :addAxis(tactile.gamepadAxis(1, 'triggerleft'))
    :addAxis(tactile.gamepadAxis(1, 'triggerright'))
     :addButton(tactile.gamepadButtons(1, 'a'))
    :addButton(tactile.keys 'x')
}
  
function love.update(dt)
  local inputVector = vector(Control.Horizontal(), Control.Vertical())
  player.pos = player.pos + player.speed * inputVector * dt
  
  if Control.Fire:isDown() then
    player:shoot()
  end
end
The new version isn't officially released yet, because I want some people to test it and make sure the API is solid and I haven't overlooked anything. So...

GitHub link!

Let me know what you think!
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [library] Tactile v2.0 pre-release

Post by D0NM »

Well... when I dynamically add/remove gamepads
All the controls go wrong )) (gamepad numbers shift...)

I have to rearrange them and reassign.

Does anybody have any cool solution for
TACTILE + dynamical add/remove GamePads support?
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
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: [library] Tactile v2.0 pre-release

Post by Tesselode »

D0NM wrote:Well... when I dynamically add/remove gamepads
All the controls go wrong )) (gamepad numbers shift...)

I have to rearrange them and reassign.

Does anybody have any cool solution for
TACTILE + dynamical add/remove GamePads support?
Yeah, I haven't really thought much about complex gamepad setups...generally it's just one plugged in to a computer at a time. If you find a good solution, let me know!
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [library] Tactile v2.0 pre-release + Don's D-PAD support

Post by D0NM »

Tesselode wrote: If you find a good solution, let me know!
sure! :awesome:

:cool:
well.. I had bad times with Tactile recently.
It seems that all the pressed() methods return true on start.
So, I had to add an extra update in the beginning of my game states.

Code: Select all

    Control1.fire:update()
    Control1.jump:update()
Or else I got insta-pressed buttons.

I use main love.update() and update all the tactile stuff there.
But also I use some hump/gamestate stuff. And it seems to run BEFORE the main love.update() function.

I cannot dig deeper now - working on my project very hard.
Just wanted to tell u.

And thank u for a nice Tactile. It saves my time somehow )
Now adding some pull requests of missing GamePads GUIDs and key mappings into the open source DB gamecontrollerdb.txt

I dont know what to do with unknown gamepads now. Probably I have to bind all the used in the project buttons to the GUID
and tell the player to change the keys...

----
UPDATE:
Also had problems with getHat (D-PAD directions input).
My first thought was modding your lib,

Code: Select all

function tactile.gamepadHat(num, hat)
end
but instead I'm writing a detector for D-PAD. Or I'd better wrap it to emulate an Axis... Yeah

UPDATE2:

ok. the 1st version works fine:

Code: Select all

local function gamepadHat(num, hat, axis)
    if axis == "horizontal" then
        return function()
            local joystick = love.joystick.getJoysticks()[num]
            local h = joystick:getHat(hat)
            if h == "l" or h == "lu" or h == "ld" then
                return -1
            elseif h == "r" or h == "ru" or h == "rd" then
                return 1
            end
            return 0
        end
    else
        return function()
            local joystick = love.joystick.getJoysticks()[num]
            local h = joystick:getHat(hat)
            if h == "u" or h == "ru" or h == "lu" then
                return -1
            elseif h == "d" or h == "rd" or h == "ld" then
                return 1
            end
            return 0
        end
    end
end
  • num - joysick nuber
    hat - number of the nad (usually 1, or use Joystick:getHatCount() )
    axis - "horizontal" or "vertical"
then add it as an axis:

Code: Select all

 :addAxis(gamepadHat(1, 1, "horizontal"))

Code: Select all

:addAxis(gamepadHat(1, 1, "vertical"))
It works. Back to the coding ))
Tesselode, it would be nice if u add DPAD / HAT support into the lib. ^_-
You'll have to add your common checks if there is a joystick. And whether there is a hat.
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
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: [library] Tactile v2.0 pre-release

Post by D0NM »

Hey hey hey!
The game-pad mappings DB has been revived and moved to a new address:

https://github.com/p-groarke/SDL_GameControllerDB
star & watch it ;)

UPD: I'm very sorry. This new mapping DB is in the new SDL format.
Love 0.10.2 doesn't support it yet.
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:
Post Reply

Who is online

Users browsing this forum: No registered users and 65 guests