2016-07-25 02:04:27 +02:00
|
|
|
#pragma once
|
|
|
|
#include <wut.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \defgroup vpad_input VPAD Input
|
|
|
|
* \ingroup vpad
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
"C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct VPADVec2D VPADVec2D;
|
|
|
|
typedef struct VPADVec3D VPADVec3D;
|
|
|
|
typedef struct VPADTouchData VPADTouchData;
|
|
|
|
typedef struct VPADAccStatus VPADAccStatus;
|
|
|
|
typedef struct VPADGyroStatus VPADGyroStatus;
|
|
|
|
typedef struct VPADStatus VPADStatus;
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
typedef enum VPADButtons
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
2016-07-25 03:03:46 +02:00
|
|
|
VPAD_BUTTON_A = 0x8000,
|
|
|
|
VPAD_BUTTON_B = 0x4000,
|
|
|
|
VPAD_BUTTON_X = 0x2000,
|
|
|
|
VPAD_BUTTON_Y = 0x1000,
|
|
|
|
VPAD_BUTTON_LEFT = 0x0800,
|
|
|
|
VPAD_BUTTON_RIGHT = 0x0400,
|
|
|
|
VPAD_BUTTON_UP = 0x0200,
|
|
|
|
VPAD_BUTTON_DOWN = 0x0100,
|
|
|
|
VPAD_BUTTON_ZL = 0x0080,
|
|
|
|
VPAD_BUTTON_ZR = 0x0040,
|
|
|
|
VPAD_BUTTON_L = 0x0020,
|
|
|
|
VPAD_BUTTON_R = 0x0010,
|
|
|
|
VPAD_BUTTON_PLUS = 0x0008,
|
|
|
|
VPAD_BUTTON_MINUS = 0x0004,
|
|
|
|
VPAD_BUTTON_HOME = 0x0002,
|
|
|
|
VPAD_BUTTON_SYNC = 0x0001,
|
|
|
|
VPAD_BUTTON_STICK_R = 0x00020000,
|
|
|
|
VPAD_BUTTON_STICK_L = 0x00040000,
|
|
|
|
VPAD_BUTTON_TV = 0x00010000,
|
|
|
|
} VPADButtons;
|
|
|
|
|
|
|
|
typedef enum VPADTouchPadValidity
|
|
|
|
{
|
|
|
|
//! Both X and Y touchpad positions are accurate
|
|
|
|
VPAD_VALID = 0x0,
|
|
|
|
|
|
|
|
//! X position is inaccurate
|
|
|
|
VPAD_INVALID_X = 0x1,
|
|
|
|
|
|
|
|
//! Y position is inaccurate
|
|
|
|
VPAD_INVALID_Y = 0x2,
|
|
|
|
} VPADTouchPadValidity;
|
|
|
|
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
typedef enum VPADReadError
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
2016-07-25 03:03:46 +02:00
|
|
|
VPAD_READ_SUCCESS = 0,
|
|
|
|
VPAD_READ_NO_SAMPLES = -1,
|
|
|
|
VPAD_READ_INVALID_CONTROLLER = -2,
|
|
|
|
} VPADReadError;
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
struct VPADVec2D
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
};
|
|
|
|
CHECK_OFFSET(VPADVec2D, 0x00, x);
|
|
|
|
CHECK_OFFSET(VPADVec2D, 0x04, y);
|
|
|
|
CHECK_SIZE(VPADVec2D, 0x08);
|
|
|
|
|
|
|
|
struct VPADVec3D
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
};
|
|
|
|
CHECK_OFFSET(VPADVec3D, 0x00, x);
|
|
|
|
CHECK_OFFSET(VPADVec3D, 0x04, y);
|
|
|
|
CHECK_OFFSET(VPADVec3D, 0x08, z);
|
|
|
|
CHECK_SIZE(VPADVec3D, 0x0C);
|
|
|
|
|
|
|
|
struct VPADTouchData
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
|
|
|
uint16_t x;
|
|
|
|
uint16_t y;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
//! 0 if screen is not currently being touched
|
2016-07-25 02:04:27 +02:00
|
|
|
uint16_t touched;
|
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
//! Bitfield of VPADTouchPadValidity to indicate how touch sample accuracy
|
|
|
|
uint16_t validity;
|
|
|
|
};
|
|
|
|
CHECK_OFFSET(VPADTouchData, 0x00, x);
|
|
|
|
CHECK_OFFSET(VPADTouchData, 0x02, y);
|
|
|
|
CHECK_OFFSET(VPADTouchData, 0x04, touched);
|
|
|
|
CHECK_OFFSET(VPADTouchData, 0x06, validity);
|
|
|
|
CHECK_SIZE(VPADTouchData, 0x08);
|
|
|
|
|
|
|
|
struct VPADAccStatus
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
|
|
|
float unk1;
|
|
|
|
float unk2;
|
|
|
|
float unk3;
|
|
|
|
float unk4;
|
|
|
|
float unk5;
|
|
|
|
VPADVec2D vertical;
|
2016-07-25 03:03:46 +02:00
|
|
|
};
|
|
|
|
CHECK_OFFSET(VPADAccStatus, 0x14, vertical);
|
|
|
|
CHECK_SIZE(VPADAccStatus, 0x1c);
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
struct VPADGyroStatus
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
|
|
|
float unk1;
|
|
|
|
float unk2;
|
|
|
|
float unk3;
|
|
|
|
float unk4;
|
|
|
|
float unk5;
|
|
|
|
float unk6;
|
2016-07-25 03:03:46 +02:00
|
|
|
};
|
|
|
|
CHECK_SIZE(VPADGyroStatus, 0x18);
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
struct VPADStatus
|
2016-07-25 02:04:27 +02:00
|
|
|
{
|
2016-07-25 03:03:46 +02:00
|
|
|
//! Indicates what VPADButtons are held down
|
|
|
|
uint32_t hold;
|
|
|
|
|
|
|
|
//! Indicates what VPADButtons have been pressed since last sample
|
|
|
|
uint32_t trigger;
|
|
|
|
|
|
|
|
//! Indicates what VPADButtons have been released since last sample
|
|
|
|
uint32_t release;
|
|
|
|
|
|
|
|
//! Position of left analog stick
|
|
|
|
VPADVec2D leftStick;
|
|
|
|
|
|
|
|
//! Position of right analog stick
|
|
|
|
VPADVec2D rightStick;
|
|
|
|
|
|
|
|
//! Status of DRC accelorometer
|
2016-07-25 02:04:27 +02:00
|
|
|
VPADAccStatus accelorometer;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
//! Status of DRC gyro
|
2016-07-25 02:04:27 +02:00
|
|
|
VPADGyroStatus gyro;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
UNKNOWN(2);
|
|
|
|
|
|
|
|
//! Current touch position on DRC
|
|
|
|
VPADTouchData tpNormal;
|
|
|
|
|
|
|
|
//! Filtered touch position, first level of smoothing
|
|
|
|
VPADTouchData tpFiltered1;
|
|
|
|
|
|
|
|
//! Filtered touch position, second level of smoothing
|
|
|
|
VPADTouchData tpFiltered2;
|
|
|
|
|
|
|
|
UNKNOWN(0x28);
|
|
|
|
|
|
|
|
//! Status of DRC magnetometer
|
2016-07-25 02:04:27 +02:00
|
|
|
VPADVec3D mag;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
//! Current volume set by the slide control
|
2016-07-25 02:04:27 +02:00
|
|
|
uint8_t slideVolume;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
//! Battery level of controller
|
2016-07-25 02:04:27 +02:00
|
|
|
uint8_t battery;
|
2016-07-25 03:03:46 +02:00
|
|
|
|
|
|
|
//! Status of DRC microphone
|
2016-07-25 02:04:27 +02:00
|
|
|
uint8_t micStatus;
|
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
//! Unknown volume related value
|
|
|
|
uint8_t slideVolumeEx;
|
2016-07-25 02:04:27 +02:00
|
|
|
|
2016-07-25 03:03:46 +02:00
|
|
|
UNKNOWN(0x7);
|
|
|
|
};
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x00, hold);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x04, trigger);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x08, release);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x0C, leftStick);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x14, rightStick);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x1C, accelorometer);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x38, gyro);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x52, tpNormal);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x5A, tpFiltered1);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x62, tpFiltered2);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0x94, mag);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0xA0, slideVolume);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0xA1, battery);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0xA2, micStatus);
|
|
|
|
CHECK_OFFSET(VPADStatus, 0xA3, slideVolumeEx);
|
|
|
|
CHECK_SIZE(VPADStatus, 0xAC);
|
|
|
|
|
|
|
|
//! Deprecated
|
2016-07-25 02:04:27 +02:00
|
|
|
void
|
|
|
|
VPADInit();
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
VPADRead(uint32_t chan,
|
|
|
|
VPADStatus *buffers,
|
|
|
|
uint32_t count,
|
|
|
|
VPADReadError *error);
|
|
|
|
|
|
|
|
void
|
|
|
|
VPADGetTPCalibratedPoint(uint32_t chan,
|
|
|
|
VPADTouchData *calibratedData,
|
|
|
|
VPADTouchData *uncalibratedData);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @} */
|