ObjFW
Loading...
Searching...
No Matches
OHGameController.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#ifdef OBJFWHID_LOCAL_INCLUDES
21# import "OFObject.h"
22# import "OFString.h"
23#else
24# if defined(__has_feature) && __has_feature(modules)
25@import ObjFW;
26# else
27# import <ObjFW/OFObject.h>
28# import <ObjFW/OFString.h>
29# endif
30#endif
31
32#import "OHGamepad.h"
33#import "OHExtendedGamepad.h"
34
35OF_ASSUME_NONNULL_BEGIN
36
37@class OFArray OF_GENERIC(ObjectType);
38@class OFNumber;
39@class OHGameControllerProfile;
40
47{
48 OF_RESERVE_IVARS(OHGameController, 4)
49}
50
51#ifdef OF_HAVE_CLASS_PROPERTIES
52@property (class, readonly, nonatomic)
53 OFArray <OHGameController *> *controllers;
54#endif
55
59@property (readonly, nonatomic, copy) OFString *name;
60
64@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *vendorID;
65
69@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *productID;
70
74@property (readonly, nonatomic) id <OHGameControllerProfile> profile;
75
80@property OF_NULLABLE_PROPERTY (readonly, nonatomic) id <OHGamepad> gamepad;
81
86@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
87 id <OHExtendedGamepad> extendedGamepad;
88
94+ (OFArray OF_GENERIC(OHGameController *) *)controllers;
95
96- (instancetype)init OF_UNAVAILABLE;
97
106- (void)updateState;
107@end
108
109#ifdef __cplusplus
110extern "C" {
111#endif
112extern const uint16_t OHVendorIDSony;
113extern const uint16_t OHVendorIDNintendo;
114extern const uint16_t OHVendorIDGoogle;
115extern const uint16_t OHProductIDDualShock4;
116extern const uint16_t OHProductIDDualSense;
117extern const uint16_t OHProductIDLeftJoyCon;
118extern const uint16_t OHProductIDRightJoyCon;
119extern const uint16_t OHProductIDN64Controller;
120extern const uint16_t OHProductIDStadiaController;
121#ifdef __cplusplus
122}
123#endif
124
125OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:109
Provides a way to store a number in an object.
Definition OFNumber.h:47
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for handling strings.
Definition OFString.h:143
A class for reading state from a game controller.
Definition OHGameController.h:47
OFNumber * productID
The product ID of the controller or nil if unavailable.
Definition OHGameController.h:69
OFNumber * vendorID
The vendor ID of the controller or nil if unavailable.
Definition OHGameController.h:64
id< OHGamepad > gamepad
The gamepad profile for the game controller, or nil if not supported.
Definition OHGameController.h:80