ObjFWHID: Change prefix to OH
Let's leave 3 letter prefixes to 3rd parties. FossilOrigin-Name: afae3291bff5cad99191b902e6e4e81c711893566fe204467ee1a059a0e84377
This commit is contained in:
parent
131c556738
commit
3996357958
23 changed files with 174 additions and 176 deletions
2
Doxyfile
2
Doxyfile
|
@ -49,5 +49,5 @@ PREDEFINED = _Nonnull= \
|
|||
SIGUSR2
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
IGNORE_PREFIX = HID OF OF_ OT OT_
|
||||
IGNORE_PREFIX = OF OF_ OH OT OT_
|
||||
EXTRACT_STATIC = yes
|
||||
|
|
|
@ -9,18 +9,18 @@ LIB_MAJOR = ${OBJFWHID_LIB_MAJOR}
|
|||
LIB_MINOR = ${OBJFWHID_LIB_MINOR}
|
||||
LIB_PATCH = ${OBJFWHID_LIB_PATCH}
|
||||
|
||||
SRCS = HIDGameController.m \
|
||||
HIDGameControllerAxis.m \
|
||||
HIDGameControllerButton.m \
|
||||
HIDGameControllerDirectionalPad.m \
|
||||
HIDGameControllerElement.m \
|
||||
HIDGameControllerMapping.m
|
||||
SRCS = OHGameController.m \
|
||||
OHGameControllerAxis.m \
|
||||
OHGameControllerButton.m \
|
||||
OHGameControllerDirectionalPad.m \
|
||||
OHGameControllerElement.m \
|
||||
OHGameControllerMapping.m
|
||||
|
||||
INCLUDES := ${SRCS:.m=.h} \
|
||||
ObjFWHID.h
|
||||
|
||||
SRCS += HIDGameControllerEmulatedAxis.m \
|
||||
HIDGameControllerEmulatedButton.m
|
||||
SRCS += OHGameControllerEmulatedAxis.m \
|
||||
OHGameControllerEmulatedButton.m
|
||||
|
||||
includesubdir = ObjFWHID
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameController.h"
|
||||
#import "OHGameController.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HIDGameControllerMapping;
|
||||
@class OHGameControllerMapping;
|
||||
|
||||
@interface HIDEvdevGameController: HIDGameController
|
||||
@interface OHEvdevGameController: OHGameController
|
||||
{
|
||||
OFString *_path;
|
||||
int _fd;
|
||||
|
@ -31,7 +31,7 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
unsigned long *_evBits, *_keyBits, *_absBits;
|
||||
uint16_t _vendorID, _productID;
|
||||
OFString *_name;
|
||||
HIDGameControllerMapping *_mapping;
|
||||
OHGameControllerMapping *_mapping;
|
||||
}
|
||||
|
||||
- (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
|
|
@ -23,7 +23,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#import "HIDEvdevGameController.h"
|
||||
#import "OHEvdevGameController.h"
|
||||
|
||||
#import "OFArray.h"
|
||||
#import "OFDictionary.h"
|
||||
|
@ -31,9 +31,9 @@
|
|||
#import "OFLocale.h"
|
||||
#import "OFNumber.h"
|
||||
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "HIDGameControllerMapping.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
#import "OHGameControllerMapping.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/input.h>
|
||||
|
@ -44,14 +44,14 @@
|
|||
#import "OFOutOfRangeException.h"
|
||||
#import "OFReadFailedException.h"
|
||||
|
||||
@interface HIDEvdevGameControllerAxis: HIDGameControllerAxis
|
||||
@interface OHEvdevGameControllerAxis: OHGameControllerAxis
|
||||
{
|
||||
@public
|
||||
int32_t _minValue, _maxValue;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface HIDEvdevGameControllerMapping: HIDGameControllerMapping
|
||||
@interface OHEvdevGameControllerMapping: OHGameControllerMapping
|
||||
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
|
||||
axes: (OFDictionary *)axes OF_METHOD_FAMILY(init);
|
||||
@end
|
||||
|
@ -266,10 +266,10 @@ scale(float value, float min, float max)
|
|||
return ((value - min) / (max - min) * 2) - 1;
|
||||
}
|
||||
|
||||
@implementation HIDEvdevGameController
|
||||
@implementation OHEvdevGameController
|
||||
@synthesize name = _name, unmappedMapping = _mapping;
|
||||
|
||||
+ (OFArray OF_GENERIC(HIDGameController *) *)controllers
|
||||
+ (OFArray OF_GENERIC(OHGameController *) *)controllers
|
||||
{
|
||||
OFMutableArray *controllers = [OFMutableArray array];
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
|
@ -277,7 +277,7 @@ scale(float value, float min, float max)
|
|||
for (OFString *device in [[OFFileManager defaultManager]
|
||||
contentsOfDirectoryAtPath: @"/dev/input"]) {
|
||||
OFString *path;
|
||||
HIDGameController *controller;
|
||||
OHGameController *controller;
|
||||
|
||||
if (![device hasPrefix: @"event"])
|
||||
continue;
|
||||
|
@ -285,7 +285,7 @@ scale(float value, float min, float max)
|
|||
path = [@"/dev/input" stringByAppendingPathComponent: device];
|
||||
|
||||
@try {
|
||||
controller = [[[HIDEvdevGameController alloc]
|
||||
controller = [[[OHEvdevGameController alloc]
|
||||
of_initWithPath: path] autorelease];
|
||||
} @catch (OFOpenItemFailedException *e) {
|
||||
if (e.errNo == EACCES)
|
||||
|
@ -368,13 +368,13 @@ scale(float value, float min, float max)
|
|||
i++) {
|
||||
if (OFBitSetIsSet(_keyBits, buttonIDs[i])) {
|
||||
OFString *buttonName;
|
||||
HIDGameControllerButton *button;
|
||||
OHGameControllerButton *button;
|
||||
|
||||
buttonName = buttonToName(buttonIDs[i]);
|
||||
if (buttonName == nil)
|
||||
continue;
|
||||
|
||||
button = [[[HIDGameControllerButton alloc]
|
||||
button = [[[OHGameControllerButton alloc]
|
||||
initWithName: buttonName] autorelease];
|
||||
|
||||
[buttons setObject: button forKey: buttonName];
|
||||
|
@ -398,13 +398,13 @@ scale(float value, float min, float max)
|
|||
i < sizeof(axisIDs) / sizeof(*axisIDs); i++) {
|
||||
if (OFBitSetIsSet(_absBits, axisIDs[i])) {
|
||||
OFString *axisName;
|
||||
HIDEvdevGameControllerAxis *axis;
|
||||
OHEvdevGameControllerAxis *axis;
|
||||
|
||||
axisName = axisToName(axisIDs[i]);
|
||||
if (axisName == nil)
|
||||
continue;
|
||||
|
||||
axis = [[[HIDEvdevGameControllerAxis
|
||||
axis = [[[OHEvdevGameControllerAxis
|
||||
alloc] initWithName: axisName]
|
||||
autorelease];
|
||||
|
||||
|
@ -414,7 +414,7 @@ scale(float value, float min, float max)
|
|||
}
|
||||
[axes makeImmutable];
|
||||
|
||||
_mapping = [[HIDEvdevGameControllerMapping alloc]
|
||||
_mapping = [[OHEvdevGameControllerMapping alloc]
|
||||
of_initWithButtons: buttons
|
||||
axes: axes];
|
||||
|
||||
|
@ -470,7 +470,7 @@ scale(float value, float min, float max)
|
|||
for (size_t i = 0; i < sizeof(buttonIDs) / sizeof(*buttonIDs);
|
||||
i++) {
|
||||
OFString *name;
|
||||
HIDGameControllerButton *button;
|
||||
OHGameControllerButton *button;
|
||||
|
||||
if (!OFBitSetIsSet(_keyBits, buttonIDs[i]))
|
||||
continue;
|
||||
|
@ -494,7 +494,7 @@ scale(float value, float min, float max)
|
|||
i++) {
|
||||
struct input_absinfo info;
|
||||
OFString *name;
|
||||
HIDEvdevGameControllerAxis *axis;
|
||||
OHEvdevGameControllerAxis *axis;
|
||||
|
||||
if (!OFBitSetIsSet(_absBits, axisIDs[i]))
|
||||
continue;
|
||||
|
@ -503,7 +503,7 @@ scale(float value, float min, float max)
|
|||
if (name == nil)
|
||||
continue;
|
||||
|
||||
axis = (HIDEvdevGameControllerAxis *)
|
||||
axis = (OHEvdevGameControllerAxis *)
|
||||
[_mapping.axes objectForKey: name];
|
||||
if (axis == nil)
|
||||
continue;
|
||||
|
@ -529,8 +529,8 @@ scale(float value, float min, float max)
|
|||
|
||||
for (;;) {
|
||||
OFString *name;
|
||||
HIDGameControllerButton *button;
|
||||
HIDEvdevGameControllerAxis *axis;
|
||||
OHGameControllerButton *button;
|
||||
OHEvdevGameControllerAxis *axis;
|
||||
|
||||
errno = 0;
|
||||
|
||||
|
@ -580,7 +580,7 @@ scale(float value, float min, float max)
|
|||
if (name == nil)
|
||||
continue;
|
||||
|
||||
axis = (HIDEvdevGameControllerAxis *)
|
||||
axis = (OHEvdevGameControllerAxis *)
|
||||
[_mapping.axes objectForKey: name];
|
||||
if (axis == nil)
|
||||
continue;
|
||||
|
@ -595,11 +595,11 @@ scale(float value, float min, float max)
|
|||
objc_autoreleasePoolPop(pool);
|
||||
}
|
||||
|
||||
- (OFComparisonResult)compare: (HIDEvdevGameController *)otherController
|
||||
- (OFComparisonResult)compare: (OHEvdevGameController *)otherController
|
||||
{
|
||||
unsigned long long selfIndex, otherIndex;
|
||||
|
||||
if (![otherController isKindOfClass: [HIDEvdevGameController class]])
|
||||
if (![otherController isKindOfClass: [OHEvdevGameController class]])
|
||||
@throw [OFInvalidArgumentException exception];
|
||||
|
||||
selfIndex = [_path substringFromIndex: 16].unsignedLongLongValue;
|
||||
|
@ -615,10 +615,10 @@ scale(float value, float min, float max)
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation HIDEvdevGameControllerAxis
|
||||
@implementation OHEvdevGameControllerAxis
|
||||
@end
|
||||
|
||||
@implementation HIDEvdevGameControllerMapping
|
||||
@implementation OHEvdevGameControllerMapping
|
||||
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
|
||||
axes: (OFDictionary *)axes
|
||||
{
|
|
@ -31,19 +31,19 @@
|
|||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HIDGameControllerMapping;
|
||||
@class OFArray OF_GENERIC(ObjectType);
|
||||
@class OFNumber;
|
||||
@class OHGameControllerMapping;
|
||||
|
||||
/**
|
||||
* @class HIDGameController HIDGameController.h ObjFWHID/HIDGameController.h
|
||||
* @class OHGameController OHGameController.h ObjFWHID/OHGameController.h
|
||||
*
|
||||
* @brief A class for reading state from a game controller.
|
||||
*/
|
||||
@interface HIDGameController: OFObject
|
||||
@interface OHGameController: OFObject
|
||||
#ifdef OF_HAVE_CLASS_PROPERTIES
|
||||
@property (class, readonly, nonatomic)
|
||||
OFArray <HIDGameController *> *controllers;
|
||||
OFArray <OHGameController *> *controllers;
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -65,19 +65,19 @@ OF_ASSUME_NONNULL_BEGIN
|
|||
* @brief An unmapped mapping for the game controller, meaning no remapping is
|
||||
* being performed.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerMapping *unmappedMapping;
|
||||
@property (readonly, nonatomic) OHGameControllerMapping *unmappedMapping;
|
||||
|
||||
/**
|
||||
* @brief Returns the available controllers.
|
||||
*
|
||||
* @return The available controllers
|
||||
*/
|
||||
+ (OFArray OF_GENERIC(HIDGameController *) *)controllers;
|
||||
+ (OFArray OF_GENERIC(OHGameController *) *)controllers;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the current state from the game controller.
|
||||
*
|
||||
* The state returned by @ref HIDGameController's methods does not change until
|
||||
* The state returned by @ref OHGameController's methods does not change until
|
||||
* this method is called.
|
||||
*
|
||||
* @throw OFReadFailedException The controller's state could not be read
|
|
@ -19,22 +19,22 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameController.h"
|
||||
#import "OHGameController.h"
|
||||
#import "OFArray.h"
|
||||
#import "OFNumber.h"
|
||||
#import "OFSet.h"
|
||||
|
||||
#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
|
||||
# include "HIDEvdevGameController.h"
|
||||
# include "OHEvdevGameController.h"
|
||||
#endif
|
||||
|
||||
@implementation HIDGameController
|
||||
@implementation OHGameController
|
||||
@dynamic name, unmappedMapping;
|
||||
|
||||
+ (OFArray OF_GENERIC(HIDGameController *) *)controllers
|
||||
+ (OFArray OF_GENERIC(OHGameController *) *)controllers
|
||||
{
|
||||
#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
|
||||
return [HIDEvdevGameController controllers];
|
||||
return [OHEvdevGameController controllers];
|
||||
#else
|
||||
return [OFArray array];
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ([self isMemberOfClass: [HIDGameController class]]) {
|
||||
if ([self isMemberOfClass: [OHGameController class]]) {
|
||||
@try {
|
||||
[self doesNotRecognizeSelector: _cmd];
|
||||
} @catch (id e) {
|
||||
|
@ -85,5 +85,5 @@
|
|||
@end
|
||||
|
||||
#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
|
||||
# include "HIDEvdevGameController.m"
|
||||
# include "OHEvdevGameController.m"
|
||||
#endif
|
|
@ -17,20 +17,20 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameControllerElement.h"
|
||||
#import "OHGameControllerElement.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* @class HIDGameControllerAxis \
|
||||
* HIDGameControllerAxis.h ObjFWHID/HIDGameControllerAxis.h
|
||||
* @class OHGameControllerAxis \
|
||||
* OHGameControllerAxis.h ObjFWHID/OHGameControllerAxis.h
|
||||
*
|
||||
* @brief An axis of a game controller.
|
||||
*/
|
||||
@interface HIDGameControllerAxis: HIDGameControllerElement
|
||||
@interface OHGameControllerAxis: OHGameControllerElement
|
||||
{
|
||||
float _value;
|
||||
OF_RESERVE_IVARS(HIDGameControllerButton, 4)
|
||||
OF_RESERVE_IVARS(OHGameControllerButton, 4)
|
||||
}
|
||||
|
||||
/**
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
|
||||
@implementation HIDGameControllerAxis
|
||||
@implementation OHGameControllerAxis
|
||||
@synthesize value = _value;
|
||||
|
||||
- (OFString *)description
|
|
@ -17,20 +17,20 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameControllerElement.h"
|
||||
#import "OHGameControllerElement.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* @class HIDGameControllerButton \
|
||||
* HIDGameControllerButton.h ObjFWHID/HIDGameControllerButton.h
|
||||
* @class OHGameControllerButton \
|
||||
* OHGameControllerButton.h ObjFWHID/OHGameControllerButton.h
|
||||
*
|
||||
* @brief A button of a game controller.
|
||||
*/
|
||||
@interface HIDGameControllerButton: HIDGameControllerElement
|
||||
@interface OHGameControllerButton: OHGameControllerElement
|
||||
{
|
||||
float _value;
|
||||
OF_RESERVE_IVARS(HIDGameControllerButton, 4)
|
||||
OF_RESERVE_IVARS(OHGameControllerButton, 4)
|
||||
}
|
||||
|
||||
/**
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
|
||||
@implementation HIDGameControllerButton
|
||||
@implementation OHGameControllerButton
|
||||
@synthesize value = _value;
|
||||
|
||||
- (bool)isPressed
|
|
@ -17,68 +17,68 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameControllerElement.h"
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "OHGameControllerElement.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* @class HIDGameControllerDirectionalPad \
|
||||
* HIDGameControllerDirectionalPad.h \
|
||||
* ObjFWHID/HIDGameControllerDirectionalPad.h
|
||||
* @class OHGameControllerDirectionalPad \
|
||||
* OHGameControllerDirectionalPad.h
|
||||
* ObjFWHID/OHGameControllerDirectionalPad.h
|
||||
*
|
||||
* @brief An directional pad or thumb stick of a game controller.
|
||||
*/
|
||||
OF_SUBCLASSING_RESTRICTED
|
||||
@interface HIDGameControllerDirectionalPad: HIDGameControllerElement
|
||||
@interface OHGameControllerDirectionalPad: OHGameControllerElement
|
||||
{
|
||||
HIDGameControllerAxis *_xAxis, *_yAxis;
|
||||
HIDGameControllerButton *_upButton, *_downButton;
|
||||
HIDGameControllerButton *_leftButton, *_rightButton;
|
||||
OHGameControllerAxis *_xAxis, *_yAxis;
|
||||
OHGameControllerButton *_upButton, *_downButton;
|
||||
OHGameControllerButton *_leftButton, *_rightButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The X axis of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerAxis *xAxis;
|
||||
@property (readonly, nonatomic) OHGameControllerAxis *xAxis;
|
||||
|
||||
/**
|
||||
* @brief The Y axis of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerAxis *yAxis;
|
||||
@property (readonly, nonatomic) OHGameControllerAxis *yAxis;
|
||||
|
||||
/**
|
||||
* @brief The up button of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerButton *upButton;
|
||||
@property (readonly, nonatomic) OHGameControllerButton *upButton;
|
||||
|
||||
/**
|
||||
* @brief The down button of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerButton *downButton;
|
||||
@property (readonly, nonatomic) OHGameControllerButton *downButton;
|
||||
|
||||
/**
|
||||
* @brief The left button of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerButton *leftButton;
|
||||
@property (readonly, nonatomic) OHGameControllerButton *leftButton;
|
||||
|
||||
/**
|
||||
* @brief The right button of the directional pad.
|
||||
*/
|
||||
@property (readonly, nonatomic) HIDGameControllerButton *rightButton;
|
||||
@property (readonly, nonatomic) OHGameControllerButton *rightButton;
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
xAxis: (HIDGameControllerAxis *)xAxis
|
||||
yAxis: (HIDGameControllerAxis *)yAxis;
|
||||
xAxis: (OHGameControllerAxis *)xAxis
|
||||
yAxis: (OHGameControllerAxis *)yAxis;
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
upButton: (HIDGameControllerButton *)upButton
|
||||
downButton: (HIDGameControllerButton *)downButton
|
||||
leftButton: (HIDGameControllerButton *)leftButton
|
||||
rightButton: (HIDGameControllerButton *)rightButton;
|
||||
upButton: (OHGameControllerButton *)upButton
|
||||
downButton: (OHGameControllerButton *)downButton
|
||||
leftButton: (OHGameControllerButton *)leftButton
|
||||
rightButton: (OHGameControllerButton *)rightButton;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerDirectionalPad.h"
|
||||
#import "HIDGameControllerEmulatedAxis.h"
|
||||
#import "HIDGameControllerEmulatedButton.h"
|
||||
#import "OHGameControllerDirectionalPad.h"
|
||||
#import "OHGameControllerEmulatedAxis.h"
|
||||
#import "OHGameControllerEmulatedButton.h"
|
||||
|
||||
@implementation HIDGameControllerDirectionalPad
|
||||
@implementation OHGameControllerDirectionalPad
|
||||
@synthesize xAxis = _xAxis, yAxis = _yAxis;
|
||||
@synthesize upButton = _upButton, downButton = _downButton;
|
||||
@synthesize leftButton = _leftButton, rightButton = _rightButton;
|
||||
|
@ -34,8 +34,8 @@
|
|||
}
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
xAxis: (HIDGameControllerAxis *)xAxis
|
||||
yAxis: (HIDGameControllerAxis *)yAxis
|
||||
xAxis: (OHGameControllerAxis *)xAxis
|
||||
yAxis: (OHGameControllerAxis *)yAxis
|
||||
{
|
||||
self = [super initWithName: name];
|
||||
|
||||
|
@ -43,16 +43,16 @@
|
|||
_xAxis = [xAxis retain];
|
||||
_yAxis = [yAxis retain];
|
||||
|
||||
_upButton = [[HIDGameControllerEmulatedButton alloc]
|
||||
_upButton = [[OHGameControllerEmulatedButton alloc]
|
||||
initWithAxis: _yAxis
|
||||
positive: false];
|
||||
_downButton = [[HIDGameControllerEmulatedButton alloc]
|
||||
_downButton = [[OHGameControllerEmulatedButton alloc]
|
||||
initWithAxis: _yAxis
|
||||
positive: true];
|
||||
_leftButton = [[HIDGameControllerEmulatedButton alloc]
|
||||
_leftButton = [[OHGameControllerEmulatedButton alloc]
|
||||
initWithAxis: _xAxis
|
||||
positive: false];
|
||||
_rightButton = [[HIDGameControllerEmulatedButton alloc]
|
||||
_rightButton = [[OHGameControllerEmulatedButton alloc]
|
||||
initWithAxis: _xAxis
|
||||
positive: true];
|
||||
} @catch (id e) {
|
||||
|
@ -64,10 +64,10 @@
|
|||
}
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
upButton: (HIDGameControllerButton *)upButton
|
||||
downButton: (HIDGameControllerButton *)downButton
|
||||
leftButton: (HIDGameControllerButton *)leftButton
|
||||
rightButton: (HIDGameControllerButton *)rightButton
|
||||
upButton: (OHGameControllerButton *)upButton
|
||||
downButton: (OHGameControllerButton *)downButton
|
||||
leftButton: (OHGameControllerButton *)leftButton
|
||||
rightButton: (OHGameControllerButton *)rightButton
|
||||
{
|
||||
self = [super initWithName: name];
|
||||
|
||||
|
@ -77,10 +77,10 @@
|
|||
_leftButton = [leftButton retain];
|
||||
_rightButton = [rightButton retain];
|
||||
|
||||
_xAxis = [[HIDGameControllerEmulatedAxis alloc]
|
||||
_xAxis = [[OHGameControllerEmulatedAxis alloc]
|
||||
initWithNegativeButton: _leftButton
|
||||
positiveButton: _rightButton];
|
||||
_yAxis = [[HIDGameControllerEmulatedAxis alloc]
|
||||
_yAxis = [[OHGameControllerEmulatedAxis alloc]
|
||||
initWithNegativeButton: _upButton
|
||||
positiveButton: _downButton];
|
||||
} @catch (id e) {
|
|
@ -32,17 +32,17 @@
|
|||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* @class HIDGameControllerElement \
|
||||
* HIDGameControllerElement.h ObjFWHID/HIDGameControllerElement.h
|
||||
* @class OHGameControllerElement \
|
||||
* OHGameControllerElement.h ObjFWHID/OHGameControllerElement.h
|
||||
*
|
||||
* @brief An element of a game controller, e.g. a button, an axis or a
|
||||
* directional pad.
|
||||
*/
|
||||
@interface HIDGameControllerElement: OFObject
|
||||
@interface OHGameControllerElement: OFObject
|
||||
{
|
||||
OFString *_name;
|
||||
bool _analog;
|
||||
OF_RESERVE_IVARS(HIDGameControllerElement, 4)
|
||||
OF_RESERVE_IVARS(OHGameControllerElement, 4)
|
||||
}
|
||||
|
||||
/**
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerElement.h"
|
||||
#import "OHGameControllerElement.h"
|
||||
|
||||
@implementation HIDGameControllerElement
|
||||
@implementation OHGameControllerElement
|
||||
@synthesize name = _name, analog = _analog;
|
||||
|
||||
- (instancetype)init
|
|
@ -17,22 +17,22 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HIDGameControllerButton;
|
||||
@class OHGameControllerButton;
|
||||
|
||||
OF_SUBCLASSING_RESTRICTED
|
||||
@interface HIDGameControllerEmulatedAxis: HIDGameControllerAxis
|
||||
@interface OHGameControllerEmulatedAxis: OHGameControllerAxis
|
||||
{
|
||||
HIDGameControllerButton *_negativeButton, *_positiveButton;
|
||||
OHGameControllerButton *_negativeButton, *_positiveButton;
|
||||
}
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)
|
||||
initWithNegativeButton: (HIDGameControllerButton *)negativeButton
|
||||
positiveButton: (HIDGameControllerButton *)positiveButton;
|
||||
initWithNegativeButton: (OHGameControllerButton *)negativeButton
|
||||
positiveButton: (OHGameControllerButton *)positiveButton;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
|
@ -19,21 +19,20 @@
|
|||
|
||||
#import "config.h"
|
||||
|
||||
#import "HIDGameControllerEmulatedAxis.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "OHGameControllerEmulatedAxis.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
|
||||
@implementation HIDGameControllerEmulatedAxis
|
||||
@implementation OHGameControllerEmulatedAxis
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- (instancetype)
|
||||
initWithNegativeButton: (HIDGameControllerButton *)negativeButton
|
||||
positiveButton: (HIDGameControllerButton *)positiveButton
|
||||
- (instancetype)initWithNegativeButton: (OHGameControllerButton *)negativeButton
|
||||
positiveButton: (OHGameControllerButton *)positiveButton
|
||||
{
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
OFString *name;;
|
||||
OFString *name;
|
||||
|
||||
@try {
|
||||
name = [OFString stringWithFormat:
|
|
@ -17,21 +17,21 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HIDGameControllerAxis;
|
||||
@class OHGameControllerAxis;
|
||||
|
||||
OF_SUBCLASSING_RESTRICTED
|
||||
@interface HIDGameControllerEmulatedButton: HIDGameControllerButton
|
||||
@interface OHGameControllerEmulatedButton: OHGameControllerButton
|
||||
{
|
||||
HIDGameControllerAxis *_axis;
|
||||
OHGameControllerAxis *_axis;
|
||||
bool _positive;
|
||||
}
|
||||
|
||||
- (instancetype)initWithName: (OFString *)name OF_UNAVAILABLE;
|
||||
- (instancetype)initWithAxis: (HIDGameControllerAxis *)axis
|
||||
- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
|
||||
positive: (bool)positive;
|
||||
@end
|
||||
|
|
@ -19,16 +19,16 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerEmulatedButton.h"
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "OHGameControllerEmulatedButton.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
|
||||
@implementation HIDGameControllerEmulatedButton: HIDGameControllerButton
|
||||
@implementation OHGameControllerEmulatedButton: OHGameControllerButton
|
||||
- (instancetype)initWithName: (OFString *)name
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- (instancetype)initWithAxis: (HIDGameControllerAxis *)axis
|
||||
- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
|
||||
positive: (bool)positive
|
||||
{
|
||||
void *pool = objc_autoreleasePoolPush();
|
|
@ -31,45 +31,44 @@
|
|||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HIDGameControllerAxis;
|
||||
@class HIDGameControllerButton;
|
||||
@class HIDGameControllerDirectionalPad;
|
||||
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
|
||||
@class OHGameControllerAxis;
|
||||
@class OHGameControllerButton;
|
||||
@class OHGameControllerDirectionalPad;
|
||||
|
||||
/**
|
||||
* @class HIDGameControllerMapping \
|
||||
* HIDGameControllerMapping.h ObjFWHID/HIDGameControllerMapping.h
|
||||
* @class OHGameControllerMapping \
|
||||
* OHGameControllerMapping.h ObjFWHID/OHGameControllerMapping.h
|
||||
*
|
||||
* @brief A mapping for a @ref HIDGameController.
|
||||
* @brief A mapping for a @ref OHGameController.
|
||||
*/
|
||||
@interface HIDGameControllerMapping: OFObject
|
||||
@interface OHGameControllerMapping: OFObject
|
||||
{
|
||||
OFDictionary OF_GENERIC(OFString *, HIDGameControllerButton *)
|
||||
*_buttons;
|
||||
OFDictionary OF_GENERIC(OFString *, HIDGameControllerAxis *) *_axes;
|
||||
OFDictionary OF_GENERIC(OFString *, HIDGameControllerDirectionalPad *)
|
||||
OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons;
|
||||
OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *_axes;
|
||||
OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *)
|
||||
*_directionalPads;
|
||||
OF_RESERVE_IVARS(HIDGameControllerMapping, 4)
|
||||
OF_RESERVE_IVARS(OHGameControllerMapping, 4)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A map of all button names to their @ref HIDGameControllerButton.
|
||||
* @brief A map of all button names to their @ref OHGameControllerButton.
|
||||
*/
|
||||
@property (readonly, nonatomic)
|
||||
OFDictionary OF_GENERIC(OFString *, HIDGameControllerButton *) *buttons;
|
||||
OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *buttons;
|
||||
|
||||
/**
|
||||
* @brief A map of all axis names to their @ref HIDGameControllerAxis.
|
||||
* @brief A map of all axis names to their @ref OHGameControllerAxis.
|
||||
*/
|
||||
@property (readonly, nonatomic)
|
||||
OFDictionary OF_GENERIC(OFString *, HIDGameControllerAxis *) *axes;
|
||||
OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *axes;
|
||||
|
||||
/**
|
||||
* @brief A map of all directional pads to their
|
||||
* @ref HIDGameControllerDirectionalPad.
|
||||
* @ref OHGameControllerDirectionalPad.
|
||||
*/
|
||||
@property (readonly, nonatomic) OFDictionary OF_GENERIC(OFString *,
|
||||
HIDGameControllerDirectionalPad *) *directionalPads;
|
||||
OHGameControllerDirectionalPad *) *directionalPads;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import "HIDGameControllerMapping.h"
|
||||
#import "OHGameControllerMapping.h"
|
||||
#import "OFDictionary.h"
|
||||
|
||||
@implementation HIDGameControllerMapping: OFObject
|
||||
@implementation OHGameControllerMapping: OFObject
|
||||
@synthesize buttons = _buttons, axes = _axes;
|
||||
@synthesize directionalPads = _directionalPads;
|
||||
|
|
@ -17,8 +17,8 @@
|
|||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "HIDGameController.h"
|
||||
#import "HIDGameControllerElement.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "HIDGameControllerDirectionalPad.h"
|
||||
#import "OHGameController.h"
|
||||
#import "OHGameControllerElement.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
#import "OHGameControllerDirectionalPad.h"
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
|
||||
#import "OTTestCase.h"
|
||||
|
||||
#import "HIDGameController.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "HIDGameControllerMapping.h"
|
||||
#import "OHGameController.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
#import "OHGameControllerMapping.h"
|
||||
|
||||
#import "OTAssertionFailedException.h"
|
||||
#import "OTTestSkippedException.h"
|
||||
|
@ -285,9 +285,9 @@ isSubclassOfClass(Class class, Class superclass)
|
|||
|
||||
for (;;) {
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
HIDGameController *controller =
|
||||
[[HIDGameController controllers] objectAtIndex: 0];
|
||||
HIDGameControllerButton *button =
|
||||
OHGameController *controller =
|
||||
[[OHGameController controllers] objectAtIndex: 0];
|
||||
OHGameControllerButton *button =
|
||||
[controller.unmappedMapping.buttons
|
||||
objectForKey: @"A"];
|
||||
|
||||
|
@ -549,9 +549,9 @@ isSubclassOfClass(Class class, Class superclass)
|
|||
|
||||
for (;;) {
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
HIDGameController *controller =
|
||||
[[HIDGameController controllers] objectAtIndex: 0];
|
||||
HIDGameControllerButton *button =
|
||||
OHGameController *controller =
|
||||
[[OHGameController controllers] objectAtIndex: 0];
|
||||
OHGameControllerButton *button =
|
||||
# ifdef OF_WII
|
||||
[controller.unmappedMapping.buttons objectForKey: @"Home"];
|
||||
# else
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
#import "OFStdIOStream.h"
|
||||
#import "OFThread.h"
|
||||
|
||||
#import "HIDGameController.h"
|
||||
#import "HIDGameControllerAxis.h"
|
||||
#import "HIDGameControllerButton.h"
|
||||
#import "HIDGameControllerMapping.h"
|
||||
#import "OHGameController.h"
|
||||
#import "OHGameControllerAxis.h"
|
||||
#import "OHGameControllerButton.h"
|
||||
#import "OHGameControllerMapping.h"
|
||||
|
||||
#import "OFReadFailedException.h"
|
||||
|
||||
|
@ -51,7 +51,7 @@ static size_t buttonsPerLine = 5;
|
|||
|
||||
@interface GameControllerTests: OFObject <OFApplicationDelegate>
|
||||
{
|
||||
OFMutableArray OF_GENERIC(HIDGameController *) *_controllers;
|
||||
OFMutableArray OF_GENERIC(OHGameController *) *_controllers;
|
||||
OFDate *_lastControllersUpdate;
|
||||
}
|
||||
@end
|
||||
|
@ -73,7 +73,7 @@ OF_APPLICATION_DELEGATE(GameControllerTests)
|
|||
[_controllers release];
|
||||
[_lastControllersUpdate release];
|
||||
|
||||
_controllers = [[HIDGameController controllers]
|
||||
_controllers = [[OHGameController controllers]
|
||||
mutableCopy];
|
||||
_lastControllersUpdate = [[OFDate alloc] init];
|
||||
|
||||
|
@ -82,8 +82,8 @@ OF_APPLICATION_DELEGATE(GameControllerTests)
|
|||
|
||||
[OFStdOut setCursorPosition: OFMakePoint(0, 0)];
|
||||
|
||||
for (HIDGameController *controller in _controllers) {
|
||||
HIDGameControllerMapping *mapping =
|
||||
for (OHGameController *controller in _controllers) {
|
||||
OHGameControllerMapping *mapping =
|
||||
controller.unmappedMapping;
|
||||
OFArray OF_GENERIC(OFString *) *buttons =
|
||||
mapping.buttons.allKeys.sortedArray;
|
||||
|
@ -104,7 +104,7 @@ OF_APPLICATION_DELEGATE(GameControllerTests)
|
|||
|
||||
i = 0;
|
||||
for (OFString *name in buttons) {
|
||||
HIDGameControllerButton *button =
|
||||
OHGameControllerButton *button =
|
||||
[mapping.buttons objectForKey: name];
|
||||
|
||||
if (i == 0)
|
||||
|
@ -135,7 +135,7 @@ OF_APPLICATION_DELEGATE(GameControllerTests)
|
|||
|
||||
i = 0;
|
||||
for (OFString *name in axes) {
|
||||
HIDGameControllerAxis *axis =
|
||||
OHGameControllerAxis *axis =
|
||||
[mapping.axes objectForKey: name];
|
||||
|
||||
if (i == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue