36@interface OOJoystickManager (Private)
39- (void) setFunctionForAxis:(
int)axis
40 function:(
int)function
43- (void) setFunctionForButton:(
int)button
44 function:(
int)function
64+ (BOOL) setStickHandlerClass:(Class)aClass
66 NSAssert(
sStickHandlerClass ==
nil,
@"Can't set joystick handler class after joystick handler is initialized.");
67 NSParameterAssert(aClass == Nil || [aClass isSubclassOfClass:[
OOJoystickManager class]]);
64+ (BOOL) setStickHandlerClass:(Class)aClass {
…}
76 if ((
self = [super
init]))
109- (BOOL) getButtonState: (
int)function
109- (BOOL) getButtonState: (
int)function {
…}
120- (BOOL) isButtonDown:(
int)button stick:(
int)stickNum
120- (BOOL) isButtonDown:(
int)button stick:(
int)stickNum {
…}
125- (double) getAxisState: (
int)function
125- (double) getAxisState: (
int)function {
…}
208- (void) saveProfileForAxis: (
int) axis
215 NSArray *controlPoints;
216 NSMutableArray *points;
221 if (!profile)
return;
226 [
dict setObject: @"Standard" forKey: @"Type"];
233 [
dict setObject: @"Spline" forKey: @"Type"];
240 [
NSNumber numberWithFloat: point.x],
241 [
NSNumber numberWithFloat: point.y],
244 [
dict setObject: points forKey: @"ControlPoints"];
248 [
dict setObject: @"Standard" forKey: @"Type"];
252 [
defaults setObject: dict forKey: STICK_ROLL_AXIS_PROFILE_SETTING];
256 [
defaults setObject: dict forKey: STICK_PITCH_AXIS_PROFILE_SETTING];
260 [
defaults setObject: dict forKey: STICK_YAW_AXIS_PROFILE_SETTING];
208- (void) saveProfileForAxis: (
int) axis {
…}
267- (void) loadProfileForAxis: (
int) axis
276 dict = [
defaults objectForKey: STICK_ROLL_AXIS_PROFILE_SETTING];
280 dict = [
defaults objectForKey: STICK_PITCH_AXIS_PROFILE_SETTING];
284 dict = [
defaults objectForKey: STICK_YAW_AXIS_PROFILE_SETTING];
291 NSString *type = [
dict objectForKey: @"Type"];
292 if ([type isEqualToString:
@"Standard"])
300 else if([type isEqualToString:
@"Spline"])
304 NSArray *points = [
dict objectForKey: @"ControlPoints"], *pointArray;
308 for (i = 0; i < [
points count]; i++)
310 pointArray = [
points objectAtIndex: i];
311 if ([pointArray
count] >= 2)
313 point = NSMakePoint([[pointArray objectAtIndex: 0] floatValue], [[pointArray objectAtIndex: 1] floatValue]);
267- (void) loadProfileForAxis: (
int) axis {
…}
330 for (i = 0; i < stickCount; i++)
350 NSDictionary *fnDict=[
NSDictionary dictionaryWithObjectsAndKeys:
351 [
NSNumber numberWithBool:YES], STICK_ISAXIS,
352 [
NSNumber numberWithInt:j], STICK_NUMBER,
353 [
NSNumber numberWithInt:i], STICK_AXBUT,
356 forKey: ENUMKEY(axismap[
j][
i])];
376 NSDictionary *fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
377 [
NSNumber numberWithBool:NO], STICK_ISAXIS,
378 [
NSNumber numberWithInt:j], STICK_NUMBER,
379 [
NSNumber numberWithInt:i], STICK_AXBUT,
382 forKey:ENUMKEY(buttonmap[
j][
i])];
390- (void) setFunction:(
int)function withDict:(NSDictionary *)stickFn
392 BOOL isAxis = [
stickFn oo_boolForKey:STICK_ISAXIS];
393 int stickNum = [
stickFn oo_intForKey:STICK_NUMBER];
394 int stickAxBt = [
stickFn oo_intForKey:STICK_AXBUT];
390- (void) setFunction:(
int)function withDict:(NSDictionary *)stickFn {
…}
411- (void) setFunctionForAxis:(
int)axis
412 function:(
int)function
426 axstate[
function] = (float)(65536 - (axisvalue + 32768)) / 65536;
411- (void) setFunctionForAxis:(
int)axis {
…}
435- (void) setFunctionForButton:(
int)button
436 function:(
int)function
446 if (buttonmap[j][i] ==
function)
435- (void) setFunctionForButton:(
int)button {
…}
457- (void) unsetAxisFunction:(
int)function
457- (void) unsetAxisFunction:(
int)function {
…}
475- (void) unsetButtonFunction:(
int)function
475- (void) unsetButtonFunction:(
int)function {
…}
532- (void) clearStickButtonState:(
int)stickButton
534 if (stickButton >= 0 && stickButton <
BUTTON_end)
532- (void) clearStickButtonState:(
int)stickButton {
…}
541- (void)setCallback:(
SEL) selector
543 hardware:(
char)hwflags
541- (void)setCallback:(
SEL) selector {
…}
562 double axisvalue = (double)evt->
value;
570 NSDictionary *fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
571 [
NSNumber numberWithBool: YES], STICK_ISAXIS,
572 [
NSNumber numberWithInt: evt->which], STICK_NUMBER,
573 [
NSNumber numberWithInt: evt->axis], STICK_AXBUT,
576 [cbObject performSelector:cbSelector withObject:fnDict];
598 OOLog(
@"decodeAxisEvent",
@"Stick axis out of range - axis was %d", evt->
axis);
633 NSDictionary *fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
634 [
NSNumber numberWithBool: NO], STICK_ISAXIS,
635 [
NSNumber numberWithInt: evt->which], STICK_NUMBER,
636 [
NSNumber numberWithInt: evt->button], STICK_AXBUT,
639 [cbObject performSelector:cbSelector withObject:fnDict];
654 OOLog(
@"decodeButtonEvent",
@"Joystick button out of range: %d", evt->button);
680 for (i = 0; i < 4; ++i)
706 forKey:AXIS_SETTINGS];
708 forKey:BUTTON_SETTINGS];
721 NSDictionary *axisSettings = [
defaults objectForKey: AXIS_SETTINGS];
722 NSDictionary *buttonSettings = [
defaults objectForKey: BUTTON_SETTINGS];
726 for (i = 0; i < [
keys count]; i++)
728 NSString *key = [
keys objectAtIndex: i];
736 for (i = 0; i < [
keys count]; i++)
738 NSString *key = [
keys objectAtIndex: i];
755- (NSString *) nameOfJoystick:(NSUInteger)stickNumber
757 return @"Dummy joystick";
755- (NSString *) nameOfJoystick:(NSUInteger)stickNumber {
…}
760- (int16_t) getAxisWithStick:(NSUInteger)stickNum axis:(NSUInteger)axisNum
760- (int16_t) getAxisWithStick:(NSUInteger)stickNum axis:(NSUInteger)axisNum {
…}
#define STICK_PRECISIONFAC
#define STICK_AXISUNASSIGNED
static Class sStickHandlerClass
static id sSharedStickHandler
#define OOLog(class, format,...)
void setDeadzone:(double newValue)
uint8_t hatstate[MAX_STICKS][MAX_HATS]
void setProfile:forAxis:(OOJoystickAxisProfile *profile,[forAxis] int axis)
NSDictionary * buttonFunctions()
OOJoystickAxisProfile * roll_profile
int8_t axismap[MAX_STICKS][MAX_AXES]
void setFunction:withDict:(int function,[withDict] NSDictionary *stickFn)
NSString * nameOfJoystick:(NSUInteger stickNumber)
NSDictionary * axisFunctions()
OOJoystickAxisProfile * pitch_profile
void saveProfileForAxis:(int axis)
BOOL butstate[BUTTON_end]
void setFunctionForAxis:function:stick:(int axis, [function] int function, [stick] int stickNum)
void unsetAxisFunction:(int function)
void loadProfileForAxis:(int axis)
int8_t buttonmap[MAX_STICKS][MAX_BUTTONS]
OOJoystickAxisProfile * yaw_profile
void decodeButtonEvent:(JoyButtonEvent *evt)
const BOOL * getAllButtonStates()
int16_t getAxisWithStick:axis:(NSUInteger stickNum,[axis] NSUInteger axisNum)
BOOL true_butstate[MAX_STICKS][MAX_BUTTONS]
void setFunctionForButton:function:stick:(int button, [function] int function, [stick] int stickNum)
NSUInteger joystickCount()
OOJoystickAxisProfile * getProfileForAxis:(int axis)
int addControl:(NSPoint point)
NSMutableArray * controlPoints
void setPower:(double newValue)
void setParameter:(double newValue)