Cafu Engine
DirectInputT Class Reference

Public Member Functions

 DirectInputT ()
 Create DirectInput object. More...
HRESULT Initialize (HINSTANCE hInstance, HWND hWindow)
 Initialize DirectInput: More...
void Release ()
 Release DirectInput object. More...
 ~DirectInputT ()
 Destrcutor. More...
HRESULT GetNextMouseEvent (DIDEVICEOBJECTDATA *MouseEvent, DWORD *ReadNrOfEvents)
 Reads the next mouse event from the mouse buffer and returns it in MouseEvent. More...
char GetMouseButtonsImmediate ()
 Returns the current state of the mouse buttons. More...

Constructor & Destructor Documentation

DirectInputT::DirectInputT ( )

Create DirectInput object.

DirectInputT::~DirectInputT ( )


Member Function Documentation

char DirectInputT::GetMouseButtonsImmediate ( )

Returns the current state of the mouse buttons.

If the n-th bit of the return value is set, the n-th mouse button is pressed.

HRESULT DirectInputT::GetNextMouseEvent ( DIDEVICEOBJECTDATA *  MouseEvent,
DWORD *  ReadNrOfEvents 

Reads the next mouse event from the mouse buffer and returns it in MouseEvent.

ReadNrOfEvents is 1 if the event was read and 0 if the buffer was empty. If something different from DI_OK or DI_BUFFEROVERFLOW is returned, MouseEvent and ReadNrOfEvents are undefined.

HRESULT DirectInputT::Initialize ( HINSTANCE  hInstance,
HWND  hWindow 

Initialize DirectInput:

  • Create DirectInput 7.0 object
  • Create Mouse Device Set DataFormat Set CooperativeLevel (Foreground and Non-Exclusive) Set BufferSize to 64 setzen for buffered mouse events. Aquire mouse. This is separated from the constructor to return errors without the use of exceptions. If Initialize() fails the deconstructor will clean up everything.
void DirectInputT::Release ( )

Release DirectInput object.

This must be possible outside of the destructor if for example the hWindow object from Initialize becomes invalid because the associated windows has been closed and reopened.

The documentation for this class was generated from the following files: