forked from takeru/Wiimote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWiimote.h
43 lines (36 loc) · 997 Bytes
/
Wiimote.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _WIIMOTE_H_
#define _WIIMOTE_H_
#include <cstdint>
#include <string>
enum wiimote_event_type_t
{
WIIMOTE_EVENT_INITIALIZE,
WIIMOTE_EVENT_SCAN_START,
WIIMOTE_EVENT_SCAN_STOP,
WIIMOTE_EVENT_CONNECT,
WIIMOTE_EVENT_DISCONNECT,
WIIMOTE_EVENT_DATA
};
enum balance_position_type_t
{
BALANCE_POSITION_TOP_RIGHT,
BALANCE_POSITION_BOTTOM_RIGHT,
BALANCE_POSITION_TOP_LEFT,
BALANCE_POSITION_BOTTOM_LEFT,
};
typedef void (*wiimote_callback_t)(wiimote_event_type_t event_type, uint16_t handle, uint8_t *data, size_t len);
class Wiimote
{
public:
void init(wiimote_callback_t cb);
void handle();
void scan(bool enable);
void reconnect(std::string bluetooth_id);
void _callback(wiimote_event_type_t event_type, uint16_t handle, uint8_t *data, size_t len);
void set_led(uint16_t handle, uint8_t leds);
void set_rumble(uint16_t handle, bool rumble);
void get_balance_weight(uint8_t *data, float *weight);
private:
wiimote_callback_t _wiimote_callback;
};
#endif