Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreWin32Input8.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Win32Input8_H__
00026 #define __Win32Input8_H__
00027 
00028 #include "OgreWin32Prerequisites.h"
00029 #include "OgreInput.h"
00030 #include "OgreInputEvent.h"
00031 
00032 #include <dinput.h>
00033 
00034 namespace Ogre {
00035 
00039     class Win32Input8 : public InputReader
00040     {
00041     public:
00042 
00043         Win32Input8();
00044         ~Win32Input8();
00045 
00047         virtual void initialise(
00048             RenderWindow* pWindow, 
00049             bool useKeyboard = true, 
00050             bool useMouse = true, 
00051             bool useGameController = false );
00052 
00054         virtual void capture();
00055 
00057         virtual bool isKeyDown(KeyCode kc) const;
00058 
00059         /*
00060          *  Mouse getters.
00061          */
00062         virtual long getMouseRelX() const;
00063         virtual long getMouseRelY() const;
00064         virtual long getMouseRelZ() const;
00065 
00066         virtual long getMouseAbsX() const;
00067         virtual long getMouseAbsY() const;
00068         virtual long getMouseAbsZ() const;
00069 
00070         virtual void getMouseState( MouseState& state ) const;
00071 
00072         virtual bool getMouseButton( uchar button ) const;
00073 
00074         void setBufferedInput(bool keys, bool mouse) ;
00075         void flushAllBuffers() ;
00076     private:
00077         // Input device details
00078         IDirectInput8* mlpDI;
00079         IDirectInputDevice8* mlpDIKeyboard;
00080         IDirectInputDevice8* mlpDIMouse;
00081 
00082         HWND mHWnd;
00083 
00085         void initialiseBufferedKeyboard();
00086         void initialiseImmediateKeyboard();
00087         void initialiseBufferedMouse();
00088         void initialiseImmediateMouse();
00089 
00090         /* immediate mode */
00091         void captureKeyboard(void);
00092         void captureMouse(void);
00093 
00094         /* buffered mode */
00095         bool readBufferedKeyboardData();
00096         bool readBufferedMouseData();
00097 
00098         /* State of modifiers at last 'capture' call 
00099            NOTE this doesn't support keyboard buffering yet */
00100         long getKeyModifiers() const;
00101 
00102     private:
00103         /* For mouse immediate mode. Note that the space origin in DX is (0,0,0), here we
00104            only hold the 'last' center for relative input. */
00105         long mMouseCenterX, mMouseCenterY, mMouseCenterZ;
00106         bool mUseKeyboard, mUseMouse;
00107 
00108         /* For mouse buffered mode. */
00109         Real mScale;
00110         Real getScaled(DWORD dwVal) const;
00111 
00112         /* For keyboard immediate mode. */
00113         char mKeyboardBuffer[256];
00114     };
00115 
00116 
00117 
00118 }
00119 
00120 
00121 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:55 2004