Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for systems without mouse or keyboard #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions baton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ local sourceFunction = {keyboardMouse = {}, joystick = {}}

-- checks whether a keyboard key is down or not
function sourceFunction.keyboardMouse.key(key)
return love.keyboard.isDown(key) and 1 or 0
return love.keyboard ~= nil and love.keyboard.isDown ~= nil and love.keyboard.isDown(key) and 1 or 0
end

-- checks whether a keyboard key is down or not,
-- but it takes a scancode as an input
function sourceFunction.keyboardMouse.sc(sc)
return love.keyboard.isScancodeDown(sc) and 1 or 0
return love.keyboard ~= nil and love.keyboard.isScancodeDown ~= nil and love.keyboard.isScancodeDown(sc) and 1 or 0
end

-- checks whether a mouse buttons is down or not.
-- note that baton doesn't detect mouse movement, just the buttons
function sourceFunction.keyboardMouse.mouse(button)
return love.mouse.isDown(tonumber(button)) and 1 or 0
return love.mouse ~= nil and love.mouse.isDown ~= nil and love.mouse.isDown(tonumber(button)) and 1 or 0
end

-- checks the position of a joystick axis
Expand Down