Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
Data Structures | Macros | Functions
controller.h File Reference

Emulate a player's controller. More...

#include "gctypes.h"

Go to the source code of this file.

Data Structures

struct  Controller
 Represents the state of a controller. More...
 

Macros

#define TILT_RADIUS   0.3
 
#define DEFAULT_CONTROLLER   ((Controller) {0, 0.f, 0.f, 0.f, 0.f})
 
#define BUTTON_BITS   0x000F
 
#define RADIUS_BITS   0x00F0
 
#define ANGLE_BITS   0xFF00
 
#define NO_BUTTON   0x00
 
#define A_BUTTON   0x01
 
#define B_BUTTON   0x02
 
#define X_BUTTON   0x03
 
#define Z_BUTTON   0x04
 
#define L_BUTTON   0x05
 
#define START_BUTTON   0x06
 
#define DPAD_UP   0x07
 
#define DPAD_DOWN   0x08
 
#define DPAD_LEFT   0x09
 
#define DPAD_RIGHT   0x0a
 
#define CSTICK_UP   0x0b
 
#define CSTICK_DOWN   0x0c
 
#define CSTICK_LEFT   0x0d
 
#define CSTICK_RIGHT   0x0e
 
#define NO_STICK   0x00
 
#define TILT_STICK   0x10
 
#define FULL_STICK   0x20
 

Functions

void setController (Controller *controller, u16 state)
 Set the state of the controller. More...
 
void writeController (Controller *controller, u32 port, bool pData)
 Write the state of controller to the memory addresses read by the game. More...
 

Detailed Description

Emulate a player's controller.


Data Structure Documentation

struct Controller

Represents the state of a controller.

Data Fields
u32 buttons

A-0100, B-0200, X-0400, Z-0010, L-0040

f32 stickX

x coordinate of control stick

f32 stickY

y coordinate of control stick

f32 CstickX

x coordinate of c-stick

f32 CstickY

y coordinate of c-stick

Macro Definition Documentation

#define BUTTON_BITS   0x000F

Controller bit mask

#define RADIUS_BITS   0x00F0

Controller bit mask

#define ANGLE_BITS   0xFF00

Controller bit mask

#define NO_BUTTON   0x00

Button Flag

#define A_BUTTON   0x01

Button Flag

#define B_BUTTON   0x02

Button Flag

#define X_BUTTON   0x03

Button Flag

#define Z_BUTTON   0x04

Button Flag

#define L_BUTTON   0x05

Button Flag

#define START_BUTTON   0x06

Button Flag

#define DPAD_UP   0x07

Button Flag

#define DPAD_DOWN   0x08

Button Flag

#define DPAD_LEFT   0x09

Button Flag

#define DPAD_RIGHT   0x0a

Button Flag

#define CSTICK_UP   0x0b

Button Flag

#define CSTICK_DOWN   0x0c

Button Flag

#define CSTICK_LEFT   0x0d

Button Flag

#define CSTICK_RIGHT   0x0e

Button Flag

#define NO_STICK   0x00

Button Flag

#define TILT_STICK   0x10

Button Flag

#define FULL_STICK   0x20

Button Flag

#define TILT_RADIUS   0.3

Radius of stick that defines a tilt

#define DEFAULT_CONTROLLER   ((Controller) {0, 0.f, 0.f, 0.f, 0.f})

Default Controller struct

Function Documentation

void setController ( Controller controller,
u16  state 
)

Set the state of the controller.

Parameters
controller- Pointer to a Controller struct.
state- 16-bit integer encoding the controller state. 0x000F - buttons 0x00F0 - stick radius 0xFF00 - stick angle
Returns
None.
void writeController ( Controller controller,
u32  port,
bool  pData 
)

Write the state of controller to the memory addresses read by the game.

Parameters
controller- Pointer to a Controller struct.
port- Which player port to write to {1,2,3,4}
pData- Write controller to PlayerData
Returns
None