A bit better integration of vst sdk files
[ardour.git] / libs / surfaces / tranzport / tranzport_control_protocol.h
index 5880f3807aaab03f2406a490c31c3920333f425e..e5193a761cdfa3d71306b034d5b6ceb672f9899a 100644 (file)
@@ -1,23 +1,30 @@
 #ifndef ardour_tranzport_control_protocol_h
 #define ardour_tranzport_control_protocol_h
 
+#include <vector>
+
+#include <sys/time.h>
 #include <pthread.h>
 #include <usb.h>
-#include <ardour/control_protocol.h>
+
+#include <glibmm/thread.h>
+
 #include <ardour/types.h>
 
-namespace ARDOUR {
+#include <control_protocol/control_protocol.h>
 
-class TranzportControlProtocol : public ControlProtocol {
+class TranzportControlProtocol : public ARDOUR::ControlProtocol
+{
   public:
-       TranzportControlProtocol (Session&);
+       TranzportControlProtocol (ARDOUR::Session&);
        virtual ~TranzportControlProtocol();
 
-       int init ();
-       bool active() const;
+       int set_active (bool yn);
+
+       static bool probe ();
 
-       void send_route_feedback (std::list<Route*>&);
-       void send_global_feedback ();
+       XMLNode& get_state ();
+       int set_state (const XMLNode&);
 
   private:
        static const int VENDORID = 0x165b;
@@ -26,6 +33,7 @@ class TranzportControlProtocol : public ControlProtocol {
        static const int WRITE_ENDPOINT = 0x02;
        const static int STATUS_OFFLINE  = 0xff;
        const static int STATUS_ONLINE = 0x01;
+       const static uint8_t WheelDirectionThreshold = 0x3f;
 
        enum LightID {
                LightRecord = 0,
@@ -60,23 +68,55 @@ class TranzportControlProtocol : public ControlProtocol {
                ButtonRecord = 0x00000100,
                ButtonShift = 0x08000000
        };
+
+       enum WheelShiftMode {
+               WheelShiftGain,
+               WheelShiftPan,
+               WheelShiftMaster
+       };
                
+       enum WheelMode {
+               WheelTimeline,
+               WheelScrub,
+               WheelShuttle
+       };
+
+       enum DisplayMode {
+               DisplayNormal,
+               DisplayBigMeter
+       };
+       
        pthread_t       thread;
        uint32_t        buttonmask;
        uint32_t        timeout;
        uint8_t        _datawheel;
        uint8_t        _device_status;
        usb_dev_handle* udev;
-       Route*          current_route;
-       uint32_t        current_track_id;
-       uint8_t         lcd_screen[2][20];
 
-       bool     last_negative;
-       uint32_t last_hrs;
-       uint32_t last_mins;
-       uint32_t last_secs;
-       uint32_t last_frames;
-       jack_nframes_t last_where;
+       uint32_t        current_track_id;
+       WheelMode       wheel_mode;
+       WheelShiftMode  wheel_shift_mode;
+       DisplayMode     display_mode;
+       ARDOUR::gain_t  gain_fraction;
+
+       Glib::Mutex 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;
+       nframes_t last_where;
+       ARDOUR::gain_t last_track_gain;
+       uint32_t       last_meter_fill;
+       struct timeval last_wheel_motion;
+       int            last_wheel_dir;
+
+       Glib::Mutex io_lock;
 
        int open ();
        int read (uint32_t timeout_override = 0);
@@ -86,19 +126,44 @@ class TranzportControlProtocol : public ControlProtocol {
        int open_core (struct usb_device*);
 
        void lcd_clear ();
-       int  lcd_write (uint8_t cell, const char *text);
-
+       void print (int row, int col, const char* text);
        int  light_on (LightID);
        int  light_off (LightID);
+       void lights_off ();
 
-       void flush_lcd ();
-       void write_clock (const uint8_t* label);
+       void enter_big_meter_mode ();
+       void enter_normal_display_mode ();
+
+       void next_display_mode ();
+
+       void normal_update ();
 
        void show_current_track ();
+       void show_track_gain ();
        void show_transport_time ();
-
-       static void* _thread_work (void* arg);
-       void* thread_work ();
+       void show_wheel_mode ();
+       void show_gain ();
+       void show_pan ();
+       void show_meter ();
+
+       void datawheel ();
+       void scrub ();
+       void scroll ();
+       void shuttle ();
+
+       void next_wheel_mode ();
+       void next_wheel_shift_mode ();
+
+       void set_current_track (ARDOUR::Route*);
+       void next_track ();
+       void prev_track ();
+       void step_gain_up ();
+       void step_gain_down ();
+       void step_pan_right ();
+       void step_pan_left ();
+
+       static void* _monitor_work (void* arg);
+       void* monitor_work ();
 
        void button_event_battery_press (bool shifted);
        void button_event_battery_release (bool shifted);
@@ -140,8 +205,10 @@ class TranzportControlProtocol : public ControlProtocol {
        void button_event_play_release (bool shifted);
        void button_event_record_press (bool shifted);
        void button_event_record_release (bool shifted);
+
+       int process (uint8_t *);
+       int update_state();
 };
 
-} // namespace
 
 #endif // ardour_tranzport_control_protocol_h