Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/input/InputManager.cc

    r5781 r5929  
    4141#include <boost/foreach.hpp>
    4242
     43#include "util/Clock.h"
    4344#include "util/Convert.h"
    4445#include "util/Exception.h"
    4546#include "util/ScopeGuard.h"
    46 #include "core/Clock.h"
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
     
    5353
    5454#include "InputBuffer.h"
    55 #include "KeyDetector.h"
    5655#include "JoyStick.h"
    5756#include "JoyStickQuantityListener.h"
     
    8887        , oisInputManager_(0)
    8988        , devices_(2)
    90         , bExclusiveMouse_(false)
     89        , mouseMode_(MouseMode::Nonexclusive)
    9190        , emptyState_(0)
    92         , keyDetector_(0)
    9391        , calibratorCallbackHandler_(0)
    9492    {
     
    9997        this->setConfigValues();
    10098
     99        if (GraphicsManager::getInstance().isFullScreen())
     100            mouseMode_ = MouseMode::Exclusive;
    101101        this->loadDevices();
    102102
     
    105105        emptyState_->setHandler(&InputHandler::EMPTY);
    106106        activeStates_[emptyState_->getPriority()] = emptyState_;
    107 
    108         // KeyDetector to evaluate a pressed key's name
    109         InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
    110         // Create a callback to avoid buttonHeld events after the key has been detected
    111         FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);
    112         bufferFunctor->setObject(this);
    113         detector->setLeaveFunctor(bufferFunctor);
    114         keyDetector_ = new KeyDetector();
    115         detector->setHandler(keyDetector_);
    116107
    117108        // Joy stick calibration helper callback
     
    124115        this->updateActiveStates();
    125116
    126         {
    127             // calibrate console command
    128             FunctorMember<InputManager>* functor = createFunctor(&InputManager::calibrate);
    129             functor->setObject(this);
    130             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "calibrate"), true);
    131         }
    132         {
    133             // reload console command
    134             FunctorMember<InputManager>* functor = createFunctor(&InputManager::reload);
    135             functor->setObject(this);
    136             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "reload"), false);
    137         }
     117        // calibrate console command
     118        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true);
     119        // reload console command
     120        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false);
    138121
    139122        CCOUT(4) << "Construction complete." << std::endl;
     
    172155        paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND"));
    173156        paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND"));
    174         if (bExclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
     157        if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
    175158        {
    176159            // Disable Windows key plus special keys (like play, stop, next, etc.)
     
    185168        paramList.insert(std::make_pair("XAutoRepeatOn", "true"));
    186169
    187         if (bExclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
     170        if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
    188171        {
    189172            if (CommandLine::getValue("keyboard_no_grab").getBool())
     
    274257    }
    275258
    276     void InputManager::setKeyDetectorCallback(const std::string& command)
    277     {
    278         this->keyDetector_->setCallbackCommand(command);
    279     }
    280 
    281259    // ############################################################
    282260    // #####                    Destruction                   #####
     
    289267
    290268        // Destroy calibrator helper handler and state
    291         delete keyDetector_;
    292269        this->destroyState("calibrator");
    293270        // Destroy KeyDetector and state
    294         delete calibratorCallbackHandler_;
    295         this->destroyState("detector");
     271        calibratorCallbackHandler_->destroy();
    296272        // destroy the empty InputState
    297273        this->destroyStateInternal(this->emptyState_);
     
    528504
    529505        // Check whether we have to change the mouse mode
     506        MouseMode::Value requestedMode = MouseMode::Dontcare;
    530507        std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
    531         if (mouseStates.empty() && bExclusiveMouse_ ||
    532             !mouseStates.empty() && mouseStates.front()->getIsExclusiveMouse() != bExclusiveMouse_)
    533         {
    534             bExclusiveMouse_ = !bExclusiveMouse_;
     508        if (mouseStates.empty())
     509            requestedMode = MouseMode::Nonexclusive;
     510        else
     511            requestedMode = mouseStates.front()->getMouseMode();
     512        if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)
     513        {
     514            mouseMode_ = requestedMode;
    535515            if (!GraphicsManager::getInstance().isFullScreen())
    536516                this->reloadInternal();
     
    722702        }
    723703        statesByName_.erase(state->getName());
    724         delete state;
     704        state->destroy();
    725705    }
    726706}
Note: See TracChangeset for help on using the changeset viewer.