2 #ifndef ardour_tranzport_control_protocol_h
3 #define ardour_tranzport_control_protocol_h
11 #include <glibmm/threads.h>
13 #include "ardour/types.h"
15 #include "control_protocol/control_protocol.h"
17 class TranzportControlProtocol : public ARDOUR::ControlProtocol
20 TranzportControlProtocol (ARDOUR::Session&);
21 virtual ~TranzportControlProtocol();
23 int set_active (bool yn);
27 XMLNode& get_state ();
28 int set_state (const XMLNode&);
31 static const int VENDORID = 0x165b;
32 static const int PRODUCTID = 0x8101;
33 static const int READ_ENDPOINT = 0x81;
34 static const int WRITE_ENDPOINT = 0x02;
35 const static int STATUS_OFFLINE = 0xff;
36 const static int STATUS_ONLINE = 0x01;
37 const static uint8_t WheelDirectionThreshold = 0x3f;
50 ButtonBattery = 0x00004000,
51 ButtonBacklight = 0x00008000,
52 ButtonTrackLeft = 0x04000000,
53 ButtonTrackRight = 0x40000000,
54 ButtonTrackRec = 0x00040000,
55 ButtonTrackMute = 0x00400000,
56 ButtonTrackSolo = 0x00000400,
57 ButtonUndo = 0x80000000,
58 ButtonIn = 0x02000000,
59 ButtonOut = 0x20000000,
60 ButtonPunch = 0x00800000,
61 ButtonLoop = 0x00080000,
62 ButtonPrev = 0x00020000,
63 ButtonAdd = 0x00200000,
64 ButtonNext = 0x00000200,
65 ButtonRewind = 0x01000000,
66 ButtonFastForward = 0x10000000,
67 ButtonStop = 0x00010000,
68 ButtonPlay = 0x00100000,
69 ButtonRecord = 0x00000100,
70 ButtonShift = 0x08000000
86 // FIXME - look at gtk2_ardour for snap settings
101 DisplayRecordingMeter,
122 uint8_t _device_status;
123 uint32_t current_track_id;
124 WheelMode wheel_mode;
125 WheelShiftMode wheel_shift_mode;
126 DisplayMode display_mode;
127 BlingMode bling_mode;
128 WheelIncrement wheel_increment;
129 usb_dev_handle* udev;
131 ARDOUR::gain_t gain_fraction;
133 Glib::Threads::Mutex update_lock;
135 bool screen_invalid[2][20];
136 char screen_current[2][20];
137 char screen_pending[2][20];
138 char screen_flash[2][20];
140 bool lights_invalid[7];
141 bool lights_current[7];
142 bool lights_pending[7];
143 bool lights_flash[7];
153 uint32_t last_frames;
154 framepos_t last_where;
155 ARDOUR::gain_t last_track_gain;
156 uint32_t last_meter_fill;
157 uint64_t last_wheel_motion;
163 int read (uint8_t *buf,uint32_t timeout_override = 0);
164 int write (uint8_t* cmd, uint32_t timeout_override = 0);
165 int write_noretry (uint8_t* cmd, uint32_t timeout_override = 0);
167 int save(char *name = "default");
168 int load(char *name = "default");
169 void print (int row, int col, const char* text);
170 void print_noretry (int row, int col, const char* text);
172 int rtpriority_set(int priority = 52);
173 int rtpriority_unset(int priority = 0);
175 int open_core (struct usb_device*);
177 static void* _monitor_work (void* arg);
178 void* monitor_work ();
180 int process (uint8_t *);
184 // bool isuptodate(); // think on this. It seems futile to update more than 30/sec
186 // A screen is a cache of what should be on the lcd
189 void screen_validate();
190 void screen_invalidate();
193 // bool screen_isuptodate(); // think on this -
195 // Commands to write to the lcd
199 bool lcd_isdamaged();
201 bool lcd_damage(int row, int col = 0, int length = 20);
202 bool lcd_isdamaged(int row, int col = 0, int length = 20);
205 int lcd_write(uint8_t* cmd, uint32_t timeout_override = 0); // pedantic alias for write
206 void lcd_fill (uint8_t fill_char);
208 void lcd_print (int row, int col, const char* text);
209 void lcd_print_noretry (int row, int col, const char* text);
211 // Commands to write to the lights
212 // FIXME - on some devices lights can have intensity and colors
215 void lights_validate();
216 void lights_invalidate();
217 void light_validate(LightID light);
218 void light_invalidate(LightID light);
220 int lights_write(uint8_t* cmd,uint32_t timeout_override = 0); // pedantic alias to write
222 // a cache of what should be lit
226 int light_set(LightID, bool offon = true);
227 int light_on (LightID);
228 int light_off (LightID);
230 // some modes for the lights, should probably be renamed
232 int lights_show_normal();
233 int lights_show_recording();
234 int lights_show_tempo();
235 int lights_show_bling();
237 void enter_big_meter_mode ();
238 void enter_normal_display_mode ();
239 void enter_config_mode();
240 void enter_recording_mode();
241 void enter_bling_mode();
243 void next_display_mode ();
244 void normal_update ();
246 void show_current_track ();
247 void show_track_gain ();
248 void show_transport_time ();
249 void show_bbt (framepos_t where);
250 void show_smpte (framepos_t where);
251 void show_wheel_mode ();
262 void next_wheel_mode ();
263 void next_wheel_shift_mode ();
265 void set_current_track (ARDOUR::Route*);
268 void step_gain_up ();
269 void step_gain_down ();
270 void step_pan_right ();
271 void step_pan_left ();
274 void button_event_battery_press (bool shifted);
275 void button_event_battery_release (bool shifted);
276 void button_event_backlight_press (bool shifted);
277 void button_event_backlight_release (bool shifted);
278 void button_event_trackleft_press (bool shifted);
279 void button_event_trackleft_release (bool shifted);
280 void button_event_trackright_press (bool shifted);
281 void button_event_trackright_release (bool shifted);
282 void button_event_trackrec_press (bool shifted);
283 void button_event_trackrec_release (bool shifted);
284 void button_event_trackmute_press (bool shifted);
285 void button_event_trackmute_release (bool shifted);
286 void button_event_tracksolo_press (bool shifted);
287 void button_event_tracksolo_release (bool shifted);
288 void button_event_undo_press (bool shifted);
289 void button_event_undo_release (bool shifted);
290 void button_event_in_press (bool shifted);
291 void button_event_in_release (bool shifted);
292 void button_event_out_press (bool shifted);
293 void button_event_out_release (bool shifted);
294 void button_event_punch_press (bool shifted);
295 void button_event_punch_release (bool shifted);
296 void button_event_loop_press (bool shifted);
297 void button_event_loop_release (bool shifted);
298 void button_event_prev_press (bool shifted);
299 void button_event_prev_release (bool shifted);
300 void button_event_add_press (bool shifted);
301 void button_event_add_release (bool shifted);
302 void button_event_next_press (bool shifted);
303 void button_event_next_release (bool shifted);
304 void button_event_rewind_press (bool shifted);
305 void button_event_rewind_release (bool shifted);
306 void button_event_fastforward_press (bool shifted);
307 void button_event_fastforward_release (bool shifted);
308 void button_event_stop_press (bool shifted);
309 void button_event_stop_release (bool shifted);
310 void button_event_play_press (bool shifted);
311 void button_event_play_release (bool shifted);
312 void button_event_record_press (bool shifted);
313 void button_event_record_release (bool shifted);
316 void button_event_mute (bool pressed, bool shifted);
320 #endif // ardour_tranzport_control_protocol_h