1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef INCL_GTKINPUT_H
|
---|
27 | #define INCL_GTKINPUT_H
|
---|
28 |
|
---|
29 | #include "OgreInput.h"
|
---|
30 |
|
---|
31 | #include <gdk/gdkevents.h>
|
---|
32 | #include <gtkmm/window.h>
|
---|
33 | #include <gtkmm/main.h>
|
---|
34 | #include <gtkmm/gl/drawingarea.h>
|
---|
35 |
|
---|
36 | #include <sigc++/object.h>
|
---|
37 |
|
---|
38 | namespace Ogre {
|
---|
39 |
|
---|
40 | class GTKInput : public InputReader, public SigC::Object
|
---|
41 | {
|
---|
42 | public:
|
---|
43 | GTKInput();
|
---|
44 | virtual ~GTKInput();
|
---|
45 |
|
---|
46 | void initialise( RenderWindow* pWindow, bool useKeyboard = true, bool useMouse = true, bool useGameController = false );
|
---|
47 | void capture();
|
---|
48 |
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Mouse getters
|
---|
52 | */
|
---|
53 | virtual long getMouseRelX() const;
|
---|
54 | virtual long getMouseRelY() const;
|
---|
55 | virtual long getMouseRelZ() const;
|
---|
56 |
|
---|
57 | virtual long getMouseAbsX() const;
|
---|
58 | virtual long getMouseAbsY() const;
|
---|
59 | virtual long getMouseAbsZ() const;
|
---|
60 |
|
---|
61 | virtual void getMouseState( MouseState& state ) const;
|
---|
62 |
|
---|
63 | virtual bool getMouseButton( uchar button ) const;
|
---|
64 |
|
---|
65 | protected:
|
---|
66 | bool on_mouse_motion(GdkEventMotion* event);
|
---|
67 | bool on_key_press(GdkEventKey* event);
|
---|
68 | bool on_key_release(GdkEventKey* event);
|
---|
69 | bool on_button_press(GdkEventButton* event);
|
---|
70 | bool on_button_release(GdkEventButton* event);
|
---|
71 | bool isKeyDownImmediate( KeyCode kc ) const;
|
---|
72 |
|
---|
73 | private:
|
---|
74 | // Capture mouse?
|
---|
75 | bool mUseMouse;
|
---|
76 | int mMouseX, mMouseY;
|
---|
77 | int mMouseCenterX, mMouseCenterY;
|
---|
78 |
|
---|
79 | Real mScale;
|
---|
80 | unsigned int mMouseKeys;
|
---|
81 | bool _visible;
|
---|
82 | typedef std::map<guint, KeyCode> InputKeyMap;
|
---|
83 | InputKeyMap _key_map;
|
---|
84 | typedef std::map<KeyCode, guint> RInputKeyMap;
|
---|
85 | RInputKeyMap _rkey_map;
|
---|
86 | typedef std::set<guint> CurKeySet;
|
---|
87 | CurKeySet _cur_keys;
|
---|
88 | CurKeySet _captured_keys;
|
---|
89 | //GTKWindow* _win;
|
---|
90 | Gtk::Window *_win;
|
---|
91 | Gtk::GL::DrawingArea * _widget;
|
---|
92 | Gtk::Main *_kit;
|
---|
93 | }; // class GTKInput
|
---|
94 |
|
---|
95 | }; // namespace Ogre
|
---|
96 |
|
---|
97 | #endif // INCL_GTKINPUT_H
|
---|