Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2009, 5:31:02 PM (15 years ago)
Author:
rgrieder
Message:

Merged all remaining revisions from core4 back to the trunk.

Location:
code/trunk
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/input/Mouse.cc

    r3276 r3327  
    3030
    3131#include <ois/OISMouse.h>
    32 #include <boost/foreach.hpp>
     32#include "core/ConsoleCommand.h"
     33#include "core/CoreIncludes.h"
    3334#include "InputState.h"
    34 #include "core/ConsoleCommand.h"
    3535
    36 // HACK (include this as last, X11 seems to define some macros...)
    3736#ifdef ORXONOX_PLATFORM_LINUX
    38 #  include <ois/linux/LinuxMouse.h>
     37// include this as last, X11 seems to define some macros...
     38#include <ois/linux/LinuxMouse.h>
    3939#endif
    4040
    4141namespace orxonox
    4242{
    43     Mouse::Mouse(unsigned int id, unsigned int windowWidth, unsigned int windowHeight)
    44         : super(id)
     43    Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
     44        : super(id, oisInputManager)
    4545    {
    46         this->setMouseClipping(windowWidth, windowHeight);
    47         // HACK:
    48         instancePointer_s = this;
    49     }
     46        RegisterRootObject(Mouse);
     47        this->windowResized(this->getWindowWidth(), this->getWindowHeight());
    5048
    51     void Mouse::setMouseClipping(unsigned int width, unsigned int height)
    52     {
    53         oisDevice_->getMouseState().width  = width;
    54         oisDevice_->getMouseState().height = height;
    55     }
    56 
    57     unsigned int Mouse::getClippingWidth() const
    58     {
    59         return oisDevice_->getMouseState().width;
    60     }
    61 
    62     unsigned int Mouse::getClippingHeight() const
    63     {
    64         return oisDevice_->getMouseState().height;
     49#ifdef ORXONOX_PLATFORM_LINUX
     50        {
     51            // Mouse grab console command
     52            FunctorMember<Mouse>* functor = createFunctor(&Mouse::grab);
     53            functor->setObject(this);
     54            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "grab"), false);
     55        }
     56        {
     57            // Mouse ungrab console command
     58            FunctorMember<Mouse>* functor = createFunctor(&Mouse::ungrab);
     59            functor->setObject(this);
     60            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "ungrab"), false);
     61        }
     62#endif
    6563    }
    6664
     
    7472            IntVector2 rel(e.state.X.rel, e.state.Y.rel);
    7573            IntVector2 clippingSize(e.state.width, e.state.height);
    76             BOOST_FOREACH(InputState* state, inputStates_)
    77                 state->mouseMoved(abs, rel, clippingSize);
     74            for (unsigned int i = 0; i < inputStates_.size(); ++i)
     75                inputStates_[i]->mouseMoved(abs, rel, clippingSize);
    7876        }
    7977
     
    8179        if (e.state.Z.rel != 0)
    8280        {
    83             BOOST_FOREACH(InputState* state, inputStates_)
    84                 state->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
     81            for (unsigned int i = 0; i < inputStates_.size(); ++i)
     82                inputStates_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
    8583        }
    8684
     
    8886    }
    8987
    90     // ############################################################
    91     // #####                   ugly hacks                     #####
    92     // ##########                                        ##########
    93     // ############################################################
    94 
    95     // HACK:
    96     SetConsoleCommand(Mouse, setMouseClipping_s, false);
    97 #ifdef ORXONOX_PLATFORM_LINUX
    98     SetConsoleCommand(Mouse, grabMouse, true);
    99     SetConsoleCommand(Mouse, ungrabMouse, true);
    100 #endif
    101     Mouse* Mouse::instancePointer_s = NULL;
     88    void Mouse::windowResized(unsigned int newWidth, unsigned int newHeight)
     89    {
     90        oisDevice_->getMouseState().width  = newWidth;
     91        oisDevice_->getMouseState().height = newHeight;
     92    }
    10293
    10394#ifdef ORXONOX_PLATFORM_LINUX
    104     void Mouse::grabMouse()
     95    void Mouse::grab()
    10596    {
    106         OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(instancePointer_s->oisDevice_);
     97        OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(oisDevice_);
    10798        assert(linuxMouse);
    10899        linuxMouse->grab(true);
    109100    }
    110101
    111     void Mouse::ungrabMouse()
     102    void Mouse::ungrab()
    112103    {
    113         OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(instancePointer_s->oisDevice_);
     104        OIS::LinuxMouse* linuxMouse = dynamic_cast<OIS::LinuxMouse*>(oisDevice_);
    114105        assert(linuxMouse);
    115106        linuxMouse->grab(false);
Note: See TracChangeset for help on using the changeset viewer.