ObjFW
Loading...
Searching...
No Matches
OHEvdevGameController.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#import "OHGameController.h"
21#import "OHGameControllerProfile.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
25@protocol OHEvdevMapping <OFObject>
26- (OHGameControllerButton *)oh_buttonForEvdevButton: (uint16_t)button;
27- (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis;
28@end
29
30@interface OHEvdevGameController: OHGameController
31{
32 OFString *_path;
33 int _fd;
34 bool _discardUntilReport;
35 unsigned long *_evBits, *_keyBits, *_absBits;
36 uint16_t _vendorID, _productID;
37 OFString *_name;
38 id <OHGameControllerProfile, OHEvdevMapping> _profile;
39}
40
41- (instancetype)oh_init OF_UNAVAILABLE;
42- (instancetype)oh_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
43- (void)oh_pollState;
44@end
45
46extern const uint16_t OHEvdevButtonIDs[];
47extern const size_t OHNumEvdevButtonIDs;
48extern const uint16_t OHEvdevAxisIDs[];
49extern const size_t OHNumEvdevAxisIDs;
50
51OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for handling strings.
Definition OFString.h:143
An axis of a game controller.
Definition OHGameControllerAxis.h:30
A button of a game controller.
Definition OHGameControllerButton.h:30
A class for reading state from a game controller.
Definition OHGameController.h:47