ObjFW  Check-in [31f8c31ac7]

Overview
Comment:OHEvdevGamepad: Fix name of trigger buttons
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 31f8c31ac796aa3a43db29a9e9bb31469af423c727eb37224f1c7395d88e25f2
User & Date: js on 2024-06-08 23:04:34
Other Links: manifest | tags
Context
2024-06-08
23:14
OHEvdevDualSense: Minor cleanup check-in: b67a849b51 user: js tags: trunk
23:04
OHEvdevGamepad: Fix name of trigger buttons check-in: 31f8c31ac7 user: js tags: trunk
22:59
ObjFWHID: Improve test for gamepad profile check-in: c7a5bfe9e6 user: js tags: trunk
Changes

Modified src/hid/OHEvdevDualSense.m from [7696fc6d10] to [c90245aab6].

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 "OHEvdevDualSense.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OHEvdevGameController.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#import "OFInvalidArgumentException.h"

@implementation OHEvdevDualSense
- (OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *)buttons
{







<
<
<







17
18
19
20
21
22
23



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

#include "config.h"

#import "OHEvdevDualSense.h"
#import "OFDictionary.h"



#import "OHGameControllerEmulatedTriggerButton.h"

#import "OFInvalidArgumentException.h"

@implementation OHEvdevDualSense
- (OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *)buttons
{
67
68
69
70
71
72
73
























74
75
76
77
78
79
80
	return [_rawProfile.buttons objectForKey: @"Circle"];
}

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

























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

- (OHGameControllerButton *)leftThumbstickButton







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	return [_rawProfile.buttons objectForKey: @"Circle"];
}

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

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

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

	return [_rawProfile.buttons objectForKey: @"L2"];
}

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

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

	return [_rawProfile.buttons objectForKey: @"R2"];
}

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

- (OHGameControllerButton *)leftThumbstickButton

Modified src/hid/OHEvdevGamepad.m from [f7c0aaf892] to [deafbe8df3].

144
145
146
147
148
149
150

151
152
153
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169

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

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]

		    initWithAxis: axis] autorelease];

	return [_rawProfile.buttons objectForKey: @"LT"];
}

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

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]

		    initWithAxis: axis] autorelease];

	return [_rawProfile.buttons objectForKey: @"RT"];
}

- (OHGameControllerButton *)leftThumbstickButton
{
	return [_rawProfile.buttons objectForKey: @"LSB"];







>
|










>
|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

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

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

	return [_rawProfile.buttons objectForKey: @"LT"];
}

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

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

	return [_rawProfile.buttons objectForKey: @"RT"];
}

- (OHGameControllerButton *)leftThumbstickButton
{
	return [_rawProfile.buttons objectForKey: @"LSB"];

Modified src/hid/OHGameControllerEmulatedTriggerButton.h from [15a75f9011] to [be397ce686].

26
27
28
29
30
31
32

33
34
35
36
OF_SUBCLASSING_RESTRICTED
@interface OHGameControllerEmulatedTriggerButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
}

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

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis;
@end

OF_ASSUME_NONNULL_END







>
|



26
27
28
29
30
31
32
33
34
35
36
37
OF_SUBCLASSING_RESTRICTED
@interface OHGameControllerEmulatedTriggerButton: OHGameControllerButton
{
	OHGameControllerAxis *_axis;
}

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

OF_ASSUME_NONNULL_END

Modified src/hid/OHGameControllerEmulatedTriggerButton.m from [249698b888] to [276359729c].

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

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

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
{
	void *pool = objc_autoreleasePoolPush();
	OFString *name;

	@try {
		name = axis.name;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [super initWithName: name];

	objc_autoreleasePoolPop(pool);

	_axis = [axis retain];

	return self;
}

- (void)dealloc







|
<
<
<
|
<
<
<
<
<
<
|

<
<







24
25
26
27
28
29
30
31



32






33
34


35
36
37
38
39
40
41

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

- (instancetype)initWithName: (OFString *)name



			axis: (OHGameControllerAxis *)axis






{
	self = [super initWithName: name];



	_axis = [axis retain];

	return self;
}

- (void)dealloc