ObjFW  Check-in [7d118b8085]

Overview
Comment:ObjFWHID: Internal rename
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7d118b808575678b3c3eafefd9f29d88c52773194701aadd5a504836612a51e0
User & Date: js on 2024-06-17 00:47:27
Other Links: manifest | tags
Context
2024-06-17
00:51
Make GCC happy again check-in: 73a310f77c user: js tags: trunk
00:47
ObjFWHID: Internal rename check-in: 7d118b8085 user: js tags: trunk
00:37
ObjFWHID: Make profiles implementation independent check-in: ddaa4f35d0 user: js tags: trunk
Changes

Modified src/hid/Makefile from [ebf0da59ae] to [e11835f6dd].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
	    OHExtendedGamepad.h		\
	    OHGameControllerProfile.h	\
	    OHGamepad.h			\
	    ObjFWHID.h

SRCS += OHDualSenseGamepad.m			\
	OHDualShock4Gamepad.m			\
	OHGameControllerEmulatedAxis.m		\
	OHGameControllerEmulatedButton.m	\
	OHGameControllerEmulatedTriggerButton.m	\
	OHStadiaGamepad.m			\
	OHXboxGamepad.m				\
	${USE_SRCS_EVDEV}			\
	${USE_SRCS_NINTENDO_3DS}		\
	${USE_SRCS_NINTENDO_DS}			\
	${USE_SRCS_NINTENDO_SWITCH}		\
	${USE_SRCS_WII}				\







|
|
|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
	    OHExtendedGamepad.h		\
	    OHGameControllerProfile.h	\
	    OHGamepad.h			\
	    ObjFWHID.h

SRCS += OHDualSenseGamepad.m			\
	OHDualShock4Gamepad.m			\
	OHEmulatedGameControllerAxis.m		\
	OHEmulatedGameControllerButton.m	\
	OHEmulatedGameControllerTriggerButton.m	\
	OHStadiaGamepad.m			\
	OHXboxGamepad.m				\
	${USE_SRCS_EVDEV}			\
	${USE_SRCS_NINTENDO_3DS}		\
	${USE_SRCS_NINTENDO_DS}			\
	${USE_SRCS_NINTENDO_SWITCH}		\
	${USE_SRCS_WII}				\

Modified src/hid/OHDualSenseGamepad.m from [3943959c39] to [cd86706e5b].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHDualSenseGamepad.h"
#import "OFDictionary.h"

#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"Triangle", @"Cross", @"Square", @"Circle", @"L1", @"R1", @"L3", @"R3",







>



<







17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHDualSenseGamepad.h"
#import "OFDictionary.h"
#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"


#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"Triangle", @"Cross", @"Square", @"Circle", @"L1", @"R1", @"L3", @"R3",
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];








|






|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];

273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	case ABS_RY:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_Z:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_RZ:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end







|


|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	case ABS_RY:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_Z:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_RZ:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end

Modified src/hid/OHDualShock4Gamepad.m from [67cdfbaf35] to [379635704c].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHDualShock4Gamepad.h"
#import "OFDictionary.h"

#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"Triangle", @"Cross", @"Square", @"Circle", @"L1", @"R1", @"L3", @"R3",







>



<







17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHDualShock4Gamepad.h"
#import "OFDictionary.h"
#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"


#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"Triangle", @"Cross", @"Square", @"Circle", @"L1", @"R1", @"L3", @"R3",
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];








|






|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];

273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	case ABS_RY:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_Z:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_RZ:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end







|


|







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
	case ABS_RY:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_Z:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_RZ:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end

Renamed and modified src/hid/OHGameControllerEmulatedAxis.h [a0f65c5e9a] to src/hid/OHEmulatedGameControllerAxis.h [a0fe4a8f6c].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerAxis.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerButton;

OF_SUBCLASSING_RESTRICTED
@interface OHGameControllerEmulatedAxis: OHGameControllerAxis
{
	OHGameControllerButton *_negativeButton, *_positiveButton;
}

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
- (instancetype)
    initWithNegativeButton: (OHGameControllerButton *)negativeButton







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerAxis.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerButton;

OF_SUBCLASSING_RESTRICTED
@interface OHEmulatedGameControllerAxis: OHGameControllerAxis
{
	OHGameControllerButton *_negativeButton, *_positiveButton;
}

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
- (instancetype)
    initWithNegativeButton: (OHGameControllerButton *)negativeButton

Renamed and modified src/hid/OHGameControllerEmulatedAxis.m [d60d8c7150] to src/hid/OHEmulatedGameControllerAxis.m [46dce32498].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#import "config.h"

#import "OHGameControllerEmulatedAxis.h"
#import "OHGameControllerButton.h"

@implementation OHGameControllerEmulatedAxis
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithNegativeButton: (OHGameControllerButton *)negativeButton
			positiveButton: (OHGameControllerButton *)positiveButton







|


|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#import "config.h"

#import "OHEmulatedGameControllerAxis.h"
#import "OHGameControllerButton.h"

@implementation OHEmulatedGameControllerAxis
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithNegativeButton: (OHGameControllerButton *)negativeButton
			positiveButton: (OHGameControllerButton *)positiveButton

Renamed and modified src/hid/OHGameControllerEmulatedButton.h [1f52540e1f] to src/hid/OHEmulatedGameControllerButton.h [ef1d24eb2d].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerButton.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerAxis;

OF_SUBCLASSING_RESTRICTED
@interface OHGameControllerEmulatedButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
	bool _positive;
}

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
- (instancetype)initWithAxis: (OHGameControllerAxis *)axis







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerButton.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerAxis;

OF_SUBCLASSING_RESTRICTED
@interface OHEmulatedGameControllerButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
	bool _positive;
}

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
- (instancetype)initWithAxis: (OHGameControllerAxis *)axis

Renamed and modified src/hid/OHGameControllerEmulatedButton.m [eefaf93827] to src/hid/OHEmulatedGameControllerButton.m [838a2c4d07].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHGameControllerEmulatedButton.h"
#import "OHGameControllerAxis.h"

@implementation OHGameControllerEmulatedButton
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
		    positive: (bool)positive







|


|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHEmulatedGameControllerButton.h"
#import "OHGameControllerAxis.h"

@implementation OHEmulatedGameControllerButton
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
		    positive: (bool)positive

Renamed and modified src/hid/OHGameControllerEmulatedTriggerButton.h [7b4bceb90d] to src/hid/OHEmulatedGameControllerTriggerButton.h [60ea9ad062].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerButton.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerAxis;

OF_SUBCLASSING_RESTRICTED
@interface OHGameControllerEmulatedTriggerButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
}

@property (readonly, nonatomic) OHGameControllerAxis *axis;

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OHGameControllerButton.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerAxis;

OF_SUBCLASSING_RESTRICTED
@interface OHEmulatedGameControllerTriggerButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
}

@property (readonly, nonatomic) OHGameControllerAxis *axis;

- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;

Renamed and modified src/hid/OHGameControllerEmulatedTriggerButton.m [e85e338284] to src/hid/OHEmulatedGameControllerTriggerButton.m [c0d9c98c3d].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHGameControllerEmulatedTriggerButton.h"
#import "OHGameControllerAxis.h"

@implementation OHGameControllerEmulatedTriggerButton
@synthesize axis = _axis;

- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}








|


|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * You should have received a copy of the GNU Lesser General Public License
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHGameControllerAxis.h"

@implementation OHEmulatedGameControllerTriggerButton
@synthesize axis = _axis;

- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

Modified src/hid/OHEvdevExtendedGamepad.m from [bb1ee3755e] to [188161fd62].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHEvdevExtendedGamepad.h"
#import "OFDictionary.h"

#import "OHEvdevGameController.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#import "OFInvalidArgumentException.h"

@implementation OHEvdevExtendedGamepad
- (instancetype)initWithKeyBits: (unsigned long *)keyBits
			 evBits: (unsigned long *)evBits
			absBits: (unsigned long *)absBits







>


<







17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHEvdevExtendedGamepad.h"
#import "OFDictionary.h"
#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHEvdevGameController.h"
#import "OHGameControllerDirectionalPad.h"


#import "OFInvalidArgumentException.h"

@implementation OHEvdevExtendedGamepad
- (instancetype)initWithKeyBits: (unsigned long *)keyBits
			 evBits: (unsigned long *)evBits
			absBits: (unsigned long *)absBits
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
}

- (OHGameControllerButton *)leftTriggerButton
{
	OHGameControllerAxis *axis = [_axes objectForKey: @"Z"];

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"LT"
			    axis: axis] autorelease];

	return [_buttons objectForKey: @"LT"];
}

- (OHGameControllerButton *)rightTriggerButton
{
	OHGameControllerAxis *axis = [_axes objectForKey: @"RZ"];

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"RT"
			    axis: axis] autorelease];

	return [_buttons objectForKey: @"RT"];
}

- (OHGameControllerButton *)leftThumbstickButton







|











|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
}

- (OHGameControllerButton *)leftTriggerButton
{
	OHGameControllerAxis *axis = [_axes objectForKey: @"Z"];

	if (axis != nil)
		return [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"LT"
			    axis: axis] autorelease];

	return [_buttons objectForKey: @"LT"];
}

- (OHGameControllerButton *)rightTriggerButton
{
	OHGameControllerAxis *axis = [_axes objectForKey: @"RZ"];

	if (axis != nil)
		return [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"RT"
			    axis: axis] autorelease];

	return [_buttons objectForKey: @"RT"];
}

- (OHGameControllerButton *)leftThumbstickButton

Modified src/hid/OHGameControllerDirectionalPad.m from [04d6b10457] to [6b45d63858].

16
17
18
19
20
21
22
23
24
25
26
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
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedAxis.h"
#import "OHGameControllerEmulatedButton.h"

@implementation OHGameControllerDirectionalPad
@synthesize xAxis = _xAxis, yAxis = _yAxis;
@synthesize up = _up, down = _down, left = _left, right = _right;

- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithName: (OFString *)name
		       xAxis: (OHGameControllerAxis *)xAxis
		       yAxis: (OHGameControllerAxis *)yAxis
{
	self = [super initWithName: name];

	@try {
		_xAxis = [xAxis retain];
		_yAxis = [yAxis retain];

		_up = [[OHGameControllerEmulatedButton alloc]
		    initWithAxis: _yAxis
			positive: false];
		_down = [[OHGameControllerEmulatedButton alloc]
		    initWithAxis: _yAxis
			positive: true];
		_left = [[OHGameControllerEmulatedButton alloc]
		    initWithAxis: _xAxis
			positive: false];
		_right = [[OHGameControllerEmulatedButton alloc]
		    initWithAxis: _xAxis
			positive: true];
	} @catch (id e) {
		[self release];
		@throw e;
	}








|
|




















|


|


|


|







16
17
18
19
20
21
22
23
24
25
26
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
 * version 3.0 along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHGameControllerDirectionalPad.h"
#import "OHEmulatedGameControllerAxis.h"
#import "OHEmulatedGameControllerButton.h"

@implementation OHGameControllerDirectionalPad
@synthesize xAxis = _xAxis, yAxis = _yAxis;
@synthesize up = _up, down = _down, left = _left, right = _right;

- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithName: (OFString *)name
		       xAxis: (OHGameControllerAxis *)xAxis
		       yAxis: (OHGameControllerAxis *)yAxis
{
	self = [super initWithName: name];

	@try {
		_xAxis = [xAxis retain];
		_yAxis = [yAxis retain];

		_up = [[OHEmulatedGameControllerButton alloc]
		    initWithAxis: _yAxis
			positive: false];
		_down = [[OHEmulatedGameControllerButton alloc]
		    initWithAxis: _yAxis
			positive: true];
		_left = [[OHEmulatedGameControllerButton alloc]
		    initWithAxis: _xAxis
			positive: false];
		_right = [[OHEmulatedGameControllerButton alloc]
		    initWithAxis: _xAxis
			positive: true];
	} @catch (id e) {
		[self release];
		@throw e;
	}

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	@try {
		_up = [up retain];
		_down = [down retain];
		_left = [left retain];
		_right = [right retain];

		_xAxis = [[OHGameControllerEmulatedAxis alloc]
		    initWithNegativeButton: _left
			    positiveButton: _right];
		_yAxis = [[OHGameControllerEmulatedAxis alloc]
		    initWithNegativeButton: _up
			    positiveButton: _down];
	} @catch (id e) {
		[self release];
		@throw e;
	}








|


|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	@try {
		_up = [up retain];
		_down = [down retain];
		_left = [left retain];
		_right = [right retain];

		_xAxis = [[OHEmulatedGameControllerAxis alloc]
		    initWithNegativeButton: _left
			    positiveButton: _right];
		_yAxis = [[OHEmulatedGameControllerAxis alloc]
		    initWithNegativeButton: _up
			    positiveButton: _down];
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/hid/OHStadiaGamepad.m from [f14cc5d0c1] to [166c5ee3f1].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHStadiaGamepad.h"
#import "OFDictionary.h"

#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"A", @"B", @"X", @"Y", @"L1", @"R1", @"L3", @"R3", @"Menu", @"Options",







>



<







17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHStadiaGamepad.h"
#import "OFDictionary.h"
#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"


#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"A", @"B", @"X", @"Y", @"L1", @"R1", @"L3", @"R3", @"Menu", @"Options",
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];








|






|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	case ABS_RZ:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_BRAKE:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_GAS:
		return ((OHGameControllerEmulatedTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end







|


|







279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	case ABS_RZ:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_BRAKE:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_GAS:
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end