1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-03 01:31:53 +02:00

Merge ConfigKeyToString and KeyToString

This commit is contained in:
Rémi Denis-Courmont 2011-02-10 20:01:54 +02:00
parent dc689548d3
commit c810198e17
9 changed files with 13 additions and 42 deletions

View File

@ -86,7 +86,7 @@
#define KEY_MOUSEWHEELLEFT 0x00F20000
#define KEY_MOUSEWHEELRIGHT 0x00F30000
VLC_EXPORT( char *, KeyToString, (uint_fast32_t i_key) ) LIBVLC_USED;
VLC_EXPORT( char *, vlc_keycode2str, (uint_fast32_t i_key) ) LIBVLC_USED;
typedef enum vlc_key {
ACTIONID_NONE = 0,

View File

@ -87,7 +87,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( val & KEY_MODIFIER_COMMAND )
[o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
char *base = KeyToString( val & ~KEY_MODIFIER );
char *base = vlc_keycode2str( val & ~KEY_MODIFIER );
if( base )
{
[o_temp_str appendString: [NSString stringWithUTF8String: base]];

View File

@ -285,27 +285,15 @@ int qtWheelEventToVLCKey( QWheelEvent *e )
return i_vlck;
}
QString VLCKeyToString( int val )
QString VLCKeyToString( unsigned val )
{
char *base = KeyToString (val & ~KEY_MODIFIER);
char *base = vlc_keycode2str (val);
if (base == NULL)
return qtr( "Unset" );
QString r = "";
if( val & KEY_MODIFIER_CTRL )
r+= qfu( "Ctrl+" );
if( val & KEY_MODIFIER_ALT )
r+= qfu( "Alt+" );
if( val & KEY_MODIFIER_SHIFT )
r+= qfu( "Shift+" );
if( val & KEY_MODIFIER_META )
r+= qfu( "Meta+" );
QString r = qfu( base );
if (base)
{
r += qfu( base );
free( base );
}
else
r += qtr( "Unset" );
free( base );
return r;
}

View File

@ -163,7 +163,7 @@ class QInputEvent;
int qtKeyModifiersToVLC( QInputEvent* e );
int qtEventToVLCKey( QKeyEvent *e );
int qtWheelEventToVLCKey( QWheelEvent *e );
QString VLCKeyToString( int val );
QString VLCKeyToString( unsigned val );
#endif

View File

@ -39,7 +39,7 @@ const string EvtKey::getAsString() const
msg_Warn( getIntf(), "Unknown action type" );
// Add the key
char *keyName = KeyToString( m_key );
char *keyName = vlc_keycode2str( m_key & ~KEY_MODIFIER );
if( keyName )
{
event += (string)":" + keyName;

View File

@ -50,7 +50,6 @@ static inline int IsConfigFloatType (int type)
}
uint_fast32_t ConfigStringToKey( const char * );
char *ConfigKeyToString( uint_fast32_t );
extern vlc_rwlock_t config_lock;

View File

@ -549,7 +549,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
int64_t val = b_retain ? p_item->saved.i : p_item->value.i;
if (p_item->i_type == CONFIG_ITEM_KEY)
{
char *psz_key = ConfigKeyToString (val);
char *psz_key = vlc_keycode2str (val);
config_Write (file, p_item->psz_text, N_("key"),
val == p_item->orig.i,
p_item->psz_name, "%s",

View File

@ -148,22 +148,6 @@ static char *utf8_cp (uint_fast32_t cp, char *buf)
return buf;
}
char *KeyToString (uint_fast32_t sym)
{
key_descriptor_t *d;
d = bsearch ((void *)(uintptr_t)sym, vlc_keys, vlc_num_keys,
sizeof (vlc_keys[0]), cmpkey);
if (d)
return strdup (d->psz_key_string);
char buf[5];
if (utf8_cp (sym, buf))
return strdup (buf);
return NULL;
}
uint_fast32_t ConfigStringToKey (const char *name)
{
uint_fast32_t mods = 0;
@ -193,7 +177,7 @@ uint_fast32_t ConfigStringToKey (const char *name)
return (vlc_towc (name, &cp) > 0) ? (mods | cp) : 0;
}
char *ConfigKeyToString (uint_fast32_t code)
char *vlc_keycode2str (uint_fast32_t code)
{
char *str, buf[5];
uintptr_t key = code & ~KEY_MODIFIER;

View File

@ -679,4 +679,4 @@ xml_Delete
xml_ReaderCreate
xml_ReaderDelete
xml_ReaderReset
KeyToString
vlc_keycode2str