xwiimote 2
xwiimote.h File Reference

Main libxwiimote API. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  xwii_event_key
 Key Event Payload. More...
 
struct  xwii_event_abs
 Absolute Motion Payload. More...
 
union  xwii_event_union
 Event Payload. More...
 
struct  xwii_event
 Event Object. More...
 

Macros

#define XWII__DEPRECATED
 
#define XWII__NAME   "Nintendo Wii Remote"
 
#define XWII_NAME_CORE   XWII__NAME
 Name of the core input device.
 
#define XWII_NAME_ACCEL   XWII__NAME " Accelerometer"
 Name of the accelerometer input device.
 
#define XWII_NAME_IR   XWII__NAME " IR"
 Name of the IR input device.
 
#define XWII_NAME_MOTION_PLUS   XWII__NAME " Motion Plus"
 Name of the motion-plus input device.
 
#define XWII_NAME_NUNCHUK   XWII__NAME " Nunchuk"
 Name of the nunchuk input device.
 
#define XWII_NAME_CLASSIC_CONTROLLER   XWII__NAME " Classic Controller"
 Name of the classic-controller input device.
 
#define XWII_NAME_BALANCE_BOARD   XWII__NAME " Balance Board"
 Name of the balance-board input device.
 
#define XWII_NAME_PRO_CONTROLLER   XWII__NAME " Pro Controller"
 Name of the pro-controller input device.
 
#define XWII_NAME_DRUMS   XWII__NAME " Drums"
 Name of the drums-controller input device.
 
#define XWII_NAME_GUITAR   XWII__NAME " Guitar"
 Name of the guitar-controller input device.
 
#define XWII_ABS_NUM   8
 Number of ABS values in an xwii_event_union.
 
#define XWII_LED(num)   (XWII_LED1 + (num) - 1)
 Create enum xwii_led constants during runtime.
 

Enumerations

enum  xwii_event_types {
  XWII_EVENT_KEY ,
  XWII_EVENT_ACCEL ,
  XWII_EVENT_IR ,
  XWII_EVENT_BALANCE_BOARD ,
  XWII_EVENT_MOTION_PLUS ,
  XWII_EVENT_PRO_CONTROLLER_KEY ,
  XWII_EVENT_PRO_CONTROLLER_MOVE ,
  XWII_EVENT_WATCH ,
  XWII_EVENT_CLASSIC_CONTROLLER_KEY ,
  XWII_EVENT_CLASSIC_CONTROLLER_MOVE ,
  XWII_EVENT_NUNCHUK_KEY ,
  XWII_EVENT_NUNCHUK_MOVE ,
  XWII_EVENT_DRUMS_KEY ,
  XWII_EVENT_DRUMS_MOVE ,
  XWII_EVENT_GUITAR_KEY ,
  XWII_EVENT_GUITAR_MOVE ,
  XWII_EVENT_GONE ,
  XWII_EVENT_NUM
}
 Event Types. More...
 
enum  xwii_event_keys {
  XWII_KEY_LEFT ,
  XWII_KEY_RIGHT ,
  XWII_KEY_UP ,
  XWII_KEY_DOWN ,
  XWII_KEY_A ,
  XWII_KEY_B ,
  XWII_KEY_PLUS ,
  XWII_KEY_MINUS ,
  XWII_KEY_HOME ,
  XWII_KEY_ONE ,
  XWII_KEY_TWO ,
  XWII_KEY_X ,
  XWII_KEY_Y ,
  XWII_KEY_TL ,
  XWII_KEY_TR ,
  XWII_KEY_ZL ,
  XWII_KEY_ZR ,
  XWII_KEY_THUMBL ,
  XWII_KEY_THUMBR ,
  XWII_KEY_C ,
  XWII_KEY_Z ,
  XWII_KEY_STRUM_BAR_UP ,
  XWII_KEY_STRUM_BAR_DOWN ,
  XWII_KEY_FRET_FAR_UP ,
  XWII_KEY_FRET_UP ,
  XWII_KEY_FRET_MID ,
  XWII_KEY_FRET_LOW ,
  XWII_KEY_FRET_FAR_LOW ,
  XWII_KEY_NUM
}
 Key Event Identifiers. More...
 
enum  xwii_drums_abs {
  XWII_DRUMS_ABS_PAD ,
  XWII_DRUMS_ABS_CYMBAL_LEFT ,
  XWII_DRUMS_ABS_CYMBAL_RIGHT ,
  XWII_DRUMS_ABS_TOM_LEFT ,
  XWII_DRUMS_ABS_TOM_RIGHT ,
  XWII_DRUMS_ABS_TOM_FAR_RIGHT ,
  XWII_DRUMS_ABS_BASS ,
  XWII_DRUMS_ABS_HI_HAT ,
  XWII_DRUMS_ABS_NUM
}
 Absolute Drum-Motion Indices. More...
 
enum  xwii_iface_type {
  XWII_IFACE_CORE = 0x000001 ,
  XWII_IFACE_ACCEL = 0x000002 ,
  XWII_IFACE_IR = 0x000004 ,
  XWII_IFACE_MOTION_PLUS = 0x000100 ,
  XWII_IFACE_NUNCHUK = 0x000200 ,
  XWII_IFACE_CLASSIC_CONTROLLER = 0x000400 ,
  XWII_IFACE_BALANCE_BOARD = 0x000800 ,
  XWII_IFACE_PRO_CONTROLLER = 0x001000 ,
  XWII_IFACE_DRUMS = 0x002000 ,
  XWII_IFACE_GUITAR = 0x004000 ,
  XWII_IFACE_ALL ,
  XWII_IFACE_WRITABLE = 0x010000
}
 Interfaces. More...
 
enum  xwii_led {
  XWII_LED1 = 1 ,
  XWII_LED2 = 2 ,
  XWII_LED3 = 3 ,
  XWII_LED4 = 4
}
 LEDs. More...
 

Functions

const char * xwii_get_iface_name (unsigned int iface)
 Return name of a given interface.
 
int xwii_iface_new (struct xwii_iface **dev, const char *syspath)
 Create new device object from syspath path.
 
void xwii_iface_ref (struct xwii_iface *dev)
 Increase ref-count by 1.
 
void xwii_iface_unref (struct xwii_iface *dev)
 Decrease ref-count by 1.
 
const char * xwii_iface_get_syspath (struct xwii_iface *dev)
 Return device syspath.
 
int xwii_iface_get_fd (struct xwii_iface *dev)
 Return file-descriptor.
 
int xwii_iface_watch (struct xwii_iface *dev, bool watch)
 Watch device for hotplug events.
 
int xwii_iface_open (struct xwii_iface *dev, unsigned int ifaces)
 Open interfaces on this device.
 
void xwii_iface_close (struct xwii_iface *dev, unsigned int ifaces)
 Close interfaces on this device.
 
unsigned int xwii_iface_opened (struct xwii_iface *dev)
 Return bitmask of opened interfaces.
 
unsigned int xwii_iface_available (struct xwii_iface *dev)
 Return bitmask of available interfaces.
 
XWII__DEPRECATED int xwii_iface_poll (struct xwii_iface *dev, struct xwii_event *ev)
 Read incoming event-queue.
 
int xwii_iface_dispatch (struct xwii_iface *dev, struct xwii_event *ev, size_t size)
 Read incoming event-queue.
 
int xwii_iface_rumble (struct xwii_iface *dev, bool on)
 Toggle rumble motor.
 
int xwii_iface_get_led (struct xwii_iface *dev, unsigned int led, bool *state)
 Read LED state.
 
int xwii_iface_set_led (struct xwii_iface *dev, unsigned int led, bool state)
 Set LED state.
 
int xwii_iface_get_battery (struct xwii_iface *dev, uint8_t *capacity)
 Read battery state.
 
int xwii_iface_get_devtype (struct xwii_iface *dev, char **devtype)
 Read device type.
 
int xwii_iface_get_extension (struct xwii_iface *dev, char **extension)
 Read extension type.
 
void xwii_iface_set_mp_normalization (struct xwii_iface *dev, int32_t x, int32_t y, int32_t z, int32_t factor)
 Set MP normalization and calibration.
 
void xwii_iface_get_mp_normalization (struct xwii_iface *dev, int32_t *x, int32_t *y, int32_t *z, int32_t *factor)
 Read MP normalization and calibration.
 
struct xwii_monitor * xwii_monitor_new (bool poll, bool direct)
 Create a new monitor.
 
void xwii_monitor_ref (struct xwii_monitor *mon)
 Increase monitor ref-count by 1.
 
void xwii_monitor_unref (struct xwii_monitor *mon)
 Decrease monitor ref-count by 1.
 
int xwii_monitor_get_fd (struct xwii_monitor *monitor, bool blocking)
 Return internal fd.
 
char * xwii_monitor_poll (struct xwii_monitor *monitor)
 Read incoming events.
 

Detailed Description

Main libxwiimote API.

This file defines the public libxwiimote API and ABI. All identifiers are prefixed either with XWII_ or xwii_. Note that all identifiers prefixed with a double-underscore (XWII__ or xwii__) are not part of the stable ABI and may change at any time.