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:
Stefano Ceccherini
2009-08-28 19:08:52 +00:00
parent 7d50125fa5
commit ab83d3e932
2 changed files with 79 additions and 96 deletions
+25 -36
View File
@@ -1,54 +1,43 @@
/******************************************************************************** /*
/ * Copyright 2009, Haiku, Inc. All rights reserved.
/ File: DigitalPort.h * Distributed under the terms of the MIT License.
/ */
/ Description: Digital Port class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _DIGITAL_PORT_H #ifndef _DIGITAL_PORT_H
#define _DIGITAL_PORT_H #define _DIGITAL_PORT_H
#include <BeBuild.h> #include <BeBuild.h>
#include <stddef.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <stddef.h>
/* -----------------------------------------------------------------------*/
class BDigitalPort { class BDigitalPort {
public: public:
BDigitalPort(); BDigitalPort();
virtual ~BDigitalPort(); virtual ~BDigitalPort();
status_t Open(const char *portName); status_t Open(const char* portName);
void Close(void); void Close();
bool IsOpen(void); bool IsOpen();
ssize_t Read(uint8 *buf); ssize_t Read(uint8* buf);
ssize_t Write(uint8 value); ssize_t Write(uint8 value);
status_t SetAsOutput (void); status_t SetAsOutput();
bool IsOutput (void); bool IsOutput();
status_t SetAsInput (void); status_t SetAsInput();
bool IsInput (void); bool IsInput();
/* -----------------------------------------------------------------------*/
private: private:
virtual void _ReservedDigitalPort1();
virtual void _ReservedDigitalPort2();
virtual void _ReservedDigitalPort3();
virtual void _ReservedDigitalPort1(); int fFd;
virtual void _ReservedDigitalPort2(); bool fIsInput;
virtual void _ReservedDigitalPort3(); uint32 _fReserved[3];
int ffd;
bool fIsInput;
uint32 _fReserved[3];
}; };
#endif #endif // _DIGITAL_PORT_H
+53 -59
View File
@@ -1,97 +1,91 @@
/******************************************************************************** /*
/ * Copyright 2009, Haiku, Inc. All rights reserved.
/ File: Joystick.h * Distributed under the terms of the MIT License.
/ */
/ Description: Joystick port class header.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved.
/
********************************************************************************/
#ifndef _JOYSTICK_H #ifndef _JOYSTICK_H
#define _JOYSTICK_H #define _JOYSTICK_H
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h>
#include <OS.h> #include <OS.h>
#include <SupportDefs.h>
class BList; class BList;
class BString; class BString;
class _BJoystickTweaker;
struct entry_ref; struct entry_ref;
struct _extended_joystick; struct _extended_joystick;
class _BJoystickTweaker;
struct _joystick_info; struct _joystick_info;
/* -----------------------------------------------------------------------*/
class BJoystick { class BJoystick {
public: public:
BJoystick(); BJoystick();
virtual ~BJoystick(); virtual ~BJoystick();
status_t Open(const char *portName); status_t Open(const char* portName);
status_t Open(const char *portName, bool enter_enhanced); status_t Open(const char* portName, bool enhanced);
void Close(void); void Close();
status_t Update(void); status_t Update();
status_t SetMaxLatency(bigtime_t max_latency); status_t SetMaxLatency(bigtime_t maxLatency);
bigtime_t timestamp; bigtime_t timestamp;
int16 horizontal; int16 horizontal;
int16 vertical; int16 vertical;
/* NOTE: true == off */ bool button1;
bool button1; bool button2;
bool button2;
int32 CountDevices(); int32 CountDevices();
status_t GetDeviceName(int32 n, char * name, status_t GetDeviceName(int32 index, char* name,
size_t bufSize = B_OS_NAME_LENGTH); 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 GetControllerModule(BString* outName);
status_t GetControllerName(BString * out_name); status_t GetControllerName(BString* outName);
bool IsCalibrationEnabled(); bool IsCalibrationEnabled();
status_t EnableCalibration(bool calibrates = true); status_t EnableCalibration(bool calibrates = true);
int32 CountAxes(); int32 CountAxes();
status_t GetAxisValues(int16 * out_values, int32 for_stick = 0); status_t GetAxisValues(int16* outValues,
status_t GetAxisNameAt(int32 index, BString * out_name); int32 forStick = 0);
status_t GetAxisNameAt(int32 index,
BString* outName);
int32 CountHats(); int32 CountHats();
status_t GetHatValues(uint8 * out_hats, int32 for_stick = 0); status_t GetHatValues(uint8* outHats,
status_t GetHatNameAt(int32 index, BString * out_name); int32 forStick = 0);
status_t GetHatNameAt(int32 index, BString* outName);
int32 CountButtons(); int32 CountButtons();
/* NOTE: Buttons() are 1 == on */
uint32 ButtonValues(int32 for_stick = 0); uint32 ButtonValues(int32 forStick = 0);
status_t GetButtonNameAt(int32 index, BString * out_name); status_t GetButtonNameAt(int32 index,
BString* outName);
protected: protected:
virtual void Calibrate(struct _extended_joystick*);
virtual void Calibrate(struct _extended_joystick * reading);
private: private:
friend class _BJoystickTweaker; friend class _BJoystickTweaker;
void ScanDevices(bool use_disabled = false); void ScanDevices(bool useDisabled = false);
status_t GatherEnhanced_info(const entry_ref * ref = NULL); status_t GatherEnhanced_info(const entry_ref* ref = NULL);
status_t SaveConfig(const entry_ref * ref = NULL); status_t SaveConfig(const entry_ref* ref = NULL);
bool fBeBoxMode; bool fBeBoxMode;
bool fReservedBool; bool fReservedBool;
int ffd; int ffd;
BList* fDevices; BList* fDevices;
_joystick_info* fJoystickInfo; _joystick_info* fJoystickInfo;
char* fDevName; char* fDevName;
#if DEBUG #if DEBUG
public: public:
static FILE *sLogFile; static FILE* sLogFile;
#endif #endif
}; };
#endif #endif // _JOYSTICK_H