Page 2 of 2

Re: Get all keys of KeyConstant ?

Posted: Wed Jan 02, 2019 11:46 am
by al1ce.cray

Code: Select all

Input.all_keys = {
    " ", "return", "escape", "backspace", "tab", "space", "!", "\"", "#", "$", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4",
    "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
    "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "capslock", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "printscreen",
    "scrolllock", "pause", "insert", "home", "pageup", "delete", "end", "pagedown", "right", "left", "down", "up", "numlock", "kp/", "kp*", "kp-", "kp+", "kpenter",
    "kp0", "kp1", "kp2", "kp3", "kp4", "kp5", "kp6", "kp7", "kp8", "kp9", "kp.", "kp,", "kp=", "application", "power", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
    "f20", "f21", "f22", "f23", "f24", "execute", "help", "menu", "select", "stop", "again", "undo", "cut", "copy", "paste", "find", "mute", "volumeup", "volumedown",
    "alterase", "sysreq", "cancel", "clear", "prior", "return2", "separator", "out", "oper", "clearagain", "thsousandsseparator", "decimalseparator", "currencyunit",
    "currencysubunit", "lctrl", "lshift", "lalt", "lgui", "rctrl", "rshift", "ralt", "rgui", "mode", "audionext", "audioprev", "audiostop", "audioplay", "audiomute",
    "mediaselect", "brightnessdown", "brightnessup", "displayswitch", "kbdillumtoggle", "kbdillumdown", "kbdillumup", "eject", "sleep", "mouse1", "mouse2", "mouse3",
    "mouse4", "mouse5", "wheelup", "wheeldown", "fdown", "fup", "fleft", "fright", "back", "guide", "start", "leftstick", "rightstick", "l1", "r1", "l2", "r2", "dpup",
    "dpdown", "dpleft", "dpright", "leftx", "lefty", "rightx", "righty",
}

Re: Get all keys of KeyConstant ?

Posted: Wed Jan 02, 2019 8:51 pm
by 4vZEROv
Don't know if this will help but here is my love.run where I handle inputs to do

if pressed("key") then ... end in love.update :

Code: Select all

function love.run()
    local dt = 0
    local _INPUT = {current_state = {}, previous_state = {}}

    function pressed(key) return _INPUT.current_state[key] and not _INPUT.previous_state[key] end
    function released(key) return _INPUT.previous_state[key] and not _INPUT.current_state[key] end
    function down(key) return love.keyboard.isDown(key) end   

    return function()
        love.event.pump()
        for name, a,b,c,d,e,f in love.event.poll() do
            if name == "quit"        then if not love.quit or not love.quit() then return a or 0 end end
            if name == "keypressed"  then _INPUT.current_state[a] = true  end
            if name == "keyreleased" then _INPUT.current_state[a] = false end
            love.handlers[name](a,b,c,d,e,f)
        end
        
        dt = love.timer.step()
        if dt > 0.2 then return end
        love.update(dt)
        for k,v in pairs(_INPUT.current_state) do _INPUT.previous_state[k] = v end 
        
        if lg.isActive() then lg.origin(); lg.clear(lg.getBackgroundColor()); love.draw(); lg.present() end
        love.timer.sleep(0.001)
    end
end

Re: Get all keys of KeyConstant ?

Posted: Wed Jan 02, 2019 10:44 pm
by vincentg
slime wrote: Tue Jan 01, 2019 11:55 pm And if you do discover that those user symptoms are caused by this issue, it might not be trivial to replace all your input action code with the correct implementation after the broken implementation has been used all over the place, so it's much better to start from a correct implementation even if it means your library is slightly less elegant.
Ok let's say I want to use callbacks make a correct implemnetation directly. I tested it with some controllers I have where the "hat" pad is considered as an axis, so I don't see any other way to use it the way I did. What's the correct way to handle pressed/released for those kind of controllers?

Re: Get all keys of KeyConstant ?

Posted: Wed Jan 02, 2019 10:56 pm
by vincentg
I just realized that love.joystickaxis and love.joystickhat exist! So I can use it and get all the thing I need to make this module. A bit more verbose that I expected but if this is better, that's not a bad thing. Thanks.