[3274] | 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 | |
---|
| 29 | #ifndef _Core_Mouse_H__ |
---|
| 30 | #define _Core_Mouse_H__ |
---|
| 31 | |
---|
| 32 | #include "InputPrereqs.h" |
---|
| 33 | #include "InputDevice.h" |
---|
| 34 | |
---|
| 35 | namespace orxonox |
---|
| 36 | { |
---|
| 37 | /** |
---|
| 38 | @brief |
---|
| 39 | Wraps around an OIS::Mouse and forwards the input events to |
---|
| 40 | a list of input states. |
---|
| 41 | */ |
---|
| 42 | class _CoreExport Mouse |
---|
| 43 | : public InputDeviceTemplated<MouseTraits> |
---|
| 44 | , public OIS::MouseListener |
---|
| 45 | { |
---|
[3275] | 46 | friend class InputDeviceTemplated<MouseTraits>; |
---|
[3274] | 47 | //! Super class alias |
---|
| 48 | typedef InputDeviceTemplated<MouseTraits> super; |
---|
| 49 | |
---|
| 50 | public: |
---|
| 51 | Mouse(unsigned int id, unsigned int windowWidth, unsigned int windowHeight); |
---|
| 52 | ~Mouse() { } |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | @brief |
---|
| 56 | Adjusts the mouse window metrics. |
---|
| 57 | |
---|
| 58 | This method has to be called every time the size of the window changes. |
---|
| 59 | */ |
---|
| 60 | void setMouseClipping(unsigned int width, unsigned int height); |
---|
| 61 | unsigned int getClippingWidth() const; |
---|
| 62 | unsigned int getClippingHeight() const; |
---|
| 63 | |
---|
| 64 | // HACK: |
---|
| 65 | static void setMouseClipping_s(unsigned int width, unsigned int height) |
---|
| 66 | { instancePointer_s->setMouseClipping(width, height); } |
---|
| 67 | void setConfigValues() { } |
---|
| 68 | |
---|
| 69 | private: |
---|
| 70 | // TODO: Do we need to reset the mouse position? |
---|
| 71 | void clearBuffersImpl() { } |
---|
| 72 | |
---|
| 73 | //! OIS event handler |
---|
| 74 | bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id) |
---|
| 75 | { |
---|
| 76 | super::buttonPressed(static_cast<MouseButtonCode::ByEnum>(id)); |
---|
| 77 | return true; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | //! OIS event handler |
---|
| 81 | bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id) |
---|
| 82 | { |
---|
| 83 | super::buttonReleased(static_cast<MouseButtonCode::ByEnum>(id)); |
---|
| 84 | return true; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | bool mouseMoved(const OIS::MouseEvent &arg); |
---|
| 88 | |
---|
| 89 | // HACK: |
---|
| 90 | static Mouse* instancePointer_s; |
---|
| 91 | }; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | #endif /* _Core_Mouse_H__ */ |
---|