ObjFW  Check-in [21d148d1f9]

Overview
Comment:OHGamepad: Add missing documentation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 21d148d1f997dd423bbb7b2305d397d9acde7d0d8195879893114cfe65c6876e
User & Date: js on 2024-06-08 19:26:55
Other Links: manifest | tags
Context
2024-06-08
19:32
OHGameControllerDirectionalPad: Rename methods check-in: 35e4d04158 user: js tags: trunk
19:26
OHGamepad: Add missing documentation check-in: 21d148d1f9 user: js tags: trunk
19:18
ObjFWHID: Restore XInput support check-in: 5f0cc05894 user: js tags: trunk
Changes

Modified src/hid/OHEvdevGamepad.m from [a03c43c125] to [2d485491e2].

43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57







-
+







		    self.rightShoulderButton == nil ||
		    self.leftTriggerButton == nil ||
		    self.rightTriggerButton == nil ||
		    self.leftThumbstickButton == nil ||
		    self.rightThumbstickButton == nil ||
		    self.menuButton == nil || self.optionsButton == nil ||
		    self.homeButton == nil || self.leftThumbstick == nil ||
		    self.rightThumbstick == nil || self.directionalPad == nil)
		    self.rightThumbstick == nil || self.dPad == nil)
			@throw [OFInvalidArgumentException exception];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105







-
+








- (OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *) *)
    directionalPads
{
	return [OFDictionary dictionaryWithKeysAndObjects:
	    @"Left Thumbstick", self.leftThumbstick,
	    @"Right Thumbstick", self.rightThumbstick,
	    @"D-Pad", self.directionalPad, nil];
	    @"D-Pad", self.dPad, nil];
}

- (OHGameControllerButton *)northButton
{
	return [_rawProfile.buttons objectForKey: @"Y"];
}

199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213







-
+








	return [[[OHGameControllerDirectionalPad alloc]
	    initWithName: @"Right Thumbstick"
		   xAxis: xAxis
		   yAxis: yAxis] autorelease];
}

- (OHGameControllerDirectionalPad *)directionalPad
- (OHGameControllerDirectionalPad *)dPad
{
	OHGameControllerAxis *xAxis = [_rawProfile.axes objectForKey: @"HAT0X"];
	OHGameControllerAxis *yAxis = [_rawProfile.axes objectForKey: @"HAT0Y"];
	OHGameControllerButton *upButton, *downButton;
	OHGameControllerButton *leftButton, *rightButton;

	if (xAxis != nil && yAxis != nil)

Modified src/hid/OHGamepad.h from [823c3e7afc] to [71565947d0].

27
28
29
30
31
32
33



34




35




36




37




38




39




40




41




42




43




44




45







46





47




48




49

50
51
52
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
110
111
112
113
114

115
116
117
118







+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+
+
+
+
-
+
+
+
+
+

+
+
+
+

+
+
+
+
-
+



 * @brief A game controller profile representing a gamepad.
 */
@interface OHGamepad: OHGameControllerProfile
{
	OF_RESERVE_IVARS(OHGamepad, 4)
}

/**
 * @brief The north button on the gamepad's diamond pad.
 */
@property (readonly, nonatomic) OHGameControllerButton *northButton;

/**
 * @brief The south button on the gamepad's diamond pad.
 */
@property (readonly, nonatomic) OHGameControllerButton *southButton;

/**
 * @brief The west button on the gamepad's diamond pad.
 */
@property (readonly, nonatomic) OHGameControllerButton *westButton;

/**
 * @brief The east button on the gamepad's diamond pad.
 */
@property (readonly, nonatomic) OHGameControllerButton *eastButton;

/**
 * @brief The left shoulder button.
 */
@property (readonly, nonatomic) OHGameControllerButton *leftShoulderButton;

/**
 * @brief The right shoulder button.
 */
@property (readonly, nonatomic) OHGameControllerButton *rightShoulderButton;

/**
 * @brief The left trigger button.
 */
@property (readonly, nonatomic) OHGameControllerButton *leftTriggerButton;

/**
 * @brief The right trigger button.
 */
@property (readonly, nonatomic) OHGameControllerButton *rightTriggerButton;

/**
 * @brief The left thumb stick button.
 */
@property (readonly, nonatomic) OHGameControllerButton *leftThumbstickButton;

/**
 * @brief The right thumb stick button.
 */
@property (readonly, nonatomic) OHGameControllerButton *rightThumbstickButton;

/**
 * @brief The menu button, sometimes also called start button.
 */
@property (readonly, nonatomic) OHGameControllerButton *menuButton;

/**
 * @brief The options button, sometimes also called select button.
 */
@property (readonly, nonatomic) OHGameControllerButton *optionsButton;

/**
 * @brief The home button.
 *
 * This button is optional and may be `nil`.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
@property (readonly, nonatomic) OHGameControllerButton *homeButton;
    OHGameControllerButton *homeButton;

/**
 * @brief The left thumb stick.
 */
@property (readonly, nonatomic) OHGameControllerDirectionalPad *leftThumbstick;

/**
 * @brief The right thumb stick.
 */
@property (readonly, nonatomic) OHGameControllerDirectionalPad *rightThumbstick;

/**
 * @brief The D-Pad.
 */
@property (readonly, nonatomic) OHGameControllerDirectionalPad *directionalPad;
@property (readonly, nonatomic) OHGameControllerDirectionalPad *dPad;
@end

OF_ASSUME_NONNULL_END

Modified src/hid/OHGamepad.m from [422aa06dbe] to [051467454d].

21
22
23
24
25
26
27
28

29
21
22
23
24
25
26
27

28
29







-
+


#import "OHGamepad.h"

@implementation OHGamepad
@dynamic northButton, southButton, westButton, eastButton, leftShoulderButton;
@dynamic rightShoulderButton, leftTriggerButton, rightTriggerButton;
@dynamic leftThumbstickButton, rightThumbstickButton, menuButton, optionsButton;
@dynamic homeButton, leftThumbstick, rightThumbstick, directionalPad;
@dynamic homeButton, leftThumbstick, rightThumbstick, dPad;
@end

Modified src/hid/OHXInputGameController.m from [44a8b230ca] to [6b31e51715].

207
208
209
210
211
212
213
214

215
216

217
218

219
220

221
222
223
224
225
226
227
207
208
209
210
211
212
213

214
215

216
217

218
219

220
221
222
223
224
225
226
227







-
+

-
+

-
+

-
+







	_gamepad.rightThumbstick.xAxis.value =
	    (float)state.Gamepad.sThumbRX /
	    (state.Gamepad.sThumbRX < 0 ? -INT16_MIN : INT16_MAX);
	_gamepad.rightThumbstick.yAxis.value =
	    -(float)state.Gamepad.sThumbRY /
	    (state.Gamepad.sThumbRY < 0 ? -INT16_MIN : INT16_MAX);

	_gamepad.directionalPad.upButton.value =
	_gamepad.dPad.upButton.value =
	    !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP);
	_gamepad.directionalPad.downButton.value =
	_gamepad.dPad.downButton.value =
	    !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN);
	_gamepad.directionalPad.leftButton.value =
	_gamepad.dPad.leftButton.value =
	    !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT);
	_gamepad.directionalPad.rightButton.value =
	_gamepad.dPad.rightButton.value =
	    !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT);
}

- (OFString *)name
{
	switch (XInputVersion) {
	case 14: