ObjFW  Check-in [498a91a2a4]

Overview
Comment:OFGameController: Rename axis to analog stick

This was just wrong, an analog stick has two axes.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 498a91a2a4b43e06874d4f18e14fbcc2e83f68ee0cb05d84ef19e8011eba91f2
User & Date: js on 2024-05-05 19:56:47
Other Links: branch diff | manifest | tags
Context
2024-05-05
23:07
OFGameController: Fix typos check-in: 3ef11175bc user: js tags: gamecontroller
19:56
OFGameController: Rename axis to analog stick check-in: 498a91a2a4 user: js tags: gamecontroller
19:22
OFGameController: Add support for Nintendo DS check-in: a7a6705d90 user: js tags: gamecontroller
Changes

Modified src/OFGameController.h from [d675a51f7b] to [542208ba0a].

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

/**
 * @brief The currently pressed buttons on the controller.
 */
@property (readonly, nonatomic) OFSet OF_GENERIC(OFString *) *pressedButtons;

/**
 * @brief The number of axes the controller has.
 */
@property (readonly, nonatomic) size_t numAxes;

/**
 * @brief Returns the number of available controllers.
 *
 * @return The number of available controllers
 */
+ (size_t)numControllers;

/**
 * @brief Returns the specified controller.
 *
 * @param index The index of the controller to return
 * @return The specified controller
 */
+ (OFGameController *)controllerWithIndex: (size_t)index;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Returns the current position of the specified axis.
 *
 * The range is from (-1, -1) to (1, 1).
 *
 * @param index The index of the axis whose position to return
 * @return The current position of the specified axis
 */
- (OFPoint)positionOfAxisWithIndex: (size_t)index;
@end

OF_ASSUME_NONNULL_END







|

|



















|



|
|

|



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

/**
 * @brief The currently pressed buttons on the controller.
 */
@property (readonly, nonatomic) OFSet OF_GENERIC(OFString *) *pressedButtons;

/**
 * @brief The number of analog sticks the controller has.
 */
@property (readonly, nonatomic) size_t numAnalogSticks;

/**
 * @brief Returns the number of available controllers.
 *
 * @return The number of available controllers
 */
+ (size_t)numControllers;

/**
 * @brief Returns the specified controller.
 *
 * @param index The index of the controller to return
 * @return The specified controller
 */
+ (OFGameController *)controllerWithIndex: (size_t)index;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Returns the current position of the specified analog stick.
 *
 * The range is from (-1, -1) to (1, 1).
 *
 * @param index The index of the analog stick whose position to return
 * @return The current position of the specified analog stick
 */
- (OFPoint)positionOfAnalogStickWithIndex: (size_t)index;
@end

OF_ASSUME_NONNULL_END

Modified src/OFGameController.m from [fafb3475e1] to [5f3c3f51d8].

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

#if defined(OF_NINTENDO_DS)
# include "platform/NintendoDS/OFGameController.m"
#elif defined(F_NINTENDO_3DS)
# include "platform/Nintendo3DS/OFGameController.m"
#else
@implementation OFGameController
@dynamic buttons, pressedButtons, numAxes;

+ (size_t)numControllers
{
	return 0;
}

+ (OFGameController *)controllerWithIndex: (size_t)index
{
	@throw [OFOutOfRangeException exception];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (OFPoint)positionOfAxisWithIndex: (size_t)index
{
	OF_UNRECOGNIZED_SELECTOR
}
@end
#endif







|
















|





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

#if defined(OF_NINTENDO_DS)
# include "platform/NintendoDS/OFGameController.m"
#elif defined(F_NINTENDO_3DS)
# include "platform/Nintendo3DS/OFGameController.m"
#else
@implementation OFGameController
@dynamic buttons, pressedButtons, numAnalogSticks;

+ (size_t)numControllers
{
	return 0;
}

+ (OFGameController *)controllerWithIndex: (size_t)index
{
	@throw [OFOutOfRangeException exception];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (OFPoint)positionOfAnalogSticksWithIndex: (size_t)index
{
	OF_UNRECOGNIZED_SELECTOR
}
@end
#endif

Modified src/platform/Nintendo3DS/OFGameController.m from [9240091586] to [5edf21e397].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
		[pressedButtons addObject: @"C-Stick Down"];

	[pressedButtons makeImmutable];

	return pressedButtons;
}

- (size_t)numAxes
{
	return 1;
}

- (OFPoint)positionOfAxisWithIndex: (size_t)index
{
	circlePosition pos;

	if (index > 0)
		@throw [OFOutOfRangeException exception];

	hidCircleRead(&pos);







|




|







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
		[pressedButtons addObject: @"C-Stick Down"];

	[pressedButtons makeImmutable];

	return pressedButtons;
}

- (size_t)numAnalogSticks
{
	return 1;
}

- (OFPoint)positionOfAnalogStickWithIndex: (size_t)index
{
	circlePosition pos;

	if (index > 0)
		@throw [OFOutOfRangeException exception];

	hidCircleRead(&pos);

Modified src/platform/NintendoDS/OFGameController.m from [1ef9eba7af] to [30201f00f5].

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
		[pressedButtons addObject: @"Y"];

	[pressedButtons makeImmutable];

	return pressedButtons;
}

- (size_t)numAxes
{
	return 0;
}

- (OFPoint)positionOfAxisWithIndex: (size_t)index
{
	@throw [OFOutOfRangeException exception];
}
@end







|




|




109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
		[pressedButtons addObject: @"Y"];

	[pressedButtons makeImmutable];

	return pressedButtons;
}

- (size_t)numAnalogSticks
{
	return 0;
}

- (OFPoint)positionOfAnalogStickWithIndex: (size_t)index
{
	@throw [OFOutOfRangeException exception];
}
@end