2002-08-11 02:45:28 +04:00
|
|
|
/********************************************************************************
|
|
|
|
/
|
|
|
|
/ File: Joystick.h
|
|
|
|
/
|
|
|
|
/ Description: Joystick port class header.
|
|
|
|
/
|
|
|
|
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
|
|
|
|
/
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _JOYSTICK_H
|
|
|
|
#define _JOYSTICK_H
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
class BList;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BString;
|
|
|
|
struct entry_ref;
|
2002-08-11 02:45:28 +04:00
|
|
|
struct _extended_joystick;
|
2007-10-16 00:13:55 +04:00
|
|
|
class _BJoystickTweaker;
|
2002-08-11 02:45:28 +04:00
|
|
|
|
2008-08-03 22:20:05 +04:00
|
|
|
typedef struct _joystick_info {
|
|
|
|
char module_name[64];
|
|
|
|
char controller_name[64];
|
|
|
|
int16 num_axes;
|
|
|
|
int16 num_buttons;
|
|
|
|
int16 num_hats;
|
|
|
|
uint32 num_sticks;
|
|
|
|
bool calibration_enable;
|
|
|
|
bigtime_t max_latency;
|
2008-08-23 15:16:31 +04:00
|
|
|
BList name_axis;
|
|
|
|
BList name_hat;
|
|
|
|
BList name_button;
|
|
|
|
// BList name_
|
2008-08-03 22:20:05 +04:00
|
|
|
} joystick_info;
|
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
/* -----------------------------------------------------------------------*/
|
|
|
|
class BJoystick {
|
|
|
|
public:
|
|
|
|
BJoystick();
|
|
|
|
virtual ~BJoystick();
|
|
|
|
|
2008-08-23 15:16:31 +04:00
|
|
|
status_t Open(const char *portName);
|
|
|
|
status_t Open(const char *portName, bool enter_enhanced = true);
|
2002-08-11 02:45:28 +04:00
|
|
|
void Close(void);
|
|
|
|
|
|
|
|
status_t Update(void);
|
2008-08-23 15:16:31 +04:00
|
|
|
status_t SetMaxLatency(bigtime_t max_latency);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
|
|
|
bigtime_t timestamp;
|
|
|
|
int16 horizontal;
|
|
|
|
int16 vertical;
|
2008-08-23 15:16:31 +04:00
|
|
|
|
|
|
|
/* NOTE: true == off */
|
|
|
|
bool button1;
|
2002-08-11 02:45:28 +04:00
|
|
|
bool button2;
|
|
|
|
|
|
|
|
int32 CountDevices();
|
2008-08-11 20:45:26 +04:00
|
|
|
status_t GetDeviceName(int32 n, char * name,
|
2002-08-11 02:45:28 +04:00
|
|
|
size_t bufSize = B_OS_NAME_LENGTH);
|
|
|
|
|
2008-08-23 15:16:31 +04:00
|
|
|
bool EnterEnhancedMode(const entry_ref * ref = NULL);
|
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
int32 CountSticks();
|
2008-08-23 15:16:31 +04:00
|
|
|
|
|
|
|
status_t GetControllerModule(BString * out_name);
|
|
|
|
status_t GetControllerName(BString * out_name);
|
|
|
|
|
|
|
|
bool IsCalibrationEnabled();
|
|
|
|
status_t EnableCalibration(bool calibrates = true);
|
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
int32 CountAxes();
|
2008-08-23 15:16:31 +04:00
|
|
|
status_t GetAxisValues(int16 * out_values, int32 for_stick = 0);
|
|
|
|
status_t GetAxisNameAt(int32 index, BString * out_name);
|
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
int32 CountHats();
|
2008-08-23 15:16:31 +04:00
|
|
|
status_t GetHatValues(uint8 * out_hats, int32 for_stick = 0);
|
|
|
|
status_t GetHatNameAt(int32 index, BString * out_name);
|
|
|
|
|
2002-08-11 02:45:28 +04:00
|
|
|
int32 CountButtons();
|
2008-08-23 15:16:31 +04:00
|
|
|
/* NOTE: Buttons() are 1 == on */
|
|
|
|
uint32 ButtonValues(int32 for_stick = 0);
|
|
|
|
status_t GetButtonNameAt(int32 index, BString * out_name);
|
2002-08-11 02:45:28 +04:00
|
|
|
/* -----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2008-08-23 15:16:31 +04:00
|
|
|
virtual void Calibrate(struct _extended_joystick * reading);
|
2002-08-11 02:45:28 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class _BJoystickTweaker;
|
2008-08-03 22:20:05 +04:00
|
|
|
|
2008-08-23 15:16:31 +04:00
|
|
|
void ScanDevices(bool use_disabled = false);
|
|
|
|
status_t GatherEnhanced_info(const entry_ref * ref = NULL);
|
|
|
|
status_t SaveConfig(const entry_ref * ref = NULL);
|
|
|
|
|
|
|
|
bool fBeBoxMode;
|
|
|
|
bool fReservedBool;
|
|
|
|
int ffd;
|
|
|
|
BList* fDevices;
|
|
|
|
_joystick_info* fJoystickInfo;
|
|
|
|
char* fDevName;
|
2008-08-11 20:45:26 +04:00
|
|
|
#if DEBUG
|
2008-08-03 22:20:05 +04:00
|
|
|
public:
|
|
|
|
static FILE *sLogFile;
|
|
|
|
#endif
|
2002-08-11 02:45:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|