###################################
### ZInput for AGK              ###
### By Husbjorn ("Rudolpho")    ###
### 2021-07-26                  ###
###################################
#
### Core commands ###
# Initialize(hWnd) - Takes the main window handle as argument; set to 0 to use the default. Returns true on successful initialization, otherwise false.
Initialize,I,I,Initialize,0,0,0,0,Initialize
#
# GetInputDeviceCount() - Returns the number of available input devices
GetInputDeviceCount,I,0,GetInputDeviceCount,0,0,0,0,GetInputDeviceCount
#
# GetInputDeviceName(deviceId) - Returns the name of the input device with the given id
GetInputDeviceName,S,I,GetInputDeviceName,0,0,0,0,GetInputDeviceName
#
# GetInputDeviceType(deviceId) - Returns the type id of the input device with the given id
GetInputDeviceType,I,I,GetInputDeviceType,0,0,0,0,GetInputDeviceType
#
# GetInputDeviceTypeName(deviceId) - Returns a textual representation of the type of the input device with the given id
GetInputDeviceTypeName,S,I,GetInputDeviceTypeName,0,0,0,0,GetInputDeviceTypeName
#
# RescanForInputDevices() - Scans the system for available input devices - this may invalidate previously returned device handles. Useful for plug-and-play devices.
RescanForInputDevices,0,0,RescanForInputDevices,0,0,0,0,RescanForInputDevices
#
# AcquireInputDevice(deviceId) - Returns a handle to use for accessing the device with the given id, or zero if the device could not be acquired
AcquireInputDevice,I,I,AcquireInputDevice,0,0,0,0,AcquireInputDevice
#
# ReleaseInputDevice(deviceId) - Releases a previously acquired device handle; call this when you're done using a particular input device. Returns true on success or false otherwise.
ReleaseInputDevice,I,I,ReleaseInputDevice,0,0,0,0,ReleaseInputDevice
#
# PollInputDevice(device) - Updates the information about the given input device; this must be called periodically to update the values returned by other commands.
PollInputDevice,I,I,PollInputDevice,0,0,0,0,PollInputDevice
#
#
### Button commands ###
# GetInputDeviceButtonCount(device) - Returns the number of buttons available on the given device.
GetInputDeviceButtonCount,I,I,GetInputDeviceButtonCount,0,0,0,0,GetInputDeviceButtonCount
#
# IsInputDeviceButtonDown(device, buttonId) - Returns true if the given button is currently held down for the given device.
IsInputDeviceButtonDown,I,II,IsInputDeviceButtonDown,0,0,0,0,IsInputDeviceButtonDown
#
# IsInputDeviceButtonHit(device, buttonId) - Returns true if the given button was hit since the last call to PollInputDevice.
IsInputDeviceButtonHit,I,II,IsInputDeviceButtonHit,0,0,0,0,IsInputDeviceButtonHit
#
# IsInputDeviceButtonReleased(device, buttonId) - Returns true if the given button was released since the last call to PollInputDevice.
IsInputDeviceButtonReleased,I,II,IsInputDeviceButtonReleased,0,0,0,0,IsInputDeviceButtonReleased
#
# GetInputDeviceButtonMask(device) - Returns a bit mask where each bit corresponds to whether the corresponding button is pressed. At most 32 buttons can be represented.
GetInputDeviceButtonMask,I,I,GetInputDeviceButtonMask,0,0,0,0,GetInputDeviceButtonMask
#
#
### Axis commands ###
# GetInputDeviceAxisCount(device) - Returns the number of axes available on the given device.
GetInputDeviceAxisCount,I,I,GetInputDeviceAxisCount,0,0,0,0,GetInputDeviceAxisCount
#
# GetInputDeviceAxisType(device, axisId) - Returns the type identifier of the given axis on the device.
GetInputDeviceAxisType,I,II,GetInputDeviceAxisType,0,0,0,0,GetInputDeviceAxisType
#
# GetInputDeviceAxisValue(device, axisId, minValue, maxValue) - Returns the current position of the given device axis, mapped onto the specified floating point range.
GetInputDeviceAxisValue,F,IIFF,GetInputDeviceAxisValue,0,0,0,0,GetInputDeviceAxisValue
#
# SetInputDeviceAxisDeadzone(device, axisId, range) - Sets the deadzone of the given device axis. The range denotes the normalized distance from the center position [0..1].
SetInputDeviceAxisDeadzone,0,IIF,SetInputDeviceAxisDeadzone,0,0,0,0,SetInputDeviceAxisDeadzone
#
# SetInputDeviceAxisSaturation(device, axisId, saturation) - Sets the saturation range of the given device axis. The reported value will cap out on reaching this distance from the center.
SetInputDeviceAxisSaturation,0,IIF,SetInputDeviceAxisSaturation,0,0,0,0,SetInputDeviceAxisSaturation
#
# SetInputDeviceAxisThreshold(device, axisId, threshold) - Sets the threshold range of the given device axis. 
SetInputDeviceAxisThreshold,0,IIF,SetInputDeviceAxisThreshold,0,0,0,0,SetInputDeviceAxisThreshold
#
#
### Point-of-view commands ###
# GetInputDevicePovCount(device) - Returns the number of POV hats (directional / angular inputs) available on the given device.
GetInputDevicePovCount,I,I,GetInputDevicePovCount,0,0,0,0,GetInputDevicePovCount
#
# IsInputDevicePovPressed(device, povId) - Returns true if the given POV is pressed (for example if one or more directional buttons on a DPAD are pressed), or false otherwise.
IsInputDevicePovPressed,I,II,IsInputDevicePovPressed,0,0,0,0,IsInputDevicePovPressed
#
# GetInputDevicePovAngle(device, povId) - Returns the current state of the given POV control as an angle where north is 0, right 90 and so on. Only valid if the POV is also pressed.
GetInputDevicePovAngle,F,II,GetInputDevicePovAngle,0,0,0,0,GetInputDevicePovAngle
#
# IsInputDeviceDirectionalButtonDown(device, povId, buttonId) - Returns true if the given directional button (up-0/right-1/down-2/left-3) is currently held down.
IsInputDeviceDirectionalButtonDown,I,III,IsInputDirectionalButtonDown,0,0,0,0,IsInputDirectionalButtonDown
#
# IsInputDeviceDirectionalButtonHit(device, povId, buttonId) - Returns true if the given directional button (up-0/right-1/down-2/left-3) was pressed since the last call to PollInputDevice.
IsInputDeviceDirectionalButtonHit,I,III,IsInputDirectionalButtonHit,0,0,0,0,IsInputDirectionalButtonHit
#
# IsInputDeviceDirectionalButtonReleased(device, povId, buttonId) - Returns true if the given directional button was released since the last call to PollInputDevice.
IsInputDeviceDirectionalButtonReleased,I,III,IsInputDirectionalButtonReleased,0,0,0,0,IsInputDirectionalButtonReleased
#
#
### Force feedback ###
# GetInputDeviceForceFeedbackMotorCount(device) - Returns the number of force feedback motors available on the given device.
GetInputDeviceForceFeedbackMotorCount,I,I,GetInputDeviceForceFeedbackMotorCount,0,0,0,0,GetInputDeviceForceFeedbackMotorCount
#
# SetInputDeviceForceFeedback(device, motorId, amplitude) - Sets the current amplitude of the given force feedback motor. The amplitude range is [-1 .. +1].
SetInputDeviceForceFeedback,0,III,SetInputDeviceForceFeedback,0,0,0,0,SetInputDeviceForceFeedback
#
#
### Error handling ###
# SetErrorReportingMode(mode) - Sets the error reporting mode; 0 for debug (legacy message box popups whenever there's an error / warning) or 1 for silent (manual query). Returns true if the mode was valid and successfully set, or false otherwise.
SetErrorReportingMode,I,I,SetErrorReportingMode,0,0,0,0,SetErrorReportingMode
#
# GetLastErrorType() - Returns the type (severity) of the last encountered error as follows: 0 - none (there is no error), 1 - warning, 2 - error.
GetLastErrorType,I,0,GetLastErrorType,0,0,0,0,GetLastErrorType
#
# GetLastErrorMessage(clear) - Returns a string holding the last reported error message, or "N/A" if there isn't any (if there isn't any error, GetLastErrorType() also returns zero). If the clear argument is set to true, the last error message is cleared. If it is instead set to false, this same error message will be returned by another call to this function as long as no more recent error message has overwritten it.
GetLastErrorMessage,S,I,GetLastErrorMessage,0,0,0,0,GetLastErrorMessage