ObjFW
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 
23 OF_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)initWithPath: (OFString *)path;
42 - (void)oh_pollState;
43 @end
44 
45 extern const uint16_t OHEvdevButtonIDs[];
46 extern const size_t OHNumEvdevButtonIDs;
47 extern const uint16_t OHEvdevAxisIDs[];
48 extern const size_t OHNumEvdevAxisIDs;
49 
50 OF_ASSUME_NONNULL_END
A button of a game controller.
Definition: OHGameControllerButton.h:29
A class for reading state from a game controller.
Definition: OHGameController.h:46
The root class for all other classes inside ObjFW.
Definition: OFObject.h:690
An axis of a game controller.
Definition: OHGameControllerAxis.h:29
A class for handling strings.
Definition: OFString.h:142