]> git.sesse.net Git - vlc/blobdiff - modules/video_output/caca.c
New video output driver: "vmem", for direct memory access.
[vlc] / modules / video_output / caca.c
index bb71e7944f4f4435a96cdc4814fd1b67356dced8..0b9ac28f66d9b7b164f838805ef018157bdb2bb8 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
-#include <stdlib.h>                                                /* free() */
-#include <string.h>                                            /* strerror() */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc/vlc.h>
+#include <vlc_vout.h>
+#include <vlc_interface.h>
+#include <vlc_playlist.h>
+#include <vlc_keys.h>
 
 #include <caca.h>
 
 #   define caca_set_display_title(x,y) caca_set_window_title(y)
 #endif
 
-#include <vlc/vlc.h>
-#include <vlc/vout.h>
-#include <vlc/intf.h>
-#include <vlc_keys.h>
-
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -299,39 +301,92 @@ static int Manage( vout_thread_t *p_vout )
 #else
     int ev;
 #endif
-    vlc_value_t val;
 
-    while( caca_get_event(p_vout->p_sys->p_dp,
-                          CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE, &ev, 0) )
+    while( caca_get_event(p_vout->p_sys->p_dp, CACA_EVENT_ANY, &ev, 0) )
     {
-        /* Acknowledge the resize */
+        playlist_t *p_playlist;
+        vlc_value_t val;
+
 #ifdef CACA_API_VERSION_1
-        if( ev.type == CACA_EVENT_RESIZE )
+#ifdef CACA_EVENT_OPAQUE
+        switch( caca_get_event_type( &ev ) )
 #else
-        if( ev == CACA_EVENT_RESIZE )
+        switch( ev.type )
+#endif /* CACA_EVENT_OPAQUE */
+#else
+        switch( ev )
 #endif
         {
-            caca_refresh_display( p_vout->p_sys->p_dp );
-            continue;
-        }
-
+        case CACA_EVENT_KEY_RELEASE:
 #ifdef CACA_API_VERSION_1
-        switch( ev.data.key.ch )
+#ifdef CACA_EVENT_OPAQUE
+            switch( caca_get_event_key_ch( &ev ) )
+#else
+            switch( ev.data.key.ch )
+#endif /* CACA_EVENT_OPAQUE */
 #else
-        switch( ev & 0x00ffffff )
+            switch( ev & 0x00ffffff )
 #endif
-        {
-        case 'q':
-            val.i_int = KEY_MODIFIER_CTRL | 'q';
+            {
+            case 'q':
+                val.i_int = KEY_MODIFIER_CTRL | 'q';
+                break;
+            case ' ':
+                val.i_int = KEY_SPACE;
+                break;
+            default:
+                continue;
+            }
+
+            var_Set( p_vout->p_libvlc, "key-pressed", val );
+            break;
+        case CACA_EVENT_RESIZE:
+            /* Acknowledge the resize */
+            caca_refresh_display( p_vout->p_sys->p_dp );
+            break;
+#ifdef CACA_API_VERSION_1
+        case  CACA_EVENT_MOUSE_MOTION:
+            val.i_int =
+#ifdef CACA_EVENT_OPAQUE
+                caca_get_event_mouse_x( &ev )
+#else
+                ev.data.mouse.x
+#endif /* CACA_EVENT_OPAQUE */
+                * p_vout->render.i_width
+                         / cucul_get_canvas_width( p_vout->p_sys->p_cv );
+            var_Set( p_vout, "mouse-x", val );
+            val.i_int =
+#ifdef CACA_EVENT_OPAQUE
+                caca_get_event_mouse_y( &ev ) 
+#else
+                ev.data.mouse.y
+#endif /* CACA_EVENT_OPAQUE */
+                * p_vout->render.i_height
+                         / cucul_get_canvas_height( p_vout->p_sys->p_cv );
+            var_Set( p_vout, "mouse-y", val );
+            val.b_bool = VLC_TRUE;
+            var_Set( p_vout, "mouse-moved", val );
             break;
-        case ' ':
-            val.i_int = KEY_SPACE;
+        case CACA_EVENT_MOUSE_RELEASE:
+            val.b_bool = VLC_TRUE;
+            var_Set( p_vout, "mouse-clicked", val );
             break;
+        case CACA_EVENT_QUIT:
+        {
+            p_playlist = vlc_object_find( p_vout,
+                                          VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+            if( p_playlist )
+            {
+                playlist_Stop( p_playlist );
+                vlc_object_release( p_playlist );
+            }
+            vlc_object_kill( p_vout->p_libvlc );
+            break;
+        }
+#endif
         default:
-            continue;
+            break;
         }
-
-        var_Set( p_vout->p_libvlc, "key-pressed", val );
     }
 
     return VLC_SUCCESS;
@@ -356,6 +411,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
  *****************************************************************************/
 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
 {
+    VLC_UNUSED(p_pic);
     caca_refresh_display( p_vout->p_sys->p_dp );
 }