reader.lua changes to reflect new emulator

pull/2/merge
HW 13 years ago
parent 716d81a28b
commit 32b85d2035

@ -19,23 +19,29 @@
require "alt_getopt" require "alt_getopt"
KEY_PAGE_UP = 109 KEY_PAGEUP = 109 -- nonstandard
KEY_PAGE_DOWN = 124 KEY_PAGEDOWN = 124 -- nonstandard
KEY_BACK = 91 -- nonstandard
KEY_BACK = 91
KEY_MENU = 139 KEY_MENU = 139
-- DPad: -- DPad:
KEY_UP = 122 KEY_UP = 122 -- nonstandard
KEY_DOWN = 123 KEY_DOWN = 123 -- nonstandard
KEY_LEFT = 105 KEY_LEFT = 105
KEY_RIGHT = 106 KEY_RIGHT = 106
KEY_BTN = 92 KEY_BTN = 92 -- nonstandard
-- constants from <linux/input.h>
EV_KEY = 1
-- event values
EVENT_VALUE_KEY_PRESS = 1
EVENT_VALUE_KEY_REPEAT = 2
EVENT_VALUE_KEY_RELEASE = 0
-- option parsing: -- option parsing:
longopts = { longopts = {
password = "p", password = "p",
goto = "g",
gamma = "G", gamma = "G",
device = "d", device = "d",
help = "h" help = "h"
@ -68,6 +74,18 @@ if optarg["d"] == "k3" then
input.open("/dev/input/event0") input.open("/dev/input/event0")
input.open("/dev/input/event1") input.open("/dev/input/event1")
input.open("/dev/input/event2") input.open("/dev/input/event2")
elseif optarg["d"] == "emu" then
input.open("")
-- SDL key codes
KEY_PAGEDOWN = 112
KEY_PAGEUP = 117
KEY_BACK = 22 -- backspace
KEY_MENU = 67 -- F1
KEY_UP = 111
KEY_DOWN = 116
KEY_LEFT = 113
KEY_RIGHT = 114
KEY_BTN = 36 -- enter for now
else else
input.open("/dev/input/event0") input.open("/dev/input/event0")
input.open("/dev/input/event1") input.open("/dev/input/event1")
@ -192,25 +210,23 @@ end
function mainloop() function mainloop()
while 1 do while 1 do
local events = input.waitForEvent() local ev = input.waitForEvent()
for _, ev in ipairs(events) do if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
if ev.type == 1 and (ev.value == 1 or ev.value == 2) then local secs, usecs = util.gettime()
local secs, usecs = util.gettime() if ev.code == KEY_PAGEUP then
if ev.code == KEY_PAGE_DOWN then print(cache)
print(cache) goto(pageno + 1)
goto(pageno + 1) print(cache)
print(cache) elseif ev.code == KEY_PAGEDOWN then
elseif ev.code == KEY_PAGE_UP then print(cache)
print(cache) goto(pageno - 1)
goto(pageno - 1) print(cache)
print(cache) elseif ev.code == KEY_BACK then
elseif ev.code == KEY_BACK then return
return
end
local nsecs, nusecs = util.gettime()
local dur = (nsecs - secs) * 1000000 + nusecs - usecs
print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur)
end end
local nsecs, nusecs = util.gettime()
local dur = (nsecs - secs) * 1000000 + nusecs - usecs
print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur)
end end
end end
end end

Loading…
Cancel
Save