Commit 6db9bea7 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed hotkeys for non-ascii-character and non-arrow keys

parent 01ec282c
...@@ -1095,6 +1095,7 @@ static struct ...@@ -1095,6 +1095,7 @@ static struct
{ NSCarriageReturnCharacter, KEY_ENTER }, { NSCarriageReturnCharacter, KEY_ENTER },
{ NSEnterCharacter, KEY_ENTER }, { NSEnterCharacter, KEY_ENTER },
{ NSBackspaceCharacter, KEY_BACKSPACE }, { NSBackspaceCharacter, KEY_BACKSPACE },
{ NSDeleteCharacter, KEY_DELETE },
{0,0} {0,0}
}; };
...@@ -1147,6 +1148,51 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1147,6 +1148,51 @@ unsigned int CocoaKeyToVLC( unichar i_key )
return [NSString stringWithFormat:@"%C", NSRightArrowFunctionKey]; return [NSString stringWithFormat:@"%C", NSRightArrowFunctionKey];
else if([theString rangeOfString:@"Left"].location != NSNotFound) else if([theString rangeOfString:@"Left"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSLeftArrowFunctionKey]; return [NSString stringWithFormat:@"%C", NSLeftArrowFunctionKey];
else if([theString rangeOfString:@"Enter"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSEnterCharacter]; // we treat NSCarriageReturnCharacter as aquivalent
else if([theString rangeOfString:@"Insert"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSInsertFunctionKey];
else if([theString rangeOfString:@"Home"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSHomeFunctionKey];
else if([theString rangeOfString:@"End"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSEndFunctionKey];
else if([theString rangeOfString:@"Pageup"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSPageUpFunctionKey];
else if([theString rangeOfString:@"Pagedown"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSPageDownFunctionKey];
else if([theString rangeOfString:@"Menu"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSMenuFunctionKey];
else if([theString rangeOfString:@"Tab"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSTabCharacter];
else if([theString rangeOfString:@"Backspace"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSBackspaceCharacter];
else if([theString rangeOfString:@"Delete"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSDeleteCharacter];
else if([theString rangeOfString:@"F12"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF12FunctionKey];
else if([theString rangeOfString:@"F11"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF11FunctionKey];
else if([theString rangeOfString:@"F10"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF10FunctionKey];
else if([theString rangeOfString:@"F9"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF9FunctionKey];
else if([theString rangeOfString:@"F8"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF8FunctionKey];
else if([theString rangeOfString:@"F7"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF7FunctionKey];
else if([theString rangeOfString:@"F6"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF6FunctionKey];
else if([theString rangeOfString:@"F5"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF5FunctionKey];
else if([theString rangeOfString:@"F4"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF4FunctionKey];
else if([theString rangeOfString:@"F3"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF3FunctionKey];
else if([theString rangeOfString:@"F2"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF2FunctionKey];
else if([theString rangeOfString:@"F1"].location != NSNotFound)
return [NSString stringWithFormat:@"%C", NSF1FunctionKey];
/* note that we don't support esc here, since it is reserved for leaving fullscreen */
} }
return theString; return theString;
......
...@@ -79,16 +79,22 @@ static VLCSimplePrefs *_o_sharedInstance = nil; ...@@ -79,16 +79,22 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
- (NSString *)OSXStringKeyToString:(NSString *)theString - (NSString *)OSXStringKeyToString:(NSString *)theString
{ {
if (![theString isEqualToString:@""]) { if (![theString isEqualToString:@""]) {
/* modifiers */
theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]];
/* remove cruft */
theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""]; theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""]; theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
/* show non-character keys correctly */
theString = [theString stringByReplacingOccurrencesOfString:@"Right" withString:[NSString stringWithUTF8String:"\xE2\x86\x92"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Right" withString:[NSString stringWithUTF8String:"\xE2\x86\x92"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Left" withString:[NSString stringWithUTF8String:"\xE2\x86\x90"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Left" withString:[NSString stringWithUTF8String:"\xE2\x86\x90"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Up" withString:[NSString stringWithUTF8String:"\xE2\x86\x91"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Up" withString:[NSString stringWithUTF8String:"\xE2\x86\x91"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Down" withString:[NSString stringWithUTF8String:"\xE2\x86\x93"]]; theString = [theString stringByReplacingOccurrencesOfString:@"Down" withString:[NSString stringWithUTF8String:"\xE2\x86\x93"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Enter" withString:[NSString stringWithUTF8String:"\xe2\x86\xb5"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Tab" withString:[NSString stringWithUTF8String:"\xe2\x87\xa5"]];
theString = [theString stringByReplacingOccurrencesOfString:@"Delete" withString:[NSString stringWithUTF8String:"\xe2\x8c\xab"]]; /* capitalize plain characters to suit the menubar's look */
theString = [theString capitalizedString]; theString = [theString capitalizedString];
} }
else else
...@@ -1263,18 +1269,17 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -1263,18 +1269,17 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
NSString *keyString = [o_theEvent characters]; NSString *keyString = [o_theEvent characters];
unichar key = [keyString characterAtIndex:0]; unichar key = [keyString characterAtIndex:0];
/* modifiers */
if( [o_theEvent modifierFlags] & NSControlKeyMask ) if( [o_theEvent modifierFlags] & NSControlKeyMask )
[tempString appendString:@"Ctrl-"]; [tempString appendString:@"Ctrl-"];
if( [o_theEvent modifierFlags] & NSAlternateKeyMask ) if( [o_theEvent modifierFlags] & NSAlternateKeyMask )
[tempString appendString:@"Alt-"]; [tempString appendString:@"Alt-"];
if( [o_theEvent modifierFlags] & NSShiftKeyMask ) if( [o_theEvent modifierFlags] & NSShiftKeyMask )
[tempString appendString:@"Shift-"]; [tempString appendString:@"Shift-"];
if( [o_theEvent modifierFlags] & NSCommandKeyMask ) if( [o_theEvent modifierFlags] & NSCommandKeyMask )
[tempString appendString:@"Command-"]; [tempString appendString:@"Command-"];
/* non character keys */
if( key == NSUpArrowFunctionKey ) if( key == NSUpArrowFunctionKey )
[tempString appendString:@"Up"]; [tempString appendString:@"Up"];
else if( key == NSDownArrowFunctionKey ) else if( key == NSDownArrowFunctionKey )
...@@ -1283,7 +1288,53 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -1283,7 +1288,53 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
[tempString appendString:@"Left"]; [tempString appendString:@"Left"];
else if( key == NSRightArrowFunctionKey ) else if( key == NSRightArrowFunctionKey )
[tempString appendString:@"Right"]; [tempString appendString:@"Right"];
else if (![[[o_theEvent charactersIgnoringModifiers] lowercaseString] isEqualToString:@""]) else if( key == NSF1FunctionKey )
[tempString appendString:@"F1"];
else if( key == NSF2FunctionKey )
[tempString appendString:@"F2"];
else if( key == NSF3FunctionKey )
[tempString appendString:@"F3"];
else if( key == NSF4FunctionKey )
[tempString appendString:@"F4"];
else if( key == NSF5FunctionKey )
[tempString appendString:@"F5"];
else if( key == NSF6FunctionKey )
[tempString appendString:@"F6"];
else if( key == NSF7FunctionKey )
[tempString appendString:@"F7"];
else if( key == NSF8FunctionKey )
[tempString appendString:@"F8"];
else if( key == NSF9FunctionKey )
[tempString appendString:@"F9"];
else if( key == NSF10FunctionKey )
[tempString appendString:@"F10"];
else if( key == NSF11FunctionKey )
[tempString appendString:@"F11"];
else if( key == NSF12FunctionKey )
[tempString appendString:@"F12"];
else if( key == NSInsertFunctionKey )
[tempString appendString:@"Insert"];
else if( key == NSHomeFunctionKey )
[tempString appendString:@"Home"];
else if( key == NSEndFunctionKey )
[tempString appendString:@"End"];
else if( key == NSPageUpFunctionKey )
[tempString appendString:@"Pageup"];
else if( key == NSPageDownFunctionKey )
[tempString appendString:@"Pagedown"];
else if( key == NSMenuFunctionKey )
[tempString appendString:@"Menu"];
else if( key == NSTabCharacter )
[tempString appendString:@"Tab"];
else if( key == NSCarriageReturnCharacter )
[tempString appendString:@"Enter"];
else if( key == NSEnterCharacter )
[tempString appendString:@"Enter"];
else if( key == NSDeleteCharacter )
[tempString appendString:@"Delete"];
else if( key == NSBackspaceCharacter )
[tempString appendString:@"Backspace"];
else if (![[[o_theEvent charactersIgnoringModifiers] lowercaseString] isEqualToString:@""]) //plain characters
[tempString appendString:[[o_theEvent charactersIgnoringModifiers] lowercaseString]]; [tempString appendString:[[o_theEvent charactersIgnoringModifiers] lowercaseString]];
else else
return NO; return NO;
......
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