reinstate wiimote support, thanks to work by jannis pohlmann
[ardour.git] / libs / surfaces / wiimote / wiimote.h
1 /*
2     Copyright (C) 2009-2013 Paul Davis
3     Authors: Sampo Savolainen, Jannis Pohlmann
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef ardour_wiimote_control_protocol_h
22 #define ardour_wiimote_control_protocol_h
23
24 #include <cwiid.h>
25
26 #include "pbd/abstract_ui.h"
27 #include "ardour/types.h"
28 #include "control_protocol/control_protocol.h"
29
30 struct WiimoteControlUIRequest : public BaseUI::BaseRequestObject {
31 public:
32         WiimoteControlUIRequest () {}
33         ~WiimoteControlUIRequest () {}
34 };
35
36 class WiimoteControlProtocol
37         : public ARDOUR::ControlProtocol
38         , public AbstractUI<WiimoteControlUIRequest>
39 {
40 public:
41         WiimoteControlProtocol (ARDOUR::Session &);
42         virtual ~WiimoteControlProtocol ();
43
44         static bool probe ();
45         int set_active (bool yn);
46
47         XMLNode& get_state ();
48         int set_state (const XMLNode&, int version);
49
50         void start_wiimote_discovery ();
51         void stop_wiimote_discovery ();
52
53         void wiimote_callback (int mesg_count, union cwiid_mesg mesg[]);
54
55 protected:
56         void do_request (WiimoteControlUIRequest*);
57         int start ();
58         int stop ();
59
60         void thread_init ();
61
62         bool connect_idle ();
63         bool connect_wiimote ();
64
65         void update_led_state ();
66
67 protected:
68         PBD::ScopedConnectionList session_connections;
69         cwiid_wiimote_t* wiimote;
70         GSource *idle_source;
71         uint16_t button_state;
72         bool callback_thread_registered;
73 };
74
75 #endif  /* ardour_wiimote_control_protocol_h */
76