a327ex / boipushy Goto Github PK
View Code? Open in Web Editor NEWInput module for LÖVE
Input module for LÖVE
Looking at the file, requiring the module modifies the love.run, there should be a way to not automatically modify it so it could work along with other libs that modifies the love.run as well
Is the master branch kept stable enough to be based upon in development? Also are you planning on implementing some sort of versioning system so users can tell if a change will break past compatibility?
I just spent a bit of time figuring out that the reason :down(..)
would work but :pressed(..)
, etc. wouldn't was because I was calling input:update()
before checking the state of the inputs.
It might be worth highlighting this in the README.md
with an example :)
For example:
function love.update(dt)
if input:pressed('down') then print('down was pressed!') end
-- your other input checks here..
input:update()
end
Is there any way to bind all keys to a certain action (aside from manually doing each one)?
Something like:
input:bind( 'all', function() self.jumped = true end )
Hi, @adonaac
Can you document how to add support for new controllers, please? I own a generic Multilaser joystick and I'd like to use it to play test my game. I'm on OS X.
Thanks in advance! 😄
Your example if input:pressed('print') then print(1) end
actually doesn't work, input:pressed only works when the key has been bind with a function, but not with a name.
Since I updated to new version, my game broke and after some debugging I encounter that input:pressed() and input:released() seems to be broken. input:pressed() acts the same as input:down() and input:released() just returns nothing.
EDIT: after some tests I found that love.update and all the other callbacks gets overwritten. so when boipushy registers the callbacks, it does nothing, they gets overwritten with the actual function on the main.lua file.
if i add a print here
function Input:mousepressed(x, y, button)
print(button)
self.state[button_to_key[button]] = true
end
my mouse buttons cause it to print 'l' and 'r', and then crash because those are not in the button_to_key table.
r
Error: libs/Input.lua:258: table index is nil
stack traceback:
libs/Input.lua:258: in function <libs/Input.lua:256>
libs/Input.lua:62: in function <libs/Input.lua:60>
[string "boot.lua"]:425: in function <[string "boot.lua"]:399>
[C]: in function 'xpcall
i'm using nixos
If you check input:pressed
or input:released
after input:update
it will always register as false.
Don't know if this is intentional or not, but you may want to add it to the documentation.
It could be my fault, but when I'm using Thranduil and it require
s this module, the part that does... something with the path goes into an infinite loop.
Relevant code:
local current_path = ''
local current_index = 0
while debug.print ( #current_path ) ~= debug.print ( #input_path ) do
local _, index, temp = input_path:find( '(.-)%.', current_index )
if not index then current_path = input_path break end
if love.filesystem.exists( current_path .. temp ) then -- Allow for . in folder names (even though this isn't currently allowed using require...)
current_path = current_path .. temp .. '/'
current_index = index + 1
end
end
I've grepped the project to see if these variables are used anywhere and couldn't find anything, so I simply commented it out in my local repo.
This input library is very useful! Although i was wondering if you plan to implement touch inputs like the love.touchpressed and love.touchreleased functions
When you put this inside of a .love you get an error. Maybe it could be backed inside of the save directory?
Error
main.lua:3: module 'Utilities.thomas.input' not found:
no field package.preload['Utilities.thomas.input']
no file
blah blah blah blah blah...
Hey, i have questions. Consider the following:
local keys = {
a = "printA",
b = function() print("b") end,
}
local input = Input()
for k,v in pairs(keys) do
input:bind(k, v)
end
local function printA() print("a") end
If i press "a", it will call the printA function.
If i press "b" it will use the anonymous function passed.
Now, what if i want to check in update the key "a" if it is down?
function love.update(dt)
if input:down("a") then printA() end
--or
if input:down("printA") then printA() end
end
Isnt this repetitive?
I suggest, add an argument to bind that determines whether the binded key is for "down", "keypress", or "keyreleased" like
input:bind("a", "printA", "down") --default would be "keypressed"
This way, the library can check and call it internally without having to redo the if-statements
Clarify me if im wrong.
For a single-file library it makes sense to add a LICENSE header:
-- Copyright (c) 2015-2017 SSYGEN
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
local input_path = (...):match('(.-)[^%.]+$') .. '.'
local Input = {}
Input.__index = Input
...
Is the LICENSE file up to date (2015 adnnnzzzZZ)?
Anyway, I thought you might consider changing it.
According to the changelog
Changed
love.keyboard.isDown
andlove.keyboard.isScancodeDown
to error if an invalid enum value is given.
the check on line 171 will now error on Love2D 11.0 for mouseX
keycodes.
How do i deal with arguments?
Example, how can i get the x,y passed into mousepressed? The button is there with mousepressed1 and so on, but how about the x,y?
Thanks
I'm running through the Love2d tutorial and the below code causes the below error
function love.update(dt)
if input:down('kp+', 0.25) then increment() end
end
"Error
libraries/boipushy/input.lua:166: bad argument #1 to 'ipairs' (table expected, got nil)
Traceback
[C]: in function 'ipairs'
libraries/boipushy/input.lua:166: in function 'down'
main.lua:51: in function main.lua:48
libraries/boipushy/input.lua:61: in function 'update'
[C]: in function 'xpcall'"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.