2006-04-03 23:26:08 -04:00
|
|
|
#ifndef ardour_tranzport_control_protocol_h
|
|
|
|
#define ardour_tranzport_control_protocol_h
|
|
|
|
|
2006-04-04 23:05:30 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
#include <sys/time.h>
|
2006-04-06 12:51:27 -04:00
|
|
|
#include <pbd/lockmonitor.h>
|
2006-04-03 23:26:08 -04:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <usb.h>
|
|
|
|
#include <ardour/control_protocol.h>
|
|
|
|
#include <ardour/types.h>
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
#include <pbd/abstract_ui.h>
|
|
|
|
|
|
|
|
extern BaseUI::RequestType LEDChange;
|
|
|
|
extern BaseUI::RequestType Print;
|
|
|
|
extern BaseUI::RequestType SetCurrentTrack;
|
|
|
|
|
|
|
|
struct TranzportRequest : public BaseUI::BaseRequestObject {
|
|
|
|
int led;
|
|
|
|
int row;
|
|
|
|
int col;
|
|
|
|
char* text;
|
|
|
|
ARDOUR::Route* track;
|
|
|
|
};
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
class TranzportControlProtocol : public ARDOUR::ControlProtocol, public AbstractUI<TranzportRequest>
|
|
|
|
{
|
2006-04-03 23:26:08 -04:00
|
|
|
public:
|
2006-04-24 18:45:19 -04:00
|
|
|
TranzportControlProtocol (ARDOUR::Session&);
|
2006-04-03 23:26:08 -04:00
|
|
|
virtual ~TranzportControlProtocol();
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
int set_active (bool yn);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
bool caller_is_ui_thread();
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const int VENDORID = 0x165b;
|
|
|
|
static const int PRODUCTID = 0x8101;
|
|
|
|
static const int READ_ENDPOINT = 0x81;
|
|
|
|
static const int WRITE_ENDPOINT = 0x02;
|
|
|
|
const static int STATUS_OFFLINE = 0xff;
|
|
|
|
const static int STATUS_ONLINE = 0x01;
|
2006-04-05 21:52:45 -04:00
|
|
|
const static uint8_t WheelDirectionThreshold = 0x3f;
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
enum LightID {
|
|
|
|
LightRecord = 0,
|
|
|
|
LightTrackrec,
|
|
|
|
LightTrackmute,
|
|
|
|
LightTracksolo,
|
|
|
|
LightAnysolo,
|
|
|
|
LightLoop,
|
|
|
|
LightPunch
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ButtonID {
|
|
|
|
ButtonBattery = 0x00004000,
|
|
|
|
ButtonBacklight = 0x00008000,
|
|
|
|
ButtonTrackLeft = 0x04000000,
|
|
|
|
ButtonTrackRight = 0x40000000,
|
|
|
|
ButtonTrackRec = 0x00040000,
|
|
|
|
ButtonTrackMute = 0x00400000,
|
|
|
|
ButtonTrackSolo = 0x00000400,
|
|
|
|
ButtonUndo = 0x80000000,
|
|
|
|
ButtonIn = 0x02000000,
|
|
|
|
ButtonOut = 0x20000000,
|
|
|
|
ButtonPunch = 0x00800000,
|
|
|
|
ButtonLoop = 0x00080000,
|
|
|
|
ButtonPrev = 0x00020000,
|
|
|
|
ButtonAdd = 0x00200000,
|
|
|
|
ButtonNext = 0x00000200,
|
|
|
|
ButtonRewind = 0x01000000,
|
|
|
|
ButtonFastForward = 0x10000000,
|
|
|
|
ButtonStop = 0x00010000,
|
|
|
|
ButtonPlay = 0x00100000,
|
|
|
|
ButtonRecord = 0x00000100,
|
|
|
|
ButtonShift = 0x08000000
|
|
|
|
};
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
enum WheelShiftMode {
|
|
|
|
WheelShiftGain,
|
|
|
|
WheelShiftPan,
|
|
|
|
WheelShiftMaster
|
2006-04-05 21:52:45 -04:00
|
|
|
};
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
enum WheelMode {
|
|
|
|
WheelTimeline,
|
|
|
|
WheelScrub,
|
|
|
|
WheelShuttle
|
|
|
|
};
|
2006-04-09 23:54:00 -04:00
|
|
|
|
|
|
|
enum DisplayMode {
|
|
|
|
DisplayNormal,
|
|
|
|
DisplayBigMeter
|
|
|
|
};
|
2006-04-06 12:51:27 -04:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
pthread_t thread;
|
|
|
|
uint32_t buttonmask;
|
|
|
|
uint32_t timeout;
|
|
|
|
uint8_t _datawheel;
|
|
|
|
uint8_t _device_status;
|
|
|
|
usb_dev_handle* udev;
|
2006-04-29 11:40:52 -04:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
uint32_t current_track_id;
|
2006-04-05 21:52:45 -04:00
|
|
|
WheelMode wheel_mode;
|
2006-04-06 12:51:27 -04:00
|
|
|
WheelShiftMode wheel_shift_mode;
|
2006-04-09 23:54:00 -04:00
|
|
|
DisplayMode display_mode;
|
2006-04-29 11:40:52 -04:00
|
|
|
ARDOUR::gain_t gain_fraction;
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
void do_request (TranzportRequest*);
|
|
|
|
|
|
|
|
PBD::Lock update_lock;
|
|
|
|
char current_screen[2][20];
|
|
|
|
char pending_screen[2][20];
|
|
|
|
bool lights[7];
|
|
|
|
bool pending_lights[7];
|
|
|
|
|
|
|
|
bool last_negative;
|
|
|
|
uint32_t last_hrs;
|
|
|
|
uint32_t last_mins;
|
|
|
|
uint32_t last_secs;
|
|
|
|
uint32_t last_frames;
|
2006-04-03 23:26:08 -04:00
|
|
|
jack_nframes_t last_where;
|
2006-04-24 18:45:19 -04:00
|
|
|
ARDOUR::gain_t last_track_gain;
|
|
|
|
uint32_t last_meter_fill;
|
|
|
|
struct timeval last_wheel_motion;
|
|
|
|
int last_wheel_dir;
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
PBD::Lock io_lock;
|
2006-04-06 12:51:27 -04:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
int open ();
|
2006-04-04 20:21:43 -04:00
|
|
|
int read (uint32_t timeout_override = 0);
|
|
|
|
int write (uint8_t* cmd, uint32_t timeout_override = 0);
|
2006-04-03 23:26:08 -04:00
|
|
|
int close ();
|
|
|
|
|
|
|
|
int open_core (struct usb_device*);
|
|
|
|
|
|
|
|
void lcd_clear ();
|
2006-04-05 21:52:45 -04:00
|
|
|
void print (int row, int col, const char* text);
|
2006-04-03 23:26:08 -04:00
|
|
|
int light_on (LightID);
|
|
|
|
int light_off (LightID);
|
2006-04-09 23:54:00 -04:00
|
|
|
void lights_off ();
|
|
|
|
|
|
|
|
void enter_big_meter_mode ();
|
|
|
|
void enter_normal_display_mode ();
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
void next_display_mode ();
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
void normal_update ();
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
void show_current_track ();
|
2006-04-24 18:45:19 -04:00
|
|
|
void show_track_gain ();
|
2006-04-04 20:21:43 -04:00
|
|
|
void show_transport_time ();
|
2006-04-05 21:52:45 -04:00
|
|
|
void show_wheel_mode ();
|
|
|
|
void show_gain ();
|
|
|
|
void show_pan ();
|
2006-04-09 23:54:00 -04:00
|
|
|
void show_meter ();
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
void datawheel ();
|
2006-04-06 12:51:27 -04:00
|
|
|
void scrub ();
|
|
|
|
void scroll ();
|
|
|
|
void shuttle ();
|
2006-04-05 21:52:45 -04:00
|
|
|
|
|
|
|
void next_wheel_mode ();
|
2006-04-06 12:51:27 -04:00
|
|
|
void next_wheel_shift_mode ();
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
void set_current_track (ARDOUR::Route*);
|
2006-04-05 21:52:45 -04:00
|
|
|
void next_track ();
|
|
|
|
void prev_track ();
|
|
|
|
void step_gain_up ();
|
|
|
|
void step_gain_down ();
|
|
|
|
void step_pan_right ();
|
|
|
|
void step_pan_left ();
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-04-18 22:11:39 -04:00
|
|
|
static void* _monitor_work (void* arg);
|
|
|
|
void* monitor_work ();
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
void button_event_battery_press (bool shifted);
|
|
|
|
void button_event_battery_release (bool shifted);
|
|
|
|
void button_event_backlight_press (bool shifted);
|
|
|
|
void button_event_backlight_release (bool shifted);
|
|
|
|
void button_event_trackleft_press (bool shifted);
|
|
|
|
void button_event_trackleft_release (bool shifted);
|
|
|
|
void button_event_trackright_press (bool shifted);
|
|
|
|
void button_event_trackright_release (bool shifted);
|
|
|
|
void button_event_trackrec_press (bool shifted);
|
|
|
|
void button_event_trackrec_release (bool shifted);
|
|
|
|
void button_event_trackmute_press (bool shifted);
|
|
|
|
void button_event_trackmute_release (bool shifted);
|
|
|
|
void button_event_tracksolo_press (bool shifted);
|
|
|
|
void button_event_tracksolo_release (bool shifted);
|
|
|
|
void button_event_undo_press (bool shifted);
|
|
|
|
void button_event_undo_release (bool shifted);
|
|
|
|
void button_event_in_press (bool shifted);
|
|
|
|
void button_event_in_release (bool shifted);
|
|
|
|
void button_event_out_press (bool shifted);
|
|
|
|
void button_event_out_release (bool shifted);
|
|
|
|
void button_event_punch_press (bool shifted);
|
|
|
|
void button_event_punch_release (bool shifted);
|
|
|
|
void button_event_loop_press (bool shifted);
|
|
|
|
void button_event_loop_release (bool shifted);
|
|
|
|
void button_event_prev_press (bool shifted);
|
|
|
|
void button_event_prev_release (bool shifted);
|
|
|
|
void button_event_add_press (bool shifted);
|
|
|
|
void button_event_add_release (bool shifted);
|
|
|
|
void button_event_next_press (bool shifted);
|
|
|
|
void button_event_next_release (bool shifted);
|
|
|
|
void button_event_rewind_press (bool shifted);
|
|
|
|
void button_event_rewind_release (bool shifted);
|
|
|
|
void button_event_fastforward_press (bool shifted);
|
|
|
|
void button_event_fastforward_release (bool shifted);
|
|
|
|
void button_event_stop_press (bool shifted);
|
|
|
|
void button_event_stop_release (bool shifted);
|
|
|
|
void button_event_play_press (bool shifted);
|
|
|
|
void button_event_play_release (bool shifted);
|
|
|
|
void button_event_record_press (bool shifted);
|
|
|
|
void button_event_record_release (bool shifted);
|
2006-04-24 18:45:19 -04:00
|
|
|
|
|
|
|
int process (uint8_t *);
|
|
|
|
int update_state();
|
2006-04-03 23:26:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ardour_tranzport_control_protocol_h
|