Rewrote Joystick.h and DigitalPort.h
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32791 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,54 +1,43 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: DigitalPort.h
|
||||
/
|
||||
/ Description: Digital Port class header.
|
||||
/
|
||||
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
|
||||
/
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DIGITAL_PORT_H
|
||||
#define _DIGITAL_PORT_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <stddef.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------*/
|
||||
class BDigitalPort {
|
||||
|
||||
public:
|
||||
BDigitalPort();
|
||||
virtual ~BDigitalPort();
|
||||
BDigitalPort();
|
||||
virtual ~BDigitalPort();
|
||||
|
||||
status_t Open(const char *portName);
|
||||
void Close(void);
|
||||
bool IsOpen(void);
|
||||
status_t Open(const char* portName);
|
||||
void Close();
|
||||
bool IsOpen();
|
||||
|
||||
ssize_t Read(uint8 *buf);
|
||||
ssize_t Write(uint8 value);
|
||||
ssize_t Read(uint8* buf);
|
||||
ssize_t Write(uint8 value);
|
||||
|
||||
status_t SetAsOutput (void);
|
||||
bool IsOutput (void);
|
||||
status_t SetAsOutput();
|
||||
bool IsOutput();
|
||||
|
||||
status_t SetAsInput (void);
|
||||
bool IsInput (void);
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------*/
|
||||
status_t SetAsInput();
|
||||
bool IsInput();
|
||||
|
||||
private:
|
||||
virtual void _ReservedDigitalPort1();
|
||||
virtual void _ReservedDigitalPort2();
|
||||
virtual void _ReservedDigitalPort3();
|
||||
|
||||
virtual void _ReservedDigitalPort1();
|
||||
virtual void _ReservedDigitalPort2();
|
||||
virtual void _ReservedDigitalPort3();
|
||||
|
||||
int ffd;
|
||||
bool fIsInput;
|
||||
uint32 _fReserved[3];
|
||||
int fFd;
|
||||
bool fIsInput;
|
||||
uint32 _fReserved[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // _DIGITAL_PORT_H
|
||||
|
||||
|
||||
@@ -1,97 +1,91 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: Joystick.h
|
||||
/
|
||||
/ Description: Joystick port class header.
|
||||
/
|
||||
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
|
||||
/
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _JOYSTICK_H
|
||||
#define _JOYSTICK_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <OS.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BList;
|
||||
class BString;
|
||||
class _BJoystickTweaker;
|
||||
struct entry_ref;
|
||||
struct _extended_joystick;
|
||||
class _BJoystickTweaker;
|
||||
struct _joystick_info;
|
||||
|
||||
/* -----------------------------------------------------------------------*/
|
||||
class BJoystick {
|
||||
public:
|
||||
BJoystick();
|
||||
virtual ~BJoystick();
|
||||
BJoystick();
|
||||
virtual ~BJoystick();
|
||||
|
||||
status_t Open(const char *portName);
|
||||
status_t Open(const char *portName, bool enter_enhanced);
|
||||
void Close(void);
|
||||
status_t Open(const char* portName);
|
||||
status_t Open(const char* portName, bool enhanced);
|
||||
void Close();
|
||||
|
||||
status_t Update(void);
|
||||
status_t SetMaxLatency(bigtime_t max_latency);
|
||||
status_t Update();
|
||||
status_t SetMaxLatency(bigtime_t maxLatency);
|
||||
|
||||
bigtime_t timestamp;
|
||||
int16 horizontal;
|
||||
int16 vertical;
|
||||
bigtime_t timestamp;
|
||||
int16 horizontal;
|
||||
int16 vertical;
|
||||
|
||||
/* NOTE: true == off */
|
||||
bool button1;
|
||||
bool button2;
|
||||
bool button1;
|
||||
bool button2;
|
||||
|
||||
int32 CountDevices();
|
||||
status_t GetDeviceName(int32 n, char * name,
|
||||
size_t bufSize = B_OS_NAME_LENGTH);
|
||||
int32 CountDevices();
|
||||
status_t GetDeviceName(int32 index, char* name,
|
||||
size_t bufSize = B_OS_NAME_LENGTH);
|
||||
|
||||
bool EnterEnhancedMode(const entry_ref * ref = NULL);
|
||||
bool EnterEnhancedMode(const entry_ref* ref = NULL);
|
||||
|
||||
int32 CountSticks();
|
||||
int32 CountSticks();
|
||||
|
||||
status_t GetControllerModule(BString * out_name);
|
||||
status_t GetControllerName(BString * out_name);
|
||||
status_t GetControllerModule(BString* outName);
|
||||
status_t GetControllerName(BString* outName);
|
||||
|
||||
bool IsCalibrationEnabled();
|
||||
status_t EnableCalibration(bool calibrates = true);
|
||||
bool IsCalibrationEnabled();
|
||||
status_t EnableCalibration(bool calibrates = true);
|
||||
|
||||
int32 CountAxes();
|
||||
status_t GetAxisValues(int16 * out_values, int32 for_stick = 0);
|
||||
status_t GetAxisNameAt(int32 index, BString * out_name);
|
||||
int32 CountAxes();
|
||||
status_t GetAxisValues(int16* outValues,
|
||||
int32 forStick = 0);
|
||||
status_t GetAxisNameAt(int32 index,
|
||||
BString* outName);
|
||||
|
||||
int32 CountHats();
|
||||
status_t GetHatValues(uint8 * out_hats, int32 for_stick = 0);
|
||||
status_t GetHatNameAt(int32 index, BString * out_name);
|
||||
int32 CountHats();
|
||||
status_t GetHatValues(uint8* outHats,
|
||||
int32 forStick = 0);
|
||||
status_t GetHatNameAt(int32 index, BString* outName);
|
||||
|
||||
int32 CountButtons();
|
||||
/* NOTE: Buttons() are 1 == on */
|
||||
uint32 ButtonValues(int32 for_stick = 0);
|
||||
status_t GetButtonNameAt(int32 index, BString * out_name);
|
||||
int32 CountButtons();
|
||||
|
||||
uint32 ButtonValues(int32 forStick = 0);
|
||||
status_t GetButtonNameAt(int32 index,
|
||||
BString* outName);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void Calibrate(struct _extended_joystick * reading);
|
||||
virtual void Calibrate(struct _extended_joystick*);
|
||||
|
||||
private:
|
||||
friend class _BJoystickTweaker;
|
||||
|
||||
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;
|
||||
void ScanDevices(bool useDisabled = 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;
|
||||
#if DEBUG
|
||||
public:
|
||||
static FILE *sLogFile;
|
||||
static FILE* sLogFile;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // _JOYSTICK_H
|
||||
|
||||
Reference in New Issue
Block a user