Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2008, 12:12:18 AM (17 years ago)
Author:
landauf
Message:
  • added input buffer: this class captures key-input (at the moment it's using OIS directly, later it will use the InputHandler) and writes it into a string - other classes can listen to changes and can read and modify the string.
  • fixed some bugs in CommandExecutor
  • fixed a small bug (or changed a questionable feature) in Functor
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/Orxonox.cc

    r874 r955  
    8686#include "objects/test3.h"
    8787
     88#include "core/CommandExecutor.h"
     89#include "core/InputBuffer.h"
     90
    8891#include "Orxonox.h"
    8992
    9093namespace orxonox
    9194{
     95    class Testlistener : public InputBufferListener
     96    {
     97        public:
     98            Testlistener(InputBuffer* ib) : ib_(ib) {}
     99            void listen() const
     100            {
     101                std::cout << "> -->" << this->ib_->get() << "<--" << std::endl;
     102            }
     103            void execute() const
     104            {
     105std::cout << "### EXECUTE!" << std::endl;
     106                CommandExecutor::execute(this->ib_->get());
     107                this->ib_->clear();
     108            }
     109            void hintandcomplete() const
     110            {
     111std::cout << "### HINT!" << std::endl;
     112                std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
     113                this->ib_->set(CommandExecutor::complete(this->ib_->get()));
     114            }
     115            void clear() const
     116            {
     117std::cout << "### CLEAR!" << std::endl;
     118                this->ib_->clear();
     119            }
     120            void removeLast() const
     121            {
     122std::cout << "### REMOVELAST!" << std::endl;
     123                this->ib_->removeLast();
     124            }
     125
     126        private:
     127            InputBuffer* ib_;
     128    };
     129
    92130   // put this in a seperate Class or solve the problem in another fashion
    93131  class OrxListener : public Ogre::FrameListener
     
    11461184        std::cout << "2\n";
    11471185*/
     1186        InputBuffer* ib = new InputBuffer(this->getKeyboard());
     1187        Testlistener* testlistener = new Testlistener(ib);
     1188        ib->registerListener(testlistener, &Testlistener::listen, true);
     1189        ib->registerListener(testlistener, &Testlistener::execute, '\r', false);
     1190        ib->registerListener(testlistener, &Testlistener::hintandcomplete, '\t', true);
     1191        ib->registerListener(testlistener, &Testlistener::clear, '§', true);
     1192        ib->registerListener(testlistener, &Testlistener::removeLast, '\b', true);
     1193
    11481194    startRenderLoop();
    11491195  }
     
    13641410    try
    13651411    {
    1366       keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));
     1412      keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, true));
    13671413      mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));
    13681414    }
Note: See TracChangeset for help on using the changeset viewer.