Difference between revisions of "Vpad.rpl"
Jump to navigation
Jump to search
Marionumber1 (talk | contribs) (→VPAD Data: Get held, triggered, and released button flags) |
Marionumber1 (talk | contribs) (Clarify VPADRead() parameters) |
||
Line 8: | Line 8: | ||
|- | |- | ||
|VPADRead | |VPADRead | ||
− | |int VPADRead(int padnum, | + | |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 | ||
|} | |} | ||
Line 14: | Line 14: | ||
==Structures== | ==Structures== | ||
===VPAD Data=== | ===VPAD Data=== | ||
− | Can be gotten using VPADRead(), | + | 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]]. |
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> |
Revision as of 22:52, 9 April 2015
This controls communication with the Gamepad, internally called VPAD by this library. It uses the VPADBASE library internally.
Functions
Name | Prototype | Description |
---|---|---|
VPADRead | int VPADRead(int padnum, VPADData *buffer, int num_datasets, int *err); | Stores raw controller data in buffer for the specified Gamepad |
Structures
VPAD Data
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 below.
typedef struct
{
uint16_t x, y; /* Touch coordinates */
uint16_t touched; /* 1 = Touched, 0 = Not touched */
uint16_t validity; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */
} VPADTPData;
typedef struct
{
uint32_t btn_hold; /* Held buttons */
uint32_t btn_trigger; /* Buttons that are pressed at that instant */
uint32_t btn_release; /* Released buttons */
Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */
char unknown1c[0x52 - 0x1c]; /* Contains accelerometer and gyroscope data somewhere */
VPADTPData tpdata; /* Normal touchscreen data */
VPADTPData tpdata1; /* Modified touchscreen data 1 */
VPADTPData tpdata2; /* Modified touchscreen data 2 */
char unknown6a[0xa0 - 0x6a];
uint8_t volume;
uint8_t battery; /* 0 to 6 */
uint8_t unk_volume; /* One less than volume */
char unknowna4[0xac - 0xa4];
} VPADData;
Defines
Buttons
#define BUTTON_A 0x8000
#define BUTTON_B 0x4000
#define BUTTON_X 0x2000
#define BUTTON_Y 0x1000
#define BUTTON_LEFT 0x0800
#define BUTTON_RIGHT 0x0400
#define BUTTON_UP 0x0200
#define BUTTON_DOWN 0x0100
#define BUTTON_ZL 0x0080
#define BUTTON_ZR 0x0040
#define BUTTON_L 0x0020
#define BUTTON_R 0x0010
#define BUTTON_PLUS 0x0008
#define BUTTON_MINUS 0x0004
#define BUTTON_HOME 0x0002
#define BUTTON_SYNC 0x0001