* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: configuration.h,v 1.30 2003/08/10 09:22:07 gbazin Exp $
+ * $Id: configuration.h,v 1.31 2003/08/14 19:25:55 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
#define CONFIG_ITEM_BOOL 0x0050 /* Bool option */
#define CONFIG_ITEM_FLOAT 0x0060 /* Float option */
#define CONFIG_ITEM_DIRECTORY 0x0070 /* Directory option */
+#define CONFIG_ITEM_KEY 0x0080 /* Hot key option */
#define CONFIG_ITEM 0x00F0
{ static module_config_t tmp = { CONFIG_ITEM_MODULE, psz_caps, name, '\0', text, longtext, psz_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; p_config[i_config].b_advanced = advc; } i_config++
#define add_integer( name, i_value, p_callback, text, longtext, advc ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; p_config[i_config].b_advanced = advc; } i_config++
+#define add_key( name, i_value, p_callback, text, longtext, advc ) \
+ { static module_config_t tmp = { CONFIG_ITEM_KEY, NULL, name, '\0', text, longtext, NULL, i_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; p_config[i_config].b_advanced = advc; } i_config++
#define add_integer_with_range( name, i_value, i_min, i_max, p_callback, text, longtext, advc ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value, 0, i_min, i_max }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; p_config[i_config].b_advanced = advc; } i_config++
#define add_float( name, f_value, p_callback, text, longtext, advc ) \
--- /dev/null
+/*****************************************************************************
+ * hotkeys.h: keycode defines
+ *****************************************************************************
+ * Copyright (C) 2003 VideoLAN
+ * $Id: vlc_keys.h,v 1.1 2003/08/14 19:25:55 sigmunau Exp $
+ *
+ * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+#define KEY_MODIFIER 0xFF000000
+#define KEY_MODIFIER_ALT 0x01000000
+#define KEY_MODIFIER_SHIFT 0x02000000
+#define KEY_MODIFIER_CTRL 0x04000000
+#define KEY_MODIFIER_META 0x08000000
+#define KEY_MODIFIER_COMMAND 0x10000000
+
+#define KEY_SPECIAL 0x00FF0000
+#define KEY_LEFT 0x00010000
+#define KEY_RIGHT 0x00020000
+#define KEY_UP 0x00030000
+#define KEY_DOWN 0x00040000
+#define KEY_SPACE 0x00050000
+#define KEY_ENTER 0x00060000
+#define KEY_F1 0x00070000
+#define KEY_F2 0x00080000
+#define KEY_F3 0x00090000
+#define KEY_F4 0x000A0000
+#define KEY_F5 0x000B0000
+#define KEY_F6 0x000C0000
+#define KEY_F7 0x000D0000
+#define KEY_F8 0x000E0000
+#define KEY_F9 0x000F0000
+#define KEY_F10 0x00100000
+#define KEY_F11 0x00110000
+#define KEY_F12 0x00120000
+#define KEY_HOME 0x00130000
+#define KEY_END 0x00140000
+#define KEY_MENU 0x00150000
+#define KEY_ESC 0x00160000
+#define KEY_PAGEUP 0x00170000
+#define KEY_PAGEDOWN 0x00180000
+#define KEY_TAB 0x00190000
+#define KEY_BACKSPACE 0x001A0000
+
+#define KEY_ASCII 0x0000007F
+#define KEY_UNSET 0
+typedef struct key_descriptor_s
+{
+ char *psz_key_string;
+ int i_key_code;
+} key_descriptor_t;
+#define ADD_KEY(a) { a, *a }
+static const struct key_descriptor_s modifiers[] =
+{
+ { "Alt", KEY_MODIFIER_ALT },
+ { "Shift", KEY_MODIFIER_SHIFT },
+ { "Ctrl", KEY_MODIFIER_CTRL },
+ { "Meta", KEY_MODIFIER_META },
+ { "Command", KEY_MODIFIER_COMMAND }
+};
+
+static const struct key_descriptor_s keys[] =
+{
+ { "Unset", KEY_UNSET },
+ { "Left", KEY_LEFT },
+ { "Right", KEY_RIGHT },
+ { "Up", KEY_UP },
+ { "Down", KEY_DOWN },
+ { "Space", KEY_SPACE },
+ { "Enter", KEY_ENTER },
+ { "F1", KEY_F1 },
+ { "F2", KEY_F2 },
+ { "F3", KEY_F3 },
+ { "F4", KEY_F4 },
+ { "F5", KEY_F5 },
+ { "F6", KEY_F6 },
+ { "F7", KEY_F7 },
+ { "F8", KEY_F8 },
+ { "F9", KEY_F9 },
+ { "F10", KEY_F10 },
+ { "F11", KEY_F11 },
+ { "F12", KEY_F12 },
+ { "Home", KEY_HOME },
+ { "End", KEY_END },
+ { "Menu", KEY_MENU },
+ { "Esc", KEY_ESC },
+ { "Page Up", KEY_PAGEUP },
+ { "Page Down", KEY_PAGEDOWN },
+ { "Tab", KEY_TAB },
+ { "Backspace", KEY_BACKSPACE },
+ { "a", 'a' },
+ { "b", 'b' },
+ { "c", 'c' },
+ { "d", 'd' },
+ { "e", 'e' },
+ { "f", 'f' },
+ { "g", 'g' },
+ { "h", 'h' },
+ { "i", 'i' },
+ { "j", 'j' },
+ { "k", 'k' },
+ { "l", 'l' },
+ { "m", 'm' },
+ { "n", 'n' },
+ { "o", 'o' },
+ { "p", 'p' },
+ { "q", 'q' },
+ { "r", 'r' },
+ { "s", 's' },
+ { "t", 't' },
+ { "u", 'u' },
+ { "v", 'v' },
+ { "w", 'w' },
+ { "x", 'x' },
+ { "y", 'y' },
+ { "z", 'z' },
+ { "+", '+' },
+ { "-", '-' },
+ { ",", ',' },
+ { ".", '.' },
+ { "<", '<' },
+ { ">", '>' }
+};
+
+static char *KeyToString( int i_key )
+{
+ unsigned int i = 0;
+ for ( i = 0; i < sizeof(keys) / sizeof(key_descriptor_t); i++ )
+ {
+ if ( keys[i].i_key_code == i_key )
+ {
+ return keys[i].psz_key_string;
+ }
+ }
+ return NULL;
+}
* interface.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.54 2003/07/29 21:14:10 gbazin Exp $
+ * $Id: interface.cpp,v 1.55 2003/08/14 19:25:56 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
frame_sizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( frame_sizer );
+ /* Create a dummy widget that can get the keyboard focus */
+ wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
+ wxSize(0,0) );
+ p_dummy->SetFocus();
+ frame_sizer->Add( p_dummy );
+
/* Creation of the menu bar */
CreateOurMenuBar();
/* Associate drop targets with the main interface */
SetDropTarget( new DragAndDrop( p_intf ) );
#endif
+
+ UpdateAcceleratorTable();
}
Interface::~Interface()
slider_frame->Hide();
}
+void Interface::UpdateAcceleratorTable()
+{
+ /* Set some hotkeys */
+ wxAcceleratorEntry entries[6];
+ int i_key = config_GetInt( p_intf, "quit-key" );
+ int i = 0;
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ Exit_Event );
+ i_key = config_GetInt( p_intf, "stop-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ StopStream_Event );
+ i_key = config_GetInt( p_intf, "play-pause-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ PlayStream_Event );
+ i_key = config_GetInt( p_intf, "next-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ NextStream_Event );
+ i_key = config_GetInt( p_intf, "prev-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ PrevStream_Event );
+ i_key = config_GetInt( p_intf, "faster-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ FastStream_Event );
+ i_key = config_GetInt( p_intf, "slower-key" );
+ entries[i++].Set( ConvertHotkeyModifiers( i_key ), ConvertHotkey( i_key ),
+ SlowStream_Event );
+
+ wxAcceleratorTable accel( 6, entries );
+
+ if( !accel.Ok() )
+ msg_Err( p_intf, "invalid accelerator table" );
+
+ SetAcceleratorTable( accel );
+ msg_Dbg( p_intf, "accelerator table loaded" );
+
+}
+
/*****************************************************************************
* Event Handlers.
*****************************************************************************/
* preferences.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: preferences.cpp,v 1.24 2003/07/24 16:07:10 gbazin Exp $
+ * $Id: preferences.cpp,v 1.25 2003/08/14 19:25:56 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
spin->SetClientData((void *)config_data);
if( p_item->b_advanced ) b_has_advanced = VLC_TRUE;
break;
-
+ case CONFIG_ITEM_KEY:
+ {
+ label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
+ wxCheckBox *alt = new wxCheckBox( panel, -1, wxU(_("Alt")) );
+ alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
+ wxCheckBox *ctrl = new wxCheckBox( panel, -1, wxU(_("Ctrl")) );
+ ctrl->SetValue( p_item->i_value & KEY_MODIFIER_CTRL );
+ wxCheckBox *shift = new wxCheckBox( panel, -1, wxU(_("Shift")) );
+ shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
+ combo = new wxComboBox( panel, -1, wxU("f"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT );
+ for( int i = 0; i < sizeof(keys)/sizeof(key_descriptor_s); i++ )
+ {
+ combo->Append( wxU(_(keys[i].psz_key_string)), (void*)&keys[i].i_key_code );
+ }
+ combo->SetValue( wxU( KeyToString( p_item->i_value&~KEY_MODIFIER )));
+ config_data->control.combobox = combo;
+ panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+ panel_sizer->Add( alt, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+ panel_sizer->Add( ctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+ panel_sizer->Add( shift, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+ panel_sizer->Add( combo, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+ }
+ break;
case CONFIG_ITEM_FLOAT:
label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
textctrl = new wxTextCtrl( panel, -1,
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.51 2003/08/10 09:22:07 gbazin Exp $
+ * $Id: wxwindows.h,v 1.52 2003/08/14 19:25:56 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
#include <wx/dnd.h>
#include <wx/treectrl.h>
#include <wx/gauge.h>
+#include <wx/accel.h>
+#include "vlc_keys.h"
DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
wxGauge *volctrl;
private:
+ void UpdateAcceleratorTable();
void CreateOurMenuBar();
void CreateOurToolBar();
void CreateOurSlider();
int i_item_id;
};
+
+static inline int ConvertHotkeyModifiers( int i_hotkey )
+{
+ int i_accel_flags = 0;
+ if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
+ if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
+ if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
+ return i_accel_flags;
+}
+
+static inline int ConvertHotkey( int i_hotkey )
+{
+ int i_key = i_hotkey & ~KEY_MODIFIER;
+ if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
+ else if( i_key & KEY_SPECIAL )
+ {
+ switch ( i_key )
+ {
+ case KEY_LEFT: return WXK_LEFT;
+ case KEY_RIGHT: return WXK_RIGHT;
+ case KEY_UP: return WXK_UP;
+ case KEY_DOWN: return WXK_DOWN;
+ case KEY_SPACE: return WXK_SPACE;
+ case KEY_ENTER: return WXK_RETURN;
+ case KEY_F1: return WXK_F1;
+ case KEY_F2: return WXK_F2;
+ case KEY_F3: return WXK_F3;
+ case KEY_F4: return WXK_F4;
+ case KEY_F5: return WXK_F5;
+ case KEY_F6: return WXK_F6;
+ case KEY_F7: return WXK_F7;
+ case KEY_F8: return WXK_F8;
+ case KEY_F9: return WXK_F9;
+ case KEY_F10: return WXK_F10;
+ case KEY_F11: return WXK_F11;
+ case KEY_F12: return WXK_F12;
+ case KEY_HOME: return WXK_HOME;
+ case KEY_END: return WXK_HOME;
+ case KEY_MENU: return WXK_MENU;
+ case KEY_ESC: return WXK_ESCAPE;
+ case KEY_PAGEUP: return WXK_PRIOR;
+ case KEY_PAGEDOWN: return WXK_NEXT;
+ case KEY_TAB: return WXK_TAB;
+ case KEY_BACKSPACE: return WXK_BACK;
+ default:
+ return 0;
+ }
+ }
+}
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.h,v 1.77 2003/07/20 19:48:30 hartman Exp $
+ * $Id: libvlc.h,v 1.78 2003/08/14 19:25:56 sigmunau Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
*****************************************************************************/
#define Nothing here, this is just to prevent update-po from being stupid
+#include "vlc_keys.h"
static char *ppsz_sout_acodec[] = { "", "mpga", "mp3", "vorb", "a52", NULL };
static char *ppsz_sout_vcodec[] = { "", "mpgv", "mp4v", "DIV1", "DIV2",
"Currently you can choose between implementation 0 (which is the " \
"default and the fastest), 1 and 2.")
+#define FULLSCREEN_KEY_TEXT N_("Fullscreen")
+#define FULLSCREEN_KEY_LONGTEXT N_("Select the hotkey to use to swap fullscreen state")
+#define PLAY_PAUSE_KEY_TEXT N_("Pause")
+#define PLAY_PAUSE_KEY_LONGTEXT N_("Select the hotkey to use to swap paused state")
+#define PAUSE_KEY_TEXT N_("Pause only")
+#define PAUSE_KEY_LONGTEXT N_("Select the hotkey to use to pause")
+#define PLAY_KEY_TEXT N_("Play only")
+#define PLAY_KEY_LONGTEXT N_("Select the hotkey to use to play")
+#define FASTER_KEY_TEXT N_("Faster")
+#define FASTER_KEY_LONGTEXT N_("Select the hotkey to use for fast forward playback")
+#define SLOWER_KEY_TEXT N_("Slower")
+#define SLOWER_KEY_LONGTEXT N_("Select the hotkey to use for slow motion playback")
+#define NEXT_KEY_TEXT N_("Next")
+#define NEXT_KEY_LONGTEXT N_("Select the hotkey to use to skip to the next item in the playlist")
+#define PREV_KEY_TEXT N_("Previous")
+#define PREV_KEY_LONGTEXT N_("Select the hotkey to use to skip to the previous item in the playlist")
+#define STOP_KEY_TEXT N_("Stop")
+#define STOP_KEY_LONGTEXT N_("Select the hotkey to stop the playback")
+#define QUIT_KEY_TEXT N_("Quit")
+#define QUIT_KEY_LONGTEXT N_("Select the hotkey to quit the application")
+#define NAV_UP_KEY_TEXT N_("Navigate up")
+#define NAV_UP_KEY_LONGTEXT N_("Select the key to move the selector up in dvd menus")
+#define NAV_DOWN_KEY_TEXT N_("Navigate down")
+#define NAV_DOWN_KEY_LONGTEXT N_("Select the key to move the selector down in dvd menus")
+#define NAV_LEFT_KEY_TEXT N_("Navigate left")
+#define NAV_LEFT_KEY_LONGTEXT N_("Select the key to move the selector left in dvd menus")
+#define NAV_RIGHT_KEY_TEXT N_("Navigate right")
+#define NAV_RIGHT_KEY_LONGTEXT N_("Select the key to move the selector right in dvd menus")
+#define NAV_ACTIVATE_KEY_TEXT N_("Activate")
+#define NAV_ACTIVATE_KEY_LONGTEXT N_("Select the key to activate selected item in dvd menus")
+#define VOL_UP_KEY_TEXT N_("Volume up")
+#define VOL_UP_KEY_LONGTEXT N_("Select the key to turn up audio volume")
+#define VOL_DOWN_KEY_TEXT N_("Volume down")
+#define VOL_DOWN_KEY_LONGTEXT N_("Select the key to turn down audio volume")
+
#define PLAYLIST_USAGE N_("\nPlaylist items:" \
"\n *.mpg, *.vob plain MPEG-1/2 files" \
"\n [dvd:][device][@raw_device][@[title][,[chapter][,angle]]]" \
add_integer( "win9x-cv-method", 0, NULL, WIN9X_CV_TEXT, WIN9X_CV_LONGTEXT, VLC_TRUE );
#endif
+ /* Hotkey options*/
+ add_category_hint( N_("Hot keys"), NULL, VLC_FALSE );
+ add_key( "fullscreen-key", 'f', NULL, FULLSCREEN_KEY_TEXT, FULLSCREEN_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "play-pause-key", KEY_SPACE, NULL, PLAY_PAUSE_KEY_TEXT, PLAY_PAUSE_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "pause-key", 0, NULL, PAUSE_KEY_TEXT, PAUSE_KEY_LONGTEXT, VLC_TRUE );
+ add_key( "play-key", 0, NULL, PLAY_KEY_TEXT, PLAY_KEY_LONGTEXT, VLC_TRUE );
+ add_key( "faster-key", '+', NULL, FASTER_KEY_TEXT, FASTER_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "slower-key", '-', NULL, SLOWER_KEY_TEXT, SLOWER_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "next-key", 'n', NULL, NEXT_KEY_TEXT, NEXT_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "prev-key", 'p', NULL, PREV_KEY_TEXT, PREV_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "stop-key", 's', NULL, STOP_KEY_TEXT, STOP_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "nav-activate-key", KEY_ENTER, NULL, NAV_ACTIVATE_KEY_TEXT, NAV_ACTIVATE_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "nav-up-key", KEY_UP, NULL, NAV_UP_KEY_TEXT, NAV_UP_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "nav-down-key", KEY_DOWN, NULL, NAV_DOWN_KEY_TEXT, NAV_DOWN_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "nav-left-key", KEY_LEFT, NULL, NAV_LEFT_KEY_TEXT, NAV_LEFT_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "nav-right-key", KEY_RIGHT, NULL, NAV_RIGHT_KEY_TEXT, NAV_RIGHT_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "quit-key", KEY_MODIFIER_CTRL|KEY_SPACE, NULL, QUIT_KEY_TEXT, QUIT_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "vol-up-key", 'a', NULL, VOL_UP_KEY_TEXT, VOL_UP_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "vol-down-key", 'z', NULL, VOL_DOWN_KEY_TEXT, VOL_DOWN_KEY_LONGTEXT, VLC_FALSE );
+
/* Usage (mainly useful for cmd line stuff) */
add_usage_hint( PLAYLIST_USAGE );
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: configuration.c,v 1.61 2003/08/03 23:11:21 gbazin Exp $
+ * $Id: configuration.c,v 1.62 2003/08/14 19:25:56 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
*****************************************************************************/
#include <vlc/vlc.h>
+#include "vlc_keys.h"
#include <stdio.h> /* sprintf() */
#include <stdlib.h> /* free(), strtol() */
# include <direct.h>
#endif
+
+static int ConfigStringToKey( char * );
+
/*****************************************************************************
* config_GetType: get the type of a variable (bool, int, float, string)
*****************************************************************************
return -1;
}
if( (p_config->i_type!=CONFIG_ITEM_INTEGER) &&
+ (p_config->i_type!=CONFIG_ITEM_KEY) &&
(p_config->i_type!=CONFIG_ITEM_BOOL) )
{
msg_Err( p_this, "option %s does not refer to an int", psz_name );
return;
}
if( (p_config->i_type!=CONFIG_ITEM_INTEGER) &&
+ (p_config->i_type!=CONFIG_ITEM_KEY) &&
(p_config->i_type!=CONFIG_ITEM_BOOL) )
{
msg_Err( p_this, "option %s does not refer to an int", psz_name );
p_item->psz_name, (double)p_item->f_value );
#endif
break;
+ case CONFIG_ITEM_KEY:
+ if( !*psz_option_value )
+ break; /* ignore empty option */
+ p_item->i_value = ConfigStringToKey( psz_option_value );
+ break;
default:
vlc_mutex_lock( p_item->p_lock );
p_item->i_type != CONFIG_HINT_END;
p_item++ )
{
+ char *psz_key;
if( p_item->i_type & CONFIG_HINT )
/* ignore hints */
continue;
fprintf( file, "#" );
fprintf( file, "%s=%i\n", p_item->psz_name, p_item->i_value );
break;
-
+ case CONFIG_ITEM_KEY:
+ if( p_item->psz_text )
+ fprintf( file, "# %s (%s)\n", p_item->psz_text,
+ _("key") );
+ psz_key = ConfigKeyToString( p_item->i_value );
+ fprintf( file, "%s=%s\n", p_item->psz_name,
+ psz_key ? psz_key : "" );
+ if ( psz_key ) free( psz_key );
+ break;
+
case CONFIG_ITEM_FLOAT:
if( p_item->psz_text )
fprintf( file, "# %s (%s)\n", p_item->psz_text,
case CONFIG_ITEM_FLOAT:
config_PutFloat( p_this, psz_name, (float)atof(optarg) );
break;
+ case CONFIG_ITEM_KEY:
+ config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );
+ break;
case CONFIG_ITEM_BOOL:
config_PutInt( p_this, psz_name, !flag );
break;
return p_homedir;
}
+
+
+
+static int ConfigStringToKey( char *psz_key )
+{
+ int i_key = 0;
+ unsigned int i;
+ char *psz_parser = strchr( psz_key, '-' );
+ while( psz_parser && psz_parser != psz_key )
+ {
+ for ( i = 0; i < sizeof(modifiers) / sizeof(key_descriptor_t); i++ )
+ {
+ if ( !strncasecmp( modifiers[i].psz_key_string, psz_key, strlen( modifiers[i].psz_key_string ) ) )
+ {
+ i_key |= modifiers[i].i_key_code;
+ }
+ }
+ psz_key = psz_parser + 1;
+ psz_parser = strchr( psz_key, '-' );
+ }
+ for ( i = 0; i < sizeof(keys) / sizeof( key_descriptor_t ); i++ )
+ {
+ if ( !strcasecmp( keys[i].psz_key_string, psz_key ) )
+ {
+ i_key |= keys[i].i_key_code;
+ break;
+ }
+ }
+ return i_key;
+}
+
+
+static char *ConfigKeyToString( int i_key )
+{
+ char *psz_key = malloc( 100 );
+ char *p;
+ int i;
+ if ( !psz_key )
+ {
+ return NULL;
+ }
+ *psz_key = '\0';
+ p = psz_key;
+ for( i = 0; i < sizeof(modifiers) / sizeof(key_descriptor_t); i++ )
+ {
+ if ( i_key & modifiers[i].i_key_code )
+ {
+ p += sprintf( p, "%s-", modifiers[i].psz_key_string );
+ }
+ }
+ for( i = 0; i < sizeof(keys) / sizeof( key_descriptor_t); i++)
+ {
+ if ( ( i_key & ~KEY_MODIFIER ) == keys[i].i_key_code )
+ {
+ p += sprintf( p, "%s", keys[i].psz_key_string );
+ break;
+ }
+ }
+ return psz_key;
+}