Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOSDLJoystickManager Class Reference

#include <OOSDLJoystickManager.h>

+ Inheritance diagram for OOSDLJoystickManager:
+ Collaboration diagram for OOSDLJoystickManager:

Instance Methods

(id) - init
 
(BOOL) - handleSDLEvent:
 
(NSString *) - nameOfJoystick:
 
(int16_t) - getAxisWithStick:axis:
 
(NSUInteger) - joystickCount [implementation]
 
- Instance Methods inherited from OOJoystickManager
(NSPoint) - rollPitchAxis
 
(NSPoint) - viewAxis
 
(void) - setFunction:withDict:
 
(void) - unsetAxisFunction:
 
(void) - unsetButtonFunction:
 
(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
 
(void) - setCallback:object:hardware:
 
(void) - clearCallback
 
(void) - setDefaultMapping
 
(void) - clearMappings
 
(void) - clearStickStates
 
(void) - clearStickButtonState:
 
(void) - decodeAxisEvent:
 
(void) - decodeButtonEvent:
 
(void) - decodeHatEvent:
 
(void) - saveStickSettings
 
(void) - loadStickSettings
 
(void) - setFunctionForAxis:function:stick: [implementation]
 
(void) - setFunctionForButton:function:stick: [implementation]
 

Private Attributes

SDL_Joystick * stick [MAX_STICKS]
 
NSUInteger stickCount
 

Additional Inherited Members

- Class Methods inherited from OOJoystickManager
(id) + sharedStickHandler
 
(BOOL) + setStickHandlerClass:
 

Detailed Description

Definition at line 45 of file OOSDLJoystickManager.h.

Method Documentation

◆ getAxisWithStick:axis:

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

Reimplemented from OOJoystickManager.

Definition at line 1 of file OOSDLJoystickManager.m.

106 :(NSUInteger) stickNum axis:(NSUInteger) axisNum
107{
108 return SDL_JoystickGetAxis(stick[stickNum], axisNum);
109}
SDL_Joystick * stick[MAX_STICKS]

◆ handleSDLEvent:

- (BOOL) handleSDLEvent: (SDL_Event *) evt

Definition at line 1 of file OOSDLJoystickManager.m.

67 : (SDL_Event *)evt
68{
69 BOOL rc=NO;
70 switch(evt->type)
71 {
72 case SDL_JOYAXISMOTION:
73 [self decodeAxisEvent: (JoyAxisEvent *)evt];
74 rc=YES;
75 break;
76 case SDL_JOYBUTTONDOWN:
77 case SDL_JOYBUTTONUP:
78 [self decodeButtonEvent: (JoyButtonEvent *)evt];
79 rc=YES;
80 break;
81 case SDL_JOYHATMOTION:
82 [self decodeHatEvent: (JoyHatEvent *)evt];
83 rc=YES;
84 break;
85 default:
86 OOLog(@"handleSDLEvent.unknownEvent", @"%@", @"JoystickHandler was sent an event it doesn't know");
87 }
88 return rc;
89}
#define OOLog(class, format,...)
Definition OOLogging.h:88

◆ init

- (id) init

Reimplemented from OOJoystickManager.

Definition at line 1 of file OOSDLJoystickManager.m.

35{
36 int i;
37
38 // Find and open the sticks. Make sure that we don't fail if more joysticks than MAX_STICKS are detected.
39 stickCount = SDL_NumJoysticks();
40 OOLog(@"joystick.init", @"Number of joysticks detected: %ld", (long)stickCount);
42 {
44 OOLog(@"joystick.init", @"Number of joysticks detected exceeds maximum number of joysticks allowed. Setting number of active joysticks to %d.", MAX_STICKS);
45 }
46 if(stickCount)
47 {
48 for(i = 0; i < stickCount; i++)
49 {
50 // it's doubtful MAX_STICKS will ever get exceeded, but
51 // we need to be defensive.
52 if(i > MAX_STICKS)
53 break;
54
55 stick[i]=SDL_JoystickOpen(i);
56 if(!stick[i])
57 {
58 OOLog(@"joystick.init", @"Failed to open joystick #%d", i);
59 }
60 }
61 SDL_JoystickEventState(SDL_ENABLE);
62 }
63 return [super init];
64}
#define MAX_STICKS

◆ joystickCount

- (NSUInteger) joystickCount
implementation

Reimplemented from OOJoystickManager.

Definition at line 1 of file OOSDLJoystickManager.m.

95{
96 return stickCount;
97}

◆ nameOfJoystick:

- (NSString *) nameOfJoystick: (NSUInteger) stickNumber

Reimplemented from OOJoystickManager.

Definition at line 1 of file OOSDLJoystickManager.m.

100 :(NSUInteger)stickNumber
101{
102 return [NSString stringWithUTF8String:SDL_JoystickName((int)stickNumber)];
103}

Member Data Documentation

◆ stick

- (SDL_Joystick* stick[MAX_STICKS])
private

Definition at line 48 of file OOSDLJoystickManager.h.

◆ stickCount

- (NSUInteger) stickCount
private

Definition at line 49 of file OOSDLJoystickManager.h.


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