Check controller input?
First you need to called WPAD_Init()
! It is defined in wiiuse/wpad.h
Wii Remote
WPAD stores information on Wii Remote controllers in WPADData
structs, which you can get a pointer to with the WPAD_Data(chan)
function. The chan
parameter is presumably the player number? But zero-indexed. The structure is defined as follows:
typedef struct _wpad_data
{
s16 err;
u32 data_present;
u8 battery_level;
u32 btns_h;
u32 btns_l;
u32 btns_d;
u32 btns_u;
struct ir_t ir;
struct vec3w_t accel;
struct orient_t orient;
struct gforce_t gforce;
struct expansion_t exp;
} WPADData;
Rather then read from the struct directly, I think the WPAD developers would prefer you use helper functions for pulling out individual fields, such as button states. These functions are:
-
u8 WPAD_BatteryLevel(int chan)
-
u32 WPAD_ButtonsUp(int chan)
-
u32 WPAD_ButtonsDown(int chan)
-
u32 WPAD_ButtonsHeld(int chan)
-
void WPAD_IR(int chan, struct ir_t *ir)
-
void WPAD_Orientation(int chan, struct orient_t *orient)
-
void WPAD_GForce(int chan, struct gforce_t *gforce)
-
void WPAD_Accel(int chan, struct vec3w_t *accel)
-
void WPAD_Expansion(int chan, struct expansion_t *exp)
Buttons
#include <wiiuse/wpad.h>
bool home_button_pressed(int chan)
{
return (WPAD_ButtonsDown(chan) & WPAD_BUTTON_HOME > 0);
}
The full list of available buttons includes everything on the Wii Remote, the two additional buttons on the Nunchuck, all of the Classic Controller buttons, and all of the Guitar Hero buttons. They are all defined here.
No Comments