|
Treehopper C# API
|
Nintendo Wii Nunchuk More...
Classes | |
| class | JoystickEventArgs |
Public Member Functions | |
| delegate void | JoystickChangedDelegate (object sender, JoystickEventArgs e) |
| WiiNunchuk (I2C i2c) | |
| async Task | UpdateAsync () |
| Fetch an update from the Nunchuk and push it to all the properties. More... | |
Properties | |
| Vector2 | Joystick [get] |
| Gets a two-dimensional normalized vector representing the joystick state More... | |
| Button | C [get] |
| Gets the "C" button More... | |
| Button | Z [get] |
| Gets the "Z" button More... | |
| Vector3 | Accelerometer [get] |
| Gets a three-dimensional normalized vector representing the accelerometer state More... | |
| bool | AutoUpdateWhenPropertyRead = true [get, set] |
| Whether reading from one of the data properties should trigger a call to UpdateAsync() to fetch the latest state from the device. More... | |
| int | AwaitPollingInterval = 25 [get, set] |
| The interval, in milliseconds, that "AwaitValueChanged"-type functions should use when polling this Nunchuk for updates. More... | |
Events | |
| JoystickChangedDelegate | JoystickChanged |
| PropertyChangedEventHandler | PropertyChanged |
Nintendo Wii Nunchuk
This library implements an IAccelerometer-, DigitalIn-, and IPollable-compatible input device that exposes the joystick, accelerometer, C button, and Z button on a Nintendo Wii (or compatible) Nunchuk controller.
Just like all IPollable devices, there are different options for getting the data out of the peripheral. By default, AutoUpdateWhenPropertyRead will be true, so the library will automatically fetch updates from the device on-the-fly whenever you read one of the object's properties — this is a great method when you only need to grab the state of the device infrequently, as it doesn't tie up the I2C bus constantly. If your application is going to constantly read the input (say, in a game), you should change AutoUpdateWhenPropertyRead to false, and poll the sensor manually (with UpdateAsync()) whenever you want an update. Or, if you're hooking into events for the device, you can wrap this class inside a Poller<TPollable> to automatically run the polling loop for you.
| WiiNunchuk | ( | I2C | i2c | ) |
| delegate void JoystickChangedDelegate | ( | object | sender, |
| JoystickEventArgs | e | ||
| ) |
| async Task UpdateAsync | ( | ) |
Fetch an update from the Nunchuk and push it to all the properties.
Implements IPollable.
|
get |
Gets a two-dimensional normalized vector representing the joystick state
|
get |
Gets the "C" button
|
get |
Gets the "Z" button
|
get |
Gets a three-dimensional normalized vector representing the accelerometer state
|
getset |
Whether reading from one of the data properties should trigger a call to UpdateAsync() to fetch the latest state from the device.
If false, the user should periodically call UpdateAsync() to poll the device.
|
getset |
The interval, in milliseconds, that "AwaitValueChanged"-type functions should use when polling this Nunchuk for updates.
| JoystickChangedDelegate JoystickChanged |
| PropertyChangedEventHandler PropertyChanged |