In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Vpad.rpl"

From WiiUBrew
Jump to navigation Jump to search
(Filled VPADData (https://github.com/Maschell/dynamic_libs/pull/11/commits/bd0862328bf4f6adf1600418098d0bfae001a37d))
 
(20 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This controls communication with the Gamepad, using VPADBASE internally.
+
This controls communication with the Gamepad, internally called VPAD by this library. It uses the VPADBASE library internally.
  
 
==Functions==
 
==Functions==
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
|void *VPADRead(int chan, void *buffer, int length, int* err);
+
|int VPADRead(int padnum, VPADData *buffer, int num_datasets, int *err);
|Stores raw controller data in buffer
+
|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.
 
|}
 
|}
  
==VPAD Data==
+
==Structures/Enums==
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.
+
===VPAD Display Mode===
===Structure===
+
Can be gotten using VPADGetLcdMode().
{| class="wikitable"
+
 
!Offset
+
<syntaxhighlight lang="C">
!Length
+
typedef enum {
!Description
+
    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 */
|0xC
+
    DISPLAY_MODE_DEFAULT  = 0xFF /* Default mode */
|8
+
} VPADDisplayMode;
|Left Joystick, vectors for X and Y
+
</syntaxhighlight>
|-
+
 
|0x14
+
===VPAD Data===
|8
+
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]].
|Right Joystick, vectors for X and Y
+
 
|-
+
<syntaxhighlight lang="C">
|0xA0
+
typedef struct
|1
+
{
|Something related to volume slider
+
    float x, y;
|-
+
} Vec2D;
|0xA1
+
 
|1
+
typedef struct
|Battery related. Charge level?
+
{
|-
+
    float x, y, z;
|0xA3
+
} Vec3D;
|1
+
 
|Something related to volume slider(one less than 0xA0)
+
typedef struct
|-
+
{
|0xA4
+
    uint16_t x, y;              /* Touch coordinates */
|8
+
    uint16_t touched;            /* 1 = Touched, 0 = Not touched */
|Padding?
+
    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;
 +
</syntaxhighlight>
 +
 
 +
== Defines ==
 +
=== Buttons  ===
 +
<syntaxhighlight lang="C">
 +
#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
 +
 
 +
</syntaxhighlight>

Latest revision as of 17: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