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

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Nov 20 12:36:09 2005