Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::Win32Input Class Reference

Utility class for dealing with user input on a Win32 system. More...

#include <OgreWin32Input.h>

Inheritance diagram for Ogre::Win32Input:

Inheritance graph
[legend]
List of all members.

Public Methods

 Win32Input ()
 ~Win32Input ()
void initialise (RenderWindow *pWindow, bool useKeyboard=true, bool useMouse=true, bool useGameController=false)
 Initialise the input system.

void capture (void)
 Captures the state of all the input devices.

bool isKeyDown (KeyCode kc)
 Determines if the specified key is currently depressed.

int getMouseRelativeX (void)
 Retrieves the relative position of the mouse when capture was called relative to the last time.

int getMouseRelativeY (void)
 Retrieves the relative position of the mouse when capture was called relative to the last time.

void useBufferedInput (EventQueue *pEventQueue, bool keys=true, bool mouse=true)
 Tells the reader to use buffered input and update the passed in queue.

virtual void setBufferedInput (bool keys, bool mouse)
virtual bool isKeyDown (KeyCode kc) const=0
 Determines if the specified key is currently depressed.

virtual long getMouseRelativeX () const
 Retrieves the relative position of the mouse when capture was called relative to the last time.

virtual long getMouseRelativeY () const
 Retrieves the relative position of the mouse when capture was called relative to the last time.

virtual long getMouseRelativeZ () const
 Retrieves the relative position of the mouse when capture was called relative to the last time.

virtual long getMouseRelX () const=0
 Retrieves the relative (compared to the last input poll) mouse movement on the X (horizontal) axis.

virtual long getMouseRelY () const=0
 Retrieves the relative (compared to the last input poll) mouse movement on the Y (vertical) axis.

virtual long getMouseRelZ () const=0
 Retrieves the relative (compared to the last input poll) mouse movement on the Z (mouse wheel) axis.

virtual long getMouseAbsX () const=0
 Retrieves the absolute mouse position on the X (horizontal) axis.

virtual long getMouseAbsY () const=0
 Retrieves the absolute mouse position on the Y (vertical) axis.

virtual long getMouseAbsZ () const=0
 Retrieves the absolute mouse position on the Z (mouse wheel) axis.

virtual void getMouseState (MouseState &state) const=0
 Retrieves the current state of the mouse.

virtual bool getMouseButton (uchar button) const=0
 Retrieves the state of a mouse button.

void addCursorMoveListener (MouseMotionListener *c)
 Adds a mouse motion listener to the cursor object.

void removeCursorMoveListener (MouseMotionListener *c)
 Remove a mouse motion listener to the cursor object.


Static Public Methods

char getKeyChar (int keyCode, long modifiers=0)

Protected Methods

void mouseMoved ()
 Creates mouse moved or dragged events depending if any button is pressed.

void createMouseEvent (int id, int button)
 Creates a MouseEvent that first gets processed by the cursor, then gets pushed on the queue.

void triggerMouseButton (int nMouseCode, bool mousePressed)
 Creates mouse pressed, released, and clicked events.

void createKeyEvent (int id, int key)
void keyChanged (int key, bool down)
void setupKeyChars ()

Protected Attributes

long mModifiers
 The modifiers are a binary flags that represent what buttons are pressed, and what key modifiers are down (e.g.

CursormCursor
 Internal Cursor object.

EventQueuemEventQueue
 EventQueue is used for buffered input support.

bool mUseBufferedKeys
 Wether to use buffering input support - buffering support relies on using an EventQueue.

bool mUseBufferedMouse
 Wether to use buffering input support - buffering support relies on using an EventQueue.

MouseState mMouseState
 The mouse state in immediate mode.


Static Protected Attributes

bool sKeysInitialised = false

Private Attributes

LPDIRECTINPUT7 mlpDI
LPDIRECTINPUTDEVICE7 mlpDIKeyboard
LPDIRECTINPUTDEVICE7 mlpDIMouse
HWND mHWnd
char mKeyboardBuffer [256]
int mMouseX
int mMouseY
int mMouseCenterX
int mMouseCenterY
bool mLMBDown
bool mRMBDown

Detailed Description

Utility class for dealing with user input on a Win32 system.

Note that this is a basic implementation only at the moment.

Definition at line 38 of file OgreWin32Input.h.


Constructor & Destructor Documentation

Ogre::Win32Input::Win32Input  
 

Definition at line 36 of file OgreWin32Input.cpp.

References mKeyboardBuffer, mlpDI, mlpDIKeyboard, and mlpDIMouse.

Ogre::Win32Input::~Win32Input  
 

Definition at line 47 of file OgreWin32Input.cpp.

References mlpDI, mlpDIKeyboard, and mlpDIMouse.


Member Function Documentation

void Ogre::InputReader::addCursorMoveListener MouseMotionListener   c [inherited]
 

Adds a mouse motion listener to the cursor object.

This keeps the Cursor object hidden.

Definition at line 146 of file OgreInput.cpp.

References Ogre::MouseMotionTarget::addMouseMotionListener(), and Ogre::InputReader::mCursor.

Referenced by Ogre::EventProcessor::addCursorMoveListener().

void Ogre::Win32Input::capture void    [virtual]
 

Captures the state of all the input devices.

This method captures the state of all input devices and stores it internally for use when the enquiry methods are next called. This is done to ensure that all input is captured at once and therefore combinations of input are not subject to time differences when methods are called.

Implements Ogre::InputReader.

Definition at line 190 of file OgreWin32Input.cpp.

References mHWnd, mKeyboardBuffer, mlpDIKeyboard, mMouseCenterX, mMouseCenterY, mMouseX, and mMouseY.

void Ogre::InputReader::createKeyEvent int    id,
int    key
[protected, inherited]
 

Definition at line 123 of file OgreInput.cpp.

References Ogre::InputReader::mEventQueue, Ogre::InputReader::mModifiers, and Ogre::EventQueue::push().

Referenced by Ogre::InputReader::keyChanged().

void Ogre::InputReader::createMouseEvent int    id,
int    button
[protected, inherited]
 

Creates a MouseEvent that first gets processed by the cursor, then gets pushed on the queue.

Definition at line 104 of file OgreInput.cpp.

References Ogre::Cursor::getRelX(), Ogre::Cursor::getRelY(), Ogre::Cursor::getRelZ(), Ogre::Cursor::getX(), Ogre::Cursor::getY(), Ogre::Cursor::getZ(), Ogre::InputReader::mCursor, Ogre::InputReader::mEventQueue, Ogre::InputReader::mModifiers, Ogre::Cursor::processEvent(), and Ogre::EventQueue::push().

Referenced by Ogre::InputReader::mouseMoved(), and Ogre::InputReader::triggerMouseButton().

char Ogre::InputReader::getKeyChar int    keyCode,
long    modifiers = 0
[static, inherited]
 

Definition at line 205 of file OgreInput.cpp.

References Ogre::KEYCODE(), and Ogre::sKeyChars.

virtual long Ogre::InputReader::getMouseAbsX   const [pure virtual, inherited]
 

Retrieves the absolute mouse position on the X (horizontal) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseAbsY   const [pure virtual, inherited]
 

Retrieves the absolute mouse position on the Y (vertical) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseAbsZ   const [pure virtual, inherited]
 

Retrieves the absolute mouse position on the Z (mouse wheel) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual bool Ogre::InputReader::getMouseButton uchar    button const [pure virtual, inherited]
 

Retrieves the state of a mouse button.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelativeX void    const [virtual, inherited]
 

Retrieves the relative position of the mouse when capture was called relative to the last time.

Reimplemented in Ogre::Win32Input.

Definition at line 272 of file OgreInput.h.

int Ogre::Win32Input::getMouseRelativeX void    [virtual]
 

Retrieves the relative position of the mouse when capture was called relative to the last time.

Reimplemented from Ogre::InputReader.

Definition at line 305 of file OgreWin32Input.cpp.

References mMouseCenterX, and mMouseX.

virtual long Ogre::InputReader::getMouseRelativeY void    const [virtual, inherited]
 

Retrieves the relative position of the mouse when capture was called relative to the last time.

Reimplemented in Ogre::Win32Input.

Definition at line 276 of file OgreInput.h.

int Ogre::Win32Input::getMouseRelativeY void    [virtual]
 

Retrieves the relative position of the mouse when capture was called relative to the last time.

Reimplemented from Ogre::InputReader.

Definition at line 310 of file OgreWin32Input.cpp.

References mMouseCenterY, and mMouseY.

virtual long Ogre::InputReader::getMouseRelativeZ   const [virtual, inherited]
 

Retrieves the relative position of the mouse when capture was called relative to the last time.

Definition at line 280 of file OgreInput.h.

virtual long Ogre::InputReader::getMouseRelX   const [pure virtual, inherited]
 

Retrieves the relative (compared to the last input poll) mouse movement on the X (horizontal) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelY   const [pure virtual, inherited]
 

Retrieves the relative (compared to the last input poll) mouse movement on the Y (vertical) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelZ   const [pure virtual, inherited]
 

Retrieves the relative (compared to the last input poll) mouse movement on the Z (mouse wheel) axis.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

virtual void Ogre::InputReader::getMouseState MouseState   state const [pure virtual, inherited]
 

Retrieves the current state of the mouse.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

void Ogre::Win32Input::initialise RenderWindow   pWindow,
bool    useKeyboard = true,
bool    useMouse = true,
bool    useGameController = false
[virtual]
 

Initialise the input system.

Parameters:
pWindow  The window to capture input for
useKeyboard  If true, keyboard input will be supported.
useMouse  If true, mouse input will be supported.
useGameController  If true, joysticks/gamepads will be supported.

Implements Ogre::InputReader.

Definition at line 71 of file OgreWin32Input.cpp.

References mHWnd, mlpDI, mlpDIKeyboard, mMouseCenterX, and mMouseCenterY.

virtual bool Ogre::InputReader::isKeyDown KeyCode    kc const [pure virtual, inherited]
 

Determines if the specified key is currently depressed.

Note:
This enquiry method uses the state of the keyboard at the last 'capture' call.

Implemented in Ogre::SDLInput, and Ogre::Win32Input8.

bool Ogre::Win32Input::isKeyDown KeyCode    kc
 

Determines if the specified key is currently depressed.

Note that this enquiry method uses the state of the keyboard at the last 'capture' call.

Definition at line 292 of file OgreWin32Input.cpp.

References Ogre::KeyCode, and mKeyboardBuffer.

void Ogre::InputReader::keyChanged int    key,
bool    down
[protected, inherited]
 

Definition at line 157 of file OgreInput.cpp.

References Ogre::InputReader::createKeyEvent(), Ogre::KC_LCONTROL, Ogre::KC_LMENU, Ogre::KC_LSHIFT, Ogre::KC_RCONTROL, Ogre::KC_RMENU, Ogre::KC_RSHIFT, and Ogre::InputReader::mModifiers.

Referenced by Ogre::SDLInput::processBufferedKeyboard(), and Ogre::Win32Input8::readBufferedKeyboardData().

void Ogre::InputReader::mouseMoved   [protected, inherited]
 

Creates mouse moved or dragged events depending if any button is pressed.

Definition at line 132 of file OgreInput.cpp.

References Ogre::InputReader::createMouseEvent(), and Ogre::InputReader::mModifiers.

Referenced by Ogre::SDLInput::processBufferedMouse(), and Ogre::Win32Input8::readBufferedMouseData().

void Ogre::InputReader::removeCursorMoveListener MouseMotionListener   c [inherited]
 

Remove a mouse motion listener to the cursor object.

This keeps the Cursor object hidden.

Definition at line 151 of file OgreInput.cpp.

References Ogre::InputReader::mCursor, and Ogre::MouseMotionTarget::removeMouseMotionListener().

Referenced by Ogre::EventProcessor::removeCursorMoveListener().

void Ogre::InputReader::setBufferedInput bool    keys,
bool    mouse
[virtual, inherited]
 

Reimplemented in Ogre::Win32Input8.

Definition at line 70 of file OgreInput.cpp.

References Ogre::InputReader::mUseBufferedKeys, and Ogre::InputReader::mUseBufferedMouse.

void Ogre::InputReader::setupKeyChars   [protected, inherited]
 

Definition at line 215 of file OgreInput.cpp.

References Ogre::KC_0, Ogre::KC_1, Ogre::KC_2, Ogre::KC_3, Ogre::KC_4, Ogre::KC_5, Ogre::KC_6, Ogre::KC_7, Ogre::KC_8, Ogre::KC_9, Ogre::KC_A, Ogre::KC_ADD, Ogre::KC_APOSTROPHE, Ogre::KC_AT, Ogre::KC_B, Ogre::KC_BACKSLASH, Ogre::KC_C, Ogre::KC_COLON, Ogre::KC_COMMA, Ogre::KC_D, Ogre::KC_DECIMAL, Ogre::KC_DIVIDE, Ogre::KC_E, Ogre::KC_EQUALS, Ogre::KC_F, Ogre::KC_G, Ogre::KC_GRAVE, Ogre::KC_H, Ogre::KC_I, Ogre::KC_J, Ogre::KC_K, Ogre::KC_L, Ogre::KC_LBRACKET, Ogre::KC_M, Ogre::KC_MINUS, Ogre::KC_MULTIPLY, Ogre::KC_N, Ogre::KC_NUMPAD0, Ogre::KC_NUMPAD1, Ogre::KC_NUMPAD2, Ogre::KC_NUMPAD3, Ogre::KC_NUMPAD4, Ogre::KC_NUMPAD5, Ogre::KC_NUMPAD6, Ogre::KC_NUMPAD7, Ogre::KC_NUMPAD8, Ogre::KC_NUMPAD9, Ogre::KC_NUMPADCOMMA, Ogre::KC_NUMPADEQUALS, Ogre::KC_O, Ogre::KC_P, Ogre::KC_PERIOD, Ogre::KC_Q, Ogre::KC_R, Ogre::KC_RBRACKET, Ogre::KC_S, Ogre::KC_SEMICOLON, Ogre::KC_SLASH, Ogre::KC_SPACE, Ogre::KC_SUBTRACT, Ogre::KC_T, Ogre::KC_U, Ogre::KC_UNDERLINE, Ogre::KC_V, Ogre::KC_W, Ogre::KC_X, Ogre::KC_Y, Ogre::KC_Z, Ogre::KEYCODE(), and Ogre::sKeyChars.

Referenced by Ogre::InputReader::InputReader().

void Ogre::InputReader::triggerMouseButton int    nMouseCode,
bool    mousePressed
[protected, inherited]
 

Creates mouse pressed, released, and clicked events.

Definition at line 87 of file OgreInput.cpp.

References Ogre::InputReader::createMouseEvent(), and Ogre::InputReader::mModifiers.

Referenced by Ogre::SDLInput::processBufferedMouse(), and Ogre::Win32Input8::readBufferedMouseData().

void Ogre::InputReader::useBufferedInput EventQueue   pEventQueue,
bool    keys = true,
bool    mouse = true
[inherited]
 

Tells the reader to use buffered input and update the passed in queue.

Remarks:
The default behaviour of the input reader is simply to capture the current state of the mouse / keyboard on demand. An alternative is to use buffered input where all events are registered on a queue.

Definition at line 53 of file OgreInput.cpp.

References Ogre::InputReader::mCursor, Ogre::InputReader::mEventQueue, Ogre::InputReader::mUseBufferedKeys, and Ogre::InputReader::mUseBufferedMouse.

Referenced by Ogre::EventProcessor::initialise().


Member Data Documentation

Cursor* Ogre::InputReader::mCursor [protected, inherited]
 

Internal Cursor object.

Remarks:
This is a mathematical representation of where the cursor is, it does not draw a cursor.
See also:
CursorGuiElement.

Definition at line 331 of file OgreInput.h.

Referenced by Ogre::InputReader::addCursorMoveListener(), Ogre::InputReader::createMouseEvent(), Ogre::InputReader::InputReader(), Ogre::SDLInput::processBufferedMouse(), Ogre::Win32Input8::readBufferedMouseData(), Ogre::InputReader::removeCursorMoveListener(), Ogre::InputReader::useBufferedInput(), and Ogre::InputReader::~InputReader().

EventQueue* Ogre::InputReader::mEventQueue [protected, inherited]
 

EventQueue is used for buffered input support.

Definition at line 334 of file OgreInput.h.

Referenced by Ogre::InputReader::createKeyEvent(), Ogre::InputReader::createMouseEvent(), Ogre::InputReader::InputReader(), Ogre::SDLInput::SDLInput(), Ogre::InputReader::useBufferedInput(), and Ogre::Win32Input8::Win32Input8().

HWND Ogre::Win32Input::mHWnd [private]
 

Definition at line 79 of file OgreWin32Input.h.

Referenced by capture(), and initialise().

char Ogre::Win32Input::mKeyboardBuffer[256] [private]
 

Definition at line 83 of file OgreWin32Input.h.

Referenced by capture(), isKeyDown(), and Win32Input().

bool Ogre::Win32Input::mLMBDown [private]
 

Definition at line 86 of file OgreWin32Input.h.

LPDIRECTINPUT7 Ogre::Win32Input::mlpDI [private]
 

Definition at line 75 of file OgreWin32Input.h.

Referenced by initialise(), Win32Input(), and ~Win32Input().

LPDIRECTINPUTDEVICE7 Ogre::Win32Input::mlpDIKeyboard [private]
 

Definition at line 76 of file OgreWin32Input.h.

Referenced by capture(), initialise(), Win32Input(), and ~Win32Input().

LPDIRECTINPUTDEVICE7 Ogre::Win32Input::mlpDIMouse [private]
 

Definition at line 77 of file OgreWin32Input.h.

Referenced by Win32Input(), and ~Win32Input().

long Ogre::InputReader::mModifiers [protected, inherited]
 

The modifiers are a binary flags that represent what buttons are pressed, and what key modifiers are down (e.g.

shift/alt).

Definition at line 321 of file OgreInput.h.

Referenced by Ogre::Win32Input8::capture(), Ogre::InputReader::createKeyEvent(), Ogre::InputReader::createMouseEvent(), Ogre::Win32Input8::getKeyModifiers(), Ogre::InputReader::InputReader(), Ogre::InputReader::keyChanged(), Ogre::InputReader::mouseMoved(), and Ogre::InputReader::triggerMouseButton().

int Ogre::Win32Input::mMouseCenterX [private]
 

Definition at line 85 of file OgreWin32Input.h.

Referenced by capture(), getMouseRelativeX(), and initialise().

int Ogre::Win32Input::mMouseCenterY [private]
 

Definition at line 85 of file OgreWin32Input.h.

Referenced by capture(), getMouseRelativeY(), and initialise().

MouseState Ogre::InputReader::mMouseState [protected, inherited]
 

The mouse state in immediate mode.

Definition at line 342 of file OgreInput.h.

Referenced by Ogre::SDLInput::capture(), Ogre::Win32Input8::captureMouse(), Ogre::Win32Input8::getMouseAbsX(), Ogre::Win32Input8::getMouseAbsY(), Ogre::Win32Input8::getMouseAbsZ(), Ogre::Win32Input8::getMouseButton(), Ogre::SDLInput::getMouseButton(), Ogre::Win32Input8::getMouseRelX(), Ogre::SDLInput::getMouseRelX(), Ogre::Win32Input8::getMouseRelY(), Ogre::SDLInput::getMouseRelY(), Ogre::Win32Input8::getMouseRelZ(), Ogre::SDLInput::getMouseRelZ(), Ogre::Win32Input8::getMouseState(), Ogre::SDLInput::getMouseState(), and Ogre::Win32Input8::initialiseImmediateMouse().

int Ogre::Win32Input::mMouseX [private]
 

Definition at line 84 of file OgreWin32Input.h.

Referenced by capture(), and getMouseRelativeX().

int Ogre::Win32Input::mMouseY [private]
 

Definition at line 84 of file OgreWin32Input.h.

Referenced by capture(), and getMouseRelativeY().

bool Ogre::Win32Input::mRMBDown [private]
 

Definition at line 86 of file OgreWin32Input.h.

bool Ogre::InputReader::mUseBufferedKeys [protected, inherited]
 

Wether to use buffering input support - buffering support relies on using an EventQueue.

See also:
class EventQueue

Definition at line 339 of file OgreInput.h.

Referenced by Ogre::SDLInput::capture(), Ogre::InputReader::InputReader(), Ogre::Win32Input8::setBufferedInput(), Ogre::InputReader::setBufferedInput(), and Ogre::InputReader::useBufferedInput().

bool Ogre::InputReader::mUseBufferedMouse [protected, inherited]
 

Wether to use buffering input support - buffering support relies on using an EventQueue.

See also:
class EventQueue

Definition at line 339 of file OgreInput.h.

Referenced by Ogre::SDLInput::capture(), Ogre::InputReader::InputReader(), Ogre::Win32Input8::setBufferedInput(), Ogre::InputReader::setBufferedInput(), and Ogre::InputReader::useBufferedInput().

bool Ogre::InputReader::sKeysInitialised = false [static, protected, inherited]
 

Definition at line 36 of file OgreInput.cpp.

Referenced by Ogre::InputReader::InputReader().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:27:30 2004