18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
*/
#include "config.h"
#import "OHWiiGameController.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHWiiClassicController.h"
#import "OHWiimote.h"
#import "OHWiimoteWithNunchuk.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFReadFailedException.h"
#define asm __asm__
|
>
>
>
>
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
*/
#include "config.h"
#import "OHWiiGameController.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OHGameController.h"
#import "OHGameController+Private.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHWiiClassicController.h"
#import "OHWiiClassicController+Private.h"
#import "OHWiimote.h"
#import "OHWiimote+Private.h"
#import "OHWiimoteWithNunchuk.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFReadFailedException.h"
#define asm __asm__
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
for (int32_t i = 0; i < WPAD_MAX_WIIMOTES; i++) {
uint32_t type;
if (WPAD_Probe(i, &type) == WPAD_ERR_NONE &&
(type == WPAD_EXP_NONE || type == WPAD_EXP_NUNCHUK ||
type == WPAD_EXP_CLASSIC))
[controllers addObject: [[[OHWiiGameController alloc]
initWithIndex: i
type: type] autorelease]];
}
[controllers makeImmutable];
objc_autoreleasePoolPop(pool);
return controllers;
}
- (instancetype)initWithIndex: (int32_t)index type: (uint32_t)type
{
self = [super init];
@try {
_index = index;
_type = type;
if (type == WPAD_EXP_CLASSIC)
_profile = [[OHWiiClassicController alloc] init];
else if (type == WPAD_EXP_NUNCHUK)
_profile = [[OHWiimoteWithNunchuk alloc] init];
else
_profile = [[OHWiimote alloc] init];
[self updateState];
} @catch (id e) {
[self release];
@throw e;
}
|
|
|
>
>
>
>
>
|
|
|
|
|
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
for (int32_t i = 0; i < WPAD_MAX_WIIMOTES; i++) {
uint32_t type;
if (WPAD_Probe(i, &type) == WPAD_ERR_NONE &&
(type == WPAD_EXP_NONE || type == WPAD_EXP_NUNCHUK ||
type == WPAD_EXP_CLASSIC))
[controllers addObject: [[[OHWiiGameController alloc]
oh_initWithIndex: i
type: type] autorelease]];
}
[controllers makeImmutable];
objc_autoreleasePoolPop(pool);
return controllers;
}
- (instancetype)oh_init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)oh_initWithIndex: (int32_t)index type: (uint32_t)type
{
self = [super oh_init];
@try {
_index = index;
_type = type;
if (type == WPAD_EXP_CLASSIC)
_profile = [[OHWiiClassicController alloc] oh_init];
else if (type == WPAD_EXP_NUNCHUK)
_profile = [[OHWiimoteWithNunchuk alloc] oh_init];
else
_profile = [[OHWiimote alloc] oh_init];
[self updateState];
} @catch (id e) {
[self release];
@throw e;
}
|