MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
mgdl-controller.h File Reference

Header for the controller class. More...

#include "mgdl-types.h"
#include "mgdl-vector.h"

Go to the source code of this file.

Data Structures

struct  WiiController
 Struct representing the Wii controller. More...
 

Typedefs

typedef enum WiiButtons WiiButtons
 
typedef struct WiiController WiiController
 

Enumerations

enum  WiiButtons {
  Button2 = 0x0001 , Button1 = 0x0002 , ButtonB = 0x0004 , ButtonA = 0x0008 ,
  ButtonMinus = 0x0010 , ButtonHome = 0x0080 , ButtonLeft = 0x0100 , ButtonRight = 0x0200 ,
  ButtonDown = 0x0400 , ButtonUp = 0x0800 , ButtonPlus = 0x1000 , ButtonZ = (0x0001 << 16) ,
  ButtonC = (0x0002 << 16)
}
 Enum values for all the buttons on the Wii Controller.
 

Functions

void WiiController_Init (WiiController *controller, u8 channel)
 Initialize a controller and set a channel for it.
 
void WiiController_ZeroAllInputs (WiiController *controller)
 Zero all inputs on a controller.
 
void WiiController_StartFrame (WiiController *controller)
 Prepares controller for input.
 
bool WiiController_ButtonPress (WiiController *controller, int buttonEnum)
 Tells if a button was pressed down this frame.
 
bool WiiController_ButtonRelease (WiiController *controller, int buttonEnum)
 Tells if a button was released this frame.
 
bool WiiController_ButtonHeld (WiiController *controller, int buttonEnum)
 Tells if a button is down.
 
vec2 WiiController_GetCursorPosition (WiiController *controller)
 Returns the position of the cursor.
 
vec2 WiiController_GetNunchukJoystickDirection (WiiController *controller)
 Returns the direction of the nunchuck joystick.
 
float WiiController_GetRoll (WiiController *controller)
 Returns the roll reported by the gyroscope in radians.
 
float WiiController_GetPitch (WiiController *controller)
 Returns the pitch reported by the gyroscope in radians.
 
float WiiController_GetYaw (WiiController *controller)
 Returns the yaw reported by the gyroscope in radians.
 
const char * WiiController_GetButtonSymbol (int buttonEnum)
 
void _WiiController_SetButtonDown (WiiController *controller, int buttonEnum)
 
void _WiiController_SetButtonUp (WiiController *controller, int buttonEnum)
 

Detailed Description

Header for the controller class.

Function Documentation

◆ WiiController_ButtonHeld()

bool WiiController_ButtonHeld ( WiiController controller,
int  buttonEnum 
)

Tells if a button is down.

Parameters
buttonEnumThe button to query.
Returns
True if the given button was pressed down this frame or before.

◆ WiiController_ButtonPress()

bool WiiController_ButtonPress ( WiiController controller,
int  buttonEnum 
)

Tells if a button was pressed down this frame.

Parameters
buttonEnumThe button to query.
Returns
True if the given button was pressed down this frame.

◆ WiiController_ButtonRelease()

bool WiiController_ButtonRelease ( WiiController controller,
int  buttonEnum 
)

Tells if a button was released this frame.

Parameters
buttonEnumThe button to query.
Returns
True if the given button was released this frame.

◆ WiiController_GetCursorPosition()

vec2 WiiController_GetCursorPosition ( WiiController controller)

Returns the position of the cursor.

Returns
Position of the cursor in pixels.

◆ WiiController_GetNunchukJoystickDirection()

vec2 WiiController_GetNunchukJoystickDirection ( WiiController controller)

Returns the direction of the nunchuck joystick.

Note
The returned vector2 is not normalized.
Returns
Direction of the nunchuck joystick.

◆ WiiController_GetPitch()

float WiiController_GetPitch ( WiiController controller)

Returns the pitch reported by the gyroscope in radians.

Returns
Amount of pitch in radians [-Pi, Pi]. 0 means no roll.

◆ WiiController_GetRoll()

float WiiController_GetRoll ( WiiController controller)

Returns the roll reported by the gyroscope in radians.

Returns
Amount of roll in radians [-Pi, Pi]. 0 means no roll.

◆ WiiController_GetYaw()

float WiiController_GetYaw ( WiiController controller)

Returns the yaw reported by the gyroscope in radians.

Returns
Amount of yaw in radians [-Pi, Pi]. 0 means no roll.

◆ WiiController_Init()

void WiiController_Init ( WiiController controller,
u8  channel 
)

Initialize a controller and set a channel for it.

Parameters
channelChannel of the controller. Valid values [0,3]

◆ WiiController_StartFrame()

void WiiController_StartFrame ( WiiController controller)

Prepares controller for input.

Releases all buttons and clears the list of released buttons. Call this before any input and code that reads controller state.

◆ WiiController_ZeroAllInputs()

void WiiController_ZeroAllInputs ( WiiController controller)

Zero all inputs on a controller.

This releases all buttons and sets the joystick and roll to initial position.