bytepath/def/Baton.d.lua

70 lines
1.7 KiB
Lua

---@meta
---@module 'baton'
---@class BatonConfig
---@field controls table<string, string[]>
---@field pairs table<string, string[]>
---@field joystick? JoystickConfig
---@field max_joysticks? integer
---@field joystick_deadzone? number
---@class JoystickConfig
---@field controls table<string, string[]>
---@field pairs table<string, string[]>
---@field deadzone? number
---@class Baton
local Baton = {}
---Create a new input manager.
---@param config BatonConfig
---@return Baton
function Baton.new(config) end
---Update the input manager. Call every frame.
---@param dt number
function Baton:update(dt) end
---Get the current value of a control.
---Returns 1 for digital controls, -1/0/1 for analog axes.
---@param control_name string
---@return number
function Baton:get(control_name) end
---Check if a control is currently down/pressed.
---@param control_name string
---@return boolean
function Baton:down(control_name) end
---Check if a control was pressed this frame.
---@param control_name string
---@return boolean
function Baton:pressed(control_name) end
---Check if a control was released this frame.
---@param control_name string
---@return boolean
function Baton:released(control_name) end
---Get the value of a control pair (e.g., left/right).
---Returns -1 to 1 for opposing pairs.
---@param pair_name string
---@return number
function Baton:getPair(pair_name) end
---Check if a pair is down.
---@param pair_name string
---@return boolean
function Baton:downPair(pair_name) end
---Check if a pair was pressed this frame.
---@param pair_name string
---@return boolean
function Baton:pressedPair(pair_name) end
---Check if a pair was released this frame.
---@param pair_name string
---@return boolean
function Baton:releasedPair(pair_name) end
return Baton