[692] | 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 __Win32Input_H__
|
---|
| 26 | #define __Win32Input_H__
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | #include "OgreWin32Prerequisites.h"
|
---|
| 30 |
|
---|
| 31 | #ifndef OGRE_NO_DX_INPUT
|
---|
| 32 |
|
---|
| 33 | #ifdef DX7INPUTONLY
|
---|
| 34 | #include "OgreInput.h"
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | #include <dinput.h>
|
---|
| 39 |
|
---|
| 40 | namespace Ogre {
|
---|
| 41 |
|
---|
| 42 | /** Utility class for dealing with user input on a Win32 system.
|
---|
| 43 | Note that this is a basic implementation only at the moment.
|
---|
| 44 | */
|
---|
| 45 | class Win32Input : public InputReader
|
---|
| 46 | {
|
---|
| 47 | public:
|
---|
| 48 |
|
---|
| 49 | Win32Input();
|
---|
| 50 | ~Win32Input();
|
---|
| 51 |
|
---|
| 52 | /** Initialise the input system.
|
---|
| 53 | @param pWindow The window to capture input for
|
---|
| 54 | @param useKeyboard If true, keyboard input will be supported.
|
---|
| 55 | @param useMouse If true, mouse input will be supported.
|
---|
| 56 | @param useGameController If true, joysticks/gamepads will be supported.
|
---|
| 57 | */
|
---|
| 58 | void initialise(RenderWindow* pWindow, bool useKeyboard = true, bool useMouse = true, bool useGameController = false);
|
---|
| 59 |
|
---|
| 60 | /** Captures the state of all the input devices.
|
---|
| 61 | This method captures the state of all input devices and stores it internally for use when
|
---|
| 62 | the enquiry methods are next called. This is done to ensure that all input is captured at once
|
---|
| 63 | and therefore combinations of input are not subject to time differences when methods are called.
|
---|
| 64 |
|
---|
| 65 | */
|
---|
| 66 | void capture(void);
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | /*
|
---|
| 70 | * Mouse getters.
|
---|
| 71 | */
|
---|
| 72 | virtual long getMouseRelX() const;
|
---|
| 73 | virtual long getMouseRelY() const;
|
---|
| 74 | virtual long getMouseRelZ() const{return 0;};
|
---|
| 75 |
|
---|
| 76 | virtual long getMouseAbsX() const{return 0;};
|
---|
| 77 | virtual long getMouseAbsY() const{return 0;};
|
---|
| 78 | virtual long getMouseAbsZ() const{return 0;};
|
---|
| 79 |
|
---|
| 80 | virtual void getMouseState( MouseState& state ) const{};
|
---|
| 81 |
|
---|
| 82 | virtual bool getMouseButton( uchar button ) const{return false;};
|
---|
| 83 |
|
---|
| 84 | // void setBufferedInput(bool keys, bool mouse) ;
|
---|
| 85 | // void flushAllBuffers() ;
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | protected:
|
---|
| 89 | /** Determines if the specified key is currently depressed.
|
---|
| 90 | Note that this enquiry method uses the state of the keyboard at the last 'capture' call.
|
---|
| 91 | */
|
---|
| 92 | bool isKeyDownImmediate(KeyCode kc) const ;
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | private:
|
---|
| 96 | // Input device details
|
---|
| 97 | LPDIRECTINPUT7 mlpDI;
|
---|
| 98 | LPDIRECTINPUTDEVICE7 mlpDIKeyboard;
|
---|
| 99 | LPDIRECTINPUTDEVICE7 mlpDIMouse;
|
---|
| 100 |
|
---|
| 101 | HWND mHWnd;
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | // State of keyboard at last 'capture' call
|
---|
| 105 | char mKeyboardBuffer[256];
|
---|
| 106 | int mMouseX, mMouseY;
|
---|
| 107 | int mMouseCenterX, mMouseCenterY;
|
---|
| 108 | bool mLMBDown, mRMBDown;
|
---|
| 109 | };
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | #endif
|
---|
| 116 | #endif
|
---|
| 117 | #endif
|
---|