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
    00030 #ifndef DX7INPUTONLY
    00031
    00032 #include "OgreInput.h"
    00033 #include "OgreInputEvent.h"
    00034
    00035 #include <dinput.h>
    00036
    00037 namespace Ogre {
    00038
    00042     class Win32Input8 : public InputReader
    00043     {
    00044     public:
    00045
    00046         Win32Input8();
    00047         ~Win32Input8();
    00048
    00050         virtual void initialise(
    00051             RenderWindow* pWindow,
    00052             bool useKeyboard = true,
    00053             bool useMouse = true,
    00054             bool useGameController = false );
    00055
    00057         virtual void capture();
    00058
    00059
    00060         /*
    00061          *  Mouse getters.
    00062          */
    00063         virtual long getMouseRelX() const;
    00064         virtual long getMouseRelY() const;
    00065         virtual long getMouseRelZ() const;
    00066
    00067         virtual long getMouseAbsX() const;
    00068         virtual long getMouseAbsY() const;
    00069         virtual long getMouseAbsZ() const;
    00070
    00071         virtual void getMouseState( MouseState& state ) const;
    00072
    00073         virtual bool getMouseButton( uchar button ) const;
    00074
    00075         void setBufferedInput(bool keys, bool mouse) ;
    00076         void flushAllBuffers() ;
    00077     protected:
    00079         virtual bool isKeyDownImmediate(KeyCode kc) const;
    00080
    00081     private:
    00082         // Input device details
    00083         IDirectInput8* mlpDI;
    00084         IDirectInputDevice8* mlpDIKeyboard;
    00085         IDirectInputDevice8* mlpDIMouse;
    00086
    00087         HWND mHWnd;
    00088
    00090         void initialiseBufferedKeyboard();
    00091         void initialiseImmediateKeyboard();
    00092         void initialiseBufferedMouse();
    00093         void initialiseImmediateMouse();
    00094
    00095         /* immediate mode */
    00096         void captureKeyboard(void);
    00097         void captureMouse(void);
    00098
    00099         /* buffered mode */
    00100         bool readBufferedKeyboardData();
    00101         bool readBufferedMouseData();
    00102
    00103         /* State of modifiers at last 'capture' call
    00104            NOTE this doesn't support keyboard buffering yet */
    00105         long getKeyModifiers() const;
    00106
    00107         /* For mouse immediate mode. Note that the space origin in DX is (0,0,0), here we
    00108            only hold the 'last' center for relative input. */
    00109         long mMouseCenterX, mMouseCenterY, mMouseCenterZ;
    00110         bool mUseKeyboard, mUseMouse;
    00111
    00112         /* For mouse buffered mode. */
    00113         Real mScale;
    00114         Real getScaled(DWORD dwVal) const;
    00115
    00116         /* For keyboard immediate mode. */
    00117         char mKeyboardBuffer[256];
    00118     };
    00119
    00120
    00121
    00122 }
    00123
    00124 #endif
    00125 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:51 2004