OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Auto Repeat Key Input
View page
Source of version: 3
(current)
{maketoc} !!AutoRepeatKey.h {CODE(wrap="1", colors="c++")}#pragma once #include <OIS.h> class AutoRepeatKey { private: OIS::KeyCode m_nKey; unsigned int m_nChar; float m_fElapsed; float m_fDelay; float m_fRepeatDelay; float m_fInitialDelay; protected: virtual void repeatKey(OIS::KeyCode a_nKey, unsigned int a_nChar) = 0; public: AutoRepeatKey(float a_fRepeatDelay = 0.035f, float a_fInitialDelay = 0.300f); void begin(const OIS::KeyEvent &evt); void end(const OIS::KeyEvent &evt); void update(float a_fElapsed); // Elapsed time in seconds };{CODE} !!AutoRepeatKey.cpp {CODE(wrap="1", colors="c++")}#include "AutoRepeatKey.h" AutoRepeatKey::AutoRepeatKey(float a_fRepeatDelay, float a_fInitialDelay): m_nKey(OIS::KC_UNASSIGNED), m_fRepeatDelay(a_fRepeatDelay), m_fInitialDelay(a_fInitialDelay) {} void AutoRepeatKey::begin(const OIS::KeyEvent &evt) { m_nKey = evt.key; m_nChar = evt.text; m_fElapsed = 0; m_fDelay = m_fInitialDelay; } void AutoRepeatKey::end(const OIS::KeyEvent &evt) { if (m_nKey != evt.key) return; m_nKey = OIS::KC_UNASSIGNED; } void AutoRepeatKey::update(float a_fElapsed) { if (m_nKey == OIS::KC_UNASSIGNED) return; m_fElapsed += a_fElapsed; if (m_fElapsed < m_fDelay) return; m_fElapsed -= m_fDelay; m_fDelay = m_fRepeatDelay; do { repeatKey(m_nKey, m_nChar); m_fElapsed -= m_fRepeatDelay; } while (m_fElapsed >= m_fRepeatDelay); m_fElapsed = 0; }{CODE}
Search by Tags
Search Wiki by Freetags
Latest Changes
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
...more
Search
Find
Advanced
Search Help
Online Users
72 online users