xwiimote 2
Device Events

Device event handling. More...

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_ABS_NUM   8
 Number of ABS values in an xwii_event_union.
 

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...
 

Detailed Description

Device event handling.

Devices notify users about any state-changes via events. These events can contain peripheral-data, hotplug-information or more.

Enumeration Type Documentation

◆ xwii_event_types

Event Types.

Each event can be identified by the type field. New types might be added at any time so unknown event-types must be ignored by applications. The given payload of an event is described for each type. Unused payload-space is zeroed by the library. However, the payload may be extended in new revisions so applications must not depend on it being 0 or untouched.

Enumerator
XWII_EVENT_KEY 

Core-interface key event.

The payload of such events is struct xwii_event_key. Valid key-events include all the events reported by the core-interface, which is normally only LEFT, RIGHT, UP, DOWN, A, B, PLUS, MINUS, HOME, ONE, TWO.

XWII_EVENT_ACCEL 

Accelerometer event.

Provides accelerometer data. Payload is struct xwii_event_abs and only the first element in the abs-array is used. The x, y and z fields contain the accelerometer data. Note that the accelerometer reports acceleration data, not speed data!

XWII_EVENT_IR 

IR-Camera event.

Provides IR-camera events. The camera can track up two four IR sources. As long as a single source is tracked, it stays at it's pre-allocated slot. The four available slots are reported as struct xwii_event_abs payload. The x and y fields contain the position of each slot.

Use xwii_event_ir_is_valid() to see whether a specific slot is currently valid or whether it currently doesn't track any IR source.

XWII_EVENT_BALANCE_BOARD 

Balance-Board event.

Provides balance-board weight data. Four sensors report weight-data for each of the four edges of the board. The data is available as struct xwii_event_abs payload. The x fields of the first four array-entries contain the weight-value.

XWII_EVENT_MOTION_PLUS 

Motion-Plus event.

Motion-Plus gyroscope events. These describe rotational speed, not acceleration, of the motion-plus extension. The payload is available as struct xwii_event_abs and the x, y and z field of the first array-element describes the motion-events in the 3 dimensions.

XWII_EVENT_PRO_CONTROLLER_KEY 

Pro-Controller key event.

Button events of the pro-controller are reported via this interface and not via the core-interface (which only reports core-buttons). Valid buttons include: LEFT, RIGHT, UP, DOWN, PLUS, MINUS, HOME, X, Y, A, B, TR, TL, ZR, ZL, THUMBL, THUMBR. Payload type is struct xwii_event_key.

XWII_EVENT_PRO_CONTROLLER_MOVE 

Pro-Controller movement event.

Movement of analog sticks are reported via this event. The payload is a struct xwii_event_abs and the first two array elements contain the absolute x and y position of both analog sticks.

XWII_EVENT_WATCH 

Hotplug Event.

This event is sent whenever an extension was hotplugged (plugged or unplugged), a device-detection finished or some other static data changed which cannot be monitored separately. No payload is provided. An application should check what changed by examining the device is testing whether all required interfaces are still available. Non-hotplug aware devices may discard this event.

This is only returned if you explicitly watched for hotplug events. See xwii_iface_watch().

This event is also returned if an interface is closed because the kernel closed our file-descriptor (for whatever reason). This is returned regardless whether you watch for hotplug events or not.

XWII_EVENT_CLASSIC_CONTROLLER_KEY 

Classic Controller key event.

Button events of the classic controller are reported via this interface and not via the core-interface (which only reports core-buttons). Valid buttons include: LEFT, RIGHT, UP, DOWN, PLUS, MINUS, HOME, X, Y, A, B, TR, TL, ZR, ZL. Payload type is struct xwii_event_key.

XWII_EVENT_CLASSIC_CONTROLLER_MOVE 

Classic Controller movement event.

Movement of analog sticks are reported via this event. The payload is a struct xwii_event_abs and the first two array elements contain the absolute x and y position of both analog sticks. The x value of the third array element contains the absolute position of the TL trigger. The y value contains the absolute position for the TR trigger. Note that many classic controllers do not have analog TL/TR triggers, in which case these read 0 or MAX (63). The digital TL/TR buttons are always reported correctly.

XWII_EVENT_NUNCHUK_KEY 

Nunchuk key event.

Button events of the nunchuk controller are reported via this interface and not via the core-interface (which only reports core-buttons). Valid buttons include: C, Z Payload type is struct xwii_event_key.

XWII_EVENT_NUNCHUK_MOVE 

Nunchuk movement event.

Movement events of the nunchuk controller are reported via this interface. Payload is of type struct xwii_event_abs. The first array element contains the x/y positions of the analog stick. The second array element contains the accelerometer information.

XWII_EVENT_DRUMS_KEY 

Drums key event.

Button events for drums controllers. Valid buttons are PLUS and MINUS for the +/- buttons on the center-bar. Payload type is struct xwii_event_key.

XWII_EVENT_DRUMS_MOVE 

Drums movement event.

Movement and pressure events for drums controllers. Payload is of type struct xwii_event_abs. The indices are describe as enum xwii_drums_abs and each of them contains the corresponding stick-movement or drum-pressure values.

XWII_EVENT_GUITAR_KEY 

Guitar key event.

Button events for guitar controllers. Valid buttons are HOME and PLUS for the StarPower/Home button and the + button. Furthermore, you get FRET_FAR_UP, FRET_UP, FRET_MID, FRET_LOW, FRET_FAR_LOW for fret activity and STRUM_BAR_UP and STRUM_BAR_LOW for the strum bar. Payload type is struct xwii_event_key.

XWII_EVENT_GUITAR_MOVE 

Guitar movement event.

Movement information for guitar controllers. Payload is of type struct xwii_event_abs. The first element contains X and Y direction of the analog stick. The second element contains whammy-bar movement information as x-value. The third element contains fret-bar absolute positioning information as x-value.

XWII_EVENT_GONE 

Removal Event.

This event is sent whenever the device was removed. No payload is provided. Non-hotplug aware applications may discard this event.

This is only returned if you explicitly watched for hotplug events. See xwii_iface_watch().

XWII_EVENT_NUM 

Number of available event types.

The value of this constant may increase on each new library revision. It is not guaranteed to stay constant. However, it may never shrink.

◆ xwii_event_keys

Key Event Identifiers.

For each key found on a supported device, a separate key identifier is defined. Note that a device may have a specific key (for instance: HOME) on the main device and on an extension device. An application can detect which key was pressed examining the event-type field. Some devices report common keys as both, extension and core events. In this case the kernel is required to filter these and you should report it as a bug. A single physical key-press should never be reported twice, even on two different interfaces.

Most of the key-names should be self-explanatory.

Enumerator
XWII_KEY_THUMBL 

Left thumb button.

This is reported if the left analog stick is pressed. Not all analog sticks support this. The Wii-U Pro Controller is one of few devices that report this event.

XWII_KEY_THUMBR 

Right thumb button.

This is reported if the right analog stick is pressed. Not all analog sticks support this. The Wii-U Pro Controller is one of few devices that report this event.

XWII_KEY_C 

Extra C button.

This button is not part of the standard action pad but reported by extension controllers like the Nunchuk. It is supposed to extend the standard A and B buttons.

XWII_KEY_Z 

Extra Z button.

This button is not part of the standard action pad but reported by extension controllers like the Nunchuk. It is supposed to extend the standard X and Y buttons.

XWII_KEY_STRUM_BAR_UP 

Guitar Strum-bar-up event.

Emitted by guitars if the strum-bar is moved up.

XWII_KEY_STRUM_BAR_DOWN 

Guitar Strum-bar-down event.

Emitted by guitars if the strum-bar is moved down.

XWII_KEY_FRET_FAR_UP 

Guitar Fret-Far-Up event.

Emitted by guitars if the upper-most fret-bar is pressed.

XWII_KEY_FRET_UP 

Guitar Fret-Up event.

Emitted by guitars if the second-upper fret-bar is pressed.

XWII_KEY_FRET_MID 

Guitar Fret-Mid event.

Emitted by guitars if the mid fret-bar is pressed.

XWII_KEY_FRET_LOW 

Guitar Fret-Low event.

Emitted by guitars if the second-lowest fret-bar is pressed.

XWII_KEY_FRET_FAR_LOW 

Guitar Fret-Far-Low event.

Emitted by guitars if the lower-most fret-bar is pressed.

XWII_KEY_NUM 

Number of key identifiers.

This defines the number of available key-identifiers. It is not guaranteed to stay constant and may change when new identifiers are added. However, it will never shrink.

◆ xwii_drums_abs

Absolute Drum-Motion Indices.

A drum-payload can contain a lot of different absolute motion events all in a single object. Depending on the event-type, the array offsets for absolute-motion events are different. This enum describes the indices used for drums.

Note that these mimic the kernel API. If new drums with more tom-toms or cymbals are supported, the corresponding TOM and CYMBAL values will be added. That's also why there is no TOM_MID, but only TOM_FAR_RIGHT so far.

Enumerator
XWII_DRUMS_ABS_PAD 

Control pad motion.

X and Y direction available.

XWII_DRUMS_ABS_CYMBAL_LEFT 

Cymbal pressure, just X direction.

XWII_DRUMS_ABS_CYMBAL_RIGHT 

Cymbal pressure, just X direction.

XWII_DRUMS_ABS_TOM_LEFT 

Mid-left tom pressure, just X direction.

XWII_DRUMS_ABS_TOM_RIGHT 

Mid-right tom pressure, just X direction.

XWII_DRUMS_ABS_TOM_FAR_RIGHT 

Right-most tom pressure, just X direction.

XWII_DRUMS_ABS_BASS 

Bass pressure, just X direction.

XWII_DRUMS_ABS_HI_HAT 

Hi-Hat pressure, just X direction.

XWII_DRUMS_ABS_NUM 

Number of drums payloads, may get increased for new ones.