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://ogre.sourceforge.net/
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     private:
00075         // Input device details
00076         IDirectInput8* mlpDI;
00077         IDirectInputDevice8* mlpDIKeyboard;
00078         IDirectInputDevice8* mlpDIMouse;
00079 
00080         HWND mHWnd;
00081 
00083         void initialiseBufferedKeyboard();
00084         void initialiseImmediateKeyboard();
00085         void initialiseBufferedMouse();
00086         void initialiseImmediateMouse();
00087 
00088         /* immediate mode */
00089         void captureKeyboard(void);
00090         void captureMouse(void);
00091 
00092         /* buffered mode */
00093         bool readBufferedKeyboardData();
00094         bool readBufferedMouseData();
00095 
00096         /* State of modifiers at last 'capture' call 
00097            NOTE this doesn't support keyboard buffering yet */
00098         long getKeyModifiers();
00099 
00100     private:
00101         /* For mouse immediate mode. Note that the space origin in DX is (0,0,0), here we
00102            only hold the 'last' center for relative input. */
00103         long mMouseCenterX, mMouseCenterY, mMouseCenterZ;
00104 
00105         /* For mouse buffered mode. */
00106         Real mScale;
00107         Real getScaled(DWORD dwVal);
00108 
00109         /* For keyboard immediate mode. */
00110         char mKeyboardBuffer[256];
00111     };
00112 
00113 
00114 
00115 }
00116 
00117 
00118 #endif

Copyright © 2002 by The OGRE Team