Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

nglInputDevice Class Reference

#include <nglInputDevice.h>

List of all members.


Detailed Description

Input devices interface.

This class manages input devices like joysticks or tablets. It uses a simple abstraction model :

Analog 4-axis 10-button 1-hat Saitek joystick

Game port #1

Input device instances are created via Enum() (the constructor is not available). Values are read by polling, you have to explicitly call Update() to update the buttons and axis values, then read them via GetButtonState() and GetAxeValue().

Note that the core keyboard and mouse are not handled by thic class, they are implicitly managed by nglWindow due to their interaction with the windowing system.


Public Member Functions

Life cycle
virtual ~nglInputDevice ()
Status polling
bool Update ()
nglString GetPort ()
nglString GetName ()
uint GetButtonCount ()
bool GetButtonState (uint Index)
uint GetAxeCount ()
float GetAxeValue (uint Index)
void Dump (uint Level=0) const

Static Public Member Functions

Enumeration
static nglInputDeviceEnum (uint Index)

Friends

class nglInputDeviceInstance


Constructor & Destructor Documentation

virtual nglInputDevice::~nglInputDevice  )  [virtual]
 


Member Function Documentation

void nglInputDevice::Dump uint  Level = 0  )  const
 

Dumps device description info at log level Level.

static nglInputDevice* nglInputDevice::Enum uint  Index  )  [static]
 

Enumerate available input devices

Parameters:
Index an arbitrary index starting from 0
Returns:
input device intance, must be deleted by the user
To build an input device instance, you have to take one returned by Enum(). Example :

nglInputDevice* dev;
uint i = 0;

while ((dev = nglInputDevice::Enum(i++)))
{
  dev->Dump();
  delete dev;
}

You can have several instances representing the same device (queried with the same index), and you must delete all of them when you don't need them.

uint nglInputDevice::GetAxeCount  ) 
 

Number of axis.

float nglInputDevice::GetAxeValue uint  Index  ) 
 

Value of the

Index-nth axis (-1 to 1).

uint nglInputDevice::GetButtonCount  ) 
 

Number of buttons.

bool nglInputDevice::GetButtonState uint  Index  ) 
 

State of the

Index-nth button.

nglString nglInputDevice::GetName  ) 
 

Device description.

nglString nglInputDevice::GetPort  ) 
 

Physical port description.

bool nglInputDevice::Update  ) 
 

Polls for current buttons and axis values

Returns:
if false, the device could not be read (it might have been disconnected)


Friends And Related Function Documentation

friend class nglInputDeviceInstance [friend]
 


Generated on Thu Feb 3 22:26:10 2005 for NGL by  doxygen 1.4.1