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

#include <PlayerEntityStickMapper.h>

Instance Methods

(void) - resetStickFunctions
 
(void) - setGuiToStickMapperScreen:resetCurrentRow:
 
(void) - setGuiToStickMapperScreen:
 
(void) - stickMapperInputHandler:view:
 
(void) - updateFunction:
 
(NSDictionary *) - makeStickGuiDictHeader:
 
(NSDictionary *) - makeStickGuiDict:allowable:axisfn:butfn:
 
(void) - checkCustomEquipButtons:ignore: [implementation]
 
(void) - removeFunction: [implementation]
 
(void) - displayFunctionList:skip: [implementation]
 
(NSString *) - describeStickDict: [implementation]
 
(NSString *) - hwToString: [implementation]
 
(NSArray *) - stickFunctionList [implementation]
 

Detailed Description

Definition at line 52 of file PlayerEntityStickMapper.h.

Method Documentation

◆ checkCustomEquipButtons:ignore:

- (void) checkCustomEquipButtons: (NSDictionary *)  stickFn
ignore: (int idx 
implementation

Definition at line 1 of file PlayerEntityStickMapper.m.

317 :(NSDictionary *)stickFn ignore:(int)idx
318{
319 int i;
320 for (i = 0; i < [customEquipActivation count]; i++)
321 {
322 if (i != idx) {
323 NSMutableDictionary *custEquip = [[customEquipActivation objectAtIndex:i] mutableCopy];
324 NSDictionary *bf = [[customEquipActivation objectAtIndex:i] objectForKey:CUSTOMEQUIP_BUTTONACTIVATE];
325 if ([bf oo_integerForKey:STICK_NUMBER] == [stickFn oo_integerForKey:STICK_NUMBER] &&
326 [bf oo_integerForKey:STICK_AXBUT] == [stickFn oo_integerForKey:STICK_AXBUT] &&
327 [custEquip objectForKey:CUSTOMEQUIP_BUTTONACTIVATE])
328 {
329 [custEquip removeObjectForKey:CUSTOMEQUIP_BUTTONACTIVATE];
330 }
331 bf = [[customEquipActivation objectAtIndex:i] objectForKey:CUSTOMEQUIP_BUTTONMODE];
332 if ([bf oo_integerForKey:STICK_NUMBER] == [stickFn oo_integerForKey:STICK_NUMBER] &&
333 [bf oo_integerForKey:STICK_AXBUT] == [stickFn oo_integerForKey:STICK_AXBUT] &&
334 [custEquip objectForKey:CUSTOMEQUIP_BUTTONMODE])
335 {
336 [custEquip removeObjectForKey:CUSTOMEQUIP_BUTTONMODE];
337 }
338 [customEquipActivation replaceObjectAtIndex:i withObject:custEquip];
339 [custEquip release];
340 }
341 }
342}
#define STICK_NUMBER
#define STICK_AXBUT
#define CUSTOMEQUIP_BUTTONACTIVATE
#define CUSTOMEQUIP_BUTTONMODE
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

◆ describeStickDict:

- (NSString *) describeStickDict: (NSDictionary *)  stickDict
implementation

Definition at line 1 of file PlayerEntityStickMapper.m.

539 : (NSDictionary *)stickDict
540{
541 NSString *desc=nil;
542 if(stickDict)
543 {
544 int thingNumber=[(NSNumber *)[stickDict objectForKey: STICK_AXBUT]
545 intValue];
546 int stickNumber=[(NSNumber *)[stickDict objectForKey: STICK_NUMBER]
547 intValue];
548 // Button or axis?
549 if([(NSNumber *)[stickDict objectForKey: STICK_ISAXIS] boolValue])
550 {
551 desc=[NSString stringWithFormat: @"Stick %d axis %d",
552 stickNumber+1, thingNumber+1];
553 }
554 else if(thingNumber >= MAX_REAL_BUTTONS)
555 {
556 static const char dir[][6] = { "up", "right", "down", "left" };
557 desc=[NSString stringWithFormat: @"Stick %d hat %d %s",
558 stickNumber+1, (thingNumber - MAX_REAL_BUTTONS) / 4 + 1,
559 dir[thingNumber & 3]];
560 }
561 else
562 {
563 desc=[NSString stringWithFormat: @"Stick %d button %d",
564 stickNumber+1, thingNumber+1];
565 }
566 }
567 return desc;
568}
#define MAX_REAL_BUTTONS
return nil

◆ displayFunctionList:skip:

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

Definition at line 1 of file PlayerEntityStickMapper.m.

404 :(GuiDisplayGen *)gui
405 skip:(NSUInteger)skip
406{
408
409 [gui setColor:[OOColor greenColor] forRow: GUI_ROW_HEADING];
410 [gui setArray:[NSArray arrayWithObjects:
411 @"Function", @"Assigned to", @"Type", nil]
412 forRow:GUI_ROW_HEADING];
413
414 if(!stickFunctions)
415 {
416 stickFunctions = [[self stickFunctionList] retain];
417 }
418 NSDictionary *assignedAxes = [stickHandler axisFunctions];
419 NSDictionary *assignedButs = [stickHandler buttonFunctions];
420
421 NSUInteger i, n_functions = [stickFunctions count];
422 NSInteger n_rows, start_row, previous = 0;
423
424 if (skip >= n_functions)
425 skip = n_functions - 1;
426
427 if (n_functions < MAX_ROWS_FUNCTIONS)
428 {
429 skip = 0;
430 previous = 0;
431 n_rows = MAX_ROWS_FUNCTIONS;
432 start_row = GUI_ROW_FUNCSTART;
433 }
434 else
435 {
436 n_rows = MAX_ROWS_FUNCTIONS - 1;
437 start_row = GUI_ROW_FUNCSTART;
438 if (skip > 0)
439 {
440 n_rows -= 1;
441 start_row += 1;
442 if (skip > MAX_ROWS_FUNCTIONS)
443 previous = skip - (MAX_ROWS_FUNCTIONS - 2);
444 else
445 previous = 0;
446 }
447 }
448
449 if (n_functions > 0)
450 {
451 if (skip > 0)
452 {
453 [gui setColor:[OOColor greenColor] forRow:GUI_ROW_FUNCSTART];
454 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil] forRow:GUI_ROW_FUNCSTART];
455 [gui setKey:[NSString stringWithFormat:@"More:%lld", previous] forRow:GUI_ROW_FUNCSTART];
456 }
457
458 for(i=0; i < (n_functions - skip) && (int)i < n_rows; i++)
459 {
460 NSDictionary *entry = [stickFunctions objectAtIndex: i + skip];
461 if ([entry objectForKey:KEY_HEADER]) {
462 NSString *header = [entry objectForKey:KEY_HEADER];
463 [gui setArray:[NSArray arrayWithObjects:header, @"", @"", nil] forRow:i + start_row];
464 [gui setColor:[OOColor cyanColor] forRow:i + start_row];
465 }
466 else
467 {
468 NSString *allowedThings;
469 NSString *assignment;
470 NSString *axFuncKey = [entry oo_stringForKey:KEY_AXISFN];
471 NSString *butFuncKey = [entry oo_stringForKey:KEY_BUTTONFN];
472 int allowable = [entry oo_intForKey:KEY_ALLOWABLE];
473 switch(allowable)
474 {
475 case HW_AXIS:
476 allowedThings=@"Axis";
477 assignment=[self describeStickDict:
478 [assignedAxes objectForKey: axFuncKey]];
479 break;
480 case HW_BUTTON:
481 allowedThings=@"Button";
482 int bf = [butFuncKey integerValue];
483 if (bf < 10000)
484 {
485 assignment=[self describeStickDict:
486 [assignedButs objectForKey: butFuncKey]];
487 }
488 else
489 {
490 NSString *key = CUSTOMEQUIP_BUTTONACTIVATE;
491 bf -= 10000;
492 if (bf >= 10000)
493 {
494 bf -= 10000;
496 }
497 assignment=[self describeStickDict:
498 [[customEquipActivation objectAtIndex:bf] objectForKey:key]];
499 }
500 break;
501 default:
502 allowedThings=@"Axis/Button";
503
504 // axis has priority
505 assignment=[self describeStickDict:
506 [assignedAxes objectForKey: axFuncKey]];
507 if(!assignment)
508 assignment=[self describeStickDict:
509 [assignedButs objectForKey: butFuncKey]];
510 }
511
512 // Find out what's assigned for this function currently.
513 if (assignment == nil)
514 {
515 assignment = @" - ";
516 }
517
518 [gui setArray: [NSArray arrayWithObjects:
519 [entry objectForKey: KEY_GUIDESC], assignment, allowedThings, nil]
520 forRow: i + start_row];
521 //[gui setKey: GUI_KEY_OK forRow: i + start_row];
522 [gui setKey: [NSString stringWithFormat: @"Index:%llu", i + skip] forRow: i + start_row];
523 }
524 }
525 if (i < n_functions - skip)
526 {
527 [gui setColor: [OOColor greenColor] forRow: start_row + i];
528 [gui setArray: [NSArray arrayWithObjects: DESC(@"gui-more"), @" --> ", nil] forRow: start_row + i];
529 [gui setKey: [NSString stringWithFormat: @"More:%llu", n_rows + skip] forRow: start_row + i];
530 i++;
531 }
532
533 [gui setSelectableRange: NSMakeRange(GUI_ROW_STICKPROFILE, i + start_row - GUI_ROW_STICKPROFILE)];
534 }
535
536}
#define HW_BUTTON
#define HW_AXIS
#define KEY_HEADER
#define MAX_ROWS_FUNCTIONS
#define GUI_ROW_FUNCSTART
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 * cyanColor()
Definition OOColor.m:286
OOColor * greenColor()
Definition OOColor.m:274
NSDictionary * buttonFunctions()
NSDictionary * axisFunctions()

◆ hwToString:

- (NSString *) hwToString: (int hwFlags
implementation

Definition at line 1 of file PlayerEntityStickMapper.m.

571 : (int)hwFlags
572{
573 NSString *hwString;
574 switch(hwFlags)
575 {
576 case HW_AXIS:
577 hwString = @"axis";
578 break;
579 case HW_BUTTON:
580 hwString = @"button";
581 break;
582 default:
583 hwString = @"axis/button";
584 }
585 return hwString;
586}

◆ makeStickGuiDict:allowable:axisfn:butfn:

- (NSDictionary *) makeStickGuiDict: (NSString *)  what
allowable: (int allowable
axisfn: (int axisfn
butfn: (int butfn 

Definition at line 1 of file PlayerEntityStickMapper.m.

903 :(NSString *)what
904 allowable:(int)allowable
905 axisfn:(int)axisfn
906 butfn:(int)butfn
907{
908 NSMutableDictionary *guiDict = [NSMutableDictionary dictionary];
909
910 if ([what length] > 50) what = [[what substringToIndex:28] stringByAppendingString:@"..."];
911 [guiDict setObject: what forKey: KEY_GUIDESC];
912 [guiDict setObject: [NSNumber numberWithInt: allowable]
913 forKey: KEY_ALLOWABLE];
914 if(axisfn >= 0)
915 [guiDict setObject: [NSNumber numberWithInt: axisfn]
916 forKey: KEY_AXISFN];
917 if(butfn >= 0)
918 [guiDict setObject: [NSNumber numberWithInt: butfn]
919 forKey: KEY_BUTTONFN];
920 return guiDict;
921}

◆ makeStickGuiDictHeader:

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

Definition at line 1 of file PlayerEntityStickMapper.m.

923 :(NSString *)header
924{
925 NSMutableDictionary *guiDict = [NSMutableDictionary dictionary];
926 [guiDict setObject:header forKey:KEY_HEADER];
927 [guiDict setObject:@"" forKey:KEY_ALLOWABLE];
928 [guiDict setObject:@"" forKey:KEY_AXISFN];
929 [guiDict setObject:@"" forKey:KEY_BUTTONFN];
930 return guiDict;
931}

◆ removeFunction:

- (void) removeFunction: (int idx
implementation

Definition at line 1 of file PlayerEntityStickMapper.m.

345 :(int)idx
346{
348 NSDictionary *entry = [stickFunctions objectAtIndex:idx];
349 NSNumber *butfunc = [entry objectForKey:KEY_BUTTONFN];
350 NSNumber *axfunc = [entry objectForKey:KEY_AXISFN];
351 BOOL custom = NO;
352 selFunctionIdx = idx;
353
354 // Some things can have either axis or buttons - make sure we clear
355 // both!
356 if(butfunc)
357 {
358 // special case for OXP equipment buttons
359 if ([butfunc intValue] >= 10000)
360 {
361 int bf = [butfunc intValue];
362 custom = YES;
363 NSString *key = CUSTOMEQUIP_BUTTONACTIVATE;
364 bf -= 10000;
365 if (bf >= 10000)
366 {
367 bf -= 10000;
369 }
370 NSMutableDictionary *custEquip = [[customEquipActivation objectAtIndex:bf] mutableCopy];
371 if ([key isEqualToString:CUSTOMEQUIP_BUTTONACTIVATE] && [custEquip objectForKey:CUSTOMEQUIP_BUTTONACTIVATE]) [custEquip removeObjectForKey:key];
372 if ([key isEqualToString:CUSTOMEQUIP_BUTTONMODE] && [custEquip objectForKey:CUSTOMEQUIP_BUTTONMODE]) [custEquip removeObjectForKey:key];
373 [customEquipActivation replaceObjectAtIndex:bf withObject:custEquip];
374 [custEquip release];
375 }
376 else
377 {
378 [stickHandler unsetButtonFunction:[butfunc intValue]];
379 }
380 }
381 if(axfunc)
382 {
383 [stickHandler unsetAxisFunction:[axfunc intValue]];
384 }
385 if (!custom)
386 {
387 [stickHandler saveStickSettings];
388 }
389 else
390 {
391 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
392 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
393 }
394
395 unsigned skip;
396 if (selFunctionIdx < MAX_ROWS_FUNCTIONS - 1)
397 skip = 0;
398 else
399 skip = ((selFunctionIdx - 1) / (MAX_ROWS_FUNCTIONS - 2)) * (MAX_ROWS_FUNCTIONS - 2) + 1;
400 [self setGuiToStickMapperScreen: skip];
401}
void unsetButtonFunction:(int function)
void unsetAxisFunction:(int function)

◆ resetStickFunctions

- (void) resetStickFunctions

Definition at line 1 of file PlayerEntityStickMapper.m.

50{
51 [stickFunctions release];
52 stickFunctions = nil;
53}

◆ setGuiToStickMapperScreen:

- (void) setGuiToStickMapperScreen: (unsigned)  skip

Definition at line 1 of file PlayerEntityStickMapper.m.

56 :(unsigned)skip
57{
58 [self setGuiToStickMapperScreen: skip resetCurrentRow: NO];
59}

◆ setGuiToStickMapperScreen:resetCurrentRow:

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

Definition at line 1 of file PlayerEntityStickMapper.m.

61 :(unsigned)skip resetCurrentRow: (BOOL) resetCurrentRow
62{
63 GuiDisplayGen *gui = [UNIVERSE gui];
65 NSArray *stickList = [stickHandler listSticks];
66 unsigned stickCount = [stickList count];
67 unsigned i;
68
69 OOGUITabStop tabStop[GUI_MAX_COLUMNS];
70 tabStop[0] = 10;
71 tabStop[1] = 290;
72 tabStop[2] = 400;
73 [gui setTabStops:tabStop];
74
75 gui_screen = GUI_SCREEN_STICKMAPPER;
76 [gui clear];
77 [gui setTitle:[NSString stringWithFormat:@"Configure Joysticks"]];
78
79 for(i=0; i < stickCount; i++)
80 {
81 NSString *stickNameForThisRow = [NSString stringWithFormat: @"Stick %d %@", i+1, [stickList objectAtIndex: i]];
82 // for more than 2 sticks, the stick name rows are populated by more than one name if needed
83 NSString *stickNameAdditional = nil;
84 if (stickCount > 2 && OOStringWidthInEm(stickNameForThisRow) > 18.0)
85 {
86 // string is too long, truncate it until its length gets below threshold
87 do {
88 stickNameForThisRow = [[stickNameForThisRow substringToIndex:[stickNameForThisRow length] - 5]
89 stringByAppendingString:@"..."];
90 } while (OOStringWidthInEm(stickNameForThisRow) > 18.0);
91 }
92 unsigned j = i + 2;
93 if (j < stickCount)
94 {
95 stickNameAdditional = [NSString stringWithFormat: @"Stick %d %@", j+1, [stickList objectAtIndex: j]];
96 if (OOStringWidthInEm(stickNameAdditional) > 11.0)
97 {
98 // string is too long, truncate it until its length gets below threshold
99 do {
100 stickNameAdditional = [[stickNameAdditional substringToIndex:[stickNameAdditional length] - 5]
101 stringByAppendingString:@"..."];
102 } while (OOStringWidthInEm(stickNameAdditional) > 11.0);
103 }
104 }
105 [gui setArray:[NSArray arrayWithObjects:
106 stickNameForThisRow,
107 @"", // skip one column
108 stickNameAdditional,
109 nil]
110 forRow:i + GUI_ROW_STICKNAME];
111 }
112
113 [gui setArray: [NSArray arrayWithObjects: DESC(@"stickmapper-profile"), nil] forRow: GUI_ROW_STICKPROFILE];
114 [gui setKey: GUI_KEY_OK forRow: GUI_ROW_STICKPROFILE];
115 [self displayFunctionList:gui skip:skip];
116
117 [gui setArray:[NSArray arrayWithObject:@"Select a function and press Enter to modify or 'u' to unset."]
118 forRow:GUI_ROW_INSTRUCT];
119
120 [gui setText:@"Space to return to previous screen." forRow:GUI_ROW_INSTRUCT+1 align:GUI_ALIGN_CENTER];
121
122 if (resetCurrentRow)
123 {
124 [gui setSelectedRow: GUI_ROW_STICKPROFILE];
125 }
126 [[UNIVERSE gameView] suppressKeysUntilKeyUp];
127 [gui setForegroundTextureKey:[self status] == STATUS_DOCKED ? @"docked_overlay" : @"paused_overlay"];
128 [gui setBackgroundTextureKey:@"settings"];
129}
NSInteger OOGUITabStop
CGFloat OOStringWidthInEm(NSString *text)
BOOL setBackgroundTextureKey:(NSString *key)
BOOL setSelectedRow:(OOGUIRow row)
BOOL setForegroundTextureKey:(NSString *key)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setTitle:(NSString *str)
void setTabStops:(OOGUITabSettings stops)

◆ stickFunctionList

- (NSArray *) stickFunctionList
implementation

Definition at line 1 of file PlayerEntityStickMapper.m.

592{
593 NSMutableArray *funcList = [NSMutableArray array];
594
595 // propulsion
596 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-propulsion")]];
597 [funcList addObject:
598 [self makeStickGuiDict:DESC(@"stickmapper-roll")
599 allowable:HW_AXIS
600 axisfn:AXIS_ROLL
601 butfn:STICK_NOFUNCTION]];
602 [funcList addObject:
603 [self makeStickGuiDict:DESC(@"stickmapper-pitch")
604 allowable:HW_AXIS
605 axisfn:AXIS_PITCH
606 butfn:STICK_NOFUNCTION]];
607 [funcList addObject:
608 [self makeStickGuiDict:DESC(@"stickmapper-yaw")
609 allowable:HW_AXIS
610 axisfn:AXIS_YAW
611 butfn:STICK_NOFUNCTION]];
612 [funcList addObject:
613 [self makeStickGuiDict:DESC(@"stickmapper-increase-thrust")
614 allowable:HW_AXIS|HW_BUTTON
615 axisfn:AXIS_THRUST
616 butfn:BUTTON_INCTHRUST]];
617 [funcList addObject:
618 [self makeStickGuiDict:DESC(@"stickmapper-decrease-thrust")
619 allowable:HW_AXIS|HW_BUTTON
620 axisfn:AXIS_THRUST
621 butfn:BUTTON_DECTHRUST]];
622 [funcList addObject:
623 [self makeStickGuiDict:DESC(@"stickmapper-fuel-injection")
624 allowable:HW_BUTTON
625 axisfn:STICK_NOFUNCTION
626 butfn:BUTTON_FUELINJECT]];
627 [funcList addObject:
628 [self makeStickGuiDict:DESC(@"stickmapper-hyperspeed")
629 allowable:HW_BUTTON
630 axisfn:STICK_NOFUNCTION
631 butfn:BUTTON_HYPERSPEED]];
632 [funcList addObject:
633 [self makeStickGuiDict:DESC(@"stickmapper-hyperdrive")
634 allowable:HW_BUTTON
635 axisfn:STICK_NOFUNCTION
636 butfn:BUTTON_HYPERDRIVE]];
637 [funcList addObject:
638 [self makeStickGuiDict:DESC(@"stickmapper-gal-hyperdrive")
639 allowable:HW_BUTTON
640 axisfn:STICK_NOFUNCTION
641 butfn:BUTTON_GALACTICDRIVE]];
642
643 [funcList addObject:
644 [self makeStickGuiDict:DESC(@"stickmapper-roll/pitch-precision-toggle")
645 allowable:HW_BUTTON
646 axisfn:STICK_NOFUNCTION
647 butfn:BUTTON_PRECISION]];
648
649 // navigation
650 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-navigation")]];
651 [funcList addObject:
652 [self makeStickGuiDict:DESC(@"stickmapper-compass-mode-next")
653 allowable:HW_BUTTON
654 axisfn:STICK_NOFUNCTION
655 butfn:BUTTON_COMPASSMODE]];
656 [funcList addObject:
657 [self makeStickGuiDict:DESC(@"stickmapper-compass-mode-prev")
658 allowable:HW_BUTTON
659 axisfn:STICK_NOFUNCTION
660 butfn:BUTTON_COMPASSMODE_PREV]];
661 [funcList addObject:
662 [self makeStickGuiDict:DESC(@"stickmapper-scanner-zoom")
663 allowable:HW_BUTTON
664 axisfn:STICK_NOFUNCTION
665 butfn:BUTTON_SCANNERZOOM]];
666 [funcList addObject:
667 [self makeStickGuiDict:DESC(@"stickmapper-scanner-unzoom")
668 allowable:HW_BUTTON
669 axisfn:STICK_NOFUNCTION
670 butfn:BUTTON_SCANNERUNZOOM]];
671 [funcList addObject:
672 [self makeStickGuiDict:DESC(@"stickmapper-view-forward")
673 allowable:HW_AXIS|HW_BUTTON
674 axisfn:AXIS_VIEWY
675 butfn:BUTTON_VIEWFORWARD]];
676 [funcList addObject:
677 [self makeStickGuiDict:DESC(@"stickmapper-view-aft")
678 allowable:HW_AXIS|HW_BUTTON
679 axisfn:AXIS_VIEWY
680 butfn:BUTTON_VIEWAFT]];
681 [funcList addObject:
682 [self makeStickGuiDict:DESC(@"stickmapper-view-port")
683 allowable:HW_AXIS|HW_BUTTON
684 axisfn:AXIS_VIEWX
685 butfn:BUTTON_VIEWPORT]];
686 [funcList addObject:
687 [self makeStickGuiDict:DESC(@"stickmapper-view-starboard")
688 allowable:HW_AXIS|HW_BUTTON
689 axisfn:AXIS_VIEWX
690 butfn:BUTTON_VIEWSTARBOARD]];
691 [funcList addObject:
692 [self makeStickGuiDict:DESC(@"stickmapper-ext-view-cycle")
693 allowable:HW_BUTTON
694 axisfn:STICK_NOFUNCTION
695 butfn:BUTTON_EXTVIEWCYCLE]];
696 [funcList addObject:
697 [self makeStickGuiDict:DESC(@"stickmapper-toggle-ID")
698 allowable:HW_BUTTON
699 axisfn:STICK_NOFUNCTION
700 butfn:BUTTON_ID]];
701 [funcList addObject:
702 [self makeStickGuiDict:DESC(@"stickmapper-docking-clearance")
703 allowable:HW_BUTTON
704 axisfn:STICK_NOFUNCTION
705 butfn:BUTTON_DOCKINGCLEARANCE]];
706 [funcList addObject:
707 [self makeStickGuiDict:DESC(@"stickmapper-dockcpu")
708 allowable:HW_BUTTON
709 axisfn:STICK_NOFUNCTION
710 butfn:BUTTON_DOCKCPU]];
711 [funcList addObject:
712 [self makeStickGuiDict:DESC(@"stickmapper-dockcpufast")
713 allowable:HW_BUTTON
714 axisfn:STICK_NOFUNCTION
715 butfn:BUTTON_DOCKCPUFAST]];
716 [funcList addObject:
717 [self makeStickGuiDict:DESC(@"stickmapper-docking-music")
718 allowable:HW_BUTTON
719 axisfn:STICK_NOFUNCTION
720 butfn:BUTTON_DOCKINGMUSIC]];
721
722 // offensive
723 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-offensive")]];
724 [funcList addObject:
725 [self makeStickGuiDict:DESC(@"stickmapper-weapons-online-toggle")
726 allowable:HW_BUTTON
727 axisfn:STICK_NOFUNCTION
728 butfn:BUTTON_WEAPONSONLINETOGGLE]];
729 [funcList addObject:
730 [self makeStickGuiDict:DESC(@"stickmapper-primary-weapon")
731 allowable:HW_BUTTON
732 axisfn:STICK_NOFUNCTION
733 butfn:BUTTON_FIRE]];
734 [funcList addObject:
735 [self makeStickGuiDict:DESC(@"stickmapper-secondary-weapon")
736 allowable:HW_BUTTON
737 axisfn:STICK_NOFUNCTION
738 butfn:BUTTON_LAUNCHMISSILE]];
739 [funcList addObject:
740 [self makeStickGuiDict:DESC(@"stickmapper-arm-secondary")
741 allowable:HW_BUTTON
742 axisfn:STICK_NOFUNCTION
743 butfn:BUTTON_ARMMISSILE]];
744 [funcList addObject:
745 [self makeStickGuiDict:DESC(@"stickmapper-disarm-secondary")
746 allowable:HW_BUTTON
747 axisfn:STICK_NOFUNCTION
748 butfn:BUTTON_UNARM]];
749 [funcList addObject:
750 [self makeStickGuiDict:DESC(@"stickmapper-target-nearest-incoming-missile")
751 allowable:HW_BUTTON
752 axisfn:STICK_NOFUNCTION
753 butfn:BUTTON_TARGETINCOMINGMISSILE]];
754 [funcList addObject:
755 [self makeStickGuiDict:DESC(@"stickmapper-cycle-secondary")
756 allowable:HW_BUTTON
757 axisfn:STICK_NOFUNCTION
758 butfn:BUTTON_CYCLEMISSILE]];
759 [funcList addObject:
760 [self makeStickGuiDict:DESC(@"stickmapper-next-target")
761 allowable:HW_BUTTON
762 axisfn:STICK_NOFUNCTION
763 butfn:BUTTON_NEXTTARGET]];
764 [funcList addObject:
765 [self makeStickGuiDict:DESC(@"stickmapper-previous-target")
766 allowable:HW_BUTTON
767 axisfn:STICK_NOFUNCTION
768 butfn:BUTTON_PREVTARGET]];
769
770 // defensive
771 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-defensive")]];
772 [funcList addObject:
773 [self makeStickGuiDict:DESC(@"stickmapper-ECM")
774 allowable:HW_BUTTON
775 axisfn:STICK_NOFUNCTION
776 butfn:BUTTON_ECM]];
777 [funcList addObject:
778 [self makeStickGuiDict:DESC(@"stickmapper-jettison")
779 allowable:HW_BUTTON
780 axisfn:STICK_NOFUNCTION
781 butfn:BUTTON_JETTISON]];
782 [funcList addObject:
783 [self makeStickGuiDict:DESC(@"stickmapper-rotate-cargo")
784 allowable:HW_BUTTON
785 axisfn:STICK_NOFUNCTION
786 butfn:BUTTON_ROTATECARGO]];
787 [funcList addObject:
788 [self makeStickGuiDict:DESC(@"stickmapper-escape-pod")
789 allowable:HW_BUTTON
790 axisfn:STICK_NOFUNCTION
791 butfn:BUTTON_ESCAPE]];
792
793 // oxp special equip
794 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-special-equip")]];
795 [funcList addObject:
796 [self makeStickGuiDict:DESC(@"stickmapper-mfd-select-next")
797 allowable:HW_BUTTON
798 axisfn:STICK_NOFUNCTION
799 butfn:BUTTON_MFDSELECTNEXT]];
800 [funcList addObject:
801 [self makeStickGuiDict:DESC(@"stickmapper-mfd-select-prev")
802 allowable:HW_BUTTON
803 axisfn:STICK_NOFUNCTION
804 butfn:BUTTON_MFDSELECTPREV]];
805 [funcList addObject:
806 [self makeStickGuiDict:DESC(@"stickmapper-mfd-cycle-next")
807 allowable:HW_BUTTON
808 axisfn:STICK_NOFUNCTION
809 butfn:BUTTON_MFDCYCLENEXT]];
810 [funcList addObject:
811 [self makeStickGuiDict:DESC(@"stickmapper-mfd-cycle-prev")
812 allowable:HW_BUTTON
813 axisfn:STICK_NOFUNCTION
814 butfn:BUTTON_MFDCYCLEPREV]];
815 [funcList addObject:
816 [self makeStickGuiDict:DESC(@"stickmapper-prime-equipment")
817 allowable:HW_BUTTON
818 axisfn:STICK_NOFUNCTION
819 butfn:BUTTON_PRIMEEQUIPMENT]];
820 [funcList addObject:
821 [self makeStickGuiDict:DESC(@"stickmapper-prime-prev-equipment")
822 allowable:HW_BUTTON
823 axisfn:STICK_NOFUNCTION
824 butfn:BUTTON_PRIMEEQUIPMENT]];
825 [funcList addObject:
826 [self makeStickGuiDict:DESC(@"stickmapper-activate-equipment")
827 allowable:HW_BUTTON
828 axisfn:STICK_NOFUNCTION
829 butfn:BUTTON_ACTIVATEEQUIPMENT]];
830 [funcList addObject:
831 [self makeStickGuiDict:DESC(@"stickmapper-mode-equipment")
832 allowable:HW_BUTTON
833 axisfn:STICK_NOFUNCTION
834 butfn:BUTTON_MODEEQUIPMENT]];
835 [funcList addObject:
836 [self makeStickGuiDict:DESC(@"stickmapper-fastactivate-a")
837 allowable:HW_BUTTON
838 axisfn:STICK_NOFUNCTION
839 butfn:BUTTON_CLOAK]];
840 [funcList addObject:
841 [self makeStickGuiDict:DESC(@"stickmapper-fastactivate-b")
842 allowable:HW_BUTTON
843 axisfn:STICK_NOFUNCTION
844 butfn:BUTTON_ENERGYBOMB]];
845
846 // misc
847 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-misc")]];
848 [funcList addObject:
849 [self makeStickGuiDict:DESC(@"stickmapper-snapshot")
850 allowable:HW_BUTTON
851 axisfn:STICK_NOFUNCTION
852 butfn:BUTTON_SNAPSHOT]];
853 [funcList addObject:
854 [self makeStickGuiDict:DESC(@"stickmapper-pause")
855 allowable:HW_BUTTON
856 axisfn:STICK_NOFUNCTION
857 butfn:BUTTON_PAUSE]];
858 [funcList addObject:
859 [self makeStickGuiDict:DESC(@"stickmapper-toggle-hud")
860 allowable:HW_BUTTON
861 axisfn:STICK_NOFUNCTION
862 butfn:BUTTON_TOGGLEHUD]];
863 [funcList addObject:
864 [self makeStickGuiDict:DESC(@"stickmapper-comms-log")
865 allowable:HW_BUTTON
866 axisfn:STICK_NOFUNCTION
867 butfn:BUTTON_COMMSLOG]];
868#if OO_FOV_INFLIGHT_CONTROL_ENABLED
869 [funcList addObject:
870 [self makeStickGuiDict:DESC(@"stickmapper-increase-field-of-view")
871 allowable:HW_AXIS|HW_BUTTON
872 axisfn:AXIS_FIELD_OF_VIEW
873 butfn:BUTTON_INC_FIELD_OF_VIEW]];
874 [funcList addObject:
875 [self makeStickGuiDict:DESC(@"stickmapper-decrease-field-of-view")
876 allowable:HW_AXIS|HW_BUTTON
877 axisfn:AXIS_FIELD_OF_VIEW
878 butfn:BUTTON_DEC_FIELD_OF_VIEW]];
879#endif
880 if ([customEquipActivation count] > 0) {
881 [funcList addObject:[self makeStickGuiDictHeader:DESC(@"stickmapper-header-oxp-equip")]];
882 int i;
883 for (i = 0; i < [customEquipActivation count]; i++)
884 {
885 [funcList addObject:
886 [self makeStickGuiDict:[NSString stringWithFormat: @"Activate '%@'", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
887 allowable:HW_BUTTON
888 axisfn:STICK_NOFUNCTION
889 butfn:(i+10000)]];
890 [funcList addObject:
891 [self makeStickGuiDict:[NSString stringWithFormat: @"Mode '%@'", [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPNAME]]
892 allowable:HW_BUTTON
893 axisfn:STICK_NOFUNCTION
894 butfn:(i+20000)]];
895 }
896
897 }
898 return funcList;
899}
unsigned count

◆ stickMapperInputHandler:view:

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

Definition at line 1 of file PlayerEntityStickMapper.m.

132 :(GuiDisplayGen *)gui
133 view:(MyOpenGLView *)gameView
134{
136
137 // Don't do anything if the user is supposed to be selecting
138 // a function - other than look for Escape.
139 if(waitingForStickCallback)
140 {
141 if([gameView isDown: 27])
142 {
143 [stickHandler clearCallback];
144 [gui setArray: [NSArray arrayWithObjects:
145 @"Function setting aborted.", nil]
146 forRow: GUI_ROW_INSTRUCT];
147 waitingForStickCallback=NO;
148 }
149
150 // Break out now.
151 return;
152 }
153
154 [self handleGUIUpDownArrowKeys];
155
156 if ([gui selectedRow] == GUI_ROW_STICKPROFILE && [gameView isDown: 13])
157 {
158 [self setGuiToStickProfileScreen: gui];
159 return;
160 }
161
162 NSString* key = [gui keyForRow: [gui selectedRow]];
163 if ([key hasPrefix:@"Index:"])
164 selFunctionIdx=[[[key componentsSeparatedByString:@":"] objectAtIndex: 1] intValue];
165 else
166 selFunctionIdx=-1;
167
168 if([gameView isDown: 13])
169 {
170 if ([key hasPrefix:@"More:"])
171 {
172 int from_function = [[[key componentsSeparatedByString:@":"] objectAtIndex: 1] intValue];
173 if (from_function < 0) from_function = 0;
174
175 [self setGuiToStickMapperScreen:from_function];
176 if ([[UNIVERSE gui] selectedRow] < 0)
177 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART];
178 if (from_function == 0)
179 [[UNIVERSE gui] setSelectedRow: GUI_ROW_FUNCSTART + MAX_ROWS_FUNCTIONS - 1];
180 return;
181 }
182
183 NSDictionary *entry=[stickFunctions objectAtIndex: selFunctionIdx];
184 int hw=[(NSNumber *)[entry objectForKey: KEY_ALLOWABLE] intValue];
185 [stickHandler setCallback: @selector(updateFunction:)
186 object: self
187 hardware: hw];
188
189 // Print instructions
190 NSString *instructions;
191 switch(hw)
192 {
193 case HW_AXIS:
194 instructions = @"Fully deflect the axis you want to use for this function. Esc aborts.";
195 break;
196 case HW_BUTTON:
197 instructions = @"Press the button you want to use for this function. Esc aborts.";
198 break;
199 default:
200 instructions = @"Press the button or deflect the axis you want to use for this function.";
201 }
202 [gui setArray: [NSArray arrayWithObjects: instructions, nil] forRow: GUI_ROW_INSTRUCT];
203 waitingForStickCallback=YES;
204 }
205
206 if([gameView isDown: 'u'])
207 {
208 if (selFunctionIdx >= 0) [self removeFunction: selFunctionIdx];
209 }
210}
#define GUI_ROW_STICKPROFILE
#define UNIVERSE
Definition Universe.h:842
OOGUIRow selectedRow
NSString * keyForRow:(OOGUIRow row)
void setCallback:object:hardware:(SEL selector,[object] id obj,[hardware] char hwflags)

◆ updateFunction:

- (void) updateFunction: (NSDictionary *)  hwDict

Definition at line 1 of file PlayerEntityStickMapper.m.

215 : (NSDictionary *)hwDict
216{
218 waitingForStickCallback = NO;
219
220 // Right time and the right place?
221 if(gui_screen != GUI_SCREEN_STICKMAPPER)
222 {
223 OOLog(@"joystick.configure.error", @"%s called when not on stick mapper screen.", __PRETTY_FUNCTION__);
224 return;
225 }
226 // What moved?
227 int function;
228 NSDictionary *entry = [stickFunctions objectAtIndex:selFunctionIdx];
229 if([hwDict oo_boolForKey:STICK_ISAXIS])
230 {
231 function=[entry oo_intForKey: KEY_AXISFN];
232 if (function == AXIS_THRUST)
233 {
234 [stickHandler unsetButtonFunction:BUTTON_INCTHRUST];
235 [stickHandler unsetButtonFunction:BUTTON_DECTHRUST];
236 }
237#if OO_FOV_INFLIGHT_CONTROL_ENABLED
238 if (function == AXIS_FIELD_OF_VIEW)
239 {
240 [stickHandler unsetButtonFunction:BUTTON_INC_FIELD_OF_VIEW];
241 [stickHandler unsetButtonFunction:BUTTON_DEC_FIELD_OF_VIEW];
242 }
243#endif
244 if (function == AXIS_VIEWX)
245 {
246 [stickHandler unsetButtonFunction:BUTTON_VIEWPORT];
247 [stickHandler unsetButtonFunction:BUTTON_VIEWSTARBOARD];
248 }
249 if (function == AXIS_VIEWY)
250 {
251 [stickHandler unsetButtonFunction:BUTTON_VIEWFORWARD];
252 [stickHandler unsetButtonFunction:BUTTON_VIEWAFT];
253 }
254 }
255 else
256 {
257 function = [entry oo_intForKey:KEY_BUTTONFN];
258 if (function == BUTTON_INCTHRUST || function == BUTTON_DECTHRUST)
259 {
260 [stickHandler unsetAxisFunction:AXIS_THRUST];
261 }
262#if OO_FOV_INFLIGHT_CONTROL_ENABLED
263 if (function == BUTTON_INC_FIELD_OF_VIEW || function == BUTTON_DEC_FIELD_OF_VIEW)
264 {
265 [stickHandler unsetAxisFunction:AXIS_FIELD_OF_VIEW];
266 }
267#endif
268 if (function == BUTTON_VIEWPORT || function == BUTTON_VIEWSTARBOARD)
269 {
270 [stickHandler unsetAxisFunction:AXIS_VIEWX];
271 }
272 if (function == BUTTON_VIEWFORWARD || function == BUTTON_VIEWAFT)
273 {
274 [stickHandler unsetAxisFunction:AXIS_VIEWY];
275 }
276 }
277 // special case for OXP equipment buttons
278 if (function >= 10000)
279 {
280 NSString *key = CUSTOMEQUIP_BUTTONACTIVATE;
281 function -= 10000;
282 if (function >= 10000)
283 {
284 function -= 10000;
286 }
287 NSMutableDictionary *custEquip = [[customEquipActivation objectAtIndex:function] mutableCopy];
288 [custEquip setObject:hwDict forKey:key];
289 [customEquipActivation replaceObjectAtIndex:function withObject:custEquip];
290 [custEquip release];
291 [self checkCustomEquipButtons:hwDict ignore:function];
292 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
293 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
294 }
295 else
296 {
297 [stickHandler setFunction:function withDict:hwDict];
298 [self checkCustomEquipButtons:hwDict ignore:-1];
299 [stickHandler saveStickSettings];
300 }
301
302 // Update the GUI (this will refresh the function list).
303 unsigned skip;
304 if (selFunctionIdx < MAX_ROWS_FUNCTIONS - 1)
305 {
306 skip = 0;
307 }
308 else
309 {
310 skip = ((selFunctionIdx - 1) / (MAX_ROWS_FUNCTIONS - 2)) * (MAX_ROWS_FUNCTIONS - 2) + 1;
311 }
312
313 [self setGuiToStickMapperScreen:skip];
314}
#define STICK_ISAXIS
@ BUTTON_VIEWSTARBOARD
@ BUTTON_VIEWAFT
@ BUTTON_VIEWPORT
@ BUTTON_VIEWFORWARD
@ BUTTON_INCTHRUST
@ BUTTON_DECTHRUST
@ AXIS_VIEWX
@ AXIS_THRUST
@ AXIS_VIEWY
#define OOLog(class, format,...)
Definition OOLogging.h:88
void setFunction:withDict:(int function,[withDict] NSDictionary *stickFn)

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