Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / os / device / Joystick.h
bloba554a2cf6a0d0be6cf4658d874d07270e520cc3a
1 /*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _JOYSTICK_H
6 #define _JOYSTICK_H
9 #include <OS.h>
10 #include <SupportDefs.h>
13 class BList;
14 class BString;
15 class _BJoystickTweaker;
16 struct entry_ref;
17 struct _extended_joystick;
18 struct _joystick_info;
21 class BJoystick {
22 public:
23 BJoystick();
24 virtual ~BJoystick();
26 status_t Open(const char* portName);
27 status_t Open(const char* portName, bool enhanced);
28 void Close();
30 status_t Update();
31 status_t SetMaxLatency(bigtime_t maxLatency);
33 bigtime_t timestamp;
34 int16 horizontal;
35 int16 vertical;
37 bool button1;
38 bool button2;
40 int32 CountDevices();
41 status_t GetDeviceName(int32 index, char* name,
42 size_t bufSize = B_OS_NAME_LENGTH);
44 status_t RescanDevices();
45 // Haiku extension. Updates the list of devices
46 // as enumerated by CountDevices() and
47 // GetDeviceName() with possibly newly plugged
48 // in devices.
50 bool EnterEnhancedMode(const entry_ref* ref = NULL);
52 int32 CountSticks();
54 int32 CountAxes();
55 status_t GetAxisValues(int16* outValues,
56 int32 forStick = 0);
57 status_t GetAxisNameAt(int32 index,
58 BString* outName);
60 int32 CountHats();
61 status_t GetHatValues(uint8* outHats,
62 int32 forStick = 0);
63 status_t GetHatNameAt(int32 index, BString* outName);
65 int32 CountButtons();
66 uint32 ButtonValues(int32 forStick = 0);
67 // Allows access to the first 32 buttons where
68 // each set bit indicates a pressed button.
69 status_t GetButtonValues(bool* outButtons,
70 int32 forStick = 0);
71 // Haiku extension. Allows to retrieve the state
72 // of an arbitrary count of buttons. The
73 // outButtons argument is an array of boolean
74 // values with at least CountButtons() elements.
75 // True means the button is pressed and false
76 // means it is released.
77 status_t GetButtonNameAt(int32 index,
78 BString* outName);
80 status_t GetControllerModule(BString* outName);
81 status_t GetControllerName(BString* outName);
83 bool IsCalibrationEnabled();
84 status_t EnableCalibration(bool calibrates = true);
86 protected:
87 virtual void Calibrate(struct _extended_joystick*);
89 private:
90 friend class _BJoystickTweaker;
92 void ScanDevices(bool useDisabled = false);
94 void _ReservedJoystick1();
95 virtual void _ReservedJoystick2();
96 virtual void _ReservedJoystick3();
97 virtual status_t _Reserved_Joystick_4(void *, ...);
98 virtual status_t _Reserved_Joystick_5(void *, ...);
99 virtual status_t _Reserved_Joystick_6(void *, ...);
101 bool fBeBoxMode;
102 bool fReservedBool;
103 int fFD;
104 BList* fDevices;
105 _joystick_info* fJoystickInfo;
106 BList* fJoystickData;
108 uint32 _reserved_Joystick_[10];
111 #endif // _JOYSTICK_H