Vpad.rpl: Difference between revisions

From WiiUBrew
Jump to navigation Jump to search
Filfat (talk | contribs)
Added keys from https://github.com/Relys/libwiiu/blob/master/libwiiu/src/vpad.h
C0mm4nd (talk | contribs)
Filled VPADData (https://github.com/Maschell/dynamic_libs/pull/11/commits/bd0862328bf4f6adf1600418098d0bfae001a37d)
 
(12 intermediate revisions by 6 users not shown)
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
|Y button
|-
|KEY_DRC_ZR
|0x0040
|Y button
|-
|KEY_DRC_L
|0x0020
|Y button
|-
|KEY_DRC_R
|0x0010
|Y button


|-
</syntaxhighlight>
|KEY_DRC_PLUS
|0x0008
|Y button
|-
|KEY_DRC_MINUS
|0x0004
|Y button
|-
|KEY_DRC_SYNC
|0x0001
|Y button
|-
|KEY_DRC_HOME
|0x0002
|Y button
|}

Latest revision as of 16:55, 4 July 2017

This controls communication with the Gamepad, internally called VPAD by this library. It uses the VPADBASE library internally.

Functions

Name Prototype 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 int VPADRead(int padnum, VPADData *buffer, int num_datasets, int *err); 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/Enums

VPAD Display Mode

Can be gotten using VPADGetLcdMode().

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;

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
{
    float x, y;
} Vec2D;

typedef struct
{
    float x, y, z;
} Vec3D;

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
{
    Vec3D X,Y,Z;
} VPADOrientation;

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 */
    Vec3D acc;                   /* Accelerometer value */
    f32 accValue;                /* Accelerometer magnitude */
    f32 accSpeed;                /* Accelerometer variation */
    Vec2D accVertical;           /* Vertical direction of DRC */
    Vec3D gyro;                  /* Gyro data */
    Vec3D angle;                 /* Angle data */
    s8 vpadErr;                  /* Error status */
    VPADTPData tpdata;           /* Normal touchscreen data */
    VPADTPData tpdata1;          /* Modified touchscreen data 1 */
    VPADTPData tpdata2;          /* Modified touchscreen data 2 */
    VPADOrientation dir;         /* Orientation in three-dimensional space */
    BOOL headphoneStatus;        /* Headphone status (TRUE : headphones are inserted) */
    Vec3D magnet;                /* Magnetometer value */
    u8 volume;                   /* Slide Volume value (0 - 255) */
    u8 batteryLevel;             /* Battery level ( 0 - 6 ) */
    u8 micStatus;                /* Mic status */
    u8 volumeCalibrated;         /* One less than volume */
    u8 __paddings__[7];
} 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
#define BUTTON_STICK_R     0x00020000
#define BUTTON_STICK_L     0x00040000
#define BUTTON_TV          0x00010000