34@interface OOJoystickManager (Private)
37- (void)setFunctionForAxis:(
int)axis
38 function:(
int)function
41- (void)setFunctionForButton:(
int)button
42 function:(
int)function
59+ (BOOL)setStickHandlerClass:(Class)aClass
61 NSAssert(
sStickHandlerClass ==
nil,
@"Can't set joystick handler class after joystick handler is initialized.");
62 NSParameterAssert(aClass == Nil || [aClass isSubclassOfClass:[
OOJoystickManager class]]);
70 if ((
self = [super
init])) {
98- (BOOL)getButtonState:(
int)function
108- (BOOL)isButtonDown:(
int)button stick:(
int)stickNum
113- (double)getAxisState:(
int)function
181- (void)saveProfileForAxis:(
int)axis
188 NSArray* controlPoints;
189 NSMutableArray* points;
199 [
dict setObject:@"Standard" forKey:@"Type"];
204 [
dict setObject:@"Spline" forKey:@"Type"];
214 [
dict setObject:points forKey:@"ControlPoints"];
216 [
dict setObject:@"Standard" forKey:@"Type"];
219 [
defaults setObject:dict forKey:STICK_ROLL_AXIS_PROFILE_SETTING];
221 [
defaults setObject:dict forKey:STICK_PITCH_AXIS_PROFILE_SETTING];
223 [
defaults setObject:dict forKey:STICK_YAW_AXIS_PROFILE_SETTING];
228- (void)loadProfileForAxis:(
int)axis
236 dict = [
defaults objectForKey:STICK_ROLL_AXIS_PROFILE_SETTING];
238 dict = [
defaults objectForKey:STICK_PITCH_AXIS_PROFILE_SETTING];
240 dict = [
defaults objectForKey:STICK_YAW_AXIS_PROFILE_SETTING];
245 NSString* type = [
dict objectForKey:@"Type"];
246 if ([type isEqualToString:
@"Standard"]) {
252 }
else if ([type isEqualToString:
@"Spline"]) {
255 NSArray *points = [
dict objectForKey:@"ControlPoints"], *pointArray;
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]);
277 for (i = 0; i < stickCount; i++) {
292 NSDictionary* fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
293 [
NSNumber numberWithBool:YES], STICK_ISAXIS,
294 [
NSNumber numberWithInt:j], STICK_NUMBER,
295 [
NSNumber numberWithInt:i], STICK_AXBUT,
298 forKey:ENUMKEY(axismap[
j][
i])];
314 NSDictionary* fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
315 [
NSNumber numberWithBool:NO], STICK_ISAXIS,
316 [
NSNumber numberWithInt:j], STICK_NUMBER,
317 [
NSNumber numberWithInt:i], STICK_AXBUT,
320 forKey:ENUMKEY(buttonmap[
j][
i])];
336 NSDictionary* fnDict = [
NSDictionary dictionaryWithObjectsAndKeys:
337 [
NSNumber numberWithBool:NO], STICK_ISAXIS,
338 [
NSNumber numberWithInt:j], STICK_NUMBER,
339 [
NSNumber numberWithInt:i], STICK_AXBUT,
342 forKey:ENUMKEY(guibuttonmap[
j][
i])];
349- (void)setFunction:(
int)function withDict:(NSDictionary*)stickFn
351 BOOL isAxis = [
stickFn oo_boolForKey:STICK_ISAXIS];
352 int stickNum = [
stickFn oo_intForKey:STICK_NUMBER];
353 int stickAxBt = [
stickFn oo_intForKey:STICK_AXBUT];
374- (void)setFunctionForAxis:(
int)axis
375 function:(
int)function
388 axstate[
function] = (float)(65536 - (axisvalue + 32768)) / 65536;
394- (void)setFunctionForButton:(
int)button
395 function:(
int)function
403 if (buttonmap[j][i] ==
function) {
412- (void)setGuiFunctionForButton:(
int)button
413 function:(
int)function
430- (void)unsetAxisFunction:(
int)function
435 if (
axismap[j][i] ==
function) {
444- (void)unsetButtonFunction:(
int)function
457- (void)unsetGuiButtonFunction:(
int)function
503- (void)clearStickButtonState:(
int)stickButton
505 if (stickButton >= 0 && stickButton <
BUTTON_end) {
510- (void)setCallback:(
SEL)selector
512 hardware:(
char)hwflags
530 forKey:AXIS_SETTINGS];
532 forKey:BUTTON_SETTINGS];
534 forKey:GUI_BUTTON_SETTINGS];
546 NSDictionary* axisSettings = [
defaults objectForKey:AXIS_SETTINGS];
547 NSDictionary* buttonSettings = [
defaults objectForKey:BUTTON_SETTINGS];
548 NSDictionary* guiButtonSettings = [
defaults objectForKey:GUI_BUTTON_SETTINGS];
552 for (i = 0; i < [
keys count]; i++) {
553 NSString* key = [
keys objectAtIndex:i];
558 if (buttonSettings) {
560 for (i = 0; i < [
keys count]; i++) {
561 NSString* key = [
keys objectAtIndex:i];
569 if (guiButtonSettings) {
571 for (i = 0; i < [
keys count]; i++) {
572 NSString* key = [
keys objectAtIndex:i];
588- (NSString*)nameOfJoystick:(NSUInteger)stickNumber
590 return @"Dummy joystick";
593- (int16_t)getAxisWithStick:(NSUInteger)stickNum axis:(NSUInteger)axisNum
#define STICK_PRECISIONFAC
#define STICK_AXISUNASSIGNED
static Class sStickHandlerClass
static id sSharedStickHandler
void setDeadzone:(double newValue)
NSDictionary * guiButtonFunctions()
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)
int8_t guibuttonmap[MAX_STICKS][MAX_BUTTONS]
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 setGuiFunctionForButton:function:stick:(int button, [function] int function, [stick] int stickNum)
void loadProfileForAxis:(int axis)
int8_t buttonmap[MAX_STICKS][MAX_BUTTONS]
OOJoystickAxisProfile * yaw_profile
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)