Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/input/InputState.cc @ 5696

Last change on this file since 5696 was 5695, checked in by rgrieder, 15 years ago

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

  • Property svn:eol-style set to native
File size: 3.3 KB
RevLine 
[1637]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[3274]29#include "InputState.h"
30#include "core/Functor.h"
[1637]31
32namespace orxonox
33{
[3327]34    //! Sets priority of it's a high priority and resizes the handler list
35    InputState::InputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
36        : name_(name)
37        , bAlwaysGetsInput_(bAlwaysGetsInput)
38        , bTransparent_(bTransparent)
[5695]39        , bExclusiveMouse_(true)
[3274]40        , bExpired_(true)
41        , handlers_(2)
[1637]42        , joyStickHandlerAll_(0)
[3274]43        , enterFunctor_(0)
44        , leaveFunctor_(0)
[1637]45    {
[3327]46        if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
47            priority_ = priority;
48        else
49            priority_ = 0;
50
51        handlers_.resize(InputDeviceEnumerator::FirstJoyStick + this->getJoyStickList().size(), NULL);
[1637]52    }
53
[3274]54    bool InputState::isInputDeviceEnabled(unsigned int device)
[1637]55    {
[3274]56        if (device < handlers_.size())
57            return handlers_[device] != NULL;
58        else
59            return false;
60    }
[1637]61
[3327]62    //! Called by JoyStickQuantityListener upon joy stick adding/removal
63    void InputState::JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList)
[3274]64    {
65        unsigned int oldSize = handlers_.size();
[3327]66        handlers_.resize(InputDeviceEnumerator::FirstJoyStick + joyStickList.size(), NULL);
[3274]67
68        for (unsigned int i = oldSize; i < handlers_.size(); ++i)
69            handlers_[i] = joyStickHandlerAll_;
70
71        bExpired_ = true;
[1637]72    }
73
[3274]74    bool InputState::setJoyStickHandler(InputHandler* handler, unsigned int joyStick)
[1637]75    {
[3274]76        unsigned device = joyStick + firstJoyStickIndex_s;
77        if (joyStick >= handlers_.size() - device)
[1637]78            return false;
79
[3274]80        handlers_[device] = handler;
81        bExpired_ = true;
[1637]82        return true;
83    }
84
[3327]85    void InputState::setJoyStickHandler(InputHandler* handler)
[1637]86    {
87        joyStickHandlerAll_ = handler;
[3274]88        for (unsigned int i = firstJoyStickIndex_s; i < handlers_.size(); ++i)
89            handlers_[i] = handler;
90        bExpired_ = true;
[1637]91    }
92
[3327]93    void InputState::setHandler(InputHandler* handler)
[1637]94    {
[3274]95        setKeyHandler(handler);
96        setMouseHandler(handler);
[3327]97        setJoyStickHandler(handler);
[1637]98    }
99
[3274]100    void InputState::entered()
[1637]101    {
[3274]102        if (enterFunctor_)
103            (*enterFunctor_)();
104           
[1637]105    }
[3196]106
[3274]107    void InputState::left()
[3196]108    {
[3274]109        if (leaveFunctor_)
110            (*leaveFunctor_)();
[3196]111    }
[1637]112}
Note: See TracBrowser for help on using the repository browser.