ObjFW  Check-in [899801a8b8]

Overview
Comment:OFGameController: Quirks for Mega Drive controller
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 899801a8b852a49b6846ab33e92f6c76b6e53fb2d38a7c65e09c8e7f56826d02
User & Date: js on 2024-05-10 12:58:34
Other Links: branch diff | manifest | tags
Context
2024-05-11
09:56
OFGameController: Remove Mega Drive quirk check-in: 4f69c96c54 user: js tags: gamecontroller
2024-05-10
12:58
OFGameController: Quirks for Mega Drive controller check-in: 899801a8b8 user: js tags: gamecontroller
00:27
OFGameController: Add support for Windows check-in: 22f6f258d8 user: js tags: gamecontroller
Changes

Modified src/OFGameController.h from [1c2cd608b4] to [92436c98c4].

42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
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







+










+







 *   * @ref OFGameControllerButtonL
 *   * @ref OFGameControllerButtonR
 *   * @ref OFGameControllerButtonZL
 *   * @ref OFGameControllerButtonZR
 *   * @ref OFGameControllerButtonSelect
 *   * @ref OFGameControllerButtonStart
 *   * @ref OFGameControllerButtonHome
 *   * @ref OFGameControllerButtonCapture
 *   * @ref OFGameControllerButtonLeftStick
 *   * @ref OFGameControllerButtonRightStick
 *   * @ref OFGameControllerButtonDPadUp
 *   * @ref OFGameControllerButtonDPadDown
 *   * @ref OFGameControllerButtonDPadLeft
 *   * @ref OFGameControllerButtonDPadRight
 *   * @ref OFGameControllerButtonCPadUp
 *   * @ref OFGameControllerButtonCPadDown
 *   * @ref OFGameControllerButtonCPadLeft
 *   * @ref OFGameControllerButtonCPadRight
 *   * @ref OFGameControllerButtonMode
 */
typedef OFConstantString *OFGameControllerButton;

#ifdef __cplusplus
extern "C" {
#endif
/**
178
179
180
181
182
183
184





185
186
187
188
189
190
191
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198







+
+
+
+
+







 */
extern const OFGameControllerButton OFGameControllerButtonCPadLeft;

/**
 * @brief The C-Pad Right button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCPadRight;

/**
 * @brief The Mode button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonMode;
#ifdef __cplusplus
}
#endif

/**
 * @brief A class for reading state from a game controller.
 */

Modified src/OFGameController.m from [55650ba23c] to [1fb5242392].

42
43
44
45
46
47
48

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







+







const OFGameControllerButton OFGameControllerButtonDPadDown = @"D-Pad Down";
const OFGameControllerButton OFGameControllerButtonDPadLeft = @"D-Pad Left";
const OFGameControllerButton OFGameControllerButtonDPadRight = @"D-Pad Right";
const OFGameControllerButton OFGameControllerButtonCPadUp = @"C-Pad Up";
const OFGameControllerButton OFGameControllerButtonCPadDown = @"C-Pad Down";
const OFGameControllerButton OFGameControllerButtonCPadLeft = @"C-Pad Left";
const OFGameControllerButton OFGameControllerButtonCPadRight = @"C-Pad Right";
const OFGameControllerButton OFGameControllerButtonMode = @"Mode";

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include "platform/Linux/OFGameController.m"
#elif defined(OF_WINDOWS)
# include "platform/Windows/OFGameController.m"
#elif defined(OF_NINTENDO_DS)
# include "platform/NintendoDS/OFGameController.m"

Modified src/platform/Linux/OFGameController.m from [fb841c3ea2] to [3f585adcc6].

36
37
38
39
40
41
42

43
44
45
46
47
48
49
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







+







#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"

static const uint16_t vendorIDNintendo = 0x057E;
static const uint16_t productIDN64Controller = 0x2019;
static const uint16_t productIDMegaDriveController = 0x201E;

@interface OFGameController ()
- (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
@end

static const uint16_t buttons[] = {
	BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2,
67
68
69
70
71
72
73
















74
75
76
77
78
79
80
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







			return OFGameControllerButtonCPadUp;
		case BTN_X:
			return OFGameControllerButtonCPadDown;
		case BTN_MODE:
			return OFGameControllerButtonHome;
		case BTN_Z:
			return OFGameControllerButtonCapture;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDMegaDriveController) {
		switch (button) {
		case BTN_B:
			return OFGameControllerButtonA;
		case BTN_A:
			return OFGameControllerButtonB;
		case BTN_Z:
			return OFGameControllerButtonC;
		case BTN_TR2:
			return OFGameControllerButtonStart;
		case BTN_TR:
			return OFGameControllerButtonMode;
		case BTN_THUMBL:
			return OFGameControllerButtonCapture;
		}
	}

	switch (button) {
	case BTN_A:
		return OFGameControllerButtonA;
	case BTN_B: