Oolite
Loading...
Searching...
No Matches
PlayerEntity(KeyMapper) Category Reference

#include <PlayerEntityKeyMapper.h>

Instance Methods

(void) - resetKeyFunctions
(void) - initCheckingDictionary
(void) - setGuiToKeyMapperScreen:resetCurrentRow:
(void) - setGuiToKeyMapperScreen:
(void) - keyMapperInputHandler:view:
(void) - setGuiToKeyConfigScreen
(void) - setGuiToKeyConfigScreen:
(void) - handleKeyConfigKeys:view:
(void) - outputKeyDefinition:shift:mod1:mod2:skiprows:
(void) - setGuiToKeyConfigEntryScreen
(void) - handleKeyConfigEntryKeys:view:
(void) - setGuiToConfirmClearScreen
(void) - handleKeyMapperConfirmClearKeys:view:
(void) - setGuiToKeyboardLayoutScreen:
(void) - setGuiToKeyboardLayoutScreen:resetCurrentRow:
(void) - handleKeyboardLayoutEntryKeys:view:
(NSString *) - validateKey:checkKeys:
(NSDictionary *) - makeKeyGuiDict:keyDef:
(NSDictionary *) - makeKeyGuiDictHeader:
(BOOL) - entryIsIndexCustomEquip: [implementation]
(BOOL) - entryIsDictCustomEquip: [implementation]
(BOOL) - entryIsCustomEquip: [implementation]
(NSArray *) - getCustomEquipArray: [implementation]
(NSUInteger) - getCustomEquipIndex: [implementation]
(NSString *) - getCustomEquipKeyDefType: [implementation]
(void) - updateKeyDefinition:index: [implementation]
(void) - updateShiftKeyDefinition:index: [implementation]
(void) - displayKeyFunctionList:skip: [implementation]
(NSArray *) - keyFunctionList [implementation]
(NSString *) - keyboardDescription: [implementation]
(NSArray *) - keyboardLayoutList [implementation]
(void) - displayKeyboardLayoutList:skip: [implementation]
(NSArray *) - validateAllKeys [implementation]
(NSString *) - searchArrayForMatch:key:checkKeys: [implementation]
(BOOL) - entryIsEqualToDefault: [implementation]
(BOOL) - compareKeyEntries:second: [implementation]
(void) - saveKeySetting: [implementation]
(void) - unsetKeySetting: [implementation]
(void) - deleteKeySetting: [implementation]
(void) - deleteAllKeySettings [implementation]
(NSDictionary *) - loadKeySettings [implementation]
(void) - reloadPage [implementation]

Detailed Description

Definition at line 65 of file PlayerEntityKeyMapper.h.

Method Documentation

◆ compareKeyEntries:second:

- (BOOL) compareKeyEntries: (NSDictionary*) first
second: (NSDictionary*) second 
implementation

Extends class PlayerEntity.

Definition at line 1468 of file PlayerEntityKeyMapper.m.

1468 :(NSDictionary*)first second:(NSDictionary*)second
1469{
1470 if ([(NSString*)[first objectForKey:@"key"] integerValue] == [(NSString*)[second objectForKey:@"key"] integerValue]) {
1471 if ([[first objectForKey:@"shift"] boolValue] == [[second objectForKey:@"shift"] boolValue] &&
1472 [[first objectForKey:@"mod1"] boolValue] == [[second objectForKey:@"mod1"] boolValue] &&
1473 [[first objectForKey:@"mod2"] boolValue] == [[second objectForKey:@"mod2"] boolValue])
1474 return YES;
1475 }
1476 return NO;
1477}

◆ deleteAllKeySettings

- (void) deleteAllKeySettings
implementation

Extends class PlayerEntity.

Definition at line 1570 of file PlayerEntityKeyMapper.m.

1571{
1572 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1573 [defaults removeObjectForKey:KEYCONFIG_OVERRIDES];
1574 if ([customEquipActivation count] > 0) {
1575 NSUInteger i;
1576 for (i = 0; i < [customEquipActivation count]; i++) {
1577 NSString* eq = [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY];
1578 OOEquipmentType* item = [OOEquipmentType equipmentTypeWithIdentifier:eq];
1579 if ([item defaultActivateKey])
1580 [[customEquipActivation objectAtIndex:i] setObject:[item defaultActivateKey] forKey:CUSTOMEQUIP_KEYACTIVATE];
1581 else
1582 [[customEquipActivation objectAtIndex:i] removeObjectForKey:CUSTOMEQUIP_KEYACTIVATE];
1583
1584 if ([item defaultModeKey])
1585 [[customEquipActivation objectAtIndex:i] setObject:[item defaultModeKey] forKey:CUSTOMEQUIP_KEYMODE];
1586 else
1587 [[customEquipActivation objectAtIndex:i] removeObjectForKey:CUSTOMEQUIP_KEYMODE];
1588 }
1589 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
1590 }
1591 // reload settings
1592 [self initKeyConfigSettings];
1593}
unsigned count
#define CUSTOMEQUIP_KEYACTIVATE
#define CUSTOMEQUIP_KEYMODE
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)

◆ deleteKeySetting:

- (void) deleteKeySetting: (NSString*) key
implementation

Extends class PlayerEntity.

Definition at line 1553 of file PlayerEntityKeyMapper.m.

1553 :(NSString*)key
1554{
1555 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1556 if (![self entryIsCustomEquip:key]) {
1557 NSMutableDictionary* keyconf = [NSMutableDictionary dictionaryWithDictionary:[defaults objectForKey:KEYCONFIG_OVERRIDES]];
1558 [keyconf removeObjectForKey:key];
1559 [defaults setObject:keyconf forKey:KEYCONFIG_OVERRIDES];
1560 } else {
1561 NSString* custkey = [self getCustomEquipKeyDefType:key];
1562 [[customEquipActivation objectAtIndex:[self getCustomEquipIndex:key]] removeObjectForKey:custkey];
1563 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
1564 }
1565 // reload settings
1566 [self initKeyConfigSettings];
1567}

◆ displayKeyboardLayoutList:skip:

- (void) displayKeyboardLayoutList: (GuiDisplayGen*) gui
skip: (NSUInteger) skip 
implementation

Extends class PlayerEntity.

Definition at line 1207 of file PlayerEntityKeyMapper.m.

1207 :(GuiDisplayGen*)gui skip:(NSUInteger)skip
1208{
1209 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_KC_HEADING];
1210 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-keyconfig-kbd-layout"), nil] forRow:GUI_ROW_KC_HEADING];
1211
1212 if (!kbdLayouts)
1213 kbdLayouts = [[self keyboardLayoutList] retain];
1214
1215 NSUInteger i, n_functions = [kbdLayouts count];
1216 NSInteger n_rows, start_row, previous = 0;
1217
1218 if (skip >= n_functions)
1219 skip = n_functions - 1;
1220
1221 if (n_functions < MAX_ROWS_KC_FUNCTIONS) {
1222 skip = 0;
1223 previous = 0;
1224 n_rows = MAX_ROWS_KC_FUNCTIONS;
1225 start_row = GUI_ROW_KC_FUNCSTART;
1226 } else {
1227 n_rows = MAX_ROWS_KC_FUNCTIONS - 1;
1228 start_row = GUI_ROW_KC_FUNCSTART;
1229 if (skip > 0) {
1230 n_rows -= 1;
1231 start_row += 1;
1232 if (skip > MAX_ROWS_KC_FUNCTIONS)
1233 previous = skip - (MAX_ROWS_KC_FUNCTIONS - 2);
1234 else
1235 previous = 0;
1236 }
1237 }
1238
1239 if (n_functions > 0) {
1240 if (skip > 0) {
1241 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_KC_FUNCSTART];
1242 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil] forRow:GUI_ROW_KC_FUNCSTART];
1243 [gui setKey:[NSString stringWithFormat:@"More:%zd", previous] forRow:GUI_ROW_KC_FUNCSTART];
1244 }
1245
1246 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1247 NSString* kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
1248
1249 for (i = 0; i < (n_functions - skip) && (int)i < n_rows; i++) {
1250 NSDictionary* entry = [kbdLayouts objectAtIndex:i + skip];
1251 NSString* desc = [entry objectForKey:@"description"];
1252 NSString* selected = @"";
1253 if ([[entry objectForKey:@"key"] isEqualToString:kbd])
1254 selected = DESC(@"oolite-keyconfig-kbd-current");
1255 [gui setArray:[NSArray arrayWithObjects:desc, selected, nil] forRow:i + start_row];
1256 [gui setKey:[NSString stringWithFormat:@"Index:%zu", i + skip] forRow:i + start_row];
1257 }
1258 if (i < n_functions - skip) {
1259 [gui setColor:[OOColor greenColor] forRow:start_row + i];
1260 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil] forRow:start_row + i];
1261 [gui setKey:[NSString stringWithFormat:@"More:%zu", n_rows + skip] forRow:start_row + i];
1262 i++;
1263 }
1264
1265 [gui setSelectableRange:NSMakeRange(GUI_ROW_KC_FUNCSTART, i + start_row - GUI_ROW_KC_FUNCSTART)];
1266 }
1267}
#define MAX_ROWS_KC_FUNCTIONS
#define GUI_ROW_KC_FUNCSTART
#define DESC(key)
Definition Universe.h:832
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
OOColor * greenColor()
Definition OOColor.m:264
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

◆ displayKeyFunctionList:skip:

- (void) displayKeyFunctionList: (GuiDisplayGen*) gui
skip: (NSUInteger) skip 
implementation

Extends class PlayerEntity.

Definition at line 764 of file PlayerEntityKeyMapper.m.

764 :(GuiDisplayGen*)gui skip:(NSUInteger)skip
765{
766 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_KC_HEADING];
767 [gui setArray:[NSArray arrayWithObjects:
768 DESC(@"oolite-keyconfig-column-function"), DESC(@"oolite-keyconfig-column-assigned-to"), DESC(@"oolite-keyconfig-column-overrides"), nil]
769 forRow:GUI_ROW_KC_HEADING];
770
771 NSDictionary* overrides = [self loadKeySettings];
772
773 if (!keyFunctions) {
774 keyFunctions = [[self keyFunctionList] retain];
775 }
776
777 NSUInteger i, n_functions = [keyFunctions count];
778 NSInteger n_rows, start_row, previous = 0;
779 NSString* validate = nil;
780
781 if (skip >= n_functions)
782 skip = n_functions - 1;
783
784 if (n_functions < MAX_ROWS_KC_FUNCTIONS) {
785 skip = 0;
786 previous = 0;
787 n_rows = MAX_ROWS_KC_FUNCTIONS;
788 start_row = GUI_ROW_KC_FUNCSTART;
789 } else {
790 n_rows = MAX_ROWS_KC_FUNCTIONS - 1;
791 start_row = GUI_ROW_KC_FUNCSTART;
792 if (skip > 0) {
793 n_rows -= 1;
794 start_row += 1;
795 if (skip > MAX_ROWS_KC_FUNCTIONS)
796 previous = skip - (MAX_ROWS_KC_FUNCTIONS - 2);
797 else
798 previous = 0;
799 }
800 }
801
802 if (n_functions > 0) {
803 if (skip > 0) {
804 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_KC_FUNCSTART];
805 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil] forRow:GUI_ROW_KC_FUNCSTART];
806 [gui setKey:[NSString stringWithFormat:@"More:%zd", previous] forRow:GUI_ROW_KC_FUNCSTART];
807 }
808
809 for (i = 0; i < (n_functions - skip) && (int)i < n_rows; i++) {
810 NSDictionary* entry = [keyFunctions objectAtIndex:i + skip];
811 if ([entry objectForKey:KEY_KC_HEADER]) {
812 NSString* header = [entry objectForKey:KEY_KC_HEADER];
813 [gui setArray:[NSArray arrayWithObjects:header, @"", @"", nil] forRow:i + start_row];
814 [gui setColor:[OOColor cyanColor] forRow:i + start_row];
815 } else {
816 NSString* assignment = nil;
817 NSString* override = nil;
818 if (![self entryIsDictCustomEquip:entry]) {
819 // Find out what's assigned for this function currently.
820 assignment = [PLAYER keyBindingDescription2:[entry objectForKey:KEY_KC_DEFINITION]];
821 override = ([overrides objectForKey:[entry objectForKey:KEY_KC_DEFINITION]] ? @"Yes" : @""); // work out whether this assignment is overriding the setting in keyconfig2.plist
822 validate = [self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray*)[keyconfig2_settings objectForKey:[entry objectForKey:KEY_KC_DEFINITION]]];
823 } else {
824 NSString* custom_keytype = [self getCustomEquipKeyDefType:[entry oo_stringForKey:KEY_KC_DEFINITION]];
825 NSUInteger idx = [self getCustomEquipIndex:[entry oo_stringForKey:KEY_KC_DEFINITION]];
826 assignment = [PLAYER getKeyBindingDescription:[[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype]];
827 OOEquipmentType* item = [OOEquipmentType equipmentTypeWithIdentifier:[[customEquipActivation objectAtIndex:idx] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]];
828 bool result = true;
829 int j, k;
830 NSArray* defArray = nil;
831 NSArray* compArray = nil;
832
833 if ([custom_keytype isEqualToString:CUSTOMEQUIP_KEYACTIVATE]) {
834 defArray = [item defaultActivateKey];
835 compArray = [[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype];
836 }
837 if ([custom_keytype isEqualToString:CUSTOMEQUIP_KEYMODE]) {
838 defArray = [item defaultModeKey];
839 compArray = [[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype];
840 }
841 for (j = 0; j < [defArray count]; j++) {
842 for (k = 0; k < [compArray count]; k++) {
843 if (![self compareKeyEntries:[defArray objectAtIndex:j] second:[compArray objectAtIndex:k]]) {
844 result = false;
845 break;
846 }
847 }
848 if (result == false)
849 break;
850 }
851
852 override = (!result ? @"Yes" : @"");
853 validate = [self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray*)[[customEquipActivation objectAtIndex:idx] oo_arrayForKey:custom_keytype]];
854 }
855 if (assignment == nil) {
856 assignment = @" - ";
857 }
858
859 [gui setArray:[NSArray arrayWithObjects:
860 [entry objectForKey:KEY_KC_GUIDESC], assignment, override, nil]
861 forRow:i + start_row];
862 [gui setKey:[NSString stringWithFormat:@"Index:%zu", i + skip] forRow:i + start_row];
863 if (validate) {
864 [gui setColor:[OOColor orangeColor] forRow:i + start_row];
865 }
866 }
867 }
868 if (i < n_functions - skip) {
869 [gui setColor:[OOColor greenColor] forRow:start_row + i];
870 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil] forRow:start_row + i];
871 [gui setKey:[NSString stringWithFormat:@"More:%zu", n_rows + skip] forRow:start_row + i];
872 i++;
873 }
874
875 [gui setSelectableRange:NSMakeRange(GUI_ROW_KC_SELECTKBD, (i + start_row - GUI_ROW_KC_FUNCSTART) + (GUI_ROW_KC_FUNCSTART - GUI_ROW_KC_SELECTKBD))];
876 }
877}
return nil
#define KEY_KC_HEADER
OOColor * cyanColor()
Definition OOColor.m:274
OOColor * orangeColor()
Definition OOColor.m:289
NSArray * defaultActivateKey()
NSArray * defaultModeKey()

◆ entryIsCustomEquip:

- (BOOL) entryIsCustomEquip: (NSString*) entry
implementation

Extends class PlayerEntity.

Definition at line 308 of file PlayerEntityKeyMapper.m.

308 :(NSString*)entry
309{
310 BOOL result = NO;
311 if ([entry hasPrefix:@"activate_"] || [entry hasPrefix:@"mode_"])
312 result = YES;
313 return result;
314}

◆ entryIsDictCustomEquip:

- (BOOL) entryIsDictCustomEquip: (NSDictionary*) dict
implementation

Extends class PlayerEntity.

Definition at line 303 of file PlayerEntityKeyMapper.m.

303 :(NSDictionary*)dict
304{
305 return [self entryIsCustomEquip:[dict oo_stringForKey:KEY_KC_DEFINITION]];
306}

◆ entryIsEqualToDefault:

- (BOOL) entryIsEqualToDefault: (NSString*) key
implementation

Extends class PlayerEntity.

Definition at line 1451 of file PlayerEntityKeyMapper.m.

1451 :(NSString*)key
1452{
1453 NSArray* def = (NSArray*)[kdic_check objectForKey:key];
1454 NSUInteger i;
1455
1456 if ([def count] != [key_list count])
1457 return NO;
1458 for (i = 0; i < [key_list count]; i++) {
1459 NSDictionary* orig = (NSDictionary*)[def objectAtIndex:i];
1460 NSDictionary* entrd = (NSDictionary*)[key_list objectAtIndex:i];
1461 if (![self compareKeyEntries:orig second:entrd])
1462 return NO;
1463 }
1464 return YES;
1465}
static NSDictionary * kdic_check
static NSMutableArray * key_list

◆ entryIsIndexCustomEquip:

- (BOOL) entryIsIndexCustomEquip: (NSUInteger) idx
implementation

Extends class PlayerEntity.

Definition at line 298 of file PlayerEntityKeyMapper.m.

298 :(NSUInteger)idx
299{
300 return [self entryIsCustomEquip:[[keyFunctions objectAtIndex:idx] oo_stringForKey:KEY_KC_DEFINITION]];
301}

◆ getCustomEquipArray:

- (NSArray *) getCustomEquipArray: (NSString*) key_def
implementation

Extends class PlayerEntity.

Definition at line 316 of file PlayerEntityKeyMapper.m.

316 :(NSString*)key_def
317{
318 NSString* eq = nil;
319 NSUInteger i;
320 NSString* key;
321 if ([key_def hasPrefix:@"activate_"]) {
322 eq = [key_def stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
324 }
325 if ([key_def hasPrefix:@"mode_"]) {
326 eq = [key_def stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
328 }
329 if (eq == nil)
330 return nil;
331 for (i = 0; i < [customEquipActivation count]; i++) {
332 if ([[[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY] isEqualToString:eq]) {
333 return [[customEquipActivation objectAtIndex:i] oo_arrayForKey:key];
334 }
335 }
336 return nil;
337}
#define CUSTOMEQUIP_EQUIPKEY

◆ getCustomEquipIndex:

- (NSUInteger) getCustomEquipIndex: (NSString*) key_def
implementation

Extends class PlayerEntity.

Definition at line 339 of file PlayerEntityKeyMapper.m.

339 :(NSString*)key_def
340{
341 NSString* eq = nil;
342 NSUInteger i;
343 if ([key_def hasPrefix:@"activate_"]) {
344 eq = [key_def stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
345 }
346 if ([key_def hasPrefix:@"mode_"]) {
347 eq = [key_def stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
348 }
349 if (eq == nil)
350 return -1;
351 for (i = 0; i < [customEquipActivation count]; i++) {
352 if ([[[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY] isEqualToString:eq]) {
353 return i;
354 }
355 }
356 return -1;
357}

◆ getCustomEquipKeyDefType:

- (NSString *) getCustomEquipKeyDefType: (NSString*) key_def
implementation

Extends class PlayerEntity.

Definition at line 359 of file PlayerEntityKeyMapper.m.

359 :(NSString*)key_def
360{
361 if ([key_def hasPrefix:@"activate_"]) {
363 }
364 if ([key_def hasPrefix:@"mode_"]) {
365 return CUSTOMEQUIP_KEYMODE;
366 }
367 return @"";
368}

◆ handleKeyboardLayoutEntryKeys:view:

- (void) handleKeyboardLayoutEntryKeys: (GuiDisplayGen*) gui
view: (MyOpenGLView*) gameView 

Extends class PlayerEntity.

Definition at line 1105 of file PlayerEntityKeyMapper.m.

1105 :(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
1106{
1107 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
1108 [self handleGUIUpDownArrowKeys];
1109 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
1110 if ([gameView isDown:gvMouseDoubleClick])
1111 [gameView clearMouse];
1112
1113 NSString* key = [gui keyForRow:[gui selectedRow]];
1114 if (selectKeyPress) {
1115 if ([key hasPrefix:@"More:"]) {
1116 int from_function = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
1117 if (from_function < 0)
1118 from_function = 0;
1119
1121 if (from_function == 0)
1123 [self setGuiToKeyboardLayoutScreen:from_function];
1124 if ([gameView isDown:gvMouseDoubleClick])
1125 [gameView clearMouse];
1126 return;
1127 }
1128
1129 // update the keyboard code
1130 NSUInteger idx = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
1131 NSString* kbd = [[kbdLayouts objectAtIndex:idx] objectForKey:@"key"];
1132 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1133 [defaults setObject:kbd forKey:@"keyboard-code"];
1134 [self initKeyConfigSettings];
1135 [self initCheckingDictionary];
1136
1137 [gameView clearKeys]; // try to stop key bounces
1138 [self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
1139 }
1140 if ([gameView isDown:27]) // escape - return without change
1141 {
1142 [gameView clearKeys]; // try to stop key bounces
1143 [self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
1144 }
1145}
@ gvMouseDoubleClick
static long current_row
OOGUIRow selectedRow
NSString * keyForRow:(OOGUIRow row)
BOOL isDown:(int key)
const BOOL * getAllButtonStates()

References PlayerEntity::checkKeyPress:, MyOpenGLView::clearKeys, MyOpenGLView::clearMouse, current_row, OOJoystickManager::getAllButtonStates, GUI_ROW_KC_FUNCSTART, gvMouseDoubleClick, PlayerEntity::handleGUIUpDownArrowKeys, PlayerEntity::initCheckingDictionary, PlayerEntity::initKeyConfigSettings, MyOpenGLView::isDown:, GuiDisplayGen::keyForRow:, MAX_ROWS_KC_FUNCTIONS, GuiDisplayGen::selectedRow, PlayerEntity::setGuiToKeyboardLayoutScreen:, PlayerEntity::setGuiToKeyMapperScreen:resetCurrentRow:, and OOJoystickManager::sharedStickHandler.

Here is the call graph for this function:

◆ handleKeyConfigEntryKeys:view:

- (void) handleKeyConfigEntryKeys: (GuiDisplayGen*) gui
view: (MyOpenGLView*) gameView 

Extends class PlayerEntity.

Definition at line 601 of file PlayerEntityKeyMapper.m.

601 :(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
602{
603 NSUInteger end_row = 21;
604 if ([[self hud] allowBigGui]) {
605 end_row = 27;
606 }
607
608 [self handleGUIUpDownArrowKeys];
609 if ([gameView lastKeyWasShifted])
610 last_shift = YES;
611
612 [gui setText:
613 [NSString stringWithFormat:@"%@: %@", DESC(@"oolite-keyconfig-update-key"), [gameView typedString]]
614 forRow:end_row];
615 [gui setColor:[OOColor cyanColor] forRow:end_row];
616
617 if ([self checkKeyPress:n_key_gui_select]) {
618 [gameView suppressKeysUntilKeyUp];
619 // update function key
620 [self updateKeyDefinition:[gameView typedString] index:key_index];
621 [gameView clearKeys]; // try to stop key bounces
622 [self setGuiToKeyConfigScreen:YES];
623 }
624 if ([gameView isDown:27]) // escape
625 {
626 [gameView suppressKeysUntilKeyUp];
627 // don't update function key
628 [self setGuiToKeyConfigScreen:YES];
629 }
630}
static BOOL last_shift
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
NSMutableString * typedString

References MyOpenGLView::clearKeys, OOColor::cyanColor, PlayerEntity::handleGUIUpDownArrowKeys, last_shift, GuiDisplayGen::setColor:forRow:, PlayerEntity::setGuiToKeyConfigScreen:, GuiDisplayGen::setText:forRow:, MyOpenGLView::suppressKeysUntilKeyUp, MyOpenGLView::typedString, and PlayerEntity::updateKeyDefinition:index:.

Here is the call graph for this function:

◆ handleKeyConfigKeys:view:

- (void) handleKeyConfigKeys: (GuiDisplayGen*) gui
view: (MyOpenGLView*) gameView 

Extends class PlayerEntity.

Definition at line 514 of file PlayerEntityKeyMapper.m.

514 :(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
515{
516 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
517 [self handleGUIUpDownArrowKeys];
518 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
519 if ([gameView isDown:gvMouseDoubleClick])
520 [gameView clearMouse];
521
522 if (selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_KEY || [gui selectedRow] == (GUI_ROW_KC_KEY + 5))) {
523 key_index = ([gui selectedRow] == GUI_ROW_KC_KEY ? 0 : 1);
524 [self setGuiToKeyConfigEntryScreen];
525 }
526
527 if (selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_SHIFT || [gui selectedRow] == (GUI_ROW_KC_SHIFT + 5))) {
528 [self updateShiftKeyDefinition:@"shift" index:([gui selectedRow] == GUI_ROW_KC_SHIFT ? 0 : 1)];
529 [self setGuiToKeyConfigScreen];
530 }
531 if (selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_MOD1 || [gui selectedRow] == (GUI_ROW_KC_MOD1 + 5))) {
532 [self updateShiftKeyDefinition:@"mod1" index:([gui selectedRow] == GUI_ROW_KC_MOD1 ? 0 : 1)];
533 [self setGuiToKeyConfigScreen];
534 }
535 if (selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_MOD2 || [gui selectedRow] == (GUI_ROW_KC_MOD2 + 5))) {
536 [self updateShiftKeyDefinition:@"mod2" index:([gui selectedRow] == GUI_ROW_KC_MOD2 ? 0 : 1)];
537 [self setGuiToKeyConfigScreen];
538 }
539
540 if (selectKeyPress && [gui selectedRow] == GUI_ROW_KC_SAVE) {
541 [self saveKeySetting:[selected_entry objectForKey:KEY_KC_DEFINITION]];
542 [self reloadPage];
543 }
544
545 if ((selectKeyPress && [gui selectedRow] == GUI_ROW_KC_CANCEL) || [gameView isDown:27]) {
546 // esc or Cancel was pressed - get out of here
547 [self reloadPage];
548 }
549}
#define GUI_ROW_KC_MOD2
#define GUI_ROW_KC_SAVE
#define GUI_ROW_KC_SHIFT
#define GUI_ROW_KC_MOD1
#define GUI_ROW_KC_CANCEL
#define GUI_ROW_KC_KEY
static NSUInteger key_index

References PlayerEntity::checkKeyPress:, MyOpenGLView::clearMouse, OOJoystickManager::getAllButtonStates, GUI_ROW_KC_CANCEL, GUI_ROW_KC_KEY, GUI_ROW_KC_MOD1, GUI_ROW_KC_MOD2, GUI_ROW_KC_SAVE, GUI_ROW_KC_SHIFT, gvMouseDoubleClick, PlayerEntity::handleGUIUpDownArrowKeys, MyOpenGLView::isDown:, key_index, PlayerEntity::reloadPage, PlayerEntity::saveKeySetting:, GuiDisplayGen::selectedRow, PlayerEntity::setGuiToKeyConfigEntryScreen, PlayerEntity::setGuiToKeyConfigScreen, OOJoystickManager::sharedStickHandler, and PlayerEntity::updateShiftKeyDefinition:index:.

Here is the call graph for this function:

◆ handleKeyMapperConfirmClearKeys:view:

- (void) handleKeyMapperConfirmClearKeys: (GuiDisplayGen*) gui
view: (MyOpenGLView*) gameView 

Extends class PlayerEntity.

Definition at line 734 of file PlayerEntityKeyMapper.m.

734 :(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
735{
736 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
737 [self handleGUIUpDownArrowKeys];
738
739 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
740 if ([gameView isDown:gvMouseDoubleClick])
741 [gameView clearMouse];
742
743 // Translation issue: we can't confidently use raw Y and N ascii as shortcuts. It's better to use the load-previous-commander keys.
744 id valueYes = [[[UNIVERSE descriptions] oo_stringForKey:@"load-previous-commander-yes" defaultValue:@"y"] lowercaseString];
745 id valueNo = [[[UNIVERSE descriptions] oo_stringForKey:@"load-previous-commander-no" defaultValue:@"n"] lowercaseString];
746 unsigned char cYes, cNo;
747
748 cYes = [valueYes characterAtIndex:0] & 0x00ff; // Use lower byte of unichar.
749 cNo = [valueNo characterAtIndex:0] & 0x00ff; // Use lower byte of unichar.
750
751 if ((selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_CONFIRMCLEAR_YES)) || [gameView isDown:cYes] || [gameView isDown:cYes - 32]) {
752 [self deleteAllKeySettings];
753 [gameView suppressKeysUntilKeyUp];
754 [self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
755 }
756
757 if ((selectKeyPress && ([gui selectedRow] == GUI_ROW_KC_CONFIRMCLEAR_NO)) || [gameView isDown:27] || [gameView isDown:cNo] || [gameView isDown:cNo - 32]) {
758 // esc or NO was pressed - get out of here
759 [gameView suppressKeysUntilKeyUp];
760 [self setGuiToKeyMapperScreen:0 resetCurrentRow:YES];
761 }
762}
#define GUI_ROW_KC_CONFIRMCLEAR_YES
#define GUI_ROW_KC_CONFIRMCLEAR_NO

References PlayerEntity::checkKeyPress:, MyOpenGLView::clearMouse, PlayerEntity::deleteAllKeySettings, OOJoystickManager::getAllButtonStates, GUI_ROW_KC_CONFIRMCLEAR_NO, GUI_ROW_KC_CONFIRMCLEAR_YES, gvMouseDoubleClick, PlayerEntity::handleGUIUpDownArrowKeys, MyOpenGLView::isDown:, PlayerEntity::setGuiToKeyMapperScreen:resetCurrentRow:, OOJoystickManager::sharedStickHandler, and MyOpenGLView::suppressKeysUntilKeyUp.

Here is the call graph for this function:

◆ initCheckingDictionary

- (void) initCheckingDictionary

Extends class PlayerEntity.

Definition at line 78 of file PlayerEntityKeyMapper.m.

79{
80 NSMutableDictionary* kdicmaster = [NSMutableDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keyconfig2.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
81 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
82 NSString* kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
83 NSMutableDictionary* kdic = [NSMutableDictionary dictionaryWithDictionary:[kdicmaster objectForKey:kbd]];
84
85 NSUInteger i;
86 NSArray* keys = nil;
87 id key = nil;
88 NSArray* def_list = nil;
89
90 keys = [kdic allKeys];
91 for (i = 0; i < [keys count]; i++) {
92 key = [keys objectAtIndex:i];
93
94 if ([[kdic objectForKey:key] isKindOfClass:[NSArray class]]) {
95 def_list = (NSArray*)[kdic objectForKey:key];
96 [kdic setObject:[self processKeyCode:def_list] forKey:key];
97 }
98 }
99 [kdic_check release];
100 kdic_check = [[NSDictionary alloc] initWithDictionary:kdic];
101
102 // these keys can't be used with mod keys
103 [nav_keys release];
104 nav_keys = [[NSArray alloc] initWithObjects:@"key_roll_left", @"key_roll_right", @"key_pitch_forward", @"key_pitch_back", @"key_yaw_left", @"key_yaw_right",
105 @"key_fire_lasers", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_arrow_right", @"key_gui_arrow_left", nil];
106 // these keys can't be used with ctrl
107 [camera_keys release];
108 camera_keys = [[NSArray alloc] initWithObjects:@"key_custom_view_zoom_out", @"key_custom_view_zoom_in", @"key_custom_view_roll_left", @"key_custom_view_roll_right",
109 @"key_custom_view_pan_left", @"key_custom_view_pan_right", @"key_custom_view_rotate_up", @"key_custom_view_rotate_down", @"key_custom_view_pan_down",
110 @"key_custom_view_pan_up", @"key_custom_view_rotate_left", @"key_custom_view_rotate_right", nil];
111}
static NSArray * nav_keys
static NSArray * camera_keys
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)

References camera_keys, ResourceManager::dictionaryFromFilesNamed:inFolder:mergeMode:cache:, initCheckingDictionary, kdic_check, nav_keys, nil, and PlayerEntity::processKeyCode:.

Referenced by initCheckingDictionary.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keyboardDescription:

- (NSString *) keyboardDescription: (NSString*) kbd
implementation

Extends class PlayerEntity.

Definition at line 1147 of file PlayerEntityKeyMapper.m.

1147 :(NSString*)kbd
1148{
1149 NSString* map = @"";
1150#if OOLITE_WINDOWS
1151 map = @"keymappings_windows.plist";
1152#endif
1153#if OOLITE_LINUX
1154 map = @"keymappings_linux.plist";
1155#endif
1156#if OOLITE_MAC_COCOA_UI
1157 map = @"keymappings_mac.plist";
1158#endif
1159 NSDictionary* kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:map inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
1160 NSDictionary* sect = [kmap objectForKey:kbd];
1161 return [sect objectForKey:@"description"];
1162}

◆ keyboardLayoutList

- (NSArray *) keyboardLayoutList
implementation

Extends class PlayerEntity.

Definition at line 1164 of file PlayerEntityKeyMapper.m.

1165{
1166 NSString* map = @"";
1167#if OOLITE_WINDOWS
1168 map = @"keymappings_windows.plist";
1169#endif
1170#if OOLITE_LINUX
1171 map = @"keymappings_linux.plist";
1172#endif
1173#if OOLITE_MAC_COCOA_UI
1174 map = @"keymappings_mac.plist";
1175#endif
1176 NSDictionary* kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:map inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
1177 NSMutableArray* kbdList = [NSMutableArray array];
1178 NSArray* keys = [kmap allKeys];
1179 NSUInteger i;
1180 NSDictionary* def = nil;
1181
1182 for (i = 0; i < [keys count]; i++) {
1183 if (![[keys objectAtIndex:i] isEqualToString:@"default"]) {
1184 [kbdList addObject:[[NSDictionary alloc] initWithObjectsAndKeys:[keys objectAtIndex:i], @"key",
1185 [self keyboardDescription:[keys objectAtIndex:i]], @"description",
1186 //([[keys objectAtIndex:i] isEqualToString:kbd] ? @"Current" : @""), @"selected",
1187 nil]];
1188 } else {
1189 // key the "default" item separate, so we can add it at the top of the list, rather than getting it sorted
1190 def = [[NSDictionary alloc] initWithObjectsAndKeys:[keys objectAtIndex:i], @"key",
1191 [self keyboardDescription:[keys objectAtIndex:i]], @"description",
1192 //([[keys objectAtIndex:i] isEqualToString:kbd] ? @"Current" : @""), @"selected",
1193 nil];
1194 }
1195 }
1196
1197 NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"description" ascending:YES];
1198 NSArray* sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
1199 NSMutableArray* sorted = [NSMutableArray arrayWithArray:[kbdList sortedArrayUsingDescriptors:sortDescriptors]];
1200 [sorted insertObject:def atIndex:0];
1201
1202 [sortDescriptor release];
1203
1204 return sorted;
1205}

References ResourceManager::dictionaryFromFilesNamed:inFolder:mergeMode:cache:, PlayerEntity::keyboardDescription:, keyboardLayoutList, and nil.

Referenced by keyboardLayoutList.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keyFunctionList

- (NSArray *) keyFunctionList
implementation

Extends class PlayerEntity.

Definition at line 879 of file PlayerEntityKeyMapper.m.

880{
881 NSMutableArray* funcList = [NSMutableArray array];
882
883 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-screen-access")]];
884 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_ship") keyDef:@"key_launch_ship"]];
885 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_options") keyDef:@"key_gui_screen_options"]];
886 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_equipship") keyDef:@"key_gui_screen_equipship"]];
887 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_interfaces") keyDef:@"key_gui_screen_interfaces"]];
888 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_screen_status") keyDef:@"key_gui_screen_status"]];
889 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_chart_screens") keyDef:@"key_gui_chart_screens"]];
890 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_system_data") keyDef:@"key_gui_system_data"]];
891 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_market") keyDef:@"key_gui_market"]];
892
893 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-propulsion")]];
894 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_roll_left") keyDef:@"key_roll_left"]];
895 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_roll_right") keyDef:@"key_roll_right"]];
896 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pitch_forward") keyDef:@"key_pitch_forward"]];
897 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pitch_back") keyDef:@"key_pitch_back"]];
898 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_yaw_left") keyDef:@"key_yaw_left"]];
899 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_yaw_right") keyDef:@"key_yaw_right"]];
900
901 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_increase_speed") keyDef:@"key_increase_speed"]];
902 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_decrease_speed") keyDef:@"key_decrease_speed"]];
903 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_inject_fuel") keyDef:@"key_inject_fuel"]];
904 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_jumpdrive") keyDef:@"key_jumpdrive"]];
905 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_hyperspace") keyDef:@"key_hyperspace"]];
906 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_galactic_hyperspace") keyDef:@"key_galactic_hyperspace"]];
907
908 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-navigation")]];
909 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_compass_mode") keyDef:@"key_next_compass_mode"]];
910 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prev_compass_mode") keyDef:@"key_prev_compass_mode"]];
911 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_scanner_zoom") keyDef:@"key_scanner_zoom"]];
912 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_scanner_unzoom") keyDef:@"key_scanner_unzoom"]];
913 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_forward") keyDef:@"key_view_forward"]];
914 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_aft") keyDef:@"key_view_aft"]];
915 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_port") keyDef:@"key_view_port"]];
916 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_view_starboard") keyDef:@"key_view_starboard"]];
917 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_ident_system") keyDef:@"key_ident_system"]];
918
919 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_docking_clearance_request") keyDef:@"key_docking_clearance_request"]];
920 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_autopilot") keyDef:@"key_autopilot"]];
921 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_autodock") keyDef:@"key_autodock"]];
922 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_docking_music") keyDef:@"key_docking_music"]];
923
924 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-offensive")]];
925 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_weapons_online_toggle") keyDef:@"key_weapons_online_toggle"]];
926 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fire_lasers") keyDef:@"key_fire_lasers"]];
927 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_missile") keyDef:@"key_launch_missile"]];
928 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_target_missile") keyDef:@"key_target_missile"]];
929 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_untarget_missile") keyDef:@"key_untarget_missile"]];
930 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_target_incoming_missile") keyDef:@"key_target_incoming_missile"]];
931 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_missile") keyDef:@"key_next_missile"]];
932 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_next_target") keyDef:@"key_next_target"]];
933 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_previous_target") keyDef:@"key_previous_target"]];
934
935 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-defensive")]];
936 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_ecm") keyDef:@"key_ecm"]];
937 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_cargo") keyDef:@"key_dump_cargo"]];
938 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_rotate_cargo") keyDef:@"key_rotate_cargo"]];
939 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_launch_escapepod") keyDef:@"key_launch_escapepod"]];
940
941 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-special-equip")]];
942 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_cycle_next_mfd") keyDef:@"key_cycle_next_mfd"]];
943 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_cycle_previous_mfd") keyDef:@"key_cycle_previous_mfd"]];
944 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_switch_next_mfd") keyDef:@"key_switch_next_mfd"]];
945 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_switch_previous_mfd") keyDef:@"key_switch_previous_mfd"]];
946
947 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prime_next_equipment") keyDef:@"key_prime_next_equipment"]];
948 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_prime_previous_equipment") keyDef:@"key_prime_previous_equipment"]];
949 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_activate_equipment") keyDef:@"key_activate_equipment"]];
950 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mode_equipment") keyDef:@"key_mode_equipment"]];
951 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fastactivate_equipment_a") keyDef:@"key_fastactivate_equipment_a"]];
952 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_fastactivate_equipment_b") keyDef:@"key_fastactivate_equipment_b"]];
953
954 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-chart-screen")]];
955 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_advanced_nav_array_next") keyDef:@"key_advanced_nav_array_next"]];
956 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_advanced_nav_array_previous") keyDef:@"key_advanced_nav_array_previous"]];
957 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_home") keyDef:@"key_map_home"]];
958 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_end") keyDef:@"key_map_end"]];
959 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_info") keyDef:@"key_map_info"]];
960 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_zoom_in") keyDef:@"key_map_zoom_in"]];
961 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_zoom_out") keyDef:@"key_map_zoom_out"]];
962 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_next_system") keyDef:@"key_map_next_system"]];
963 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_map_previous_system") keyDef:@"key_map_previous_system"]];
964 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_chart_highlight") keyDef:@"key_chart_highlight"]];
965
966 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-planet-info-screen")]];
967 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_home") keyDef:@"key_system_home"]];
968 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_end") keyDef:@"key_system_end"]];
969 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_next_system") keyDef:@"key_system_next_system"]];
970 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_system_previous_system") keyDef:@"key_system_previous_system"]];
971
972 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-market-screen")]];
973 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_filter_cycle") keyDef:@"key_market_filter_cycle"]];
974 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sorter_cycle") keyDef:@"key_market_sorter_cycle"]];
975 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_buy_one") keyDef:@"key_market_buy_one"]];
976 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sell_one") keyDef:@"key_market_sell_one"]];
977 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_buy_max") keyDef:@"key_market_buy_max"]];
978 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_market_sell_max") keyDef:@"key_market_sell_max"]];
979
980 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-misc")]];
981 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_snapshot") keyDef:@"key_snapshot"]];
982 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_pausebutton") keyDef:@"key_pausebutton"]];
983 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_show_fps") keyDef:@"key_show_fps"]];
984 //[funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_bloom_toggle") keyDef:@"key_bloom_toggle"]];
985 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mouse_control_roll") keyDef:@"key_mouse_control_roll"]];
986 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_mouse_control_yaw") keyDef:@"key_mouse_control_yaw"]];
987 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_hud_toggle") keyDef:@"key_hud_toggle"]];
988#if OO_FOV_INFLIGHT_CONTROL_ENABLED
989 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_inc_field_of_view") keyDef:@"key_inc_field_of_view"]];
990 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dec_field_of_view") keyDef:@"key_dec_field_of_view"]];
991#endif
992 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_comms_log") keyDef:@"key_comms_log"]];
993
994 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-custom-view")]];
995 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view") keyDef:@"key_custom_view"]];
996 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_zoom_in") keyDef:@"key_custom_view_zoom_in"]];
997 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_zoom_out") keyDef:@"key_custom_view_zoom_out"]];
998 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_roll_left") keyDef:@"key_custom_view_roll_left"]];
999 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_roll_right") keyDef:@"key_custom_view_roll_right"]];
1000 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_left") keyDef:@"key_custom_view_pan_left"]];
1001 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_right") keyDef:@"key_custom_view_pan_right"]];
1002 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_up") keyDef:@"key_custom_view_pan_up"]];
1003 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_pan_down") keyDef:@"key_custom_view_pan_down"]];
1004 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_left") keyDef:@"key_custom_view_rotate_left"]];
1005 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_right") keyDef:@"key_custom_view_rotate_right"]];
1006 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_up") keyDef:@"key_custom_view_rotate_up"]];
1007 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_custom_view_rotate_down") keyDef:@"key_custom_view_rotate_down"]];
1008
1009 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-oxz-manager")]];
1010 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_setfilter") keyDef:@"key_oxzmanager_setfilter"]];
1011 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_showinfo") keyDef:@"key_oxzmanager_showinfo"]];
1012 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_oxzmanager_extract") keyDef:@"key_oxzmanager_extract"]];
1013
1014 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-gui")]];
1015 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_left") keyDef:@"key_gui_arrow_left"]];
1016 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_right") keyDef:@"key_gui_arrow_right"]];
1017 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_up") keyDef:@"key_gui_arrow_up"]];
1018 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_arrow_down") keyDef:@"key_gui_arrow_down"]];
1019 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_page_down") keyDef:@"key_gui_page_down"]];
1020 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_page_up") keyDef:@"key_gui_page_up"]];
1021 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_gui_select") keyDef:@"key_gui_select"]];
1022
1023 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-debug")]];
1024 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_target_state") keyDef:@"key_dump_target_state"]];
1025 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_dump_entity_list") keyDef:@"key_dump_entity_list"]];
1026 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_full") keyDef:@"key_debug_full"]];
1027 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_collision") keyDef:@"key_debug_collision"]];
1028 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_console_connect") keyDef:@"key_debug_console_connect"]];
1029 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_bounding_boxes") keyDef:@"key_debug_bounding_boxes"]];
1030 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_shaders") keyDef:@"key_debug_shaders"]];
1031 [funcList addObject:[self makeKeyGuiDict:DESC(@"oolite-keydesc-key_debug_off") keyDef:@"key_debug_off"]];
1032
1033 if ([customEquipActivation count] > 0) {
1034 [funcList addObject:[self makeKeyGuiDictHeader:DESC(@"oolite-keydesc-header-oxp-equip")]];
1035 int i;
1036 for (i = 0; i < [customEquipActivation count]; i++) {
1037 [funcList addObject:[self makeKeyGuiDict:[NSString stringWithFormat:@"%@ '%@'", DESC(@"oolite-keyconfig-cust-activate"), [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
1038 keyDef:[NSString stringWithFormat:@"activate_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]]];
1039 [funcList addObject:[self makeKeyGuiDict:[NSString stringWithFormat:@"%@ '%@'", DESC(@"oolite-keyconfig-cust-mode"), [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
1040 keyDef:[NSString stringWithFormat:@"mode_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]]];
1041 }
1042 }
1043 return funcList;
1044}

◆ keyMapperInputHandler:view:

- (void) keyMapperInputHandler: (GuiDisplayGen*) gui
view: (MyOpenGLView*) gameView 

Extends class PlayerEntity.

Definition at line 189 of file PlayerEntityKeyMapper.m.

189 :(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
190{
191 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
192 [self handleGUIUpDownArrowKeys];
193 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
194 if ([gameView isDown:gvMouseDoubleClick])
195 [gameView clearMouse];
196
197 NSString* key = [gui keyForRow:[gui selectedRow]];
198 if ([key hasPrefix:@"Index:"])
199 selFunctionIdx = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
200 else
201 selFunctionIdx = -1;
202
203 if (selectKeyPress) {
204 if ([key hasPrefix:@"More:"]) {
205 int from_function = [[[key componentsSeparatedByString:@":"] objectAtIndex:1] intValue];
206 if (from_function < 0)
207 from_function = 0;
208
210 if (from_function == 0)
212 [self setGuiToKeyMapperScreen:from_function];
213 if ([gameView isDown:gvMouseDoubleClick])
214 [gameView clearMouse];
215 return;
216 }
217 if ([key hasPrefix:@"kbd:"]) {
218 [self setGuiToKeyboardLayoutScreen:0];
219 if ([gameView isDown:gvMouseDoubleClick])
220 [gameView clearMouse];
221 return;
222 }
223 current_row = [gui selectedRow];
224 selected_entry = [keyFunctions objectAtIndex:selFunctionIdx];
225 [key_list release];
226 if (![self entryIsDictCustomEquip:selected_entry]) {
227 key_list = [[NSMutableArray alloc] initWithArray:(NSArray*)[keyconfig2_settings objectForKey:[selected_entry objectForKey:KEY_KC_DEFINITION]] copyItems:YES];
228 } else {
229 key_list = [[NSMutableArray alloc] initWithArray:[self getCustomEquipArray:[selected_entry oo_stringForKey:KEY_KC_DEFINITION]]];
230 }
231 [gameView clearKeys]; // try to stop key bounces
232 [self setGuiToKeyConfigScreen:YES];
233 }
234
235 if ([gameView isDown:'u']) {
236 // pressed 'u' on an "more" line
237 if ([key hasPrefix:@"More:"])
238 return;
239
240 current_row = [gui selectedRow];
241 [self unsetKeySetting:[[keyFunctions objectAtIndex:selFunctionIdx] objectForKey:KEY_KC_DEFINITION]];
242 [self reloadPage];
243 }
244
245 if ([gameView isDown:'r']) {
246 // reset single entry or all
247 if (![gameView isCtrlDown]) {
248 // pressed 'r' on an "more" line
249 if ([key hasPrefix:@"More:"])
250 return;
251
252 current_row = [gui selectedRow];
253
254 NSString* delkey = [[keyFunctions objectAtIndex:selFunctionIdx] objectForKey:KEY_KC_DEFINITION];
255 [self deleteKeySetting:delkey];
256 // special case - when default activate/mode key set in custom equipment
257 if ([self entryIsCustomEquip:delkey]) {
258 int idx = [self getCustomEquipIndex:delkey];
259 NSString* eq = nil;
260 NSString* lookupKey = nil;
261 bool update = false;
262
263 if ([delkey hasPrefix:@"activate_"]) {
264 eq = [delkey stringByReplacingOccurrencesOfString:@"activate_" withString:@""];
265 lookupKey = CUSTOMEQUIP_KEYACTIVATE;
266 }
267 if ([delkey hasPrefix:@"mode_"]) {
268 eq = [delkey stringByReplacingOccurrencesOfString:@"mode_" withString:@""];
269 lookupKey = CUSTOMEQUIP_KEYMODE;
270 }
271
272 OOEquipmentType* item = [OOEquipmentType equipmentTypeWithIdentifier:eq];
273
274 if ([item defaultActivateKey] && [lookupKey isEqualToString:CUSTOMEQUIP_KEYACTIVATE]) {
275 [[customEquipActivation objectAtIndex:idx] setObject:[item defaultActivateKey] forKey:lookupKey];
276 update = true;
277 }
278 if ([item defaultModeKey] && [lookupKey isEqualToString:CUSTOMEQUIP_KEYMODE]) {
279 [[customEquipActivation objectAtIndex:idx] setObject:[item defaultModeKey] forKey:lookupKey];
280 update = true;
281 }
282
283 if (update) {
284 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
285 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
286 }
287 }
288
289 [self reloadPage];
290 } else {
291 [self setGuiToConfirmClearScreen];
292 }
293 }
294 if ([gameView isDown:' '] && !has_error)
295 [self setGuiToGameOptionsScreen];
296}
static NSDictionary * selected_entry
static BOOL has_error

References PlayerEntity::checkKeyPress:, MyOpenGLView::clearKeys, MyOpenGLView::clearMouse, current_row, CUSTOMEQUIP_KEYACTIVATE, CUSTOMEQUIP_KEYMODE, OOEquipmentType::defaultActivateKey, OOEquipmentType::defaultModeKey, PlayerEntity::deleteKeySetting:, OOEquipmentType::equipmentTypeWithIdentifier:, OOJoystickManager::getAllButtonStates, PlayerEntity::getCustomEquipArray:, PlayerEntity::getCustomEquipIndex:, GUI_ROW_KC_FUNCSTART, gvMouseDoubleClick, PlayerEntity::handleGUIUpDownArrowKeys, has_error, MyOpenGLView::isDown:, key_list, GuiDisplayGen::keyForRow:, MAX_ROWS_KC_FUNCTIONS, nil, PlayerEntity::reloadPage, selected_entry, GuiDisplayGen::selectedRow, PlayerEntity::setGuiToConfirmClearScreen, PlayerEntity::setGuiToGameOptionsScreen, PlayerEntity::setGuiToKeyboardLayoutScreen:, PlayerEntity::setGuiToKeyConfigScreen:, PlayerEntity::setGuiToKeyMapperScreen:, OOJoystickManager::sharedStickHandler, and PlayerEntity::unsetKeySetting:.

Here is the call graph for this function:

◆ loadKeySettings

- (NSDictionary *) loadKeySettings
implementation

Extends class PlayerEntity.

Definition at line 1596 of file PlayerEntityKeyMapper.m.

1597{
1598 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1599 return [defaults objectForKey:KEYCONFIG_OVERRIDES];
1600}

◆ makeKeyGuiDict:keyDef:

- (NSDictionary *) makeKeyGuiDict: (NSString*) what
keyDef: (NSString*) keyDef 

Extends class PlayerEntity.

Definition at line 1046 of file PlayerEntityKeyMapper.m.

1046 :(NSString*)what keyDef:(NSString*)key_def
1047{
1048 NSMutableDictionary* guiDict = [NSMutableDictionary dictionary];
1049 if ([what length] > 50)
1050 what = [[what substringToIndex:48] stringByAppendingString:@"..."];
1051 [guiDict setObject:what forKey:KEY_KC_GUIDESC];
1052 [guiDict setObject:key_def forKey:KEY_KC_DEFINITION];
1053 return guiDict;
1054}

◆ makeKeyGuiDictHeader:

- (NSDictionary *) makeKeyGuiDictHeader: (NSString*) header

Extends class PlayerEntity.

Definition at line 1056 of file PlayerEntityKeyMapper.m.

1056 :(NSString*)header
1057{
1058 NSMutableDictionary* guiDict = [NSMutableDictionary dictionary];
1059 [guiDict setObject:header forKey:KEY_KC_HEADER];
1060 [guiDict setObject:@"" forKey:KEY_KC_GUIDESC];
1061 [guiDict setObject:@"" forKey:KEY_KC_DEFINITION];
1062 return guiDict;
1063}

◆ outputKeyDefinition:shift:mod1:mod2:skiprows:

- (void) outputKeyDefinition: (NSString*) key
shift: (NSString*) shift
mod1: (NSString*) mod1
mod2: (NSString*) mod2
skiprows: (NSUInteger) skiprows 

Extends class PlayerEntity.

Definition at line 471 of file PlayerEntityKeyMapper.m.

471 :(NSString*)key shift:(NSString*)shift mod1:(NSString*)mod1 mod2:(NSString*)mod2 skiprows:(NSUInteger)skiprows
472{
473 GuiDisplayGen* gui = [UNIVERSE gui];
474
475 [gui setArray:[NSArray arrayWithObjects:
476 (skiprows == 0 ? DESC(@"oolite-keyconfig-update-key") : DESC(@"oolite-keyconfig-update-alternate")), key, nil]
477 forRow:GUI_ROW_KC_KEY + skiprows];
478 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_KEY + skiprows];
479
480 if (![nav_keys containsObject:[selected_entry objectForKey:KEY_KC_DEFINITION]]) {
481 if (![key isEqualToString:DESC(@"oolite-keycode-unset")]) {
482 [gui setArray:[NSArray arrayWithObjects:
483 DESC(@"oolite-keyconfig-update-shift"), shift, nil]
484 forRow:GUI_ROW_KC_SHIFT + skiprows];
485 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_SHIFT + skiprows];
486
487 // camera movement keys can't use ctrl
488 if (![camera_keys containsObject:[selected_entry objectForKey:KEY_KC_DEFINITION]]) {
489 [gui setArray:[NSArray arrayWithObjects:
490 DESC(@"oolite-keyconfig-update-mod1"), mod1, nil]
491 forRow:GUI_ROW_KC_MOD1 + skiprows];
492 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_MOD1 + skiprows];
493 } else {
494 [gui setArray:[NSArray arrayWithObjects:
495 DESC(@"oolite-keyconfig-update-mod1"), DESC(@"not-applicable"), nil]
496 forRow:GUI_ROW_KC_MOD1 + skiprows];
497 }
498
499#if OOLITE_MAC_COCOA_UI
500 [gui setArray:[NSArray arrayWithObjects:
501 DESC(@"oolite-keyconfig-update-mod2-mac"), mod2, nil]
502 forRow:GUI_ROW_KC_MOD2 + skiprows];
503#else
504 [gui setArray:[NSArray arrayWithObjects:
505 DESC(@"oolite-keyconfig-update-mod2-pc"), mod2, nil]
506 forRow:GUI_ROW_KC_MOD2 + skiprows];
507#endif
508 [gui setKey:GUI_KEY_OK
509 forRow:GUI_ROW_KC_MOD2 + skiprows];
510 }
511 }
512}
#define KEY_KC_DEFINITION

References camera_keys, DESC, KEY_KC_DEFINITION, nav_keys, selected_entry, GuiDisplayGen::setArray:forRow:, and GuiDisplayGen::setKey:forRow:.

Here is the call graph for this function:

◆ reloadPage

- (void) reloadPage
implementation

Extends class PlayerEntity.

Definition at line 1603 of file PlayerEntityKeyMapper.m.

1604{
1605 // Update the GUI (this will refresh the function list).
1606 unsigned skip;
1607 if (selFunctionIdx < MAX_ROWS_KC_FUNCTIONS - 1) {
1608 skip = 0;
1609 } else {
1610 skip = ((selFunctionIdx - 1) / (MAX_ROWS_KC_FUNCTIONS - 2)) * (MAX_ROWS_KC_FUNCTIONS - 2) + 1;
1611 }
1612
1613 [self setGuiToKeyMapperScreen:skip];
1614}

◆ resetKeyFunctions

- (void) resetKeyFunctions

Extends class PlayerEntity.

Definition at line 113 of file PlayerEntityKeyMapper.m.

114{
115 [keyFunctions release];
116 keyFunctions = nil;
117}

References nil, and resetKeyFunctions.

Referenced by resetKeyFunctions.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveKeySetting:

- (void) saveKeySetting: (NSString*) key
implementation

Extends class PlayerEntity.

Definition at line 1480 of file PlayerEntityKeyMapper.m.

1480 :(NSString*)key
1481{
1482 // check for a blank entry
1483 if ([key_list count] > 1 && [[(NSDictionary*)[key_list objectAtIndex:1] objectForKey:@"key"] integerValue] == 0) {
1484 [key_list removeObjectAtIndex:1];
1485 }
1486 // make sure the primary and alternate keys are different
1487 if ([key_list count] > 1) {
1488 if ([self compareKeyEntries:[key_list objectAtIndex:0] second:[key_list objectAtIndex:1]]) {
1489 [key_list removeObjectAtIndex:1];
1490 }
1491 }
1492 // see if we've set the key settings to blank - in which case, delete the override
1493 if ([[(NSDictionary*)[key_list objectAtIndex:0] objectForKey:@"key"] integerValue] == 0) {
1494 if ([key_list count] == 1 || ([key_list count] > 1 && [[(NSDictionary*)[key_list objectAtIndex:1] objectForKey:@"key"] isEqualToString:@""])) {
1495 [self deleteKeySetting:key];
1496 // reload settings
1497 [self initKeyConfigSettings];
1498 [self reloadPage];
1499 return;
1500 }
1501 }
1502
1503 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1504
1505 if (![self entryIsCustomEquip:key]) {
1506 // if we've got the same settings as the default, revert to the default
1507 if ([self entryIsEqualToDefault:key]) {
1508 [self deleteKeySetting:key];
1509 // reload settings
1510 [self initKeyConfigSettings];
1511 [self reloadPage];
1512 return;
1513 }
1514 NSMutableDictionary* keyconf = [NSMutableDictionary dictionaryWithDictionary:[defaults objectForKey:KEYCONFIG_OVERRIDES]];
1515 [keyconf setObject:key_list forKey:key];
1516 [defaults setObject:keyconf forKey:KEYCONFIG_OVERRIDES];
1517 } else {
1518 NSUInteger idx = [self getCustomEquipIndex:key];
1519 NSString* custkey = [self getCustomEquipKeyDefType:key];
1520 NSMutableDictionary* custEquip = [[customEquipActivation objectAtIndex:idx] mutableCopy];
1521 [custEquip setObject:key_list forKey:custkey];
1522 [customEquipActivation replaceObjectAtIndex:idx withObject:custEquip];
1523 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
1524 }
1525 // reload settings
1526 [self initKeyConfigSettings];
1527 [self reloadPage];
1528}

◆ searchArrayForMatch:key:checkKeys:

- (NSString *) searchArrayForMatch: (NSArray*) search_list
key: (NSString*) key
checkKeys: (NSArray*) check_keys 
implementation

Extends class PlayerEntity.

Definition at line 1421 of file PlayerEntityKeyMapper.m.

1421 :(NSArray*)search_list key:(NSString*)key checkKeys:(NSArray*)check_keys
1422{
1423 NSString* search = nil;
1424 NSUInteger i, j, k;
1425 for (i = 0; i < [search_list count]; i++) {
1426 search = (NSString*)[search_list objectAtIndex:i];
1427 // only check other key settings, not the one we've been passed
1428 if (![search isEqualToString:key]) {
1429 // get the array from keyconfig2_settings
1430 // we need to compare all entries to each other to look for any match, as any match would indicate a conflict
1431 NSArray* current = nil;
1432 if (![self entryIsCustomEquip:search]) {
1433 current = (NSArray*)[keyconfig2_settings objectForKey:search];
1434 } else {
1435 NSUInteger idx = [self getCustomEquipIndex:search];
1436 NSString* keytype = [self getCustomEquipKeyDefType:search];
1437 current = (NSArray*)[[customEquipActivation objectAtIndex:idx] objectForKey:keytype];
1438 }
1439 for (j = 0; j < [current count]; j++) {
1440 for (k = 0; k < [check_keys count]; k++) {
1441 if ([self compareKeyEntries:[current objectAtIndex:j] second:[check_keys objectAtIndex:k]])
1442 return search;
1443 }
1444 }
1445 }
1446 }
1447 return nil;
1448}

◆ setGuiToConfirmClearScreen

- (void) setGuiToConfirmClearScreen

Extends class PlayerEntity.

Definition at line 701 of file PlayerEntityKeyMapper.m.

702{
703 GuiDisplayGen* gui = [UNIVERSE gui];
704 OOGUIScreenID oldScreen = gui_screen;
705
706 gui_screen = GUI_SCREEN_KEYBOARD_CONFIRMCLEAR;
707 BOOL guiChanged = (oldScreen != gui_screen);
708
709 [gui clear];
710 [gui setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-clear-overrides-title")]];
711
712 [gui addLongText:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-clear-overrides")]
713 startingAtRow:GUI_ROW_KC_CONFIRMCLEAR
714 align:GUI_ALIGN_LEFT];
715
716 [gui setText:DESC(@"oolite-keyconfig-clear-yes") forRow:GUI_ROW_KC_CONFIRMCLEAR_YES align:GUI_ALIGN_CENTER];
717 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_CONFIRMCLEAR_YES];
718
719 [gui setText:DESC(@"oolite-keyconfig-clear-no") forRow:GUI_ROW_KC_CONFIRMCLEAR_NO align:GUI_ALIGN_CENTER];
720 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_CONFIRMCLEAR_NO];
721
722 [gui setSelectableRange:NSMakeRange(GUI_ROW_KC_CONFIRMCLEAR_YES, 2)];
723 [gui setSelectedRow:GUI_ROW_KC_CONFIRMCLEAR_NO];
724
725 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
726 [gui setBackgroundTextureKey:@"keyboardsettings"];
727
728 [[UNIVERSE gameView] clearMouse];
729 [[UNIVERSE gameView] clearKeys];
730 if (guiChanged)
731 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
732}
OOGUIScreenID
BOOL setBackgroundTextureKey:(NSString *key)
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
BOOL setForegroundTextureKey:(NSString *key)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setTitle:(NSString *str)

References GuiDisplayGen::addLongText:startingAtRow:align:, GuiDisplayGen::clear, PlayerEntity::noteGUIDidChangeFrom:to:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setForegroundTextureKey:, setGuiToConfirmClearScreen, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, and Entity::status.

Referenced by setGuiToConfirmClearScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGuiToKeyboardLayoutScreen:

- (void) setGuiToKeyboardLayoutScreen: (unsigned) skip

Extends class PlayerEntity.

Definition at line 1065 of file PlayerEntityKeyMapper.m.

1065 :(unsigned)skip
1066{
1067 [self setGuiToKeyboardLayoutScreen:skip resetCurrentRow:NO];
1068}

References PlayerEntity::setGuiToKeyboardLayoutScreen:resetCurrentRow:.

Here is the call graph for this function:

◆ setGuiToKeyboardLayoutScreen:resetCurrentRow:

- (void) setGuiToKeyboardLayoutScreen: (unsigned) skip
resetCurrentRow: (BOOL) resetCurrentRow 

Extends class PlayerEntity.

Definition at line 1070 of file PlayerEntityKeyMapper.m.

1070 :(unsigned)skip resetCurrentRow:(BOOL)resetCurrentRow
1071{
1072 GuiDisplayGen* gui = [UNIVERSE gui];
1073 MyOpenGLView* gameView = [UNIVERSE gameView];
1074 OOGUIScreenID oldScreen = gui_screen;
1075 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
1076 tabStop[0] = 10;
1077 tabStop[1] = 290;
1078 [gui setTabStops:tabStop];
1079
1080 gui_screen = GUI_SCREEN_KEYBOARD_LAYOUT;
1081 BOOL guiChanged = (oldScreen != gui_screen);
1082
1083 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
1084
1085 [gui clear];
1086 [gui setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-select-kbd")]];
1087
1088 [self displayKeyboardLayoutList:gui skip:skip];
1089
1090 [gui setArray:[NSArray arrayWithObject:DESC(@"oolite-keyconfig-keyboard-info")] forRow:GUI_ROW_KC_INSTRUCT];
1091
1092 [gui setSelectedRow:kbd_row];
1093
1094 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
1095 [gui setBackgroundTextureKey:@"keyboardsettings"];
1096
1097 [gameView clearMouse];
1098 [gameView clearKeys];
1099 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
1100
1101 if (guiChanged)
1102 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
1103}
NSInteger OOGUITabStop
void setTabStops:(OOGUITabSettings stops)

References GuiDisplayGen::clear, MyOpenGLView::clearKeys, MyOpenGLView::clearMouse, PlayerEntity::displayKeyboardLayoutList:skip:, PlayerEntity::noteGUIDidChangeFrom:to:, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setForegroundTextureKey:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setTitle:, and Entity::status.

Here is the call graph for this function:

◆ setGuiToKeyConfigEntryScreen

- (void) setGuiToKeyConfigEntryScreen

Extends class PlayerEntity.

Definition at line 551 of file PlayerEntityKeyMapper.m.

552{
553 GuiDisplayGen* gui = [UNIVERSE gui];
554 MyOpenGLView* gameView = [UNIVERSE gameView];
555 OOGUIScreenID oldScreen = gui_screen;
556 gui_screen = GUI_SCREEN_KEYBOARD_ENTRY;
557 BOOL guiChanged = (oldScreen != gui_screen);
558
559 // make sure the index we're looking for exists
560 if ([key_list count] < (key_index + 1)) {
561 // add the missing element to the array
562 NSMutableDictionary* key1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"", @"key", [NSNumber numberWithBool:NO], @"shift", [NSNumber numberWithBool:NO], @"mod1", [NSNumber numberWithBool:NO], @"mod2", nil];
563 [key_list addObject:key1];
564 [key1 release];
565 }
566 NSDictionary* def = [key_list objectAtIndex:key_index];
567 NSString* key = [def objectForKey:@"key"];
568 // if ([key isEqualToString:@"(not set)"]) key = @"";
569 OOKeyCode k_int = (OOKeyCode)[key integerValue];
570 [gameView resetTypedString];
571 [gameView setTypedString:(k_int != 0 ? [self keyCodeDescriptionShort:k_int] : @"")];
572 [gameView setStringInput:gvStringInputAll];
573
574 [gui clear];
575 [gui setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-update-entry-title")]];
576
577 NSUInteger end_row = 21;
578 if ([[self hud] allowBigGui]) {
579 end_row = 27;
580 }
581
582 [gui addLongText:DESC(@"oolite-keyconfig-update-entry-info") startingAtRow:GUI_ROW_KC_ENTRY_INFO align:GUI_ALIGN_LEFT];
583
584 [gui setText:[NSString stringWithFormat:@"%@: %@", DESC(@"oolite-keyconfig-update-key"), [gameView typedString]] forRow:end_row align:GUI_ALIGN_LEFT];
585 [gui setColor:[OOColor cyanColor] forRow:end_row];
586 [gui setSelectableRange:NSMakeRange(0, 0)];
587
588 [gui setShowTextCursor:YES];
589 [gui setCurrentRow:end_row];
590
591 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
592 [gui setBackgroundTextureKey:@"keyboardsettings"];
593 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
594
595 [gameView clearMouse];
596 [gameView clearKeys];
597 if (guiChanged)
598 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
599}
uint16_t OOKeyCode
Definition OOTypes.h:163
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
void setTypedString:(NSString *value)
void setStringInput:(enum StringInput value)

References GuiDisplayGen::addLongText:startingAtRow:align:, GuiDisplayGen::clear, MyOpenGLView::clearKeys, MyOpenGLView::clearMouse, count, OOColor::cyanColor, key_index, key_list, PlayerEntity::keyCodeDescriptionShort:, PlayerEntity::noteGUIDidChangeFrom:to:, MyOpenGLView::resetTypedString, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setCurrentRow:, GuiDisplayGen::setForegroundTextureKey:, setGuiToKeyConfigEntryScreen, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setShowTextCursor:, MyOpenGLView::setStringInput:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, MyOpenGLView::setTypedString:, Entity::status, and MyOpenGLView::typedString.

Referenced by setGuiToKeyConfigEntryScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGuiToKeyConfigScreen

- (void) setGuiToKeyConfigScreen

Extends class PlayerEntity.

Definition at line 370 of file PlayerEntityKeyMapper.m.

371{
372 [self setGuiToKeyConfigScreen:NO];
373}

References setGuiToKeyConfigScreen, and PlayerEntity::setGuiToKeyConfigScreen:.

Referenced by setGuiToKeyConfigScreen, and setGuiToKeyConfigScreen:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGuiToKeyConfigScreen:

- (void) setGuiToKeyConfigScreen: (BOOL) resetSelectedRow

Extends class PlayerEntity.

Definition at line 375 of file PlayerEntityKeyMapper.m.

375 :(BOOL)resetSelectedRow
376{
377 NSUInteger i = 0;
378 GuiDisplayGen* gui = [UNIVERSE gui];
379 OOGUIScreenID oldScreen = gui_screen;
380 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
381 tabStop[0] = 10;
382 tabStop[1] = 290;
383 [gui setTabStops:tabStop];
384
385 gui_screen = GUI_SCREEN_KEYBOARD_CONFIG;
386 BOOL guiChanged = (oldScreen != gui_screen);
387 [gui clear];
388 [gui setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-update-title")]];
389
390 [gui setArray:[NSArray arrayWithObjects:
391 DESC(@"oolite-keyconfig-update-function"), [selected_entry objectForKey:KEY_KC_GUIDESC], nil]
392 forRow:GUI_ROW_KC_UPDATE_FUNCNAME];
393 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_KC_UPDATE_FUNCNAME];
394
395 NSString* keystring = nil;
396 NSString* keyshift = nil;
397 NSString* keymod1 = nil;
398 NSString* keymod2 = nil;
399
400 NSDictionary* def = nil;
401 NSString* key = nil;
402 OOKeyCode k_int;
403
404 // get each key for the first two item in the selected entry
405 for (i = 0; i <= 1; i++) {
406 keystring = DESC(@"oolite-keycode-unset");
407 keyshift = DESC(@"oolite-keyconfig-modkey-off");
408 keymod1 = DESC(@"oolite-keyconfig-modkey-off");
409 keymod2 = DESC(@"oolite-keyconfig-modkey-off");
410
411 if ([key_list count] > i) {
412 def = [key_list objectAtIndex:i];
413 key = [def objectForKey:@"key"];
414 k_int = (OOKeyCode)[key integerValue];
415 if (k_int > 0) {
416 keystring = [self keyCodeDescription:k_int];
417 if ([[def objectForKey:@"shift"] boolValue] == YES)
418 keyshift = DESC(@"oolite-keyconfig-modkey-on");
419 if ([[def objectForKey:@"mod1"] boolValue] == YES)
420 keymod1 = DESC(@"oolite-keyconfig-modkey-on");
421 if ([[def objectForKey:@"mod2"] boolValue] == YES)
422 keymod2 = DESC(@"oolite-keyconfig-modkey-on");
423 }
424 }
425
426 [self outputKeyDefinition:keystring shift:keyshift mod1:keymod1 mod2:keymod2 skiprows:(i * 5)];
427 }
428
429 NSString* helper = DESC(@"oolite-keyconfig-update-helper");
430 if ([nav_keys containsObject:[selected_entry objectForKey:KEY_KC_DEFINITION]])
431 helper = [NSString stringWithFormat:@"%@ %@", helper, DESC(@"oolite-keyconfig-update-navkeys")];
432 if ([camera_keys containsObject:[selected_entry objectForKey:KEY_KC_DEFINITION]])
433 helper = [NSString stringWithFormat:@"%@ %@", helper, DESC(@"oolite-keyconfig-update-camkeys")];
434 [gui addLongText:helper startingAtRow:GUI_ROW_KC_UPDATE_INFO align:GUI_ALIGN_LEFT];
435
436 [gui setText:@"" forRow:GUI_ROW_KC_VALIDATION];
437
438 [gui setText:DESC(@"oolite-keyconfig-update-save") forRow:GUI_ROW_KC_SAVE align:GUI_ALIGN_CENTER];
439 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_SAVE];
440
441 [gui setText:DESC(@"oolite-keyconfig-update-cancel") forRow:GUI_ROW_KC_CANCEL align:GUI_ALIGN_CENTER];
442 [gui setKey:GUI_KEY_OK forRow:GUI_ROW_KC_CANCEL];
443
444 [gui setSelectableRange:NSMakeRange(GUI_ROW_KC_KEY, (GUI_ROW_KC_CANCEL - GUI_ROW_KC_KEY) + 1)];
445
446 NSString* validate = [self validateKey:[selected_entry objectForKey:KEY_KC_DEFINITION] checkKeys:key_list];
447 if (validate) {
448 for (i = 0; i < [keyFunctions count]; i++) {
449 if ([[[keyFunctions objectAtIndex:i] objectForKey:KEY_KC_DEFINITION] isEqualToString:validate]) {
450 [gui setText:[NSString stringWithFormat:DESC(@"oolite-keyconfig-update-validation-@"), (NSString*)[[keyFunctions objectAtIndex:i] objectForKey:KEY_KC_GUIDESC]]
451 forRow:GUI_ROW_KC_VALIDATION
452 align:GUI_ALIGN_CENTER];
453 [gui setColor:[OOColor orangeColor] forRow:GUI_ROW_KC_VALIDATION];
454 break;
455 }
456 }
457 }
458
459 if (resetSelectedRow) {
460 [gui setSelectedRow:GUI_ROW_KC_KEY];
461 }
462
463 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
464 [gui setBackgroundTextureKey:@"keyboardsettings"];
465 [[UNIVERSE gameView] clearMouse];
466 [[UNIVERSE gameView] clearKeys];
467 if (guiChanged)
468 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
469}

References GuiDisplayGen::addLongText:startingAtRow:align:, camera_keys, GuiDisplayGen::clear, count, DESC, OOColor::greenColor, KEY_KC_DEFINITION, key_list, PlayerEntity::keyCodeDescription:, nav_keys, nil, PlayerEntity::noteGUIDidChangeFrom:to:, OOColor::orangeColor, PlayerEntity::outputKeyDefinition:shift:mod1:mod2:skiprows:, selected_entry, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setForegroundTextureKey:, setGuiToKeyConfigScreen, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, Entity::status, and PlayerEntity::validateKey:checkKeys:.

Here is the call graph for this function:

◆ setGuiToKeyMapperScreen:

- (void) setGuiToKeyMapperScreen: (unsigned) skip

Extends class PlayerEntity.

Definition at line 119 of file PlayerEntityKeyMapper.m.

119 :(unsigned)skip
120{
121 [self setGuiToKeyMapperScreen:skip resetCurrentRow:NO];
122}

References PlayerEntity::setGuiToKeyMapperScreen:resetCurrentRow:.

Here is the call graph for this function:

◆ setGuiToKeyMapperScreen:resetCurrentRow:

- (void) setGuiToKeyMapperScreen: (unsigned) skip
resetCurrentRow: (BOOL) resetCurrentRow 

Extends class PlayerEntity.

Definition at line 124 of file PlayerEntityKeyMapper.m.

124 :(unsigned)skip resetCurrentRow:(BOOL)resetCurrentRow
125{
126 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
127 NSString* kbd = [defaults oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
128
129 GuiDisplayGen* gui = [UNIVERSE gui];
130 MyOpenGLView* gameView = [UNIVERSE gameView];
131 OOGUIScreenID oldScreen = gui_screen;
132 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
133 tabStop[0] = 10;
134 tabStop[1] = 290;
135 tabStop[2] = 400;
136 [gui setTabStops:tabStop];
137
138 if (!kdic_check)
140
141 gui_screen = GUI_SCREEN_KEYBOARD;
142 BOOL guiChanged = (oldScreen != gui_screen);
143 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
144
145 [gui clear];
146 [gui setTitle:[NSString stringWithFormat:@"%@", DESC(@"oolite-keyconfig-header")]];
147
148 // show keyboard layout
149 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-keyconfig-keyboard"), [self keyboardDescription:kbd], nil] forRow:GUI_ROW_KC_SELECTKBD];
150 [gui setKey:[NSString stringWithFormat:@"kbd:%@", kbd] forRow:GUI_ROW_KC_SELECTKBD];
151 [gui setColor:[OOColor yellowColor] forRow:GUI_ROW_KC_SELECTKBD];
152
153 [self displayKeyFunctionList:gui skip:skip];
154
155 has_error = NO;
156 if ([[self validateAllKeys] count] > 0) {
157 has_error = YES;
158 [gui setText:DESC(@"oolite-keyconfig-validation-error") forRow:GUI_ROW_KC_ERROR align:GUI_ALIGN_CENTER];
159 [gui setColor:[OOColor redColor] forRow:GUI_ROW_KC_ERROR];
160 }
161 [gui setArray:[NSArray arrayWithObject:DESC(@"oolite-keyconfig-initial-info-1")] forRow:GUI_ROW_KC_INSTRUCT];
162 [gui setText:DESC(@"oolite-keyconfig-initial-info-2") forRow:GUI_ROW_KC_INSTRUCT + 1 align:GUI_ALIGN_CENTER];
163 if (has_error) {
164 [gui setText:DESC(@"oolite-keyconfig-initial-error") forRow:GUI_ROW_KC_INSTRUCT + 2 align:GUI_ALIGN_CENTER];
165 } else {
166 [gui setText:DESC(@"oolite-keyconfig-initial-info-3") forRow:GUI_ROW_KC_INSTRUCT + 2 align:GUI_ALIGN_CENTER];
167 }
168
169 if (resetCurrentRow) {
170 int offset = 0;
171 if ([[keyFunctions objectAtIndex:skip] objectForKey:KEY_KC_HEADER])
172 offset = 1;
173 [gui setSelectedRow:GUI_ROW_KC_FUNCSTART + offset];
174 } else {
175 [gui setSelectedRow:current_row];
176 }
177
178 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
179 [gui setBackgroundTextureKey:@"keyboardsettings"];
180
181 [gameView clearMouse];
182 [gameView clearKeys];
183 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
184
185 if (guiChanged)
186 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
187}
OOColor * redColor()
Definition OOColor.m:259
OOColor * yellowColor()
Definition OOColor.m:279
voidpf uLong offset
Definition ioapi.h:132

References GuiDisplayGen::clear, MyOpenGLView::clearKeys, MyOpenGLView::clearMouse, count, PlayerEntity::displayKeyFunctionList:skip:, has_error, PlayerEntity::initCheckingDictionary, kdic_check, KEY_KC_HEADER, PlayerEntity::keyboardDescription:, PlayerEntity::noteGUIDidChangeFrom:to:, OOColor::redColor, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setForegroundTextureKey:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, Entity::status, validateAllKeys, and OOColor::yellowColor.

Here is the call graph for this function:

◆ unsetKeySetting:

- (void) unsetKeySetting: (NSString*) key
implementation

Extends class PlayerEntity.

Definition at line 1531 of file PlayerEntityKeyMapper.m.

1531 :(NSString*)key
1532{
1533 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1534 if (![self entryIsCustomEquip:key]) {
1535 NSMutableDictionary* keyconf = [NSMutableDictionary dictionaryWithDictionary:[defaults objectForKey:KEYCONFIG_OVERRIDES]];
1536 NSMutableArray* empty = [[NSMutableArray alloc] init];
1537 [keyconf setObject:empty forKey:key];
1538 [defaults setObject:keyconf forKey:KEYCONFIG_OVERRIDES];
1539 [empty release];
1540 } else {
1541 NSString* custkey = [self getCustomEquipKeyDefType:key];
1542 NSMutableDictionary* custEquip = [[customEquipActivation objectAtIndex:[self getCustomEquipIndex:key]] mutableCopy];
1543 [custEquip removeObjectForKey:custkey];
1544 [customEquipActivation replaceObjectAtIndex:[self getCustomEquipIndex:key] withObject:custEquip];
1545 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
1546 [custEquip release];
1547 }
1548 // reload settings
1549 [self initKeyConfigSettings];
1550}

◆ updateKeyDefinition:index:

- (void) updateKeyDefinition: (NSString*) keystring
index: (NSUInteger) index 
implementation

Extends class PlayerEntity.

Definition at line 633 of file PlayerEntityKeyMapper.m.

633 :(NSString*)keystring index:(NSUInteger)index
634{
635 NSMutableDictionary* key_def = [[NSMutableDictionary alloc] initWithDictionary:(NSDictionary*)[key_list objectAtIndex:index] copyItems:YES];
636 [key_def setObject:keystring forKey:@"key"];
637 // auto=turn on shift if the entered key was shifted
638
639 if (last_shift && [keystring length] == 1 && ![nav_keys containsObject:[selected_entry objectForKey:KEY_KC_DEFINITION]]) {
640 [key_def setObject:[NSNumber numberWithBool:YES] forKey:@"shift"];
641 }
642 if (!last_shift && [keystring length] == 1) {
643 [key_def setObject:[NSNumber numberWithBool:NO] forKey:@"shift"];
644 }
645 last_shift = NO;
646 if (index > [key_list count] - 1) {
647 [key_list insertObject:key_def atIndex:index];
648 } else {
649 [key_list replaceObjectAtIndex:index withObject:key_def];
650 }
651 [key_def release];
652 NSArray* new_array = [self processKeyCode:key_list];
653 [key_list release];
654 key_list = [[NSMutableArray alloc] initWithArray:new_array copyItems:YES];
655 [new_array release];
656}

◆ updateShiftKeyDefinition:index:

- (void) updateShiftKeyDefinition: (NSString*) key
index: (NSUInteger) index 
implementation

Extends class PlayerEntity.

Definition at line 659 of file PlayerEntityKeyMapper.m.

659 :(NSString*)key index:(NSUInteger)index
660{
661 NSMutableDictionary* key_def = [[NSMutableDictionary alloc] initWithDictionary:(NSDictionary*)[key_list objectAtIndex:index] copyItems:YES];
662 BOOL current = [[key_def objectForKey:key] boolValue];
663 BOOL keycode_changed = NO;
664 current = !current;
665 [key_def setObject:[NSNumber numberWithBool:current] forKey:key];
666 if ([key isEqualToString:@"shift"]) {
667 // force the key into upper or lower case, to limit invalid key combos as much as possible
668 NSString* keycode = [key_def objectForKey:@"key"];
669 NSInteger k_int = (OOKeyCode)[keycode integerValue];
670 if (k_int > 0) {
671 NSString* keystring = [self keyCodeDescription:k_int];
672 NSString* newstring;
673 if ([keystring length] == 1) {
674 // try switching the case. for characters that can't be switched (eg 1,2,3,etc), this should do nothing
675 if (current) {
676 newstring = [keystring uppercaseString];
677 } else {
678 newstring = [keystring lowercaseString];
679 }
680 if (![newstring isEqualToString:keystring]) {
681 [key_def setObject:newstring forKey:@"key"];
682 keycode_changed = YES;
683 }
684 }
685 }
686 }
687 if (index > [key_list count] - 1) {
688 [key_list insertObject:key_def atIndex:index];
689 } else {
690 [key_list replaceObjectAtIndex:index withObject:key_def];
691 }
692 [key_def release];
693 if (keycode_changed) {
694 NSArray* new_array = [self processKeyCode:key_list];
695 [key_list release];
696 key_list = [[NSMutableArray alloc] initWithArray:new_array copyItems:YES];
697 [new_array release];
698 }
699}

◆ validateAllKeys

- (NSArray *) validateAllKeys
implementation

Extends class PlayerEntity.

Definition at line 1270 of file PlayerEntityKeyMapper.m.

1271{
1272 NSMutableArray* failed = [[NSMutableArray alloc] init];
1273 NSString* validate = nil;
1274 NSUInteger i;
1275
1276 for (i = 0; i < [keyFunctions count]; i++) {
1277 NSDictionary* entry = [keyFunctions objectAtIndex:i];
1278 validate = [self validateKey:[entry objectForKey:KEY_KC_DEFINITION] checkKeys:(NSArray*)[keyconfig2_settings objectForKey:[entry objectForKey:KEY_KC_DEFINITION]]];
1279 if (validate) {
1280 [failed addObject:validate];
1281 }
1282 }
1283 return [failed copy];
1284}

Referenced by setGuiToKeyMapperScreen:resetCurrentRow:.

Here is the caller graph for this function:

◆ validateKey:checkKeys:

- (NSString *) validateKey: (NSString*) key
checkKeys: (NSArray*) check_keys 

Extends class PlayerEntity.

Definition at line 1287 of file PlayerEntityKeyMapper.m.

1287 :(NSString*)key checkKeys:(NSArray*)check_keys
1288{
1289 NSString* result = nil;
1290
1291 // need to group keys into validation groups
1292 NSArray* gui_keys = [NSArray arrayWithObjects:@"key_gui_arrow_left", @"key_gui_arrow_right", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_page_up",
1293 @"key_gui_page_down", @"key_gui_select", nil];
1294
1295 if ([gui_keys containsObject:key]) {
1296 result = [self searchArrayForMatch:gui_keys key:key checkKeys:check_keys];
1297 if (result)
1298 return result;
1299 }
1300
1301 NSArray* debug_keys = [NSArray arrayWithObjects:
1302 @"key_dump_target_state", @"key_dump_entity_list", @"key_debug_full", @"key_debug_collision", @"key_debug_console_connect", @"key_debug_bounding_boxes",
1303 @"key_debug_shaders", @"key_debug_off", nil];
1304
1305 if ([debug_keys containsObject:key]) {
1306 result = [self searchArrayForMatch:debug_keys key:key checkKeys:check_keys];
1307 if (result)
1308 return result;
1309 }
1310
1311 NSArray* customview_keys = [NSArray arrayWithObjects:
1312 @"key_custom_view", @"key_custom_view_zoom_out", @"key_custom_view_zoom_in", @"key_custom_view_roll_left", @"key_custom_view_pan_left",
1313 @"key_custom_view_roll_right", @"key_custom_view_pan_right", @"key_custom_view_rotate_up", @"key_custom_view_pan_up", @"key_custom_view_rotate_down",
1314 @"key_custom_view_pan_down", @"key_custom_view_rotate_left", @"key_custom_view_rotate_right", nil];
1315
1316 if ([customview_keys containsObject:key]) {
1317 result = [self searchArrayForMatch:customview_keys key:key checkKeys:check_keys];
1318 if (result)
1319 return result;
1320 }
1321
1322 NSMutableArray* inflight_keys = [NSMutableArray arrayWithObjects:
1323 @"key_roll_left", @"key_roll_right", @"key_pitch_forward", @"key_pitch_back", @"key_yaw_left", @"key_yaw_right", @"key_view_forward", @"key_view_aft",
1324 @"key_view_port", @"key_view_starboard", @"key_increase_speed", @"key_decrease_speed", @"key_inject_fuel", @"key_fire_lasers", @"key_weapons_online_toggle",
1325 @"key_launch_missile", @"key_next_missile", @"key_ecm", @"key_prime_next_equipment", @"key_prime_previous_equipment", @"key_activate_equipment",
1326 @"key_mode_equipment", @"key_fastactivate_equipment_a", @"key_fastactivate_equipment_b", @"key_target_incoming_missile", @"key_target_missile",
1327 @"key_untarget_missile", @"key_ident_system", @"key_scanner_zoom", @"key_scanner_unzoom", @"key_launch_escapepod", @"key_galactic_hyperspace",
1328 @"key_hyperspace", @"key_jumpdrive", @"key_dump_cargo", @"key_rotate_cargo", @"key_autopilot", @"key_autodock", @"key_docking_clearance_request",
1329 @"key_snapshot", @"key_cycle_next_mfd", @"key_cycle_previous_mfd", @"key_switch_next_mfd", @"key_switch_previous_mfd",
1330 @"key_next_target", @"key_previous_target", @"key_comms_log", @"key_prev_compass_mode", @"key_next_compass_mode", @"key_custom_view",
1331#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1332 @"key_inc_field_of_view", @"key_dec_field_of_view",
1333#endif
1334 @"key_pausebutton", @"key_dump_target_state", nil];
1335
1336 if ([self entryIsCustomEquip:key]) {
1337 NSUInteger i;
1338 for (i = 0; i < [customEquipActivation count]; i++) {
1339 [inflight_keys addObject:[NSString stringWithFormat:@"activate_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]];
1340 [inflight_keys addObject:[NSString stringWithFormat:@"mode_%@", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY]]];
1341 }
1342 }
1343
1344 if ([inflight_keys containsObject:key]) {
1345 result = [self searchArrayForMatch:inflight_keys key:key checkKeys:check_keys];
1346 if (result)
1347 return result;
1348 }
1349
1350 NSArray* docking_keys = [NSArray arrayWithObjects:
1351 @"key_docking_music", @"key_autopilot", @"key_pausebutton", nil];
1352
1353 if ([docking_keys containsObject:key]) {
1354 result = [self searchArrayForMatch:docking_keys key:key checkKeys:check_keys];
1355 if (result)
1356 return result;
1357 }
1358
1359 NSArray* docked_keys = [[NSArray arrayWithObjects:@"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1360 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil]
1361 arrayByAddingObjectsFromArray:gui_keys];
1362
1363 if ([docked_keys containsObject:key]) {
1364 result = [self searchArrayForMatch:docked_keys key:key checkKeys:check_keys];
1365 if (result)
1366 return result;
1367 }
1368
1369 NSArray* paused_keys = [[[NSArray arrayWithObjects:@"key_pausebutton", @"key_gui_screen_options", @"key_hud_toggle", @"key_show_fps", @"key_mouse_control_roll",
1370 @"key_mouse_control_yaw", nil]
1371 arrayByAddingObjectsFromArray:debug_keys]
1372 arrayByAddingObjectsFromArray:customview_keys];
1373
1374 if ([paused_keys containsObject:key]) {
1375 result = [self searchArrayForMatch:paused_keys key:key checkKeys:check_keys];
1376 if (result)
1377 return result;
1378 }
1379
1380 NSArray* chart_keys = [NSArray arrayWithObjects:
1381 @"key_advanced_nav_array_next", @"key_advanced_nav_array_previous", @"key_map_home", @"key_map_end", @"key_map_info",
1382 @"key_map_zoom_in", @"key_map_zoom_out", @"key_map_next_system", @"key_map_previous_system", @"key_chart_highlight",
1383 @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1384 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil];
1385
1386 if ([chart_keys containsObject:key]) {
1387 result = [self searchArrayForMatch:chart_keys key:key checkKeys:check_keys];
1388 if (result)
1389 return result;
1390 }
1391
1392 NSArray* sysinfo_keys = [NSArray arrayWithObjects:
1393 @"key_system_home", @"key_system_end", @"key_system_next_system", @"key_system_previous_system",
1394 @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1395 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", nil];
1396
1397 if ([sysinfo_keys containsObject:key]) {
1398 result = [self searchArrayForMatch:sysinfo_keys key:key checkKeys:check_keys];
1399 if (result)
1400 return result;
1401 }
1402
1403 NSArray* market_keys = [NSArray arrayWithObjects:
1404 @"key_market_filter_cycle", @"key_market_sorter_cycle", @"key_market_buy_one", @"key_market_sell_one", @"key_market_buy_max",
1405 @"key_market_sell_max", @"key_launch_ship", @"key_gui_screen_options", @"key_gui_screen_equipship", @"key_gui_screen_interfaces", @"key_gui_screen_status",
1406 @"key_gui_chart_screens", @"key_gui_system_data", @"key_gui_market", @"key_gui_arrow_up", @"key_gui_arrow_down", @"key_gui_page_up",
1407 @"key_gui_page_down", @"key_gui_select", nil];
1408
1409 if ([market_keys containsObject:key]) {
1410 result = [self searchArrayForMatch:market_keys key:key checkKeys:check_keys];
1411 if (result)
1412 return result;
1413 }
1414
1415 // if we get here, we should be good
1416 return nil;
1417}

References nil, and PlayerEntity::searchArrayForMatch:key:checkKeys:.

Here is the call graph for this function:

The documentation for this category was generated from the following files: