Line 6:
Line 6:
!Prototype
!Prototype
!Description
!Description
+
|-
+
|VPADGetLcdMode
+
|int VPADGetLcdMode(int padnum, VPADDisplayMode *lcdmode);
+
|Gets LCD mode of gamepad and stores it in ''lcdmode''
+
|-
+
|VPADSetLcdMode
+
|int VPADSetLcdMode(int padnum, VPADDisplayMode lcdmode);
+
|Sets LCD mode of gamepad based on ''lcdmode''
|-
|-
|VPADRead
|VPADRead
−
|int VPADRead(int padnum, void *buffer, int length, int *err);
+
|int VPADRead(int padnum, VPADData *buffer, int num_datasets, int *err);
|Stores raw controller data in ''buffer'' for the specified Gamepad
|Stores raw controller data in ''buffer'' for the specified Gamepad
+
|-
+
|VPADShutdown
+
|void VPADShutdown(void);
+
|A deprecated function that was supposed to shut down the Gamepad.
|}
|}
−
==Structures==
+
==Structures/Enums==
+
===VPAD Display Mode===
+
Can be gotten using VPADGetLcdMode().
+
+
<syntaxhighlight lang="C">
+
typedef enum {
+
DISPLAY_MODE_STANDBY = 0, /* This is probably the mode you can set as a user in HOME - Turn display off */
+
DISPLAY_MODE_OFF = 1, /* This turns off the display completely, the gamepad can be used as a pure input controller */
+
DISPLAY_MODE_DEFAULT = 0xFF /* Default mode */
+
} VPADDisplayMode;
+
</syntaxhighlight>
+
===VPAD Data===
===VPAD Data===
−
Can be gotten using VPADRead(), length seems to control the max amount of "datasets" to keep. A single dataset containing raw controller data is 0xAC bytes.
+
Can be gotten using VPADRead(), num_datasets seems to control the max amount of "datasets" to keep. A single dataset containing raw controller data is 0xAC bytes. The first three words of a datset are bitmasks of the flags listed [[vpad.rpl#Buttons|below]].
−
{| class="wikitable"
+
−
!Offset
+
<syntaxhighlight lang="C">
−
!Length
+
typedef struct
−
!Description
+
{
−
|-
+
float x, y;
−
|2
+
} Vec2D;
−
|2
+
−
|Buttons, ABXY, Left, Right, Up, Down in that order (bits)
+
typedef struct
−
|-
+
{
−
|3
+
float x, y, z;
−
|1
+
} Vec3D;
−
|Buttons, ZL, ZR, L, R, +, -, Power/Home, Sync in that order (bits)
+
−
|-
+
typedef struct
−
|12
+
{
−
|8
+
uint16_t x, y; /* Touch coordinates */
−
|Left Joystick, vectors for X and Y
+
uint16_t touched; /* 1 = Touched, 0 = Not touched */
−
|-
+
uint16_t validity; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */
−
|20
+
} VPADTPData;
−
|8
+
−
|Right Joystick, vectors for X and Y
+
typedef struct
−
|-
+
{
−
!colspan="3"|Touchscreen Input
+
Vec3D X,Y,Z;
−
|-
+
} VPADOrientation;
−
|82
+
−
|2
+
typedef struct
−
|Touchscreen X
+
{
−
|-
+
uint32_t btn_hold; /* Held buttons */
−
|84
+
uint32_t btn_trigger; /* Buttons that are pressed at that instant */
−
|2
+
uint32_t btn_release; /* Released buttons */
−
|Touchscreen Y
+
Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */
−
|-
+
Vec3D acc; /* Accelerometer value */
−
|86
+
f32 accValue; /* Accelerometer magnitude */
−
|2
+
f32 accSpeed; /* Accelerometer variation */
−
|Flag for if touchscreen is currently being touched (1 = Yes, 0 = No)
+
Vec2D accVertical; /* Vertical direction of DRC */
−
|-
+
Vec3D gyro; /* Gyro data */
−
|88
+
Vec3D angle; /* Angle data */
−
|2
+
s8 vpadErr; /* Error status */
−
|Coordinate validation (0 = All Valid, 1 = Invalid X, 2 = Invalid Y, 3 = Both Invalid)
+
VPADTPData tpdata; /* Normal touchscreen data */
−
|-
+
VPADTPData tpdata1; /* Modified touchscreen data 1 */
−
|90
+
VPADTPData tpdata2; /* Modified touchscreen data 2 */
−
|2
+
VPADOrientation dir; /* Orientation in three-dimensional space */
−
|Modified Touchscreen X?
+
BOOL headphoneStatus; /* Headphone status (TRUE : headphones are inserted) */
−
|-
+
Vec3D magnet; /* Magnetometer value */
−
|92
+
u8 volume; /* Slide Volume value (0 - 255) */
−
|2
+
u8 batteryLevel; /* Battery level ( 0 - 6 ) */
−
|Modified Touchscreen Y?
+
u8 micStatus; /* Mic status */
−
|-
+
u8 volumeCalibrated; /* One less than volume */
−
|94
+
u8 __paddings__[7];
−
|2
+
} VPADData;
−
|Modified Flag for if touchscreen is currently being touched (1 = Yes, 0 = No)?
+
</syntaxhighlight>
−
|-
−
|96
−
|2
−
|Modified Coordinate validation (0 = All Valid, 1 = Invalid X, 2 = Invalid Y, 3 = Both Invalid)?
−
|-
−
|98
−
|2
−
|Modified Touchscreen X?
−
|-
−
|100
−
|2
−
|Modified Touchscreen Y?
−
|-
−
|102
−
|2
−
|Modified Flag for if touchscreen is currently being touched (1 = Yes, 0 = No)?
−
|-
−
|104
−
|2
−
|Modified Coordinate validation (0 = All Valid, 1 = Invalid X, 2 = Invalid Y, 3 = Both Invalid)?
−
|-
−
!colspan="3"|Other Data
−
|-
−
|160
−
|1
−
|Something related to volume slider
−
|-
−
|161
−
|1
−
|Battery related. Charge level? out of 6
−
|-
−
|163
−
|1
−
|Something related to volume slider(one less than 0xA0)
−
|-
−
|164
−
|8
−
|Padding?
−
|}
== Defines ==
== Defines ==
−
=== Keys ===
+
=== Buttons ===
−
{| class="wikitable"
+
<syntaxhighlight lang="C">
−
!Name
+
#define BUTTON_A 0x8000
−
!Value
+
#define BUTTON_B 0x4000
−
!Description
+
#define BUTTON_X 0x2000
−
|-
+
#define BUTTON_Y 0x1000
−
|KEY_DRC_LEFT
+
#define BUTTON_LEFT 0x0800
−
|0x0800
+
#define BUTTON_RIGHT 0x0400
−
|Left d-pad button
+
#define BUTTON_UP 0x0200
−
|-
+
#define BUTTON_DOWN 0x0100
−
|KEY_DRC_RIGHT
+
#define BUTTON_ZL 0x0080
−
|0x0400
+
#define BUTTON_ZR 0x0040
−
|Right d-pad button
+
#define BUTTON_L 0x0020
−
|-
+
#define BUTTON_R 0x0010
−
|KEY_DRC_UP
+
#define BUTTON_PLUS 0x0008
−
|0x0200
+
#define BUTTON_MINUS 0x0004
−
|Upper d-pad button
+
#define BUTTON_HOME 0x0002
−
|-
+
#define BUTTON_SYNC 0x0001
−
|KEY_DRC_DOWN
+
#define BUTTON_STICK_R 0x00020000
−
|0x0100
+
#define BUTTON_STICK_L 0x00040000
−
|Bottom d-pad button
+
#define BUTTON_TV 0x00010000
−
|-
−
|KEY_DRC_A
−
|0x8000
−
|A button
−
|-
−
|KEY_DRC_B
−
|0x4000
−
|B button
−
|-
−
|KEY_DRC_X
−
|0x2000
−
|X button
−
|-
−
|KEY_DRC_Y
−
|0x1000
−
|Y button
−
−
|-
−
|KEY_DRC_ZL
−
|0x0080
−
|ZL button
−
|-
−
|KEY_DRC_ZR
−
|0x0040
−
|ZR button
−
|-
−
|KEY_DRC_L
−
|0x0020
−
|L button
−
|-
−
|KEY_DRC_R
−
|0x0010
−
|R button
−
|-
+
</syntaxhighlight>
−
|KEY_DRC_PLUS
−
|0x0008
−
|Plus button
−
|-
−
|KEY_DRC_MINUS
−
|0x0004
−
|Minus button
−
|-
−
|KEY_DRC_SYNC
−
|0x0001
−
|Sync button
−
|-
−
|KEY_DRC_HOME
−
|0x0002
−
|Home button
−
|}