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

# Ogre::InputReader Class Reference

Abstract class which allows input to be read from various controllers. More...

`#include <OgreInput.h>`

Inheritance diagram for Ogre::InputReader:

[legend]
List of all members.

## Public Methods

| InputReader ()
virtual | ~InputReader ()
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 void | initialise (RenderWindow *pWindow, bool useKeyboard=true, bool useMouse=true, bool useGameController=false)=0
| Initialise the input system.
virtual void | capture ()=0
| Captures the state of all the input devices.
virtual bool | isKeyDown (KeyCode kc) const
| 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 Types

typedef std::set< KeyCode > | BufferedKeysDownSet
| Set of all the keys currently depressed based on buffered input events.

## 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 ()
virtual bool | isKeyDownImmediate (KeyCode kc) const=0
| Return whether a key is down in immediate mode.

## Protected Attributes

long | mModifiers
| The modifiers are a binary flags that represent what buttons are pressed, and what key modifiers are down (e.g.
Cursor * | mCursor
| Internal Cursor object.
EventQueue * | mEventQueue
| 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.
BufferedKeysDownSet | mBufferedKeysDown

## Static Protected Attributes

bool | sKeysInitialised = false

## Detailed Description

Abstract class which allows input to be read from various controllers.

Remarks:
  You can access an appropriate concrete subclass of this interface by calling PlatformManager::createInputReader.

Warning:
  Temporary implementation only. This class is likely to be refactored into a better design when I get time to look at it properly. For now it's a quick-and-dirty way to get what I need.

See also:
  PlatformManager::createInputReader

Definition at line 218 of file OgreInput.h.

## Member Typedef Documentation

typedef std::set<KeyCode> Ogre::InputReader::BufferedKeysDownSet`[protected]`

| Set of all the keys currently depressed based on buffered input events. Definition at line 345 of file OgreInput.h.

## Constructor & Destructor Documentation

Ogre::InputReader::InputReader | ( |  | ) |

| Definition at line 39 of file OgreInput.cpp. References mCursor, mEventQueue, mModifiers, mUseBufferedKeys, mUseBufferedMouse, setupKeyChars(), and sKeysInitialised.

Ogre::InputReader::~InputReader | ( |  | ) | `[virtual]`

| Definition at line 79 of file OgreInput.cpp. References mCursor.

## Member Function Documentation

void Ogre::InputReader::addCursorMoveListener | ( | MouseMotionListener * | c | ) |

| Adds a mouse motion listener to the cursor object. This keeps the Cursor object hidden. Definition at line 174 of file OgreInput.cpp. References Ogre::MouseMotionTarget::addMouseMotionListener(), and mCursor. Referenced by Ogre::EventProcessor::addCursorMoveListener().

virtual void Ogre::InputReader::capture | ( |  | ) | `[pure virtual]`

Captures the state of all the input devices.

Remarks:
  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.

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

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

void Ogre::InputReader::createKeyEvent | ( | int | id,
|  | int | key
| ) | `[protected]`

| Definition at line 152 of file OgreInput.cpp. References mEventQueue, mModifiers, and Ogre::EventQueue::push(). Referenced by keyChanged().

void Ogre::InputReader::createMouseEvent | ( | int | id,
|  | int | button
| ) | `[protected]`

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

Definition at line 132 of file OgreInput.cpp.

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

Referenced by mouseMoved(), and triggerMouseButton().

char Ogre::InputReader::getKeyChar | ( | int | keyCode,
|  | long | modifiers = 0
| ) | `[static]`

| Definition at line 238 of file OgreInput.cpp. References Ogre::KEYCODE(), and Ogre::sKeyChars.

virtual long Ogre::InputReader::getMouseAbsX | ( |  | ) | const`[pure virtual]`

| Retrieves the absolute mouse position on the X (horizontal) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseAbsY | ( |  | ) | const`[pure virtual]`

| Retrieves the absolute mouse position on the Y (vertical) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseAbsZ | ( |  | ) | const`[pure virtual]`

| Retrieves the absolute mouse position on the Z (mouse wheel) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual bool Ogre::InputReader::getMouseButton | ( | uchar | button | ) | const`[pure virtual]`

| Retrieves the state of a mouse button. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelativeX | ( |  | ) | const`[virtual]`

| Retrieves the relative position of the mouse when capture was called relative to the last time. Definition at line 272 of file OgreInput.h.

virtual long Ogre::InputReader::getMouseRelativeY | ( |  | ) | const`[virtual]`

| Retrieves the relative position of the mouse when capture was called relative to the last time. Definition at line 276 of file OgreInput.h.

virtual long Ogre::InputReader::getMouseRelativeZ | ( |  | ) | const`[virtual]`

| 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]`

| Retrieves the relative (compared to the last input poll) mouse movement on the X (horizontal) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelY | ( |  | ) | const`[pure virtual]`

| Retrieves the relative (compared to the last input poll) mouse movement on the Y (vertical) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual long Ogre::InputReader::getMouseRelZ | ( |  | ) | const`[pure virtual]`

| Retrieves the relative (compared to the last input poll) mouse movement on the Z (mouse wheel) axis. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual void Ogre::InputReader::getMouseState | ( | MouseState & | state | ) | const`[pure virtual]`

| Retrieves the current state of the mouse. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8.

virtual void Ogre::InputReader::initialise | ( | RenderWindow * | pWindow,
|  | bool | useKeyboard = true,
|  | bool | useMouse = true,
|  | bool | useGameController = false
| ) | `[pure virtual]`

Initialise the input system.

Note:
  Only keyboard and mouse currently implemented.

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.

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

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

bool Ogre::InputReader::isKeyDown | ( | KeyCode | kc | ) | const`[virtual]`

Determines if the specified key is currently depressed.

Note:
  In immediate mode, this enquiry method uses the state of the keyboard at the last 'capture' call.

Definition at line 370 of file OgreInput.cpp.

References isKeyDownImmediate(), Ogre::KeyCode, and mBufferedKeysDown.

Referenced by Ogre::Win32Input8::getKeyModifiers().

virtual bool Ogre::InputReader::isKeyDownImmediate | ( | KeyCode | kc | ) | const`[protected, pure virtual]`

| Return whether a key is down in immediate mode. Implemented in Ogre::GLXInput, Ogre::SDLInput, and Ogre::Win32Input8. Referenced by isKeyDown().

void Ogre::InputReader::keyChanged | ( | int | key,
|  | bool | down
| ) | `[protected]`

| Definition at line 185 of file OgreInput.cpp. References createKeyEvent(), Ogre::KC_LCONTROL, Ogre::KC_LMENU, Ogre::KC_LSHIFT, Ogre::KC_RCONTROL, Ogre::KC_RMENU, Ogre::KC_RSHIFT, mBufferedKeysDown, and mModifiers. Referenced by Ogre::GLXInput::capture(), Ogre::SDLInput::processBufferedKeyboard(), and Ogre::Win32Input8::readBufferedKeyboardData().

void Ogre::InputReader::mouseMoved | ( |  | ) | `[protected]`

| Creates mouse moved or dragged events depending if any button is pressed. Definition at line 161 of file OgreInput.cpp. References createMouseEvent(), and mModifiers. Referenced by Ogre::GLXInput::capture(), Ogre::SDLInput::processBufferedMouse(), and Ogre::Win32Input8::readBufferedMouseData().

void Ogre::InputReader::removeCursorMoveListener | ( | MouseMotionListener * | c | ) |

| Remove a mouse motion listener to the cursor object. This keeps the Cursor object hidden. Definition at line 179 of file OgreInput.cpp. References mCursor, and Ogre::MouseMotionTarget::removeMouseMotionListener(). Referenced by Ogre::EventProcessor::removeCursorMoveListener().

void Ogre::InputReader::setBufferedInput | ( | bool | keys,
|  | bool | mouse
| ) | `[virtual]`

| Reimplemented in Ogre::Win32Input8. Definition at line 71 of file OgreInput.cpp. References mUseBufferedKeys, and mUseBufferedMouse.

void Ogre::InputReader::setupKeyChars | ( |  | ) | `[protected]`

Definition at line 248 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 InputReader().

void Ogre::InputReader::triggerMouseButton | ( | int | nMouseCode,
|  | bool | mousePressed
| ) | `[protected]`

| Creates mouse pressed, released, and clicked events. Definition at line 88 of file OgreInput.cpp. References Ogre::MouseState::Buttons, createMouseEvent(), mModifiers, and mMouseState. Referenced by Ogre::GLXInput::capture(), Ogre::SDLInput::processBufferedMouse(), and Ogre::Win32Input8::readBufferedMouseData().

void Ogre::InputReader::useBufferedInput | ( | EventQueue * | pEventQueue,
|  | bool | keys = true,
|  | bool | mouse = true
| ) |

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 54 of file OgreInput.cpp.

References mCursor, mEventQueue, mUseBufferedKeys, and mUseBufferedMouse.

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

## Member Data Documentation

BufferedKeysDownSet Ogre::InputReader::mBufferedKeysDown`[protected]`

| Definition at line 346 of file OgreInput.h. Referenced by isKeyDown(), and keyChanged().

Cursor* Ogre::InputReader::mCursor`[protected]`

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 addCursorMoveListener(), Ogre::GLXInput::capture(), createMouseEvent(), InputReader(), Ogre::SDLInput::processBufferedMouse(), Ogre::Win32Input8::readBufferedMouseData(), removeCursorMoveListener(), useBufferedInput(), and ~InputReader().

EventQueue* Ogre::InputReader::mEventQueue`[protected]`

| EventQueue is used for buffered input support. Definition at line 334 of file OgreInput.h. Referenced by createKeyEvent(), createMouseEvent(), Ogre::GLXInput::GLXInput(), InputReader(), Ogre::SDLInput::SDLInput(), useBufferedInput(), and Ogre::Win32Input8::Win32Input8().

long Ogre::InputReader::mModifiers`[protected]`

| 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(), createKeyEvent(), createMouseEvent(), Ogre::Win32Input8::getKeyModifiers(), InputReader(), keyChanged(), mouseMoved(), and triggerMouseButton().

MouseState Ogre::InputReader::mMouseState`[protected]`

The mouse state in immediate mode.

Definition at line 342 of file OgreInput.h.

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

bool Ogre::InputReader::mUseBufferedKeys`[protected]`

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 InputReader(), Ogre::Win32Input8::setBufferedInput(), setBufferedInput(), and useBufferedInput().

bool Ogre::InputReader::mUseBufferedMouse`[protected]`

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::GLXInput::capture(), InputReader(), Ogre::Win32Input8::setBufferedInput(), setBufferedInput(), and useBufferedInput().

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

| Definition at line 37 of file OgreInput.cpp. Referenced by InputReader().

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

- OgreInput.h
- OgreInput.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:08 2004