xwiimote 2

- Main Page
- Modules
- Data Structures
- Files

Functions
Device Monitor

Monitor system for new wiimote devices. More...

## Functions
struct xwii_monitor * | xwii_monitor_new (bool poll, bool direct)
| Create a new monitor. More...
void | xwii_monitor_ref (struct xwii_monitor *mon)
| Increase monitor ref-count by 1. More...
void | xwii_monitor_unref (struct xwii_monitor *mon)
| Decrease monitor ref-count by 1. More...
int | xwii_monitor_get_fd (struct xwii_monitor *monitor, bool blocking)
| Return internal fd. More...
char * | xwii_monitor_poll (struct xwii_monitor *monitor)
| Read incoming events. More...

## Detailed Description

Monitor system for new wiimote devices.

This monitor can be used to enumerate all connected wiimote devices and also monitoring the system for hotplugged wiimote devices. This is a simple wrapper around libudev and should only be used if your application does not use udev on its own. See the implementation of the monitor to integrate wiimote-monitoring into your own udev routines.

## Function Documentation

struct xwii_monitor* xwii_monitor_new | ( | bool | poll,
|  | bool | direct
| ) |  |

Create a new monitor.

Creates a new monitor and returns a pointer to the opaque object. NULL is returned on failure.

Parameters

  [in] | poll | True if this monitor should watch for hotplug events
  [in] | direct | True if kernel uevents should be used instead of udevd

A monitor always provides all devices that are available on a system. If `poll` is true, the monitor also sets up a system-monitor to watch the system for new hotplug events so new devices can be detected.

A new monitor always has a ref-count of 1.

void xwii_monitor_ref | ( | struct xwii_monitor * | mon | ) |

Increase monitor ref-count by 1.

Parameters

  [in] | mon | Valid monitor object

void xwii_monitor_unref | ( | struct xwii_monitor * | mon | ) |

Decrease monitor ref-count by 1.

Parameters

  [in] | mon | Valid monitor object

If the ref-count drops below 1, the object is destroyed immediately.

int xwii_monitor_get_fd | ( | struct xwii_monitor * | monitor,
|  | bool | blocking
| ) |  |

Return internal fd.

Parameters

  [in] | monitor | A valid monitor object
  [in] | blocking | True to set the monitor in blocking mode

Returns the file-descriptor used by this monitor. If `blocking` is true, the FD is set into blocking mode. If false, it is set into non-blocking mode. Only one file-descriptor exists, that is, this function always returns the same descriptor.

This returns -1 if this monitor was not created with a hotplug-monitor. So you need this function only if you want to watch the system for hotplug events. Whenever this descriptor is readable, you should call xwii_monitor_poll() to read new incoming events.

char* xwii_monitor_poll | ( | struct xwii_monitor * | monitor | ) |

Read incoming events.

Parameters

  [in] | monitor | A valid monitor object

This returns a single device-name on each call. A device-name is actually an absolute sysfs path to the device's root-node. This is normally a path to /sys/bus/hid/devices/[dev]/. You can use this path to create a new struct xwii_iface object.

After a monitor was created, this function returns all currently available devices. After all devices have been returned, this function returns NULL once. After that, this function polls the monitor for hotplug events and returns hotplugged devices, if the monitor was opened to watch the system for hotplug events. Use xwii_monitor_get_fd() to get notified when a new event is available. If the fd is in non-blocking mode, this function never blocks but returns NULL if no new event is available.

The returned string must be freed with free() by the caller.