1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
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 | #ifndef __Win32Input8_H__
|
---|
26 | #define __Win32Input8_H__
|
---|
27 |
|
---|
28 | #include "OgreWin32Prerequisites.h"
|
---|
29 |
|
---|
30 | #ifndef OGRE_NO_DX_INPUT
|
---|
31 |
|
---|
32 | #ifndef DX7INPUTONLY
|
---|
33 |
|
---|
34 | #include "OgreInput.h"
|
---|
35 | #include "OgreInputEvent.h"
|
---|
36 |
|
---|
37 | #include <dinput.h>
|
---|
38 |
|
---|
39 | namespace Ogre {
|
---|
40 |
|
---|
41 | /** Utility class for dealing with user input on a Win32 system.
|
---|
42 | Note that this is a basic implementation only at the moment.
|
---|
43 | */
|
---|
44 | class Win32Input8 : public InputReader
|
---|
45 | {
|
---|
46 | public:
|
---|
47 |
|
---|
48 | Win32Input8();
|
---|
49 | ~Win32Input8();
|
---|
50 |
|
---|
51 | /** @copydoc InputReader::initialise */
|
---|
52 | virtual void initialise(
|
---|
53 | RenderWindow* pWindow,
|
---|
54 | bool useKeyboard = true,
|
---|
55 | bool useMouse = true,
|
---|
56 | bool useGameController = false );
|
---|
57 |
|
---|
58 | /** @copydoc InputReader::capture */
|
---|
59 | virtual void capture();
|
---|
60 |
|
---|
61 |
|
---|
62 | /*
|
---|
63 | * Mouse getters.
|
---|
64 | */
|
---|
65 | virtual long getMouseRelX() const;
|
---|
66 | virtual long getMouseRelY() const;
|
---|
67 | virtual long getMouseRelZ() const;
|
---|
68 |
|
---|
69 | virtual long getMouseAbsX() const;
|
---|
70 | virtual long getMouseAbsY() const;
|
---|
71 | virtual long getMouseAbsZ() const;
|
---|
72 |
|
---|
73 | virtual void getMouseState( MouseState& state ) const;
|
---|
74 |
|
---|
75 | virtual bool getMouseButton( uchar button ) const;
|
---|
76 |
|
---|
77 | void setBufferedInput(bool keys, bool mouse) ;
|
---|
78 | void flushAllBuffers() ;
|
---|
79 | protected:
|
---|
80 | /** @copydoc InputReader::isKeyDown */
|
---|
81 | virtual bool isKeyDownImmediate(KeyCode kc) const;
|
---|
82 |
|
---|
83 | private:
|
---|
84 | // Input device details
|
---|
85 | IDirectInput8* mlpDI;
|
---|
86 | IDirectInputDevice8* mlpDIKeyboard;
|
---|
87 | IDirectInputDevice8* mlpDIMouse;
|
---|
88 |
|
---|
89 | HWND mHWnd;
|
---|
90 |
|
---|
91 | /** specialised initialisation routines */
|
---|
92 | void initialiseBufferedKeyboard();
|
---|
93 | void initialiseImmediateKeyboard();
|
---|
94 | void initialiseBufferedMouse();
|
---|
95 | void initialiseImmediateMouse();
|
---|
96 |
|
---|
97 | /* immediate mode */
|
---|
98 | void captureKeyboard(void);
|
---|
99 | void captureMouse(void);
|
---|
100 |
|
---|
101 | /* buffered mode */
|
---|
102 | bool readBufferedKeyboardData();
|
---|
103 | bool readBufferedMouseData();
|
---|
104 |
|
---|
105 | /* State of modifiers at last 'capture' call
|
---|
106 | NOTE this doesn't support keyboard buffering yet */
|
---|
107 | long getKeyModifiers() const;
|
---|
108 |
|
---|
109 | /* For mouse immediate mode. Note that the space origin in DX is (0,0,0), here we
|
---|
110 | only hold the 'last' center for relative input. */
|
---|
111 | long mMouseCenterX, mMouseCenterY, mMouseCenterZ;
|
---|
112 | bool mUseKeyboard, mUseMouse;
|
---|
113 |
|
---|
114 | /* For mouse buffered mode. */
|
---|
115 | Real getScaled(DWORD dwVal) const;
|
---|
116 |
|
---|
117 | /* For keyboard immediate mode. */
|
---|
118 | char mKeyboardBuffer[256];
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 | #endif
|
---|
126 | #endif
|
---|
127 | #endif
|
---|