GetInputHardware
This function was added in DSL 5
Description
Returns what hardware a certain input is bound to. The possible values for type are as follows.
- button:
valueis a button from an xbox controller [0-15] - analog:
valueis an analog stick from an xbox controller [16-23] - special:
valueis the skateboard button from an xbox controller (24) - keyboard:
valueis a DirectInput Keyboard Scan Code [0,255] - mouse_button:
valueis a DirectInput Mouse button index [0,3] - mouse_movement:
valuerepresents DirectInput mouse movement [0,5]
function GetInputHardware(button_or_stick, controller) --[[ ... ]] end
Parameters
button_or_stick:integer- The button or stick ID to get the hardware for.controller:0|1|2|3- The controller to get the hardware for.
Return Values
type:string- The type of hardware the input is bound to. Possible values arebutton,analog,special,keyboard,mouse_button, ormouse_movement.value:number- The value associated with the input. The meaning of this value depends on thetypereturned.
Example
local type, value = GetInputHardware(0, 1) -- Get the hardware for button 0 on controller 1 (Left arrow keyboard key, d-pad left)
if type == 'button' then
print('Button 0 on controller 1 is bound to hardware value:', value)
elseif type == 'analog' then
print('Analog stick 0 on controller 1 is bound to hardware value:', value)
elseif type == 'special' then
print('Special button on controller 1 is bound to hardware value:', value)
elseif type == 'keyboard' then
print('Keyboard input on controller 1 is bound to hardware value:', value)
elseif type == 'mouse_button' then
print('Mouse button on controller 1 is bound to hardware value:', value)
elseif type == 'mouse_movement' then
print('Mouse movement on controller 1 is bound to hardware value:', value)
else
print('Unknown input type:', type)
end