Page 2 of 2
Re: [Library] boipushy (Input handling)
Posted: Thu Sep 24, 2015 12:44 pm
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)
Re: [Library] boipushy (Input handling)
Posted: Thu Sep 24, 2015 2:45 pm
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.
Re: [Library] boipushy (Input handling)
Posted: Sat Apr 16, 2016 10:32 pm
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.
Re: [Library] boipushy (Input handling)
Posted: Sat Apr 15, 2017 10:34 am
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
Re: boipushy (Input handling)
Posted: Sat Apr 15, 2017 6:00 pm
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')
Re: boipushy (Input handling)
Posted: Sat Apr 15, 2017 10:29 pm
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.
Re: boipushy (Input handling)
Posted: Mon Nov 06, 2017 10:43 pm
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
Re: boipushy (Input handling)
Posted: Thu Apr 12, 2018 3:08 pm
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
Re: boipushy (Input handling)
Posted: Fri Apr 13, 2018 9:46 pm
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.