#include "platforms.lua"

INPUT = {}

INPUT.LOBBY_CANCEL          = function() if not isGamepadInUse() then return InputPressed("esc") else return InputPressed("menu_cancel") end end
INPUT.LOBBY_ACCEPT          = function() if not isGamepadInUse() then return InputPressed("space") else return InputPressed("menu_accept") end end

INPUT.CONTROL_ACTION    = function() return InputPressed("lmb") end
INPUT.CONTROL_INFO      = function() if not isGamepadInUse() then return InputPressed("f") else return InputPressed("mmb") end end
INPUT.GAMEPAD_OPTIONS   = function() return isGamepadInUse() and InputPressed("interact") end

INPUT.MENU_UP           = function() if not isGamepadInUse() then return InputPressed("menu_up") or InputPressed("up") else return InputPressed("menu_up") end end
INPUT.MENU_DOWN         = function() if not isGamepadInUse() then return InputPressed("menu_down") or InputPressed("down") else return InputPressed("menu_down") end end
INPUT.MENU_LEFT         = function() if not isGamepadInUse() then return InputPressed("menu_left") or InputPressed("left") else return InputPressed("menu_left") end end
INPUT.MENU_RIGHT        = function() if not isGamepadInUse() then return InputPressed("menu_right") or InputPressed("right") else return InputPressed("menu_right") end end
INPUT.MENU_TAB_LEFT     = function() return InputPressed("menu_prev") or InputPressed("q") end
INPUT.MENU_TAB_RIGHT    = function() return InputPressed("menu_next") or InputPressed("e") end
INPUT.MENU_PREV    = function() return InputPressed("menu_prev") end
INPUT.MENU_NEXT  = function() return InputPressed("menu_next") end
INPUT.MENU_PG_UP    = function() return InputPressed("pgup") end
INPUT.MENU_PG_DOWN  = function() return InputPressed("pgdown") end


INPUT.GADGET_NITRO_START    = function() return isGamepadInUse() and InputPressed("interact") or InputPressed(GetString("savegame.mod.input.nitro")) end
INPUT.GADGET_NITRO_STOP     = function() return isGamepadInUse() and InputReleased("interact") or InputReleased(GetString("savegame.mod.input.nitro")) end
INPUT.GADGET_NITRO_DOWN     = function() return isGamepadInUse() and InputDown("interact") or InputDown(GetString("savegame.mod.input.nitro")) end
INPUT.GADGET_RAM            = function() return isGamepadInUse() and InputPressed("interact") or InputPressed(GetString("savegame.mod.input.nitro")) end


INPUT.VEHICLE_RESPAWN = function() return isGamepadInUse() and (InputPressed("vehicle_raise") or InputPressed("menu_next")) or InputPressed(GetString("savegame.mod.input.respawn")) end

INPUT.MOUSE_WHEEL_UP    = function() return not isGamepadInUse() and InputValue("mousewheel") == 1 end
INPUT.MOUSE_WHEEL_DOWN  = function() return not isGamepadInUse() and InputValue("mousewheel") == -1 end

INPUT.PRESS_D_PAD = function() return isGamepadInUse() and (InputPressed("menu_up") or InputPressed("menu_down") or InputPressed("menu_left") or InputPressed("menu_right")) end
INPUT.PRESS_L3 = function() return isGamepadInUse() and (math.abs(InputValue("mousedx")) > 1 or math.abs(InputValue("mousedy")) > 1) end