]> git.sesse.net Git - vlc/blobdiff - modules/gui/beos/VideoOutput.cpp
* Got rid of more "VideoLAN C*****" references.
[vlc] / modules / gui / beos / VideoOutput.cpp
index ed7a31c091d3305df0e937b6af588699ae0a25cd..4fae241ea9f2d9e00b914804acf9f4b4a57aabda 100644 (file)
@@ -2,7 +2,7 @@
  * vout_beos.cpp: beos video output display method
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: VideoOutput.cpp,v 1.24 2003/11/04 11:11:30 titer Exp $
+ * $Id: VideoOutput.cpp,v 1.29 2003/12/28 01:49:12 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -49,6 +49,7 @@
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 #include <vlc/vout.h>
+#include <vlc_keys.h>
 
 #include "InterfaceWindow.h"   // for load/save_settings()
 #include "DrawingTidbits.h"
@@ -107,6 +108,59 @@ beos_GetAppWindow(char *name)
     return window;
 }
 
+static const int beos_keys[][2] =
+{
+    { B_LEFT_ARROW,  KEY_LEFT },
+    { B_RIGHT_ARROW, KEY_RIGHT },
+    { B_UP_ARROW,    KEY_UP },
+    { B_DOWN_ARROW,  KEY_DOWN },
+    { B_SPACE,       KEY_SPACE },
+    { B_ENTER,       KEY_ENTER },
+    { B_F1_KEY,      KEY_F1 },
+    { B_F2_KEY,      KEY_F2 },
+    { B_F3_KEY,      KEY_F3 },
+    { B_F4_KEY,      KEY_F4 },
+    { B_F5_KEY,      KEY_F5 },
+    { B_F6_KEY,      KEY_F6 },
+    { B_F7_KEY,      KEY_F7 },
+    { B_F8_KEY,      KEY_F8 },
+    { B_F9_KEY,      KEY_F9 },
+    { B_F10_KEY,     KEY_F10 },
+    { B_F11_KEY,     KEY_F11 },
+    { B_F12_KEY,     KEY_F12 },
+    { B_HOME,        KEY_HOME },
+    { B_END,         KEY_END },
+    { B_ESCAPE,      KEY_ESC },
+    { B_PAGE_UP,     KEY_PAGEUP },
+    { B_PAGE_DOWN,   KEY_PAGEDOWN },
+    { B_TAB,         KEY_TAB },
+    { B_BACKSPACE,   KEY_BACKSPACE }
+};
+
+static int ConvertKeyFromVLC( int key )
+{
+    for( unsigned i = 0; i < sizeof( beos_keys ) / sizeof( int ) / 2; i++ )
+    {
+        if( beos_keys[i][1] == key )
+        {
+            return beos_keys[i][0];
+        }
+    }
+    return key;
+}
+
+static int ConvertKeyToVLC( int key )
+{
+    for( unsigned i = 0; i < sizeof( beos_keys ) / sizeof( int ) / 2; i++ )
+    {
+        if( beos_keys[i][0] == key )
+        {
+            return beos_keys[i][1];
+        }
+    }
+    return key;
+}
+
 /*****************************************************************************
  * get_interface_window
  *****************************************************************************/
@@ -173,8 +227,6 @@ VideoSettings::VideoSettings()
        }
        else
        {
-               fprintf( stderr, "error loading video settings: %s\n", strerror( ret ) );
-               
                // figure out if we should use vertical sync by default
                BScreen screen(B_MAIN_SCREEN_ID);
                if (screen.IsValid())
@@ -208,9 +260,7 @@ VideoSettings::~VideoSettings()
                if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK)
                        fSettings->AddInt32( "flags", Flags() );
 
-               status_t ret = save_settings( fSettings, "video_settings", "VideoLAN Client" );
-               if ( ret != B_OK )
-                       fprintf( stderr, "error saving video settings: %s\n", strerror( ret ) );
+               save_settings( fSettings, "video_settings", "VideoLAN Client" );
                delete fSettings;
        }
        else
@@ -294,17 +344,11 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
                fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
 
     // add a few useful shortcuts
-    AddShortcut( 'f', 0, new BMessage( TOGGLE_FULL_SCREEN ) );
+    // XXX works only with US keymap
     AddShortcut( '1', 0, new BMessage( RESIZE_50 ) );
     AddShortcut( '2', 0, new BMessage( RESIZE_100 ) );
     AddShortcut( '3', 0, new BMessage( RESIZE_200 ) );
 
-    // workaround for french keyboards
-    AddShortcut( '&', 0, new BMessage( RESIZE_50 ) );
-    AddShortcut( 'é', 0, new BMessage( RESIZE_100 ) );
-        // FIXME - this one doesn't work because 'é' is a multi-byte character
-    AddShortcut( '"', 0, new BMessage( RESIZE_200 ) );
-
     _SetToSettings();
 }
 
@@ -408,6 +452,13 @@ VideoWindow::MessageReceived( BMessage *p_message )
                                }
                        }
                        break;
+        case SHORTCUT:
+        {
+            vlc_value_t val;
+            p_message->FindInt32( "key", (int32*) &val.i_int );
+            var_Set( p_vout->p_vlc, "key-pressed", val );
+            break;
+        }
                default:
                        BWindow::MessageReceived( p_message );
                        break;
@@ -605,7 +656,7 @@ VideoWindow::SetFullScreen(bool doIt)
        if (doIt)
        {
            SetLook( B_NO_BORDER_WINDOW_LOOK );
-               BScreen screen(this);
+               BScreen screen( this );
                BRect rect = screen.Frame();
                Activate();
                MoveTo(0.0, 0.0);
@@ -1165,7 +1216,7 @@ VLCView::MouseDown(BPoint where)
        
                                menu->AddSeparatorItem();
        
-                               // Windwo Feel Items
+                               // Window Feel Items
 /*                             BMessage *winNormFeel = new BMessage(WINDOW_FEEL);
                                winNormFeel->AddInt32("WinFeel", (int32_t)B_NORMAL_WINDOW_FEEL);
                                BMenuItem *normWindItem = new BMenuItem("Normal Window", winNormFeel);
@@ -1225,7 +1276,7 @@ VLCView::MouseUp( BPoint where )
  * VLCVIew::MouseMoved
  *****************************************************************************/
 void
-VLCView::MouseMoved(BPoint point, uint32_t transit, const BMessage* dragMessage)
+VLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage)
 {
        fLastMouseMovedTime = system_time();
        fCursorHidden = false;
@@ -1282,74 +1333,32 @@ VLCView::Pulse()
 }
 
 /*****************************************************************************
- * VLCVIew::KeyDown
+ * VLCVIew::KeyUp
  *****************************************************************************/
-void
-VLCView::KeyDown(const char *bytes, int32_t numBytes)
+void VLCView::KeyUp( const char *bytes, int32 numBytes )
 {
-    VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window());
-    BWindow* interfaceWindow = get_interface_window();
-       if (videoWindow && numBytes > 0) {
-               uint32_t mods = modifiers();
-               switch (*bytes) {
-                       case B_TAB:
-                       case 'f':
-                       case 'F':
-                               // toggle window and full screen mode
-                               // not passing on the tab key to the default KeyDown()
-                               // implementation also avoids loosing the keyboard focus
-                               videoWindow->PostMessage(TOGGLE_FULL_SCREEN);
-                               break;
-                       case B_ESCAPE:
-                               // go back to window mode
-                               if (videoWindow->IsFullScreen())
-                                       videoWindow->PostMessage(TOGGLE_FULL_SCREEN);
-                               break;
-                       case B_SPACE:
-                               // toggle playback
-                               if (interfaceWindow)
-                                       interfaceWindow->PostMessage(PAUSE_PLAYBACK);
-                               break;
-                       case B_RIGHT_ARROW:
-                               if (interfaceWindow)
-                               {
-                                       if (mods & B_SHIFT_KEY)
-                                               // next title
-                                               interfaceWindow->PostMessage(NEXT_TITLE);
-                                       else
-                                               // next chapter
-                                               interfaceWindow->PostMessage(NEXT_CHAPTER);
-                               }
-                               break;
-                       case B_LEFT_ARROW:
-                               if (interfaceWindow)
-                               {
-                                       if (mods & B_SHIFT_KEY)
-                                               // previous title
-                                               interfaceWindow->PostMessage(PREV_TITLE);
-                                       else
-                                               // previous chapter
-                                               interfaceWindow->PostMessage(PREV_CHAPTER);
-                               }
-                               break;
-                       case B_UP_ARROW:
-                               // previous file in playlist
-                               interfaceWindow->PostMessage(PREV_FILE);
-                               break;
-                       case B_DOWN_ARROW:
-                               // next file in playlist
-                               interfaceWindow->PostMessage(NEXT_FILE);
-                               break;
-                       case B_PRINT_KEY:
-                       case 's':
-                       case 'S':
-                               videoWindow->PostMessage( SCREEN_SHOT );
-                               break;
-                       default:
-                               BView::KeyDown(bytes, numBytes);
-                               break;
-               }
-       }
+    if( numBytes < 1 )
+    {
+        return;
+    }
+
+    uint32_t mods = modifiers();
+
+    vlc_value_t val;
+    val.i_int = ConvertKeyToVLC( *bytes );
+    if( mods & B_COMMAND_KEY )
+    {
+        val.i_int |= KEY_MODIFIER_ALT;
+    }
+    if( mods & B_SHIFT_KEY )
+    {
+        val.i_int |= KEY_MODIFIER_SHIFT;
+    }
+    if( mods & B_CONTROL_KEY )
+    {
+        val.i_int |= KEY_MODIFIER_CTRL;
+    }
+    var_Set( p_vout->p_vlc, "key-pressed", val );
 }
 
 /*****************************************************************************
@@ -1368,7 +1377,7 @@ VLCView::Draw(BRect updateRect)
  *****************************************************************************/
 static int  Init       ( vout_thread_t * );
 static void End        ( vout_thread_t * );
-// static int  Manage     ( vout_thread_t * );
+static int  Manage     ( vout_thread_t * );
 static void Display    ( vout_thread_t *, picture_t * );
 
 static int  BeosOpenDisplay ( vout_thread_t *p_vout );
@@ -1396,7 +1405,7 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
 
     p_vout->pf_init = Init;
     p_vout->pf_end = End;
-    p_vout->pf_manage = NULL;
+    p_vout->pf_manage = Manage;
     p_vout->pf_render = NULL;
     p_vout->pf_display = Display;
 
@@ -1479,6 +1488,20 @@ void End( vout_thread_t *p_vout )
     BeosCloseDisplay( p_vout );
 }
 
+/*****************************************************************************
+ * Manage
+ *****************************************************************************/
+static int Manage( vout_thread_t * p_vout )
+{
+    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
+    {
+        p_vout->p_sys->p_window->PostMessage( TOGGLE_FULL_SCREEN );
+        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
+    }
+
+    return 0;
+}
+
 /*****************************************************************************
  * CloseVideo: destroy BeOS video thread output method
  *****************************************************************************