Commit ff83b90d authored by Felix Paul Kühne's avatar Felix Paul Kühne

finished hotkeys settings in simple prefs

Includes an array of not-to-be-used keys

Shows modifier keys with their corresponding symbols instead of 'Alt', etc.

Saving combinations of multiple keys won't crash anymore, but work as expected
parent bd040d3b
...@@ -153,7 +153,9 @@ ...@@ -153,7 +153,9 @@
NSToolbar *o_sprefs_toolbar; NSToolbar *o_sprefs_toolbar;
NSOpenPanel *o_selectFolderPanel; NSOpenPanel *o_selectFolderPanel;
NSArray *o_hotkeyDescriptions; NSArray *o_hotkeyDescriptions;
NSArray *o_hotkeysNonUseableKeys;
NSMutableArray *o_hotkeySettings; NSMutableArray *o_hotkeySettings;
NSNumber *o_keyInTransition;
intf_thread_t *p_intf; intf_thread_t *p_intf;
} }
...@@ -203,7 +205,7 @@ ...@@ -203,7 +205,7 @@
- (void)showHotkeySettings; - (void)showHotkeySettings;
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView; - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;
- (void)changeHotkeyTo: (NSString *)o_theNewKey; - (void)changeHotkeyTo: (int)i_theNewKey;
@end @end
......
...@@ -61,6 +61,10 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -61,6 +61,10 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
[o_hotkeySettings release]; [o_hotkeySettings release];
[o_hotkeyDescriptions release]; [o_hotkeyDescriptions release];
[o_hotkeysNonUseableKeys release];
if( o_keyInTransition )
[o_keyInTransition release];
[super dealloc]; [super dealloc];
} }
...@@ -70,20 +74,23 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -70,20 +74,23 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
{ {
NSMutableString *o_temp_str = [[[NSMutableString alloc] init] autorelease]; NSMutableString *o_temp_str = [[[NSMutableString alloc] init] autorelease];
if( val & KEY_MODIFIER_CTRL ) if( val & KEY_MODIFIER_CTRL )
[o_temp_str appendString: @"Ctrl+"]; [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]];
if( val & KEY_MODIFIER_ALT ) if( val & KEY_MODIFIER_ALT )
[o_temp_str appendString: @"Alt+"]; [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]];
if( val & KEY_MODIFIER_SHIFT ) if( val & KEY_MODIFIER_SHIFT )
[o_temp_str appendString: @"Shift+"]; [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]];
if( val & KEY_MODIFIER_COMMAND ) if( val & KEY_MODIFIER_COMMAND )
[o_temp_str appendString: @"Command+"]; [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t); unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t);
for( unsigned int i = 0; i< i_keys; i++ ) for( unsigned int i = 0; i< i_keys; i++ )
{ {
if( vlc_keys[i].i_key_code == (val& ~KEY_MODIFIER) ) if( vlc_keys[i].i_key_code == (val& ~KEY_MODIFIER) )
{ {
[o_temp_str appendString: [NSString stringWithUTF8String: vlc_keys[i].psz_key_string]]; if( vlc_keys[i].psz_key_string )
[o_temp_str appendString: [NSString stringWithUTF8String: vlc_keys[i].psz_key_string]];
else
o_temp_str = @"Unset";
} }
} }
return o_temp_str; return o_temp_str;
...@@ -101,6 +108,44 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -101,6 +108,44 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
[o_sprefs_toolbar setSizeMode: NSToolbarSizeModeRegular]; [o_sprefs_toolbar setSizeMode: NSToolbarSizeModeRegular];
[o_sprefs_toolbar setDelegate: self]; [o_sprefs_toolbar setDelegate: self];
[o_sprefs_win setToolbar: o_sprefs_toolbar]; [o_sprefs_win setToolbar: o_sprefs_toolbar];
/* setup useful stuff */
/* TODO: hard-code this instead of one-the-run generation */
o_hotkeysNonUseableKeys = [[NSArray arrayWithObjects:
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'c'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'x'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'v'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'a'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|','],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'h'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'h'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'o'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'o'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'d'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'n'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'s'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'z'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'l'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'r'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'0'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'1'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'2'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'3'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'m'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'q'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'w'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'w'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'c'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'p'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'i'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'e'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'e'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'b'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'m'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_CTRL|'m'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'?'],
[NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'?'],
nil] retain];
} }
- (NSToolbarItem *) toolbar: (NSToolbar *)o_sprefs_toolbar - (NSToolbarItem *) toolbar: (NSToolbar *)o_sprefs_toolbar
...@@ -386,7 +431,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -386,7 +431,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
break; break;
[o_tempArray_desc addObject: _NS( p_item->psz_text )]; [o_tempArray_desc addObject: _NS( p_item->psz_text )];
[o_hotkeySettings addObject: [self OSXKeyToString: p_item->value.i]]; [o_hotkeySettings addObject: [NSNumber numberWithInt: p_item->value.i]];
i++; i++;
} }
...@@ -484,7 +529,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -484,7 +529,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the Interface settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the Interface settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
...@@ -544,7 +589,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -544,7 +589,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the Audio settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the Audio settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
b_audioSettingChanged = NO; b_audioSettingChanged = NO;
...@@ -575,7 +620,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -575,7 +620,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the Video settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the Video settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
b_videoSettingChanged = NO; b_videoSettingChanged = NO;
...@@ -656,7 +701,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -656,7 +701,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the Input settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the Input settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
b_inputSettingChanged = NO; b_inputSettingChanged = NO;
...@@ -683,7 +728,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -683,7 +728,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the OSD/Subtitle settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the OSD/Subtitle settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
b_osdSettingChanged = NO; b_osdSettingChanged = NO;
...@@ -696,19 +741,17 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -696,19 +741,17 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
{ {
struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys; struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
i = 1; i = 1;
while( i < [o_hotkeySettings count] ) // FIXME: this is ugly! while( i < [o_hotkeySettings count] )
{ {
/* FIXME: this does only work for single keys!!! */ config_PutInt( p_intf, p_hotkeys[i].psz_action, [[o_hotkeySettings objectAtIndex: i-1] intValue] );
config_PutInt( p_intf, p_hotkeys[i].psz_action, StringToKey( (char *)[[o_hotkeySettings objectAtIndex: i] UTF8String] ) );
i++; i++;
} }
i = config_SaveConfigFile( p_intf, "main" ); i = config_SaveConfigFile( p_intf, "main" );
if( i != 0 ) if( i != 0 )
{ {
msg_Err( p_intf, "An error occurred while saving the Hotkey settings using SimplePrefs" ); msg_Err( p_intf, "An error occurred while saving the Hotkey settings using SimplePrefs (%i)", i );
i = 0; i = 0;
} }
b_hotkeyChanged = NO; b_hotkeyChanged = NO;
...@@ -869,7 +912,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -869,7 +912,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
{ {
[o_hotkeys_change_lbl setStringValue: [NSString stringWithFormat: _NS("Press new keys for\n\"%@\""), [o_hotkeys_change_lbl setStringValue: [NSString stringWithFormat: _NS("Press new keys for\n\"%@\""),
[o_hotkeyDescriptions objectAtIndex: [o_hotkeys_listbox selectedRow]]]]; [o_hotkeyDescriptions objectAtIndex: [o_hotkeys_listbox selectedRow]]]];
[o_hotkeys_change_keys_lbl setStringValue: [o_hotkeySettings objectAtIndex: [o_hotkeys_listbox selectedRow]]]; [o_hotkeys_change_keys_lbl setStringValue: [self OSXKeyToString:[[o_hotkeySettings objectAtIndex: [o_hotkeys_listbox selectedRow]] intValue]]];
[o_hotkeys_change_taken_lbl setStringValue: @""]; [o_hotkeys_change_taken_lbl setStringValue: @""];
[o_hotkeys_change_win setInitialFirstResponder: [o_hotkeys_change_win contentView]]; [o_hotkeys_change_win setInitialFirstResponder: [o_hotkeys_change_win contentView]];
[o_hotkeys_change_win makeFirstResponder: [o_hotkeys_change_win contentView]]; [o_hotkeys_change_win makeFirstResponder: [o_hotkeys_change_win contentView]];
...@@ -883,13 +926,21 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -883,13 +926,21 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
else if( sender == o_hotkeys_change_ok_btn ) else if( sender == o_hotkeys_change_ok_btn )
{ {
int i_returnValue; int i_returnValue;
if(! o_keyInTransition )
{
[NSApp stopModal];
[o_hotkeys_change_win close];
msg_Err( p_intf, "internal error prevented the hotkey switch" );
return;
}
b_hotkeyChanged = YES; b_hotkeyChanged = YES;
i_returnValue = [o_hotkeySettings indexOfObject: [o_hotkeys_change_keys_lbl stringValue]]; i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition];
if( i_returnValue != NSNotFound ) if( i_returnValue != NSNotFound )
[o_hotkeySettings replaceObjectAtIndex: i_returnValue withObject: @"Unset"]; [o_hotkeySettings replaceObjectAtIndex: i_returnValue withObject: [[NSNumber numberWithInt: 0] retain]];
[o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [o_hotkeys_change_keys_lbl stringValue]]; [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [o_keyInTransition retain]];
[NSApp stopModal]; [NSApp stopModal];
[o_hotkeys_change_win close]; [o_hotkeys_change_win close];
...@@ -898,7 +949,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -898,7 +949,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
} }
else if( sender == o_hotkeys_clear_btn ) else if( sender == o_hotkeys_clear_btn )
{ {
[o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: @"Unset"]; [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [NSNumber numberWithInt: 0]];
[o_hotkeys_listbox reloadData]; [o_hotkeys_listbox reloadData];
b_hotkeyChanged = YES; b_hotkeyChanged = YES;
} }
...@@ -920,18 +971,19 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -920,18 +971,19 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
if( [[aTableColumn identifier] isEqualToString: @"action"] ) if( [[aTableColumn identifier] isEqualToString: @"action"] )
return [o_hotkeyDescriptions objectAtIndex: rowIndex]; return [o_hotkeyDescriptions objectAtIndex: rowIndex];
else if( [[aTableColumn identifier] isEqualToString: @"shortcut"] ) else if( [[aTableColumn identifier] isEqualToString: @"shortcut"] )
return [o_hotkeySettings objectAtIndex: rowIndex]; return [self OSXKeyToString: [[o_hotkeySettings objectAtIndex: rowIndex] intValue]];
else else
{ {
NSLog(@"unknown TableColumn identifier (%@)!", [aTableColumn identifier] ); msg_Err( p_intf, "unknown TableColumn identifier (%s)!", [[aTableColumn identifier] UTF8String] );
return NULL; return NULL;
} }
} }
- (void)changeHotkeyTo: (NSString *)o_theNewKey - (void)changeHotkeyTo: (int)i_theNewKey
{ {
int i_returnValue; int i_returnValue;
if( o_theNewKey == @"invalid" || o_theNewKey == @"" ) i_returnValue = [o_hotkeysNonUseableKeys indexOfObject: [NSNumber numberWithInt: i_theNewKey]];
if( i_returnValue != NSNotFound || i_theNewKey == 0 )
{ {
[o_hotkeys_change_keys_lbl setStringValue: _NS("Invalid combination")]; [o_hotkeys_change_keys_lbl setStringValue: _NS("Invalid combination")];
[o_hotkeys_change_taken_lbl setStringValue: _NS("Regrettably, these keys cannot be assigned as hotkey shortcuts.")]; [o_hotkeys_change_taken_lbl setStringValue: _NS("Regrettably, these keys cannot be assigned as hotkey shortcuts.")];
...@@ -939,13 +991,20 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -939,13 +991,20 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
} }
else else
{ {
[o_hotkeys_change_keys_lbl setStringValue: o_theNewKey]; NSString *o_temp;
if( o_keyInTransition )
[o_keyInTransition release];
o_keyInTransition = [[NSNumber numberWithInt: i_theNewKey] retain];
i_returnValue = [o_hotkeySettings indexOfObject: o_theNewKey]; o_temp = [self OSXKeyToString: i_theNewKey];
[o_hotkeys_change_keys_lbl setStringValue: o_temp];
i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition];
if( i_returnValue != NSNotFound ) if( i_returnValue != NSNotFound )
[o_hotkeys_change_taken_lbl setStringValue: [NSString stringWithFormat: [o_hotkeys_change_taken_lbl setStringValue: [NSString stringWithFormat:
_NS("This combination is already taken by \"%@\"."), _NS("This combination is already taken by \"%@\"."),
[o_hotkeyDescriptions objectAtIndex: i_returnValue]]]; [self OSXKeyToString:[[o_hotkeyDescriptions objectAtIndex: i_returnValue] intValue]]]];
else else
[o_hotkeys_change_taken_lbl setStringValue: @""]; [o_hotkeys_change_taken_lbl setStringValue: @""];
...@@ -961,22 +1020,28 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -961,22 +1020,28 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
@implementation VLCHotkeyChangeWindow @implementation VLCHotkeyChangeWindow
- (BOOL)resignFirstResponder
{
/* We need to stay the first responder or we'll miss the user's input */
return NO;
}
- (void)keyDown:(NSEvent *)o_theEvent - (void)keyDown:(NSEvent *)o_theEvent
{ {
NSMutableString *o_temp = [[NSMutableString alloc] init]; int i_nonReadableKey = 0;
if( [o_theEvent modifierFlags] & NSShiftKeyMask )
[o_temp appendString: @"Shift+"];
if( [o_theEvent modifierFlags] & NSControlKeyMask ) if( [o_theEvent modifierFlags] & NSControlKeyMask )
[o_temp appendString: @"Ctrl+"]; i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_CTRL;
if( [o_theEvent modifierFlags] & NSCommandKeyMask )
[o_temp appendString: @"Command+"];
if( [o_theEvent modifierFlags] & NSAlternateKeyMask ) if( [o_theEvent modifierFlags] & NSAlternateKeyMask )
[o_temp appendString: @"Alt+"]; i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_ALT;
if( [o_theEvent modifierFlags] & NSShiftKeyMask )
i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_SHIFT;
if( [o_theEvent modifierFlags] & NSCommandKeyMask )
i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_COMMAND;
if( [o_theEvent modifierFlags] & NSFunctionKeyMask ) if( [o_theEvent modifierFlags] & NSFunctionKeyMask )
{ {
unichar key = 0; unichar key = 0;
...@@ -985,90 +1050,90 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -985,90 +1050,90 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
switch( key ) switch( key )
{ {
case 0x1b: case 0x1b:
[o_temp appendString: @"Esc"]; i_nonReadableKey = i_nonReadableKey | KEY_ESC;
break; break;
case NSF1FunctionKey: case NSF1FunctionKey:
[o_temp appendString: @"F1"]; i_nonReadableKey = i_nonReadableKey | KEY_F1;
break; break;
case NSF2FunctionKey: case NSF2FunctionKey:
[o_temp appendString: @"F2"]; i_nonReadableKey = i_nonReadableKey | KEY_F2;
break; break;
case NSF3FunctionKey: case NSF3FunctionKey:
[o_temp appendString: @"F3"]; i_nonReadableKey = i_nonReadableKey | KEY_F3;
break; break;
case NSF4FunctionKey: case NSF4FunctionKey:
[o_temp appendString: @"F4"]; i_nonReadableKey = i_nonReadableKey | KEY_F4;
break; break;
case NSF5FunctionKey: case NSF5FunctionKey:
[o_temp appendString: @"F5"]; i_nonReadableKey = i_nonReadableKey | KEY_F5;
break; break;
case NSF6FunctionKey: case NSF6FunctionKey:
[o_temp appendString: @"F6"]; i_nonReadableKey = i_nonReadableKey | KEY_F6;
break; break;
case NSF7FunctionKey: case NSF7FunctionKey:
[o_temp appendString: @"F7"]; i_nonReadableKey = i_nonReadableKey | KEY_F7;
break; break;
case NSF8FunctionKey: case NSF8FunctionKey:
[o_temp appendString: @"F8"]; i_nonReadableKey = i_nonReadableKey | KEY_F8;
break; break;
case NSF9FunctionKey: case NSF9FunctionKey:
[o_temp appendString: @"F9"]; i_nonReadableKey = i_nonReadableKey | KEY_F9;
break; break;
case NSF10FunctionKey: case NSF10FunctionKey:
[o_temp appendString: @"F10"]; i_nonReadableKey = i_nonReadableKey | KEY_F10;
break; break;
case NSF11FunctionKey: case NSF11FunctionKey:
[o_temp appendString: @"F11"]; i_nonReadableKey = i_nonReadableKey | KEY_F11;
break; break;
case NSF12FunctionKey: case NSF12FunctionKey:
[o_temp appendString: @"F12"]; i_nonReadableKey = i_nonReadableKey | KEY_F12;
break; break;
case NSInsertFunctionKey: case NSInsertFunctionKey:
[o_temp appendString: @"Insert"]; i_nonReadableKey = i_nonReadableKey | KEY_INSERT;
break; break;
case NSHomeFunctionKey: case NSHomeFunctionKey:
[o_temp appendString: @"Home"]; i_nonReadableKey = i_nonReadableKey | KEY_HOME;
break; break;
case NSEndFunctionKey: case NSEndFunctionKey:
[o_temp appendString: @"End"]; i_nonReadableKey = i_nonReadableKey | KEY_END;
break; break;
case NSPageUpFunctionKey: case NSPageUpFunctionKey:
[o_temp appendString: @"Page Up"]; i_nonReadableKey = i_nonReadableKey | KEY_PAGEUP;
break; break;
case NSPageDownFunctionKey: case NSPageDownFunctionKey:
[o_temp appendString: @"Page Down"]; i_nonReadableKey = i_nonReadableKey | KEY_PAGEDOWN;
break; break;
case NSMenuFunctionKey: case NSMenuFunctionKey:
[o_temp appendString: @"Menu"]; i_nonReadableKey = i_nonReadableKey | KEY_MENU;
break; break;
case NSTabCharacter: case NSTabCharacter:
[o_temp appendString: @"Tab"]; i_nonReadableKey = i_nonReadableKey | KEY_TAB;
break; break;
case NSDeleteCharacter: case NSDeleteCharacter:
[o_temp appendString: @"Delete"]; i_nonReadableKey = i_nonReadableKey | KEY_DELETE;
break; break;
case NSBackspaceCharacter: case NSBackspaceCharacter:
[o_temp appendString: @"Backspace"]; i_nonReadableKey = i_nonReadableKey | KEY_BACKSPACE;
break; break;
case NSUpArrowFunctionKey: case NSUpArrowFunctionKey:
[o_temp appendString: @"Up"]; i_nonReadableKey = i_nonReadableKey | KEY_UP;
break; break;
case NSDownArrowFunctionKey: case NSDownArrowFunctionKey:
[o_temp appendString: @"Down"]; i_nonReadableKey = i_nonReadableKey | KEY_DOWN;
break; break;
case NSRightArrowFunctionKey: case NSRightArrowFunctionKey:
[o_temp appendString: @"Right"]; i_nonReadableKey = i_nonReadableKey | KEY_RIGHT;
break; break;
case NSLeftArrowFunctionKey: case NSLeftArrowFunctionKey:
[o_temp appendString: @"Left"]; i_nonReadableKey = i_nonReadableKey | KEY_LEFT;
break; break;
case NSEnterCharacter: case NSEnterCharacter:
[o_temp appendString: @"Enter"]; i_nonReadableKey = i_nonReadableKey | KEY_ENTER;
break; break;
default: default:
{ {
msg_Warn( VLCIntf, "user pressed unknown function key" ); msg_Warn( VLCIntf, "user pressed unknown function key" );
o_temp = @"invalid"; i_nonReadableKey = 0;
break; break;
} }
} }
...@@ -1076,17 +1141,12 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -1076,17 +1141,12 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
else else
{ {
if( [[o_theEvent charactersIgnoringModifiers] isEqualToString: @" "] ) if( [[o_theEvent charactersIgnoringModifiers] isEqualToString: @" "] )
[o_temp appendString: @"Space"]; i_nonReadableKey = i_nonReadableKey | KEY_SPACE;
else else
[o_temp appendString: [o_theEvent charactersIgnoringModifiers]]; i_nonReadableKey = i_nonReadableKey | StringToKey( (char *)[[[o_theEvent charactersIgnoringModifiers] lowercaseString] UTF8String] );
} }
/* FIXME: implement sanity checks here as we don't want the user to interfere with hard shortcuts in our main menu */ [[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: i_nonReadableKey];
[[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: o_temp];
NSLog( @"user pressed %@", o_temp );
[o_temp release];
} }
@end @end
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