Oolite
Loading...
Searching...
No Matches
PlayerEntityKeyMapper.m
Go to the documentation of this file.
1/*
2
3PlayerEntityKeyMapper.m
4
5Oolite
6Copyright (C) 2004-2019 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
26#import "GameController.h"
27#import "HeadUpDisplay.h"
29#import "OOEquipmentType.h"
30#import "OOJoystickManager.h"
31#import "OOTexture.h"
34#import "ResourceManager.h"
35
36static NSUInteger key_index;
37static long current_row;
39static BOOL has_error = NO;
40static BOOL last_shift = NO;
41static NSDictionary* selected_entry = nil;
42static NSMutableArray* key_list = nil;
43static NSDictionary* kdic_check = nil;
44static NSArray* nav_keys = nil;
45static NSArray* camera_keys = nil;
46
47@interface PlayerEntity (KeyMapperInternal)
48
49- (void)resetKeyFunctions;
50- (void)updateKeyDefinition:(NSString*)keystring index:(NSUInteger)index;
51- (void)updateShiftKeyDefinition:(NSString*)key index:(NSUInteger)index;
52- (void)displayKeyFunctionList:(GuiDisplayGen*)gui skip:(NSUInteger)skip;
53- (NSString*)keyboardDescription:(NSString*)kbd;
54- (void)displayKeyboardLayoutList:(GuiDisplayGen*)gui skip:(NSUInteger)skip;
55- (BOOL)entryIsIndexCustomEquip:(NSUInteger)idx;
56- (BOOL)entryIsDictCustomEquip:(NSDictionary*)dict;
57- (BOOL)entryIsCustomEquip:(NSString*)entry;
58- (NSArray*)getCustomEquipArray:(NSString*)key_def;
59- (NSString*)getCustomEquipKeyDefType:(NSString*)key_def;
60- (NSArray*)keyFunctionList;
61- (NSArray*)validateAllKeys;
62- (NSString*)searchArrayForMatch:(NSArray*)search_list key:(NSString*)key checkKeys:(NSArray*)check_keys;
63- (NSUInteger)getCustomEquipIndex:(NSString*)key_def;
64- (BOOL)entryIsEqualToDefault:(NSString*)key;
65- (BOOL)compareKeyEntries:(NSDictionary*)first second:(NSDictionary*)second;
66- (void)saveKeySetting:(NSString*)key;
67- (void)unsetKeySetting:(NSString*)key;
68- (void)deleteKeySetting:(NSString*)key;
70- (NSDictionary*)loadKeySettings;
71- (void)reloadPage;
72
73@end
74
75@implementation PlayerEntity (KeyMapper)
76
77// sets up a copy of the raw keyconfig.plist file so we can run checks against it to tell if a key is set to default
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}
112
114{
115 [keyFunctions release];
116 keyFunctions = nil;
117}
118
119- (void)setGuiToKeyMapperScreen:(unsigned)skip
120{
122}
123
124- (void)setGuiToKeyMapperScreen:(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
183 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
184
185 if (guiChanged)
186 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
187}
188
189- (void)keyMapperInputHandler:(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
190{
191 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
193 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
194 if ([gameView isDown:gvMouseDoubleClick])
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])
215 return;
216 }
217 if ([key hasPrefix:@"kbd:"]) {
219 if ([gameView isDown:gvMouseDoubleClick])
221 return;
222 }
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
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
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
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 {
292 }
293 }
294 if ([gameView isDown:' '] && !has_error)
296}
297
298- (BOOL)entryIsIndexCustomEquip:(NSUInteger)idx
299{
300 return [self entryIsCustomEquip:[[keyFunctions objectAtIndex:idx] oo_stringForKey:KEY_KC_DEFINITION]];
301}
302
303- (BOOL)entryIsDictCustomEquip:(NSDictionary*)dict
304{
305 return [self entryIsCustomEquip:[dict oo_stringForKey:KEY_KC_DEFINITION]];
306}
307
308- (BOOL)entryIsCustomEquip:(NSString*)entry
309{
310 BOOL result = NO;
311 if ([entry hasPrefix:@"activate_"] || [entry hasPrefix:@"mode_"])
312 result = YES;
313 return result;
314}
315
316- (NSArray*)getCustomEquipArray:(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}
338
339- (NSUInteger)getCustomEquipIndex:(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}
358
359- (NSString*)getCustomEquipKeyDefType:(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}
369
371{
372 [self setGuiToKeyConfigScreen:NO];
373}
374
375- (void)setGuiToKeyConfigScreen:(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}
470
471- (void)outputKeyDefinition:(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}
513
514- (void)handleKeyConfigKeys:(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
515{
516 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
518 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
519 if ([gameView isDown:gvMouseDoubleClick])
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);
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)];
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)];
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)];
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}
550
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];
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
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
597 if (guiChanged)
598 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
599}
600
601- (void)handleKeyConfigEntryKeys:(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
602{
603 NSUInteger end_row = 21;
604 if ([[self hud] allowBigGui]) {
605 end_row = 27;
606 }
607
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]) {
619 // update function key
621 [gameView clearKeys]; // try to stop key bounces
622 [self setGuiToKeyConfigScreen:YES];
623 }
624 if ([gameView isDown:27]) // escape
625 {
627 // don't update function key
628 [self setGuiToKeyConfigScreen:YES];
629 }
630}
631
632// updates the overridden definition of a key to a new keycode value
633- (void)updateKeyDefinition:(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}
657
658// changes the shift/ctrl/alt state of an overridden definition
659- (void)updateShiftKeyDefinition:(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}
700
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}
733
734- (void)handleKeyMapperConfirmClearKeys:(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
735{
736 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
738
739 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
740 if ([gameView isDown:gvMouseDoubleClick])
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]) {
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
761 }
762}
763
764- (void)displayKeyFunctionList:(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}
878
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}
1045
1046- (NSDictionary*)makeKeyGuiDict:(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}
1055
1056- (NSDictionary*)makeKeyGuiDictHeader:(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}
1064
1065- (void)setGuiToKeyboardLayoutScreen:(unsigned)skip
1066{
1068}
1069
1070- (void)setGuiToKeyboardLayoutScreen:(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
1099 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
1100
1101 if (guiChanged)
1102 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
1103}
1104
1105- (void)handleKeyboardLayoutEntryKeys:(GuiDisplayGen*)gui view:(MyOpenGLView*)gameView
1106{
1107 const BOOL* joyButtonState = [[OOJoystickManager sharedStickHandler] getAllButtonStates];
1109 BOOL selectKeyPress = ([self checkKeyPress:n_key_gui_select] || joyButtonState[BUTTON_GUISELECT] || [gameView isDown:gvMouseDoubleClick]);
1110 if ([gameView isDown:gvMouseDoubleClick])
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])
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];
1136
1137 [gameView clearKeys]; // try to stop key bounces
1139 }
1140 if ([gameView isDown:27]) // escape - return without change
1141 {
1142 [gameView clearKeys]; // try to stop key bounces
1144 }
1145}
1146
1147- (NSString*)keyboardDescription:(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}
1163
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}
1206
1207- (void)displayKeyboardLayoutList:(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}
1268
1269// return an array of all functions currently in conflict
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}
1285
1286// validate a single key against any other key that might apply to it
1287- (NSString*)validateKey:(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}
1418
1419// performs a search of all keys in the search_list, and for any key that isn't the one we've passed, check the
1420// keys against the values we're passing in. if there's a hit, return the key found
1421- (NSString*)searchArrayForMatch:(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}
1449
1450// compares the currently stored key_list against the base default from keyconfig2.plist
1451- (BOOL)entryIsEqualToDefault:(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}
1466
1467// compares two key dictionaries to see if they have the same settings
1468- (BOOL)compareKeyEntries:(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}
1478
1479// saves the currently store key_list to the defaults file and updates the global definition
1480- (void)saveKeySetting:(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}
1529
1530// unsets the key setting in the overrides, and updates the global definition
1531- (void)unsetKeySetting:(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}
1551
1552// removes the key setting from the overrides, and updates the global definition
1553- (void)deleteKeySetting:(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}
1568
1569// removes all key settings from the overrides, and updates the global definition
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];
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}
1594
1595// returns all key settings from the overrides
1596- (NSDictionary*)loadKeySettings
1597{
1598 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
1599 return [defaults objectForKey:KEYCONFIG_OVERRIDES];
1600}
1601
1602// reloads the main page at the appropriate page
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}
1615
1616@end
NSInteger OOGUITabStop
@ gvMouseDoubleClick
unsigned count
return nil
uint16_t OOKeyCode
Definition OOTypes.h:163
#define GUI_ROW_KC_MOD2
#define MAX_ROWS_KC_FUNCTIONS
#define GUI_ROW_KC_SAVE
#define KEY_KC_HEADER
#define GUI_ROW_KC_SHIFT
#define GUI_ROW_KC_MOD1
#define GUI_ROW_KC_CANCEL
#define GUI_ROW_KC_FUNCSTART
#define GUI_ROW_KC_CONFIRMCLEAR_YES
#define GUI_ROW_KC_CONFIRMCLEAR_NO
#define KEY_KC_DEFINITION
#define GUI_ROW_KC_KEY
static NSDictionary * selected_entry
static NSArray * nav_keys
static NSUInteger key_index
static NSDictionary * kdic_check
static NSMutableArray * key_list
static long kbd_row
static NSArray * camera_keys
static BOOL has_error
static BOOL last_shift
static long current_row
#define CUSTOMEQUIP_KEYACTIVATE
OOGUIScreenID
#define CUSTOMEQUIP_EQUIPKEY
#define CUSTOMEQUIP_KEYMODE
#define DESC(key)
Definition Universe.h:832
OOEntityStatus status()
Definition Entity.m:733
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:(NSString *str,[forRow] OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
OOGUIRow selectedRow
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTitle:(NSString *str)
void setTabStops:(OOGUITabSettings stops)
NSString * keyForRow:(OOGUIRow row)
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
BOOL isDown:(int key)
void setTypedString:(NSString *value)
NSMutableString * typedString
void setStringInput:(enum StringInput value)
OOColor * cyanColor()
Definition OOColor.m:274
OOColor * orangeColor()
Definition OOColor.m:289
OOColor * redColor()
Definition OOColor.m:259
OOColor * greenColor()
Definition OOColor.m:264
OOColor * yellowColor()
Definition OOColor.m:279
NSArray * defaultActivateKey()
NSArray * defaultModeKey()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
const BOOL * getAllButtonStates()
NSArray * getCustomEquipArray:(NSString *key_def)
void updateKeyDefinition:index:(NSString *keystring, [index] NSUInteger index)
void setGuiToGameOptionsScreen()
BOOL entryIsCustomEquip:(NSString *entry)
NSDictionary * loadKeySettings()
BOOL checkKeyPress:(NSArray *key_def)
NSString * searchArrayForMatch:key:checkKeys:(NSArray *search_list, [key] NSString *key, [checkKeys] NSArray *check_keys)
void updateShiftKeyDefinition:index:(NSString *key, [index] NSUInteger index)
NSDictionary * makeKeyGuiDictHeader:(NSString *header)
NSString * keyboardDescription:(NSString *kbd)
NSString * keyCodeDescriptionShort:(OOKeyCode code)
void displayKeyFunctionList:skip:(GuiDisplayGen *gui, [skip] NSUInteger skip)
void setGuiToKeyMapperScreen:(unsigned skip)
void unsetKeySetting:(NSString *key)
void setGuiToKeyboardLayoutScreen:resetCurrentRow:(unsigned skip,[resetCurrentRow] BOOL resetCurrentRow)
void setGuiToKeyboardLayoutScreen:(unsigned skip)
NSUInteger getCustomEquipIndex:(NSString *key_def)
NSString * keyCodeDescription:(OOKeyCode code)
void deleteKeySetting:(NSString *key)
void outputKeyDefinition:shift:mod1:mod2:skiprows:(NSString *key,[shift] NSString *shift,[mod1] NSString *mod1,[mod2] NSString *mod2,[skiprows] NSUInteger skiprows)
NSString * getCustomEquipKeyDefType:(NSString *key_def)
void noteGUIDidChangeFrom:to:(OOGUIScreenID fromScreen,[to] OOGUIScreenID toScreen)
void saveKeySetting:(NSString *key)
NSString * validateKey:checkKeys:(NSString *key,[checkKeys] NSArray *check_keys)
NSDictionary * makeKeyGuiDict:keyDef:(NSString *what,[keyDef] NSString *keyDef)
void setGuiToKeyMapperScreen:resetCurrentRow:(unsigned skip,[resetCurrentRow] BOOL resetCurrentRow)
void displayKeyboardLayoutList:skip:(GuiDisplayGen *gui, [skip] NSUInteger skip)
NSArray * processKeyCode:(NSArray *key_def)
void setGuiToKeyConfigScreen:(BOOL resetSelectedRow)
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)
voidpf uLong offset
Definition ioapi.h:132
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque