You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
236 lines
5.9 KiB
C++
236 lines
5.9 KiB
C++
//
|
|
// G A M E.O.N.E - LOW LEVEL LIB V1.0
|
|
// Copyright (C) 2001 LEVEL ONE ENTERTAINMENT,
|
|
// Licensed under the terms of LGPL.
|
|
//:---------------------------------------------------------------------------
|
|
//:Description
|
|
//
|
|
// LOW LEVEL INPUT DEVICES
|
|
//
|
|
#ifndef _LLINPUT_DEVICES_H
|
|
#define _LLINPUT_DEVICES_H
|
|
|
|
#include "llinput.h"
|
|
|
|
|
|
//defined in llinput.h
|
|
//typedef enum { MOUSE, KEYBOARD, JOYSTICK, GAMEPAD, WHEEL, FORCE_FB_JOYSTICK, FORCE_FB_WHEEL } ;
|
|
//
|
|
#define MAX_BUTTONS (16) // maxbutton count per device
|
|
#define MAX_EVENTS (16) // size of eventqueue
|
|
|
|
|
|
|
|
/*
|
|
* Basic class for input device drivers
|
|
*/
|
|
class input_Device
|
|
{
|
|
public:
|
|
input_Device(){};
|
|
virtual ~input_Device(){};
|
|
virtual const char * GetName() const =0;
|
|
virtual inputEvent * GetEvent() =0;
|
|
virtual inputEvent * GetState(int inputid) =0;
|
|
virtual void Update()=0;
|
|
virtual void Release()=0;
|
|
virtual void Restore()=0;
|
|
virtual void ResetEvent() { m_events.Reset(); };
|
|
virtual void ClearEvent() { m_events.Clear(); };
|
|
virtual int GetEventId(const char *eventname) { return 0; };
|
|
virtual const char * GetEventName(int eventid) { return 0; };
|
|
protected:
|
|
queue<inputEvent> m_events;
|
|
inputEvent m_inputevents[MAX_EVENTS];
|
|
int m_event_index;
|
|
inputEvent m_gstate;
|
|
int m_numDevButtons;
|
|
int m_numDevAxes;
|
|
};
|
|
|
|
|
|
class input_TriggerDevice : public input_Device
|
|
{
|
|
public:
|
|
input_TriggerDevice();
|
|
~input_TriggerDevice();
|
|
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Update();
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
/*
|
|
* eventid = real event defined in llinput.h
|
|
* devicename = string found in event->devicename
|
|
* returns OK on success
|
|
*/
|
|
int MapEvent(int eventid, int userid=0, char *usereventname=0, char *devicename=0 );
|
|
void SetTriggerFilter(TxU32 trigger_mask, TxU32 trigger_filter);
|
|
private:
|
|
int m_numButtons; //number of mapped buttons
|
|
TxU32 m_state_filter; //trigger filter
|
|
TxU32 m_state_mask; //trigger mask
|
|
bool IsAllocated(int eventid,char *devicename);
|
|
};
|
|
|
|
class input_ButtonDevice : public input_Device
|
|
{
|
|
public:
|
|
input_ButtonDevice();
|
|
~input_ButtonDevice();
|
|
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Update();
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
|
|
/*
|
|
* eventid = real event defined in llinput.h
|
|
* devicename = string found in event->devicename
|
|
* returns OK on success
|
|
*/
|
|
int MapEvent(int eventid, int userid=0, char *usereventname=0, char *devicename=0 );
|
|
|
|
private:
|
|
int m_numButtons; //number of mapped buttons
|
|
bool IsAllocated(int eventid,char *devicename);
|
|
};
|
|
|
|
|
|
class input_RelcoordDevice : public input_Device
|
|
{
|
|
public:
|
|
input_RelcoordDevice();
|
|
~input_RelcoordDevice();
|
|
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Update();
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
/*
|
|
* eventid = real event defined in llinput.h
|
|
* devicename = string found in event->devicename
|
|
* returns OK on success
|
|
*/
|
|
int MapXMEvent(int eventid, char *devicename );
|
|
int MapXPEvent(int eventid, char *devicename );
|
|
int MapYMEvent(int eventid, char *devicename );
|
|
int MapYPEvent(int eventid, char *devicename );
|
|
int MapZMEvent(int eventid, char *devicename );
|
|
int MapZPEvent(int eventid, char *devicename );
|
|
|
|
private:
|
|
void AddEvent(int id);
|
|
inputEvent m_state;
|
|
inputEvent m_motionstates[6];
|
|
};
|
|
|
|
class input_AbscoordDevice : public input_Device
|
|
{
|
|
public:
|
|
input_AbscoordDevice();
|
|
~input_AbscoordDevice();
|
|
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Update();
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
int LinkXAxis(char *devicename);
|
|
int LinkYAxis(char *devicename);
|
|
int LinkZAxis(char *devicename);
|
|
void SetPosition(int x,int y,int z);
|
|
void SetXRange(int min,int max);
|
|
void SetYRange(int min,int max);
|
|
void SetZRange(int min,int max);
|
|
private:
|
|
int m_i_min_x,m_i_max_x;
|
|
int m_i_min_y,m_i_max_y;
|
|
int m_i_min_z,m_i_max_z;
|
|
void AddEvent(int id);
|
|
void ClipCoords();
|
|
inputEvent m_state;
|
|
inputEvent m_motionstates[3];
|
|
};
|
|
|
|
|
|
class input_KeyboardDevice : public input_Device
|
|
{
|
|
public:
|
|
input_KeyboardDevice();
|
|
virtual ~input_KeyboardDevice(void);
|
|
|
|
virtual void Update();
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
virtual int GetEventId(const char *eventname);
|
|
virtual const char * GetEventName(int eventid);
|
|
private:
|
|
void AddEvent(int id);
|
|
void AddEventChar(int id);
|
|
int SearchCharEvent(TxU8 eventid);
|
|
};
|
|
|
|
class input_MouseDevice : public input_Device
|
|
{
|
|
public:
|
|
input_MouseDevice();
|
|
virtual ~input_MouseDevice(void);
|
|
|
|
virtual void Update();
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
virtual int GetEventId(const char *eventname);
|
|
virtual const char * GetEventName(int eventid);
|
|
private:
|
|
void AddEvent(int id);
|
|
};
|
|
|
|
class input_JoystickDevice : public input_Device
|
|
{
|
|
public:
|
|
input_JoystickDevice();
|
|
virtual ~input_JoystickDevice(void);
|
|
|
|
virtual void Update();
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
private:
|
|
void AddEvent(int id);
|
|
int m_subnum;
|
|
TxU32 m_MotionStates[27];
|
|
};
|
|
|
|
class input_SystemDevice : public input_Device
|
|
{
|
|
public:
|
|
input_SystemDevice();
|
|
~input_SystemDevice();
|
|
|
|
virtual const char * GetName() const;
|
|
virtual inputEvent * GetEvent();
|
|
virtual inputEvent * GetState(int inputid);
|
|
virtual void Update();
|
|
virtual void Release();
|
|
virtual void Restore();
|
|
private:
|
|
};
|
|
|
|
#endif // _LLINPUT_DEVICES_H
|