RetroArch
Classes | Macros | Typedefs | Functions | Variables
connect_wii.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <boolean.h>
#include <retro_endianness.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include "joypad_connection.h"
#include "../input_defines.h"
#include "../common/hid/hid_device_driver.h"
Include dependency graph for connect_wii.c:

Classes

struct  axis_t
 
struct  connect_wii_joystick_t
 
struct  connect_wii_classic_ctrl_t
 
struct  connect_wii_expansion_t
 
struct  connect_wii_wiimote_t
 

Macros

#define WIIMOTE_STATE_DEV_FOUND   0x0001
 
#define WIIMOTE_STATE_HANDSHAKE   0x0002 /* Actual connection exists but no handshake yet */
 
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE   0x0004
 
#define WIIMOTE_STATE_CONNECTED   0x0008
 
#define WIIMOTE_STATE_EXP   0x0040
 
#define WM_SET_REPORT   0x50
 
#define WM_CMD_LED   0x11
 
#define WM_CMD_REPORT_TYPE   0x12
 
#define WM_CMD_RUMBLE   0x13
 
#define WM_CMD_IR   0x13
 
#define WM_CMD_CTRL_STATUS   0x15
 
#define WM_CMD_WRITE_DATA   0x16
 
#define WM_CMD_READ_DATA   0x17
 
#define WM_CMD_IR_2   0x1A
 
#define WM_RPT_CTRL_STATUS   0x20
 
#define WM_RPT_READ   0x21
 
#define WM_RPT_WRITE   0x22
 
#define WM_RPT_BTN   0x30
 
#define WM_RPT_BTN_ACC   0x31
 
#define WM_RPT_BTN_ACC_IR   0x33
 
#define WM_RPT_BTN_EXP   0x34
 
#define WM_RPT_BTN_ACC_EXP   0x35
 
#define WM_RPT_BTN_IR_EXP   0x36
 
#define WM_RPT_BTN_ACC_IR_EXP   0x37
 
#define WM_BT_INPUT   0x01
 
#define WM_BT_OUTPUT   0x02
 
#define WM_MAX_BATTERY_CODE   0xC8
 
#define WM_MEM_OFFSET_CALIBRATION   0x16
 
#define WM_EXP_MEM_BASE   0x04A40000
 
#define WM_EXP_MEM_ENABLE   0x04A40040
 
#define WM_EXP_MEM_CALIBR   0x04A40020
 
#define EXP_HANDSHAKE_LEN   224
 
#define WM_CTRL_STATUS_BYTE1_ATTACHMENT   0x02
 
#define WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED   0x04
 
#define WM_CTRL_STATUS_BYTE1_IR_ENABLED   0x08
 
#define WM_CTRL_STATUS_BYTE1_LED_1   0x10
 
#define WM_CTRL_STATUS_BYTE1_LED_2   0x20
 
#define WM_CTRL_STATUS_BYTE1_LED_3   0x40
 
#define WM_CTRL_STATUS_BYTE1_LED_4   0x80
 
#define WIIMOTE_LED_NONE   0x00
 
#define WIIMOTE_LED_1   0x10
 
#define WIIMOTE_LED_2   0x20
 
#define WIIMOTE_LED_3   0x40
 
#define WIIMOTE_LED_4   0x80
 
#define WIIMOTE_BUTTON_ALL   0x1F9F
 
#define CLASSIC_CTRL_BUTTON_ALL   0xFEFF
 
#define EXP_NONE   0
 
#define EXP_CLASSIC   2
 
#define IDENT_NUNCHUK   0xA4200000
 
#define IDENT_CC   0xA4200101
 
#define WIIMOTE_IS_SET(wm, s)   ((wm->state & (s)) == (s))
 
#define WIIMOTE_ENABLE_STATE(wm, s)   (wm->state |= (s))
 
#define WIIMOTE_DISABLE_STATE(wm, s)   (wm->state &= ~(s))
 
#define WIIMOTE_TOGGLE_STATE(wm, s)   ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
 

Typedefs

typedef struct axis_t axis_t
 
typedef struct connect_wii_joystick_t connect_wii_joystick_t
 
typedef struct connect_wii_classic_ctrl_t connect_wii_classic_ctrl_t
 
typedef struct connect_wii_expansion_t connect_wii_expansion_t
 
typedef struct connect_wii_wiimote_t connect_wii_wiimote
 

Functions

static bool wiimote_is_connected (struct connect_wii_wiimote_t *wm)
 
static int wiimote_send (struct connect_wii_wiimote_t *wm, uint8_t report_type, uint8_t *msg, int len)
 
static void wiimote_status (struct connect_wii_wiimote_t *wm)
 
static void wiimote_data_report (struct connect_wii_wiimote_t *wm, uint8_t type)
 
static void wiimote_set_leds (struct connect_wii_wiimote_t *wm, int leds)
 
static void wiimote_pressed_buttons (struct connect_wii_wiimote_t *wm, uint8_t *msg)
 
static int wiimote_classic_ctrl_handshake (struct connect_wii_wiimote_t *wm, struct connect_wii_classic_ctrl_t *cc, uint8_t *data, uint16_t len)
 
static float wiimote_normalize_and_interpolate (float min, float max, float t)
 
static void wiimote_process_axis (struct axis_t *axis, uint8_t raw)
 
static void classic_ctrl_event (struct connect_wii_classic_ctrl_t *cc, uint8_t *msg)
 
static void wiimote_handle_expansion (struct connect_wii_wiimote_t *wm, uint8_t *msg)
 
static int wiimote_write_data (struct connect_wii_wiimote_t *wm, uint32_t addr, uint8_t *data, uint8_t len)
 
static int wiimote_read_data (struct connect_wii_wiimote_t *wm, uint32_t addr, uint16_t len)
 
static int wiimote_handshake (struct connect_wii_wiimote_t *wm, uint8_t event, uint8_t *data, uint16_t len)
 
static void hidpad_wii_deinit (void *data)
 
static voidhidpad_wii_init (void *data, uint32_t slot, hid_driver_t *driver)
 
static int16_t hidpad_wii_get_axis (void *data, unsigned axis)
 
static void hidpad_wii_get_buttons (void *data, input_bits_t *state)
 
static void hidpad_wii_packet_handler (void *data, uint8_t *packet, uint16_t size)
 
static void hidpad_wii_set_rumble (void *data, enum retro_rumble_effect effect, uint16_t strength)
 

Variables

pad_connection_interface_t pad_connection_wii
 

Macro Definition Documentation

◆ CLASSIC_CTRL_BUTTON_ALL

#define CLASSIC_CTRL_BUTTON_ALL   0xFEFF

◆ EXP_CLASSIC

#define EXP_CLASSIC   2

◆ EXP_HANDSHAKE_LEN

#define EXP_HANDSHAKE_LEN   224

◆ EXP_NONE

#define EXP_NONE   0

◆ IDENT_CC

#define IDENT_CC   0xA4200101

◆ IDENT_NUNCHUK

#define IDENT_NUNCHUK   0xA4200000

◆ WIIMOTE_BUTTON_ALL

#define WIIMOTE_BUTTON_ALL   0x1F9F

◆ WIIMOTE_DISABLE_STATE

#define WIIMOTE_DISABLE_STATE (   wm,
  s 
)    (wm->state &= ~(s))

◆ WIIMOTE_ENABLE_STATE

#define WIIMOTE_ENABLE_STATE (   wm,
  s 
)    (wm->state |= (s))

◆ WIIMOTE_IS_SET

#define WIIMOTE_IS_SET (   wm,
  s 
)    ((wm->state & (s)) == (s))

◆ WIIMOTE_LED_1

#define WIIMOTE_LED_1   0x10

◆ WIIMOTE_LED_2

#define WIIMOTE_LED_2   0x20

◆ WIIMOTE_LED_3

#define WIIMOTE_LED_3   0x40

◆ WIIMOTE_LED_4

#define WIIMOTE_LED_4   0x80

◆ WIIMOTE_LED_NONE

#define WIIMOTE_LED_NONE   0x00

◆ WIIMOTE_STATE_CONNECTED

#define WIIMOTE_STATE_CONNECTED   0x0008

◆ WIIMOTE_STATE_DEV_FOUND

#define WIIMOTE_STATE_DEV_FOUND   0x0001

◆ WIIMOTE_STATE_EXP

#define WIIMOTE_STATE_EXP   0x0040

◆ WIIMOTE_STATE_HANDSHAKE

#define WIIMOTE_STATE_HANDSHAKE   0x0002 /* Actual connection exists but no handshake yet */

◆ WIIMOTE_STATE_HANDSHAKE_COMPLETE

#define WIIMOTE_STATE_HANDSHAKE_COMPLETE   0x0004

◆ WIIMOTE_TOGGLE_STATE

#define WIIMOTE_TOGGLE_STATE (   wm,
  s 
)    ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))

◆ WM_BT_INPUT

#define WM_BT_INPUT   0x01

◆ WM_BT_OUTPUT

#define WM_BT_OUTPUT   0x02

◆ WM_CMD_CTRL_STATUS

#define WM_CMD_CTRL_STATUS   0x15

◆ WM_CMD_IR

#define WM_CMD_IR   0x13

◆ WM_CMD_IR_2

#define WM_CMD_IR_2   0x1A

◆ WM_CMD_LED

#define WM_CMD_LED   0x11

◆ WM_CMD_READ_DATA

#define WM_CMD_READ_DATA   0x17

◆ WM_CMD_REPORT_TYPE

#define WM_CMD_REPORT_TYPE   0x12

◆ WM_CMD_RUMBLE

#define WM_CMD_RUMBLE   0x13

◆ WM_CMD_WRITE_DATA

#define WM_CMD_WRITE_DATA   0x16

◆ WM_CTRL_STATUS_BYTE1_ATTACHMENT

#define WM_CTRL_STATUS_BYTE1_ATTACHMENT   0x02

◆ WM_CTRL_STATUS_BYTE1_IR_ENABLED

#define WM_CTRL_STATUS_BYTE1_IR_ENABLED   0x08

◆ WM_CTRL_STATUS_BYTE1_LED_1

#define WM_CTRL_STATUS_BYTE1_LED_1   0x10

◆ WM_CTRL_STATUS_BYTE1_LED_2

#define WM_CTRL_STATUS_BYTE1_LED_2   0x20

◆ WM_CTRL_STATUS_BYTE1_LED_3

#define WM_CTRL_STATUS_BYTE1_LED_3   0x40

◆ WM_CTRL_STATUS_BYTE1_LED_4

#define WM_CTRL_STATUS_BYTE1_LED_4   0x80

◆ WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED

#define WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED   0x04

◆ WM_EXP_MEM_BASE

#define WM_EXP_MEM_BASE   0x04A40000

◆ WM_EXP_MEM_CALIBR

#define WM_EXP_MEM_CALIBR   0x04A40020

◆ WM_EXP_MEM_ENABLE

#define WM_EXP_MEM_ENABLE   0x04A40040

◆ WM_MAX_BATTERY_CODE

#define WM_MAX_BATTERY_CODE   0xC8

◆ WM_MEM_OFFSET_CALIBRATION

#define WM_MEM_OFFSET_CALIBRATION   0x16

◆ WM_RPT_BTN

#define WM_RPT_BTN   0x30

◆ WM_RPT_BTN_ACC

#define WM_RPT_BTN_ACC   0x31

◆ WM_RPT_BTN_ACC_EXP

#define WM_RPT_BTN_ACC_EXP   0x35

◆ WM_RPT_BTN_ACC_IR

#define WM_RPT_BTN_ACC_IR   0x33

◆ WM_RPT_BTN_ACC_IR_EXP

#define WM_RPT_BTN_ACC_IR_EXP   0x37

◆ WM_RPT_BTN_EXP

#define WM_RPT_BTN_EXP   0x34

◆ WM_RPT_BTN_IR_EXP

#define WM_RPT_BTN_IR_EXP   0x36

◆ WM_RPT_CTRL_STATUS

#define WM_RPT_CTRL_STATUS   0x20

◆ WM_RPT_READ

#define WM_RPT_READ   0x21

◆ WM_RPT_WRITE

#define WM_RPT_WRITE   0x22

◆ WM_SET_REPORT

#define WM_SET_REPORT   0x50

Typedef Documentation

◆ axis_t

typedef struct axis_t axis_t

◆ connect_wii_classic_ctrl_t

◆ connect_wii_expansion_t

◆ connect_wii_joystick_t

◆ connect_wii_wiimote

Function Documentation

◆ classic_ctrl_event()

static void classic_ctrl_event ( struct connect_wii_classic_ctrl_t cc,
uint8_t msg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hidpad_wii_deinit()

static void hidpad_wii_deinit ( void data)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hidpad_wii_get_axis()

static int16_t hidpad_wii_get_axis ( void data,
unsigned  axis 
)
static

◆ hidpad_wii_get_buttons()

static void hidpad_wii_get_buttons ( void data,
input_bits_t state 
)
static

◆ hidpad_wii_init()

static void* hidpad_wii_init ( void data,
uint32_t  slot,
hid_driver_t driver 
)
static
Here is the call graph for this function:

◆ hidpad_wii_packet_handler()

static void hidpad_wii_packet_handler ( void data,
uint8_t packet,
uint16_t  size 
)
static
Here is the call graph for this function:

◆ hidpad_wii_set_rumble()

static void hidpad_wii_set_rumble ( void data,
enum retro_rumble_effect  effect,
uint16_t  strength 
)
static
Here is the call graph for this function:

◆ wiimote_classic_ctrl_handshake()

static int wiimote_classic_ctrl_handshake ( struct connect_wii_wiimote_t wm,
struct connect_wii_classic_ctrl_t cc,
uint8_t data,
uint16_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_data_report()

static void wiimote_data_report ( struct connect_wii_wiimote_t wm,
uint8_t  type 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_handle_expansion()

static void wiimote_handle_expansion ( struct connect_wii_wiimote_t wm,
uint8_t msg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_handshake()

static int wiimote_handshake ( struct connect_wii_wiimote_t wm,
uint8_t  event,
uint8_t data,
uint16_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_is_connected()

static bool wiimote_is_connected ( struct connect_wii_wiimote_t wm)
static
Here is the caller graph for this function:

◆ wiimote_normalize_and_interpolate()

static float wiimote_normalize_and_interpolate ( float  min,
float  max,
float  t 
)
static
Here is the caller graph for this function:

◆ wiimote_pressed_buttons()

static void wiimote_pressed_buttons ( struct connect_wii_wiimote_t wm,
uint8_t msg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_process_axis()

static void wiimote_process_axis ( struct axis_t axis,
uint8_t  raw 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_read_data()

static int wiimote_read_data ( struct connect_wii_wiimote_t wm,
uint32_t  addr,
uint16_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_send()

static int wiimote_send ( struct connect_wii_wiimote_t wm,
uint8_t  report_type,
uint8_t msg,
int  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_set_leds()

static void wiimote_set_leds ( struct connect_wii_wiimote_t wm,
int  leds 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_status()

static void wiimote_status ( struct connect_wii_wiimote_t wm)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiimote_write_data()

static int wiimote_write_data ( struct connect_wii_wiimote_t wm,
uint32_t  addr,
uint8_t data,
uint8_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pad_connection_wii

pad_connection_interface_t pad_connection_wii
Initial value:
= {
}
static void * hidpad_wii_init(void *data, uint32_t slot, hid_driver_t *driver)
Definition: connect_wii.c:619
static void hidpad_wii_deinit(void *data)
Definition: connect_wii.c:611
static int16_t hidpad_wii_get_axis(void *data, unsigned axis)
Definition: connect_wii.c:647
static void hidpad_wii_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength)
Definition: connect_wii.c:717
static void hidpad_wii_get_buttons(void *data, input_bits_t *state)
Definition: connect_wii.c:676
#define NULL
Pointer to 0.
Definition: gctypes.h:65
static void hidpad_wii_packet_handler(void *data, uint8_t *packet, uint16_t size)
Definition: connect_wii.c:687