boipushy (Input handling)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: [Library] boipushy (Input handling)

Post by adnzzzzZ »

Maybe you're still calling input:update()? In the new version you shouldn't call it because it's implicit. So if you call it will happen twice (your call and the implicit one)
User avatar
Skeiks
Citizen
Posts: 51
Joined: Wed Jan 28, 2015 1:51 pm

Re: [Library] boipushy (Input handling)

Post by Skeiks »

adnzzzzZ wrote:Maybe you're still calling input:update()? In the new version you shouldn't call it because it's implicit. So if you call it will happen twice (your call and the implicit one)
Thank you! That was the problem.
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: [Library] boipushy (Input handling)

Post by megalukes »

Is it just me or this library's pressed/released functions stopped working in this new LOVE update?
I'm trying to fix it, but not so lucky so far.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: [Library] boipushy (Input handling)

Post by adnzzzzZ »

I updated this library with a new function: pressRepeat. This function allows you to trigger events on an interval if a key is held down, instead of it doing it every frame. So this:

Code: Select all

function love.load()
    input:bind('mouse1', 'some_action')
end

function love.update(dt)
    if input:pressRepeat('some_action', 0.5) then print(love.math.random()) end
end
Will print a random number to the console every 0.5 seconds from when left click is held down. You can see more about the library here:

boipushy
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: boipushy (Input handling)

Post by Inny »

Neat little library, I like it.

A note about gamepad handling, love makes use of the SDL_GameControllerDB, however the version they ship with is only updated whenever a new version of love comes out. Normally this isn't a problem, but it you want to be as up-to-date as possible (or allow players to manually update it), use something to this effect:

Code: Select all

pcall(love.joystick.loadGamepadMappings, 'gamecontrollerdb.txt')
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: boipushy (Input handling)

Post by slime »

We don't actually ship with that database. SDL has an internal list it uses, and that database is someone else's (useful) list of extra devices that aren't necessarily in SDL's list.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: boipushy (Input handling)

Post by adnzzzzZ »

I updated this with better explanations on the page and also a new function called sequence. The sequence function allows you to check for sequences of buttons pressed within an interval of each other. For instance:

Code: Select all

function love.update(dt)
  if input:sequence('right', 0.5, 'right') then
    -- dash right
  end
end
In the example above the sequence function will return true when the 'right' action is pressed twice, and the second key press happened within 0.5s of the first. This is useful for simple things like dashing, but also for more complex sequences like combos. This function must be started and finished with an action, and between each action there should be the interval limit.


boipushy
skeleton60
Prole
Posts: 3
Joined: Fri Mar 23, 2018 5:32 am

Re: boipushy (Input handling)

Post by skeleton60 »

I am playing with boipushy and when i try delay, interval or sequence features events are called immediatly

is there something i missed to enable those features?

i wrote it like in documentation:

Code: Select all

if game.playerController.input:down('f', 100) then
	print('f')
end

Code: Select all

if game.playerController.input:sequence('a', 0.5, 'a') then
        print('sequence a')
end
this print in my console "f" every update , same for sequence it print "sequence a" even if pressed a one time
User avatar
radgeRayden
Prole
Posts: 29
Joined: Sun Jul 27, 2014 6:49 pm
Location: Brasil
Contact:

Re: boipushy (Input handling)

Post by radgeRayden »

Hello, for some reason this is failing for me:

Code: Select all

function love.update(dt)
    --[...] some irrelevant code before this
    if input:pressed('walk_left') and character.deltaX > 0 then 
        character.deltaX = 0 
        print("stop left")
    end
    if input:pressed('walk_right') and character.deltaX < 0 then 
        character.deltaX = 0 
        print("stop right")
    end
    if input:down('walk_left') then 
        character.deltaX = character.deltaX - 30 * dt 
    end
    if input:down('walk_right') then 
        character.deltaX = character.deltaX + 30 * dt 
    end
    character.x, character.y = world:move(character, character.x + character.deltaX * dt, character.y + character.deltaY * dt) --I'm using bump
end
I added the prints for debug purposes, I get the "stop right" every frame when holding 'walk_left'. I'm not sure if my code is at fault here. If I hold walk_left or walk_right without pressing the opposite direction it works fine.

Edit: figured it out, I had my own definition of love.keyreleased in main.lua.
Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests