January 2015
Beginner
324 pages
7h 42m
English
The interface of our Nunchuk class (and the main part of its implementation) looks as follows:
| Tinkering/NunchukDemo/nunchuk.h | |
| Line 1 | #ifndef __NUNCHUK_H__ |
| - | #define __NUNCHUK_H__ |
| - | #define NUNCHUK_BUFFER_SIZE 6 |
| - | |
| 5 | class Nunchuk { |
| - | public: |
| - | void initialize(); |
| - | bool update(); |
| - | |
| 10 | int joystick_x() const { return _buffer[0]; } |
| - | int joystick_y() const { return _buffer[1]; } |
| - | |
| - | int x_acceleration() const { |
| - | return ((int)(_buffer[2]) << 2) | ((_buffer[5] >> 2) & 0x03); |
| 15 | } |
| - | |
| - | int y_acceleration() const { |
| - | return ((int)(_buffer[3]) << 2) | ((_buffer[5] >> 4) & 0x03); |
| - | } |
| 20 | |
| - | int z_acceleration() const { |
| - | return ((int)(_buffer[4]) << 2) | ((_buffer[5] ... |
Read now
Unlock full access