Mouse wheel support

Shane Harper shanegh at optusnet.com.au
Sat Apr 21 12:25:50 CEST 2001


The attached patch adds support for the mouse wheel (while using the XVideo
plugin). The mouse wheel can be used to move backwards/forwards by 10
seconds each time the wheel is moved.

Shane.

-- Attached file included as plaintext by Listar --
-- File: mousewheel.diff

diff -urN vlc.orig/include/input_ext-intf.h vlc/include/input_ext-intf.h
--- vlc.orig/include/input_ext-intf.h	Fri Apr 20 15:40:03 2001
+++ vlc/include/input_ext-intf.h	Sat Apr 21 19:20:31 2001
@@ -349,6 +349,7 @@
 void input_SetStatus( struct input_thread_s *, int );
 void input_SetRate  ( struct input_thread_s *, int );
 void input_Seek     ( struct input_thread_s *, off_t );
+int  input_SeekFromCurrentPosition( struct input_thread_s *, float );
 void input_DumpStream( struct input_thread_s * );
 char * input_OffsetToTime( struct input_thread_s *, char * psz_buffer, off_t );
 int  input_ChangeES ( struct input_thread_s *, struct es_descriptor_s *, u8 );
diff -urN vlc.orig/plugins/x11/vout_xvideo.c vlc/plugins/x11/vout_xvideo.c
--- vlc.orig/plugins/x11/vout_xvideo.c	Sat Apr 21 16:29:15 2001
+++ vlc/plugins/x11/vout_xvideo.c	Sat Apr 21 19:59:36 2001
@@ -66,6 +66,8 @@
 #include "netutils.h"                                 /* network_ChannelJoin */
 
 #include "main.h"
+#include "stream_control.h"                 /* needed by input_ext-intf.h... */
+#include "input_ext-intf.h"                 /* input_SeekFromCurrentPosition */
 
 
 #define GUID_YUV12_PLANAR 0x32315659
@@ -447,6 +449,14 @@
                 case Button3:
                     /* FIXME: need locking ! */
                     p_main->p_intf->b_menu_change = 1;
+                    break;
+                case Button4:   /* mouse wheel moved forwards */
+                    input_SeekFromCurrentPosition( p_main->p_intf->p_input,
+                                                    10 /*seconds*/ );
+                    break;
+                case Button5:   /* mouse wheel moved backwards */
+                    input_SeekFromCurrentPosition( p_main->p_intf->p_input,
+                                                    -10 /*seconds*/ );
                     break;
             }
         }
diff -urN vlc.orig/src/input/input_ext-intf.c vlc/src/input/input_ext-intf.c
--- vlc.orig/src/input/input_ext-intf.c	Sun Apr  8 17:24:47 2001
+++ vlc/src/input/input_ext-intf.c	Sat Apr 21 20:03:32 2001
@@ -144,6 +144,11 @@
     char        psz_time1[OFFSETTOTIME_MAX_SIZE];
     char        psz_time2[OFFSETTOTIME_MAX_SIZE];
 
+    if( i_position < 0 )
+        i_position = 0;
+    if( i_position >= p_input->stream.p_selected_area->i_size )
+        i_position = p_input->stream.p_selected_area->i_size-1;
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
     p_input->stream.p_selected_area->i_seek = i_position;
 
@@ -155,6 +160,19 @@
 
     vlc_cond_signal( &p_input->stream.stream_wait );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
+}
+
+int input_SeekFromCurrentPosition( input_thread_t *p_input,
+                                   float f_offsetInSecs )
+{
+    if( ! p_input )
+        return -1;
+    if( ! p_input->stream.b_seekable )
+        return -1;
+
+    input_Seek( p_input, p_input->stream.p_selected_area->i_tell +
+                ( f_offsetInSecs * 50 * p_input->stream.i_mux_rate ) );
+    return 0;
 }
 
 /*****************************************************************************





More information about the vlc-devel mailing list