NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / surfaces / tranzport / wheel.cc
index bc9683e6d77fb694af263eb89846e89f8b944fae..d90e0e2b6edd1214f3087c00d490a67fe74d69c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *   Copyright (C) 2006 Paul Davis 
+ *   Copyright (C) 2006 Paul Davis
  *   Copyright (C) 2007 Michael Taht
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *  
+ *
  *   */
 
 #include <iostream>
 #include <float.h>
 #include <sys/time.h>
 #include <errno.h>
-#include <ardour/route.h>
-#include <ardour/audio_track.h>
-#include <ardour/session.h>
-#include <ardour/location.h>
-#include <ardour/dB.h>
+#include "ardour/route.h"
+#include "ardour/audio_track.h"
+#include "ardour/session.h"
+#include "ardour/location.h"
+#include "ardour/dB.h"
 
 using namespace ARDOUR;
 using namespace std;
@@ -40,14 +40,14 @@ using namespace PBD;
 
 #include "i18n.h"
 
-#include <pbd/abstract_ui.cc>
+#include "pbd/abstract_ui.cc"
 
 BaseUI::RequestType LEDChange = BaseUI::new_request_type ();
 BaseUI::RequestType Print = BaseUI::new_request_type ();
 BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type ();
 
 
-#include <tranzport_control_protocol.h>
+#include "tranzport_control_protocol.h"
 
 void
 TranzportControlProtocol::datawheel ()
@@ -55,15 +55,15 @@ TranzportControlProtocol::datawheel ()
        if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) {
 
                /* track scrolling */
-               
+
                if (_datawheel < WheelDirectionThreshold) {
                        next_track ();
                } else {
                        prev_track ();
                }
 
-               timerclear (&last_wheel_motion);
-               
+               last_wheel_motion = 0;
+
        } else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
 
                if (_datawheel < WheelDirectionThreshold) {
@@ -71,13 +71,13 @@ TranzportControlProtocol::datawheel ()
                } else {
                        prev_marker ();
                }
-               
-               timerclear (&last_wheel_motion);
-               
+
+               last_wheel_motion = 0;
+
        } else if (buttonmask & ButtonShift) {
-               
+
                /* parameter control */
-               
+
                if (route_table[0]) {
                        switch (wheel_shift_mode) {
                        case WheelShiftGain:
@@ -94,29 +94,29 @@ TranzportControlProtocol::datawheel ()
                                        step_pan_left ();
                                }
                                break;
-                               
+
                        case WheelShiftMarker:
                                break;
-                               
+
                        case WheelShiftMaster:
                                break;
-                               
+
                        }
                }
-               
-               timerclear (&last_wheel_motion);
-               
+
+               last_wheel_motion = 0;
+
        } else {
-               
+
                switch (wheel_mode) {
                case WheelTimeline:
                        scroll ();
                        break;
-                       
+
                case WheelScrub:
                        scrub ();
                        break;
-                       
+
                case WheelShuttle:
                        shuttle ();
                        break;
@@ -149,41 +149,37 @@ void
 TranzportControlProtocol::scrub ()
 {
        float speed;
-       struct timeval now;
-       struct timeval delta;
+       uint64_t now;
        int dir;
-       
-       gettimeofday (&now, 0);
-       
+
+       now = g_get_monotonic_time();
+
        if (_datawheel < WheelDirectionThreshold) {
                dir = 1;
        } else {
                dir = -1;
        }
-       
+
        if (dir != last_wheel_dir) {
                /* changed direction, start over */
                speed = 0.1f;
        } else {
-               if (timerisset (&last_wheel_motion)) {
-
-                       timersub (&now, &last_wheel_motion, &delta);
-                       
+               if (last_wheel_motion != 0) {
                        /* 10 clicks per second => speed == 1.0 */
-                       
-                       speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
-                       
+
+                       speed = 100000.0f / (float) (now - last_wheel_motion)
+
                } else {
-                       
+
                        /* start at half-speed and see where we go from there */
-                       
+
                        speed = 0.5f;
                }
        }
-       
+
        last_wheel_motion = now;
        last_wheel_dir = dir;
-       
+
        set_transport_speed (speed * dir);
 }
 
@@ -194,13 +190,13 @@ TranzportControlProtocol::shuttle ()
                if (session->transport_speed() < 0) {
                        session->request_transport_speed (1.0);
                } else {
-                       session->request_transport_speed (session->transport_speed() + 0.1);
+                       session->request_transport_speed_nonzero (session->transport_speed() + 0.1);
                }
        } else {
                if (session->transport_speed() > 0) {
                        session->request_transport_speed (-1.0);
                } else {
-                       session->request_transport_speed (session->transport_speed() - 0.1);
+                       session->request_transport_speed_nonzero (session->transport_speed() - 0.1);
                }
        }
 }