2009-08-28 23:08:52 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-08-11 02:45:28 +04:00
|
|
|
#ifndef _JOYSTICK_H
|
|
|
|
#define _JOYSTICK_H
|
|
|
|
|
2009-10-11 20:40:12 +04:00
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
#include <OS.h>
|
2009-08-28 23:08:52 +04:00
|
|
|
#include <SupportDefs.h>
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-09-13 05:30:38 +04:00
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
class BList;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BString;
|
2009-08-28 23:08:52 +04:00
|
|
|
class _BJoystickTweaker;
|
2007-10-16 00:13:55 +04:00
|
|
|
struct entry_ref;
|
2002-08-11 02:45:28 +04:00
|
|
|
struct _extended_joystick;
|
2008-10-23 12:18:48 +04:00
|
|
|
struct _joystick_info;
|
2008-08-03 22:20:05 +04:00
|
|
|
|
2009-10-11 20:40:12 +04:00
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
class BJoystick {
|
|
|
|
public:
|
2009-08-28 23:08:52 +04:00
|
|
|
BJoystick();
|
|
|
|
virtual ~BJoystick();
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
status_t Open(const char* portName);
|
|
|
|
status_t Open(const char* portName, bool enhanced);
|
|
|
|
void Close();
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
status_t Update();
|
|
|
|
status_t SetMaxLatency(bigtime_t maxLatency);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
bigtime_t timestamp;
|
|
|
|
int16 horizontal;
|
|
|
|
int16 vertical;
|
2009-10-11 20:40:12 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
bool button1;
|
|
|
|
bool button2;
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
int32 CountDevices();
|
|
|
|
status_t GetDeviceName(int32 index, char* name,
|
|
|
|
size_t bufSize = B_OS_NAME_LENGTH);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
bool EnterEnhancedMode(const entry_ref* ref = NULL);
|
2008-08-23 15:16:31 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
int32 CountSticks();
|
2008-08-23 15:16:31 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
status_t GetControllerModule(BString* outName);
|
|
|
|
status_t GetControllerName(BString* outName);
|
2008-08-23 15:16:31 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
bool IsCalibrationEnabled();
|
|
|
|
status_t EnableCalibration(bool calibrates = true);
|
2008-08-23 15:16:31 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
int32 CountAxes();
|
|
|
|
status_t GetAxisValues(int16* outValues,
|
|
|
|
int32 forStick = 0);
|
|
|
|
status_t GetAxisNameAt(int32 index,
|
|
|
|
BString* outName);
|
2009-10-11 20:40:12 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
int32 CountHats();
|
|
|
|
status_t GetHatValues(uint8* outHats,
|
|
|
|
int32 forStick = 0);
|
|
|
|
status_t GetHatNameAt(int32 index, BString* outName);
|
2009-10-11 20:40:12 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
int32 CountButtons();
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
uint32 ButtonValues(int32 forStick = 0);
|
|
|
|
status_t GetButtonNameAt(int32 index,
|
|
|
|
BString* outName);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
protected:
|
|
|
|
virtual void Calibrate(struct _extended_joystick*);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class _BJoystickTweaker;
|
2008-08-03 22:20:05 +04:00
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
void ScanDevices(bool useDisabled = false);
|
|
|
|
status_t GatherEnhanced_info(const entry_ref* ref = NULL);
|
|
|
|
status_t SaveConfig(const entry_ref* ref = NULL);
|
|
|
|
|
2009-10-11 20:40:12 +04:00
|
|
|
void _ReservedJoystick1();
|
|
|
|
virtual void _ReservedJoystick2();
|
|
|
|
virtual void _ReservedJoystick3();
|
|
|
|
virtual status_t _Reserved_Joystick_4(void *, ...);
|
|
|
|
virtual status_t _Reserved_Joystick_5(void *, ...);
|
|
|
|
virtual status_t _Reserved_Joystick_6(void *, ...);
|
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
bool fBeBoxMode;
|
|
|
|
bool fReservedBool;
|
|
|
|
int ffd;
|
|
|
|
BList* fDevices;
|
|
|
|
_joystick_info* fJoystickInfo;
|
|
|
|
char* fDevName;
|
2009-10-11 20:40:12 +04:00
|
|
|
uint32 _reserved_Joystick_[10];
|
2002-08-11 02:45:28 +04:00
|
|
|
};
|
|
|
|
|
2009-08-28 23:08:52 +04:00
|
|
|
#endif // _JOYSTICK_H
|