Commit 5b797505 authored by Eric Petit's avatar Eric Petit

beos/*: fixed Alt+X shortcuts (BeOS doesn't let those hit BWindow::KeyDown

         because it's reserved for system shorcuts - added a workaround)
parent 42195685
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MsgVals.h * MsgVals.h
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: MsgVals.h,v 1.9 2003/05/30 17:30:54 titer Exp $ * $Id: MsgVals.h,v 1.10 2003/12/22 11:08:00 titer Exp $
* *
* Authors: Tony Castley <tcastley@mail.powerup.com.au> * Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com> * Stephan Aßmus <stippi@yellowbites.com>
...@@ -76,5 +76,6 @@ ...@@ -76,5 +76,6 @@
#define MSG_SOUNDPLAY 'move' // drag'n'drop from soundplay playlist #define MSG_SOUNDPLAY 'move' // drag'n'drop from soundplay playlist
#define INTERFACE_CREATED 'ifcr' /* see VlcApplication::MessageReceived() #define INTERFACE_CREATED 'ifcr' /* see VlcApplication::MessageReceived()
* in src/misc/beos_specific.cpp */ * in src/misc/beos_specific.cpp */
#define SHORTCUT 'shcu'
#endif // BEOS_MESSAGE_VALUES_H #endif // BEOS_MESSAGE_VALUES_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method * vout_beos.cpp: beos video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: VideoOutput.cpp,v 1.26 2003/11/09 16:00:54 titer Exp $ * $Id: VideoOutput.cpp,v 1.27 2003/12/22 11:08:00 titer Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -108,36 +108,55 @@ beos_GetAppWindow(char *name) ...@@ -108,36 +108,55 @@ beos_GetAppWindow(char *name)
return window; return window;
} }
static int ConvertKey( int key ) static const int beos_keys[][2] =
{ {
switch( key ) { B_LEFT_ARROW, KEY_LEFT },
{ { B_RIGHT_ARROW, KEY_RIGHT },
case B_LEFT_ARROW: { B_UP_ARROW, KEY_UP },
return KEY_LEFT; { B_DOWN_ARROW, KEY_DOWN },
case B_RIGHT_ARROW: { B_SPACE, KEY_SPACE },
return KEY_RIGHT; { B_ENTER, KEY_ENTER },
case B_UP_ARROW: { B_F1_KEY, KEY_F1 },
return KEY_UP; { B_F2_KEY, KEY_F2 },
case B_DOWN_ARROW: { B_F3_KEY, KEY_F3 },
return KEY_DOWN; { B_F4_KEY, KEY_F4 },
case B_SPACE: { B_F5_KEY, KEY_F5 },
return KEY_SPACE; { B_F6_KEY, KEY_F6 },
case B_ENTER: { B_F7_KEY, KEY_F7 },
return KEY_ENTER; { B_F8_KEY, KEY_F8 },
case B_HOME: { B_F9_KEY, KEY_F9 },
return KEY_HOME; { B_F10_KEY, KEY_F10 },
case B_END: { B_F11_KEY, KEY_F11 },
return KEY_END; { B_F12_KEY, KEY_F12 },
case B_ESCAPE: { B_HOME, KEY_HOME },
return KEY_ESC; { B_END, KEY_END },
case B_PAGE_UP: { B_ESCAPE, KEY_ESC },
return KEY_PAGEUP; { B_PAGE_UP, KEY_PAGEUP },
case B_PAGE_DOWN: { B_PAGE_DOWN, KEY_PAGEDOWN },
return KEY_PAGEDOWN; { B_TAB, KEY_TAB },
case B_TAB: { B_BACKSPACE, KEY_BACKSPACE }
return KEY_TAB; };
case B_BACKSPACE:
return 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; return key;
} }
...@@ -325,16 +344,43 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame, ...@@ -325,16 +344,43 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN); fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
// add a few useful shortcuts // 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( '1', 0, new BMessage( RESIZE_50 ) );
AddShortcut( '2', 0, new BMessage( RESIZE_100 ) ); AddShortcut( '2', 0, new BMessage( RESIZE_100 ) );
AddShortcut( '3', 0, new BMessage( RESIZE_200 ) ); AddShortcut( '3', 0, new BMessage( RESIZE_200 ) );
// workaround for french keyboards // workaround to have Alt+X shortcuts working
AddShortcut( '&', 0, new BMessage( RESIZE_50 ) ); BMessage * message;
AddShortcut( 'é', 0, new BMessage( RESIZE_100 ) ); for( unsigned i = 1; /* skip KEY_UNSET */
// FIXME - this one doesn't work because 'é' is a multi-byte character i < sizeof( vlc_keys ) / sizeof( key_descriptor_t ); i++ )
AddShortcut( '"', 0, new BMessage( RESIZE_200 ) ); {
/* Alt+X */
message = new BMessage( SHORTCUT );
message->AddInt32( "key", vlc_keys[i].i_key_code | KEY_MODIFIER_ALT );
AddShortcut( ConvertKeyFromVLC( vlc_keys[i].i_key_code ),
0, message );
/* Alt+Shift+X */
message = new BMessage( SHORTCUT );
message->AddInt32( "key", vlc_keys[i].i_key_code |
KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT );
AddShortcut( ConvertKeyFromVLC( vlc_keys[i].i_key_code ),
B_SHIFT_KEY, message );
/* Alt+Ctrl+X */
message = new BMessage( SHORTCUT );
message->AddInt32( "key", vlc_keys[i].i_key_code |
KEY_MODIFIER_ALT | KEY_MODIFIER_CTRL );
AddShortcut( ConvertKeyFromVLC( vlc_keys[i].i_key_code ),
B_CONTROL_KEY, message );
/* Alt+Shift+Ctrl+X */
message = new BMessage( SHORTCUT );
message->AddInt32( "key", vlc_keys[i].i_key_code |
KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_CTRL );
AddShortcut( ConvertKeyFromVLC( vlc_keys[i].i_key_code ),
B_SHIFT_KEY | B_CONTROL_KEY, message );
}
_SetToSettings(); _SetToSettings();
} }
...@@ -439,6 +485,13 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -439,6 +485,13 @@ VideoWindow::MessageReceived( BMessage *p_message )
} }
} }
break; 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: default:
BWindow::MessageReceived( p_message ); BWindow::MessageReceived( p_message );
break; break;
...@@ -1325,7 +1378,7 @@ void VLCView::KeyDown( const char *bytes, int32 numBytes ) ...@@ -1325,7 +1378,7 @@ void VLCView::KeyDown( const char *bytes, int32 numBytes )
uint32_t mods = modifiers(); uint32_t mods = modifiers();
vlc_value_t val; vlc_value_t val;
val.i_int = ConvertKey( *bytes ); val.i_int = ConvertKeyToVLC( *bytes );
if( mods & B_SHIFT_KEY ) if( mods & B_SHIFT_KEY )
{ {
val.i_int |= KEY_MODIFIER_SHIFT; val.i_int |= KEY_MODIFIER_SHIFT;
...@@ -1334,10 +1387,6 @@ void VLCView::KeyDown( const char *bytes, int32 numBytes ) ...@@ -1334,10 +1387,6 @@ void VLCView::KeyDown( const char *bytes, int32 numBytes )
{ {
val.i_int |= KEY_MODIFIER_CTRL; val.i_int |= KEY_MODIFIER_CTRL;
} }
if( mods & B_COMMAND_KEY )
{
val.i_int |= KEY_MODIFIER_ALT;
}
var_Set( p_vout->p_vlc, "key-pressed", val ); var_Set( p_vout->p_vlc, "key-pressed", val );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment