Oolite
Loading...
Searching...
No Matches
OOJoystickManager Class Reference

#include <OOJoystickManager.h>

Inheritance diagram for OOJoystickManager:
Collaboration diagram for OOJoystickManager:

Instance Methods

(id) - init
(NSPoint) - rollPitchAxis
(NSPoint) - viewAxis
(void) - setFunction:withDict:
(void) - unsetAxisFunction:
(void) - unsetButtonFunction:
(void) - unsetGuiButtonFunction:
(BOOL) - isButtonDown:stick:
(BOOL) - getButtonState:
(double) - getAxisState:
(double) - getSensitivity
(void) - setProfile:forAxis:
(OOJoystickAxisProfile *) - getProfileForAxis:
(void) - saveProfileForAxis:
(void) - loadProfileForAxis:
(const BOOL *) - getAllButtonStates
(NSArray *) - listSticks
(NSDictionary *) - axisFunctions
(NSDictionary *) - buttonFunctions
(NSDictionary *) - guiButtonFunctions
(void) - setCallback:object:hardware:
(void) - clearCallback
(void) - setDefaultMapping
(void) - clearMappings
(void) - clearStickStates
(void) - clearStickButtonState:
(void) - saveStickSettings
(void) - loadStickSettings
(NSUInteger) - joystickCount
(NSString *) - nameOfJoystick:
(int16_t) - getAxisWithStick:axis:
(void) - setFunctionForAxis:function:stick: [implementation]
(void) - setFunctionForButton:function:stick: [implementation]
(void) - setGuiFunctionForButton:function:stick: [implementation]

Class Methods

(id) + sharedStickHandler
(BOOL) + setStickHandlerClass:

Protected Attributes

int8_t axismap [MAX_STICKS][MAX_AXES]
int8_t buttonmap [MAX_STICKS][MAX_BUTTONS]
int8_t guibuttonmap [MAX_STICKS][MAX_BUTTONS]
BOOL true_butstate [MAX_STICKS][MAX_BUTTONS]
double axstate [AXIS_end]
BOOL butstate [BUTTON_end]
uint8_t hatstate [MAX_STICKS][MAX_HATS]
BOOL precisionMode
id cbObject
SEL cbSelector
char cbHardware
BOOL invertPitch

Private Attributes

OOJoystickAxisProfile * roll_profile
OOJoystickAxisProfile * pitch_profile
OOJoystickAxisProfile * yaw_profile

Detailed Description

Definition at line 167 of file OOJoystickManager.h.

Method Documentation

◆ axisFunctions

- (NSDictionary *) axisFunctions

Definition at line 283 of file OOJoystickManager.m.

284{
285 int i, j;
286 NSMutableDictionary* fnList = [NSMutableDictionary dictionary];
287
288 // Add axes
289 for (i = 0; i < MAX_AXES; i++) {
290 for (j = 0; j < MAX_STICKS; j++) {
291 if (axismap[j][i] >= 0) {
292 NSDictionary* fnDict = [NSDictionary dictionaryWithObjectsAndKeys:
293 [NSNumber numberWithBool:YES], STICK_ISAXIS,
294 [NSNumber numberWithInt:j], STICK_NUMBER,
295 [NSNumber numberWithInt:i], STICK_AXBUT,
296 nil];
297 [fnList setValue:fnDict
298 forKey:ENUMKEY(axismap[j][i])];
299 }
300 }
301 }
302 return fnList;
303}
#define MAX_AXES
#define MAX_STICKS
int8_t axismap[MAX_STICKS][MAX_AXES]

References axisFunctions, axismap, MAX_AXES, and MAX_STICKS.

Referenced by axisFunctions, PlayerEntity(StickMapperInternal)::displayFunctionList:skip:, PlayerEntity(OOControlsPrivate)::pollFlightControls:, and saveStickSettings.

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

◆ buttonFunctions

- (NSDictionary *) buttonFunctions

Definition at line 305 of file OOJoystickManager.m.

306{
307 int i, j;
308 NSMutableDictionary* fnList = [NSMutableDictionary dictionary];
309
310 // Add buttons
311 for (i = 0; i < MAX_BUTTONS; i++) {
312 for (j = 0; j < MAX_STICKS; j++) {
313 if (buttonmap[j][i] >= 0) {
314 NSDictionary* fnDict = [NSDictionary dictionaryWithObjectsAndKeys:
315 [NSNumber numberWithBool:NO], STICK_ISAXIS,
316 [NSNumber numberWithInt:j], STICK_NUMBER,
317 [NSNumber numberWithInt:i], STICK_AXBUT,
318 nil];
319 [fnList setValue:fnDict
320 forKey:ENUMKEY(buttonmap[j][i])];
321 }
322 }
323 }
324 return fnList;
325}
#define MAX_BUTTONS
int8_t buttonmap[MAX_STICKS][MAX_BUTTONS]

References buttonFunctions, buttonmap, MAX_BUTTONS, and MAX_STICKS.

Referenced by buttonFunctions, PlayerEntity(StickMapperInternal)::displayFunctionList:skip:, and saveStickSettings.

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

◆ clearCallback

- (void) clearCallback

Definition at line 519 of file OOJoystickManager.m.

520{
521 cbObject = nil;
522 cbHardware = 0;
523}
return nil

References cbHardware, cbObject, clearCallback, and nil.

Referenced by clearCallback, and PlayerEntity(StickMapper)::stickMapperInputHandler:view:.

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

◆ clearMappings

- (void) clearMappings

Definition at line 481 of file OOJoystickManager.m.

482{
483 memset(axismap, STICK_NOFUNCTION, sizeof axismap);
484 memset(buttonmap, STICK_NOFUNCTION, sizeof buttonmap);
485}
#define STICK_NOFUNCTION

References axismap, buttonmap, clearMappings, and STICK_NOFUNCTION.

Referenced by clearMappings, and loadStickSettings.

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

◆ clearStickButtonState:

- (void) clearStickButtonState: (int) stickButton

Definition at line 503 of file OOJoystickManager.m.

503 :(int)stickButton
504{
505 if (stickButton >= 0 && stickButton < BUTTON_end) {
506 butstate[stickButton] = 0;
507 }
508}
@ BUTTON_end
BOOL butstate[BUTTON_end]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References butstate, and BUTTON_end.

Referenced by PlayerEntity(OOControlsPrivate)::pollFlightControls:.

Here is the caller graph for this function:

◆ clearStickStates

- (void) clearStickStates

Definition at line 487 of file OOJoystickManager.m.

488{
489 int i, j;
490 for (i = 0; i < AXIS_end; i++) {
492 }
493 for (i = 0; i < BUTTON_end; i++) {
494 butstate[i] = 0;
495 }
496 for (i = 0; i < MAX_BUTTONS; i++) {
497 for (j = 0; j < MAX_STICKS; j++) {
498 true_butstate[j][i] = NO;
499 }
500 }
501}
@ AXIS_end
#define STICK_AXISUNASSIGNED
double axstate[AXIS_end]
BOOL true_butstate[MAX_STICKS][MAX_BUTTONS]

References AXIS_end, axstate, butstate, BUTTON_end, clearStickStates, MAX_BUTTONS, MAX_STICKS, STICK_AXISUNASSIGNED, and true_butstate.

Referenced by clearStickStates, PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, PlayerEntity(OOControlsPrivate)::handleKeyboardLayoutKeys, PlayerEntity(OOControlsPrivate)::handleKeyMapperScreenKeys, PlayerEntity(OOControlsPrivate)::handleStickMapperScreenKeys, init, and PlayerEntity(OOControlsPrivate)::pollDemoControls:.

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

◆ getAllButtonStates

- (const BOOL *) getAllButtonStates

Definition at line 103 of file OOJoystickManager.m.

104{
105 return butstate;
106}

References butstate, and getAllButtonStates.

Referenced by PlayerEntity(LoadSave)::commanderSelector, getAllButtonStates, PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, PlayerEntity(Controls)::handleGUIUpDownArrowKeys, PlayerEntity(KeyMapper)::handleKeyboardLayoutEntryKeys:view:, PlayerEntity(OOControlsPrivate)::handleKeyboardLayoutKeys, PlayerEntity(KeyMapper)::handleKeyConfigKeys:view:, PlayerEntity(KeyMapper)::handleKeyMapperConfirmClearKeys:view:, PlayerEntity(OOControlsPrivate)::handleKeyMapperScreenKeys, PlayerEntity(OOControlsPrivate)::handleStickMapperScreenKeys, PlayerEntity(KeyMapper)::keyMapperInputHandler:view:, PlayerEntity(LoadSave)::overwriteCommanderInputHandler, PlayerEntity(OOControlsPrivate)::pollApplicationControls, PlayerEntity(OOControlsPrivate)::pollAutopilotControls:, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(OOControlsPrivate)::pollDemoControls:, PlayerEntity(OOControlsPrivate)::pollDockedControls:, PlayerEntity(OOControlsPrivate)::pollFlightControls:, PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:, PlayerEntity(OOControlsPrivate)::pollMarketScreenControls, PlayerEntity(OOControlsPrivate)::pollViewControls, PlayerEntity(LoadSave)::saveCommanderInputHandler, and PlayerEntity(StickMapper)::stickMapperInputHandler:view:.

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

◆ getAxisState:

- (double) getAxisState: (int) function

Definition at line 113 of file OOJoystickManager.m.

113 :(int)function
114{
115 if (axstate[function] == STICK_AXISUNASSIGNED) {
117 }
118 switch (function) {
119 case AXIS_ROLL:
120 if (precisionMode) {
121 return [roll_profile value:axstate[function]] / STICK_PRECISIONFAC;
122 } else {
123 return [roll_profile value:axstate[function]];
124 }
125 case AXIS_PITCH:
126 if (precisionMode) {
127 return [pitch_profile value:axstate[function]] / STICK_PRECISIONFAC;
128 } else {
129 return [pitch_profile value:axstate[function]];
130 }
131 case AXIS_YAW:
132 if (precisionMode) {
133 return [yaw_profile value:axstate[function]] / STICK_PRECISIONFAC;
134 } else {
135 return [yaw_profile value:axstate[function]];
136 }
137 default:
138 return axstate[function];
139 }
140}
#define STICK_PRECISIONFAC
@ AXIS_PITCH
@ AXIS_YAW
@ AXIS_ROLL

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, axstate, precisionMode, STICK_AXISUNASSIGNED, STICK_PRECISIONFAC, and OOJoystickAxisProfile::value:.

Referenced by PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:, and PlayerEntity(OOControlsPrivate)::pollFlightControls:.

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

◆ getAxisWithStick:axis:

- (int16_t) getAxisWithStick: (NSUInteger) stickNum
axis: (NSUInteger) axisNum 

Reimplemented in OOSDLJoystickManager.

Definition at line 593 of file OOJoystickManager.m.

593 :(NSUInteger)stickNum axis:(NSUInteger)axisNum
594{
595 return 0;
596}

Referenced by OOJoystickManager(Private)::setFunctionForAxis:function:stick:.

Here is the caller graph for this function:

◆ getButtonState:

- (BOOL) getButtonState: (int) function

Definition at line 98 of file OOJoystickManager.m.

98 :(int)function
99{
100 return butstate[function];
101}

References butstate.

◆ getProfileForAxis:

- (OOJoystickAxisProfile *) getProfileForAxis: (int) axis

Definition at line 168 of file OOJoystickManager.m.

168 :(int)axis
169{
170 switch (axis) {
171 case AXIS_ROLL:
172 return roll_profile;
173 case AXIS_PITCH:
174 return pitch_profile;
175 case AXIS_YAW:
176 return yaw_profile;
177 }
178 return nil;
179}
OOJoystickAxisProfile * roll_profile
OOJoystickAxisProfile * pitch_profile
OOJoystickAxisProfile * yaw_profile

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, nil, pitch_profile, roll_profile, and yaw_profile.

Referenced by StickProfileScreen::deleteSelected, StickProfileScreen::mouseDown:, and saveProfileForAxis:.

Here is the caller graph for this function:

◆ getSensitivity

- (double) getSensitivity

Definition at line 142 of file OOJoystickManager.m.

143{
144 return precisionMode ? STICK_PRECISIONFAC : 1.0;
145}

References getSensitivity, precisionMode, and STICK_PRECISIONFAC.

Referenced by HeadUpDisplay(Private)::drawStickSensitivityIndicator:, and getSensitivity.

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

◆ guiButtonFunctions

- (NSDictionary *) guiButtonFunctions

Definition at line 327 of file OOJoystickManager.m.

328{
329 int i, j;
330 NSMutableDictionary* fnList = [NSMutableDictionary dictionary];
331
332 // Add buttons
333 for (i = 0; i < MAX_BUTTONS; i++) {
334 for (j = 0; j < MAX_STICKS; j++) {
335 if (guibuttonmap[j][i] >= 0) {
336 NSDictionary* fnDict = [NSDictionary dictionaryWithObjectsAndKeys:
337 [NSNumber numberWithBool:NO], STICK_ISAXIS,
338 [NSNumber numberWithInt:j], STICK_NUMBER,
339 [NSNumber numberWithInt:i], STICK_AXBUT,
340 nil];
341 [fnList setValue:fnDict
342 forKey:ENUMKEY(guibuttonmap[j][i])];
343 }
344 }
345 }
346 return fnList;
347}
int8_t guibuttonmap[MAX_STICKS][MAX_BUTTONS]

References guiButtonFunctions, guibuttonmap, MAX_BUTTONS, and MAX_STICKS.

Referenced by PlayerEntity(StickMapperInternal)::displayFunctionList:skip:, guiButtonFunctions, and saveStickSettings.

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

◆ init

- (id) init

Reimplemented in OOSDLJoystickManager.

Definition at line 68 of file OOJoystickManager.m.

69{
70 if ((self = [super init])) {
71 // set initial values for stick buttons/axes (NO for buttons,
72 // STICK_AXISUNASSIGNED for axes). Caution: calling this again
73 // after axes have been assigned will set all the axes to
74 // STICK_AXISUNASSIGNED so if there is a need to do something
75 // like this, then do it some other way, or change this method
76 // so it doesn't do that.
77 [self clearStickStates];
78
79 // Make some sensible mappings. This also ensures unassigned
80 // axes and buttons are set to unassigned (STICK_NOFUNCTION).
81 [self loadStickSettings];
82 invertPitch = NO;
83 precisionMode = NO;
84 }
85 return self;
86}

References clearStickStates, init, invertPitch, loadStickSettings, and precisionMode.

Referenced by init, and OOSDLJoystickManager::init.

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

◆ isButtonDown:stick:

- (BOOL) isButtonDown: (int) button
stick: (int) stickNum 

Definition at line 108 of file OOJoystickManager.m.

108 :(int)button stick:(int)stickNum
109{
110 return true_butstate[stickNum][button];
111}

References true_butstate.

◆ joystickCount

- (NSUInteger) joystickCount

Reimplemented in OOSDLJoystickManager.

Definition at line 583 of file OOJoystickManager.m.

584{
585 return 0;
586}

References joystickCount.

Referenced by joystickCount, listSticks, and PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:.

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

◆ listSticks

- (NSArray *) listSticks

Definition at line 272 of file OOJoystickManager.m.

273{
274 NSUInteger i, stickCount = [self joystickCount];
275
276 NSMutableArray* stickList = [NSMutableArray array];
277 for (i = 0; i < stickCount; i++) {
278 [stickList addObject:[self nameOfJoystick:i]];
279 }
280 return stickList;
281}

References joystickCount, listSticks, and nameOfJoystick:.

Referenced by listSticks, and PlayerEntity(StickMapper)::setGuiToStickMapperScreen:resetCurrentRow:.

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

◆ loadProfileForAxis:

- (void) loadProfileForAxis: (int) axis

Definition at line 228 of file OOJoystickManager.m.

228 :(int)axis
229{
230 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
231 NSDictionary* dict;
232 OOJoystickStandardAxisProfile* standard_profile;
233 OOJoystickSplineAxisProfile* spline_profile;
234
235 if (axis == AXIS_ROLL) {
236 dict = [defaults objectForKey:STICK_ROLL_AXIS_PROFILE_SETTING];
237 } else if (axis == AXIS_PITCH) {
238 dict = [defaults objectForKey:STICK_PITCH_AXIS_PROFILE_SETTING];
239 } else if (axis == AXIS_YAW) {
240 dict = [defaults objectForKey:STICK_YAW_AXIS_PROFILE_SETTING];
241 } else {
242 return;
243 }
244
245 NSString* type = [dict objectForKey:@"Type"];
246 if ([type isEqualToString:@"Standard"]) {
247 standard_profile = [[OOJoystickStandardAxisProfile alloc] init];
248 [standard_profile setDeadzone:[[dict objectForKey:@"Deadzone"] doubleValue]];
249 [standard_profile setPower:[[dict objectForKey:@"Power"] doubleValue]];
250 [standard_profile setParameter:[[dict objectForKey:@"Parameter"] doubleValue]];
251 [self setProfile:[standard_profile autorelease] forAxis:axis];
252 } else if ([type isEqualToString:@"Spline"]) {
253 spline_profile = [[OOJoystickSplineAxisProfile alloc] init];
254 [spline_profile setDeadzone:[[dict objectForKey:@"Deadzone"] doubleValue]];
255 NSArray *points = [dict objectForKey:@"ControlPoints"], *pointArray;
256 NSPoint point;
257 NSUInteger i;
258
259 for (i = 0; i < [points count]; i++) {
260 pointArray = [points objectAtIndex:i];
261 if ([pointArray count] >= 2) {
262 point = NSMakePoint([[pointArray objectAtIndex:0] floatValue], [[pointArray objectAtIndex:1] floatValue]);
263 [spline_profile addControl:point];
264 }
265 }
266 [self setProfile:[spline_profile autorelease] forAxis:axis];
267 } else {
268 [self setProfile:[[[OOJoystickStandardAxisProfile alloc] init] autorelease] forAxis:axis];
269 }
270}
unsigned count
void setDeadzone:(double newValue)
void setParameter:(double newValue)

References OOJoystickSplineAxisProfile::addControl:, AXIS_PITCH, AXIS_ROLL, AXIS_YAW, count, OOJoystickAxisProfile::setDeadzone:, OOJoystickStandardAxisProfile::setParameter:, OOJoystickStandardAxisProfile::setPower:, and setProfile:forAxis:.

Referenced by loadStickSettings.

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

◆ loadStickSettings

- (void) loadStickSettings

Definition at line 541 of file OOJoystickManager.m.

542{
543 unsigned i;
544 [self clearMappings];
545 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
546 NSDictionary* axisSettings = [defaults objectForKey:AXIS_SETTINGS];
547 NSDictionary* buttonSettings = [defaults objectForKey:BUTTON_SETTINGS];
548 NSDictionary* guiButtonSettings = [defaults objectForKey:GUI_BUTTON_SETTINGS];
549
550 if (axisSettings) {
551 NSArray* keys = [axisSettings allKeys];
552 for (i = 0; i < [keys count]; i++) {
553 NSString* key = [keys objectAtIndex:i];
554 [self setFunction:[key intValue]
555 withDict:[axisSettings objectForKey:key]];
556 }
557 }
558 if (buttonSettings) {
559 NSArray* keys = [buttonSettings allKeys];
560 for (i = 0; i < [keys count]; i++) {
561 NSString* key = [keys objectAtIndex:i];
562 [self setFunction:[key intValue]
563 withDict:[buttonSettings objectForKey:key]];
564 }
565 } else {
566 // Nothing to load - set useful defaults
567 [self setDefaultMapping];
568 }
569 if (guiButtonSettings) {
570 NSArray* keys = [guiButtonSettings allKeys];
571 for (i = 0; i < [keys count]; i++) {
572 NSString* key = [keys objectAtIndex:i];
573 [self setFunction:[key intValue]
574 withDict:[guiButtonSettings objectForKey:key]];
575 }
576 }
577 [self loadProfileForAxis:AXIS_ROLL];
578 [self loadProfileForAxis:AXIS_PITCH];
579 [self loadProfileForAxis:AXIS_YAW];
580}

References clearMappings, loadProfileForAxis:, loadStickSettings, setDefaultMapping, and setFunction:withDict:.

Referenced by init, and loadStickSettings.

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

◆ nameOfJoystick:

- (NSString *) nameOfJoystick: (NSUInteger) stickNumber

Reimplemented in OOSDLJoystickManager.

Definition at line 588 of file OOJoystickManager.m.

588 :(NSUInteger)stickNumber
589{
590 return @"Dummy joystick";
591}

Referenced by listSticks.

Here is the caller graph for this function:

◆ rollPitchAxis

- (NSPoint) rollPitchAxis

Definition at line 88 of file OOJoystickManager.m.

89{
90 return NSMakePoint([self getAxisState:AXIS_ROLL], [self getAxisState:AXIS_PITCH]);
91}

References AXIS_PITCH, AXIS_ROLL, and rollPitchAxis.

Referenced by PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:, and rollPitchAxis.

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

◆ saveProfileForAxis:

- (void) saveProfileForAxis: (int) axis

Definition at line 181 of file OOJoystickManager.m.

181 :(int)axis
182{
183 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
184 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
185 OOJoystickAxisProfile* profile;
186 OOJoystickStandardAxisProfile* standard_profile;
187 OOJoystickSplineAxisProfile* spline_profile;
188 NSArray* controlPoints;
189 NSMutableArray* points;
190 NSPoint point;
191 NSUInteger i;
192
193 profile = [self getProfileForAxis:axis];
194 if (!profile)
195 return;
196 [dict setObject:[NSNumber numberWithDouble:[profile deadzone]] forKey:@"Deadzone"];
197 if ([profile isKindOfClass:[OOJoystickStandardAxisProfile class]]) {
198 standard_profile = (OOJoystickStandardAxisProfile*)profile;
199 [dict setObject:@"Standard" forKey:@"Type"];
200 [dict setObject:[NSNumber numberWithDouble:[standard_profile power]] forKey:@"Power"];
201 [dict setObject:[NSNumber numberWithDouble:[standard_profile parameter]] forKey:@"Parameter"];
202 } else if ([profile isKindOfClass:[OOJoystickSplineAxisProfile class]]) {
203 spline_profile = (OOJoystickSplineAxisProfile*)profile;
204 [dict setObject:@"Spline" forKey:@"Type"];
205 controlPoints = [NSArray arrayWithArray:[spline_profile controlPoints]];
206 points = [[NSMutableArray alloc] initWithCapacity:[controlPoints count]];
207 for (i = 0; i < [controlPoints count]; i++) {
208 point = [[controlPoints objectAtIndex:i] pointValue];
209 [points addObject:[NSArray arrayWithObjects:
210 [NSNumber numberWithFloat:point.x],
211 [NSNumber numberWithFloat:point.y],
212 nil]];
213 }
214 [dict setObject:points forKey:@"ControlPoints"];
215 } else {
216 [dict setObject:@"Standard" forKey:@"Type"];
217 }
218 if (axis == AXIS_ROLL) {
219 [defaults setObject:dict forKey:STICK_ROLL_AXIS_PROFILE_SETTING];
220 } else if (axis == AXIS_PITCH) {
221 [defaults setObject:dict forKey:STICK_PITCH_AXIS_PROFILE_SETTING];
222 } else if (axis == AXIS_YAW) {
223 [defaults setObject:dict forKey:STICK_YAW_AXIS_PROFILE_SETTING];
224 }
225 return;
226}

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, OOJoystickSplineAxisProfile::controlPoints, OOJoystickAxisProfile::deadzone, getProfileForAxis:, OOJoystickStandardAxisProfile::parameter, and OOJoystickStandardAxisProfile::power.

Referenced by saveStickSettings.

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

◆ saveStickSettings

- (void) saveStickSettings

Definition at line 525 of file OOJoystickManager.m.

526{
527 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
528
529 [defaults setObject:[self axisFunctions]
530 forKey:AXIS_SETTINGS];
531 [defaults setObject:[self buttonFunctions]
532 forKey:BUTTON_SETTINGS];
533 [defaults setObject:[self guiButtonFunctions]
534 forKey:GUI_BUTTON_SETTINGS];
535 [self saveProfileForAxis:AXIS_ROLL];
536 [self saveProfileForAxis:AXIS_PITCH];
537 [self saveProfileForAxis:AXIS_YAW];
538 [defaults synchronize];
539}

References axisFunctions, buttonFunctions, guiButtonFunctions, saveProfileForAxis:, and saveStickSettings.

Referenced by StickProfileScreen::deleteSelected, StickProfileScreen::mouseDown:, PlayerEntity(StickMapperInternal)::removeFunction:, saveStickSettings, and PlayerEntity(StickMapper)::updateFunction:.

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

◆ setCallback:object:hardware:

- (void) setCallback: (SEL) selector
object: (id) obj
hardware: (char) hwflags 

Definition at line 510 of file OOJoystickManager.m.

510 :(SEL)selector
511 object:(id)obj
512 hardware:(char)hwflags
513{
514 cbObject = obj;
515 cbSelector = selector;
516 cbHardware = hwflags;
517}

References cbHardware, cbObject, and cbSelector.

Referenced by PlayerEntity(StickMapper)::stickMapperInputHandler:view:.

Here is the caller graph for this function:

◆ setDefaultMapping

- (void) setDefaultMapping

Definition at line 470 of file OOJoystickManager.m.

471{
472 // assign the simplest mapping: stick 0 having
473 // axis 0/1 being roll/pitch and button 0 being fire, 1 being missile
474 // All joysticks should at least have two axes and two buttons.
475 axismap[0][0] = AXIS_ROLL;
476 axismap[0][1] = AXIS_PITCH;
477 buttonmap[0][0] = BUTTON_FIRE;
479}
@ BUTTON_LAUNCHMISSILE
@ BUTTON_FIRE

References AXIS_PITCH, AXIS_ROLL, axismap, BUTTON_FIRE, BUTTON_LAUNCHMISSILE, buttonmap, and setDefaultMapping.

Referenced by loadStickSettings, and setDefaultMapping.

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

◆ setFunction:withDict:

- (void) setFunction: (int) function
withDict: (NSDictionary*) stickFn 

Definition at line 349 of file OOJoystickManager.m.

349 :(int)function withDict:(NSDictionary*)stickFn
350{
351 BOOL isAxis = [stickFn oo_boolForKey:STICK_ISAXIS];
352 int stickNum = [stickFn oo_intForKey:STICK_NUMBER];
353 int stickAxBt = [stickFn oo_intForKey:STICK_AXBUT];
354
355 if (isAxis) {
356 [self setFunctionForAxis:stickAxBt
357 function:function
358 stick:stickNum];
359 } else {
360 if (function >= BUTTON_GUILEFT && function <= BUTTON_GUISELECT)
361 {
362 [self setGuiFunctionForButton:stickAxBt
363 function:function
364 stick:stickNum];
365 }
366 else {
367 [self setFunctionForButton:stickAxBt
368 function:function
369 stick:stickNum];
370 }
371 }
372}
@ BUTTON_GUILEFT
@ BUTTON_GUISELECT

References BUTTON_GUILEFT, BUTTON_GUISELECT, setFunctionForAxis:function:stick:, setFunctionForButton:function:stick:, and setGuiFunctionForButton:function:stick:.

Referenced by loadStickSettings, and PlayerEntity(StickMapper)::updateFunction:.

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

◆ setFunctionForAxis:function:stick:

- (void) setFunctionForAxis: (int) axis
function: (int) function
stick: (int) stickNum 
implementation

Provided by category OOJoystickManager(Private).

Definition at line 374 of file OOJoystickManager.m.

374 :(int)axis
375 function:(int)function
376 stick:(int)stickNum
377{
378 NSParameterAssert(axis < MAX_AXES && stickNum < MAX_STICKS);
379
380 int16_t axisvalue = [self getAxisWithStick:stickNum axis:axis];
381 [self unsetAxisFunction:function];
382 axismap[stickNum][axis] = function;
383
384 // initialize the throttle to what it's set to now (or else the
385 // commander has to waggle the throttle to wake it up). Other axes
386 // set as default.
387 if (function == AXIS_THRUST) {
388 axstate[function] = (float)(65536 - (axisvalue + 32768)) / 65536;
389 } else {
390 axstate[function] = (float)axisvalue / STICK_NORMALDIV;
391 }
392}
@ AXIS_THRUST
#define STICK_NORMALDIV

References AXIS_THRUST, getAxisWithStick:axis:, MAX_AXES, MAX_STICKS, STICK_NORMALDIV, and unsetAxisFunction:.

Referenced by setFunction:withDict:.

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

◆ setFunctionForButton:function:stick:

- (void) setFunctionForButton: (int) button
function: (int) function
stick: (int) stickNum 
implementation

Provided by category OOJoystickManager(Private).

Definition at line 394 of file OOJoystickManager.m.

394 :(int)button
395 function:(int)function
396 stick:(int)stickNum
397{
398 NSParameterAssert(button < MAX_BUTTONS && stickNum < MAX_STICKS);
399
400 int i, j;
401 for (i = 0; i < MAX_BUTTONS; i++) {
402 for (j = 0; j < MAX_STICKS; j++) {
403 if (buttonmap[j][i] == function) {
405 break;
406 }
407 }
408 }
409 buttonmap[stickNum][button] = function;
410}

References MAX_BUTTONS, MAX_STICKS, and STICK_NOFUNCTION.

Referenced by setFunction:withDict:.

Here is the caller graph for this function:

◆ setGuiFunctionForButton:function:stick:

- (void) setGuiFunctionForButton: (int) button
function: (int) function
stick: (int) stickNum 
implementation

Definition at line 412 of file OOJoystickManager.m.

412 :(int)button
413 function:(int)function
414 stick:(int)stickNum
415{
416 NSParameterAssert(button < MAX_BUTTONS && stickNum < MAX_STICKS);
417
418 int i, j;
419 for (i = 0; i < MAX_BUTTONS; i++) {
420 for (j = 0; j < MAX_STICKS; j++) {
421 if (guibuttonmap[j][i] == function) {
423 break;
424 }
425 }
426 }
427 guibuttonmap[stickNum][button] = function;
428}

References guibuttonmap, MAX_BUTTONS, MAX_STICKS, and STICK_NOFUNCTION.

Referenced by setFunction:withDict:.

Here is the caller graph for this function:

◆ setProfile:forAxis:

- (void) setProfile: (OOJoystickAxisProfile*) profile
forAxis: (int) axis 

Definition at line 147 of file OOJoystickManager.m.

147 :(OOJoystickAxisProfile*)profile forAxis:(int)axis
148{
149 switch (axis) {
150 case AXIS_ROLL:
151 [roll_profile release];
152 roll_profile = [profile retain];
153 break;
154
155 case AXIS_PITCH:
156 [pitch_profile release];
157 pitch_profile = [profile retain];
158 break;
159
160 case AXIS_YAW:
161 [yaw_profile release];
162 yaw_profile = [profile retain];
163 break;
164 }
165 return;
166}

References AXIS_PITCH, AXIS_ROLL, AXIS_YAW, pitch_profile, roll_profile, and yaw_profile.

Referenced by loadProfileForAxis:.

Here is the caller graph for this function:

◆ setStickHandlerClass:

+ (BOOL) setStickHandlerClass: (Class) aClass

Definition at line 59 of file OOJoystickManager.m.

59 :(Class)aClass
60{
61 NSAssert(sStickHandlerClass == nil, @"Can't set joystick handler class after joystick handler is initialized.");
62 NSParameterAssert(aClass == Nil || [aClass isSubclassOfClass:[OOJoystickManager class]]);
63
64 sStickHandlerClass = aClass;
65 return YES;
66}
static Class sStickHandlerClass

References nil, and sStickHandlerClass.

Referenced by GameController::applicationDidFinishLaunching:, and MyOpenGLView::init.

Here is the caller graph for this function:

◆ sharedStickHandler

+ (id) sharedStickHandler

Definition at line 49 of file OOJoystickManager.m.

50{
51 if (sSharedStickHandler == nil) {
52 if (sStickHandlerClass == Nil)
54 sSharedStickHandler = [[sStickHandlerClass alloc] init];
55 }
57}
static id sSharedStickHandler

References nil, sharedStickHandler, sSharedStickHandler, and sStickHandlerClass.

Referenced by PlayerEntity(LoadSave)::commanderSelector, PlayerEntity(StickMapperInternal)::displayFunctionList:skip:, HeadUpDisplay(Private)::drawStickSensitivityIndicator:, PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, PlayerEntity(Controls)::handleGUIUpDownArrowKeys, PlayerEntity(KeyMapper)::handleKeyboardLayoutEntryKeys:view:, PlayerEntity(OOControlsPrivate)::handleKeyboardLayoutKeys, PlayerEntity(KeyMapper)::handleKeyConfigKeys:view:, PlayerEntity(KeyMapper)::handleKeyMapperConfirmClearKeys:view:, PlayerEntity(OOControlsPrivate)::handleKeyMapperScreenKeys, PlayerEntity(OOControlsPrivate)::handleStickMapperScreenKeys, StickProfileScreen::init, Universe::initWithGameView:, PlayerEntity(KeyMapper)::keyMapperInputHandler:view:, PlayerEntity(LoadSave)::overwriteCommanderInputHandler, PlayerEntity(OOControlsPrivate)::pollApplicationControls, PlayerEntity(OOControlsPrivate)::pollAutopilotControls:, MyOpenGLView(Input)::pollControls, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(OOControlsPrivate)::pollDemoControls:, PlayerEntity(OOControlsPrivate)::pollDockedControls:, PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:, PlayerEntity(OOControlsPrivate)::pollFlightControls:, PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:, PlayerEntity(OOControlsPrivate)::pollMarketScreenControls, PlayerEntity(OOControlsPrivate)::pollViewControls, PlayerEntity(StickMapperInternal)::removeFunction:, PlayerEntity(LoadSave)::saveCommanderInputHandler, PlayerEntity(StickMapper)::setGuiToStickMapperScreen:resetCurrentRow:, sharedStickHandler, PlayerEntity(StickMapper)::stickMapperInputHandler:view:, and PlayerEntity(StickMapper)::updateFunction:.

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

◆ unsetAxisFunction:

- (void) unsetAxisFunction: (int) function

Definition at line 430 of file OOJoystickManager.m.

430 :(int)function
431{
432 int i, j;
433 for (i = 0; i < MAX_AXES; i++) {
434 for (j = 0; j < MAX_STICKS; j++) {
435 if (axismap[j][i] == function) {
437 axstate[function] = STICK_AXISUNASSIGNED;
438 break;
439 }
440 }
441 }
442}

References axismap, axstate, MAX_AXES, MAX_STICKS, STICK_AXISUNASSIGNED, and STICK_NOFUNCTION.

Referenced by PlayerEntity(StickMapperInternal)::removeFunction:, OOJoystickManager(Private)::setFunctionForAxis:function:stick:, and PlayerEntity(StickMapper)::updateFunction:.

Here is the caller graph for this function:

◆ unsetButtonFunction:

- (void) unsetButtonFunction: (int) function

Definition at line 444 of file OOJoystickManager.m.

444 :(int)function
445{
446 int i, j;
447 for (i = 0; i < MAX_BUTTONS; i++) {
448 for (j = 0; j < MAX_STICKS; j++) {
449 if (buttonmap[j][i] == function) {
451 break;
452 }
453 }
454 }
455}

References buttonmap, MAX_BUTTONS, MAX_STICKS, and STICK_NOFUNCTION.

Referenced by PlayerEntity(StickMapperInternal)::removeFunction:, and PlayerEntity(StickMapper)::updateFunction:.

Here is the caller graph for this function:

◆ unsetGuiButtonFunction:

- (void) unsetGuiButtonFunction: (int) function

Definition at line 457 of file OOJoystickManager.m.

457 :(int)function
458{
459 int i, j;
460 for (i = 0; i < MAX_BUTTONS; i++) {
461 for (j = 0; j < MAX_STICKS; j++) {
462 if (guibuttonmap[j][i] == function) {
464 break;
465 }
466 }
467 }
468}

References guibuttonmap, MAX_BUTTONS, MAX_STICKS, and STICK_NOFUNCTION.

◆ viewAxis

- (NSPoint) viewAxis

Definition at line 93 of file OOJoystickManager.m.

94{
95 return NSMakePoint(axstate[AXIS_VIEWX], axstate[AXIS_VIEWY]);
96}
@ AXIS_VIEWX
@ AXIS_VIEWY

References AXIS_VIEWX, AXIS_VIEWY, axstate, and viewAxis.

Referenced by PlayerEntity(OOControlsPrivate)::pollFlightControls:, PlayerEntity(OOControlsPrivate)::pollViewControls, and viewAxis.

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

Member Data Documentation

◆ axismap

◆ axstate

- (double axstate[AXIS_end])
protected

◆ butstate

◆ buttonmap

◆ cbHardware

◆ cbObject

◆ cbSelector

- (SEL) cbSelector
protected

Definition at line 181 of file OOJoystickManager.h.

Referenced by setCallback:object:hardware:.

◆ guibuttonmap

◆ hatstate

- (uint8_t hatstate[MAX_STICKS][MAX_HATS])
protected

Definition at line 175 of file OOJoystickManager.h.

Referenced by OOSDLJoystickManager::decodeHatEvent:.

◆ invertPitch

- (BOOL) invertPitch
protected

Definition at line 183 of file OOJoystickManager.h.

Referenced by OOSDLJoystickManager::decodeAxisEvent:, and init.

◆ pitch_profile

- (OOJoystickAxisProfile*) pitch_profile
private

Definition at line 187 of file OOJoystickManager.h.

Referenced by getProfileForAxis:, and setProfile:forAxis:.

◆ precisionMode

- (BOOL) precisionMode
protected

◆ roll_profile

- (OOJoystickAxisProfile*) roll_profile
private

Definition at line 186 of file OOJoystickManager.h.

Referenced by getProfileForAxis:, and setProfile:forAxis:.

◆ true_butstate

- (BOOL true_butstate[MAX_STICKS][MAX_BUTTONS])
protected

◆ yaw_profile

- (OOJoystickAxisProfile*) yaw_profile
private

Definition at line 188 of file OOJoystickManager.h.

Referenced by getProfileForAxis:, and setProfile:forAxis:.


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