1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-18 05:23:22 -07:00
mm/Lua/lib/classes/JoyWrapper.lua
2016-01-12 16:05:31 -08:00

21 lines
635 B
Lua

local JoyWrapper = Class()
function JoyWrapper:init(handler, threshold)
self.handler = handler
self.old_ctrl = {}
self.threshold = threshold or 80
end
function JoyWrapper:update(inputs)
local j = inputs or joypad.getimmediate()
local jj = joypad.get()
local jx = jj['P1 X Axis']
local jy = jj['P1 Y Axis']
j["P1 Joy R"] = jx >= self.threshold or jj['P1 A Right']
j["P1 Joy L"] = jx <= -self.threshold or jj['P1 A Left']
j["P1 Joy U"] = jy >= self.threshold or jj['P1 A Up']
j["P1 Joy D"] = jy <= -self.threshold or jj['P1 A Down']
return self.handler:update(j)
end
return JoyWrapper