Blender  V2.59
SCA_MouseSensor.h
Go to the documentation of this file.
00001 /*
00002  * $Id: SCA_MouseSensor.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): José I. Romero (cleanup and fixes)
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00035 #ifndef __KX_MOUSESENSOR
00036 #define __KX_MOUSESENSOR
00037 
00038 #include "SCA_ISensor.h"
00039 #include "BoolValue.h"
00040 #include "SCA_IInputDevice.h"
00041 
00042 class SCA_MouseSensor : public SCA_ISensor
00043 {
00044         Py_Header;
00045         
00049         short int m_mousemode;
00054         bool m_triggermode;
00058         int m_val;
00059 
00060         SCA_IInputDevice::KX_EnumInputs m_hotkey;
00061         
00065         short m_x;
00066 
00070         short m_y;
00071         
00072  public:
00076         enum KX_MOUSESENSORMODE {
00077                 KX_MOUSESENSORMODE_NODEF = 0,
00078                 KX_MOUSESENSORMODE_LEFTBUTTON,
00079                 KX_MOUSESENSORMODE_MIDDLEBUTTON,
00080                 KX_MOUSESENSORMODE_RIGHTBUTTON,
00081                 KX_MOUSESENSORMODE_WHEELUP,
00082                 KX_MOUSESENSORMODE_WHEELDOWN,
00083                 KX_MOUSESENSORMODE_POSITION,
00084                 KX_MOUSESENSORMODE_POSITIONX,
00085                 KX_MOUSESENSORMODE_POSITIONY,
00086                 KX_MOUSESENSORMODE_MOVEMENT,
00087                 KX_MOUSESENSORMODE_MAX
00088         };
00089 
00090         bool isValid(KX_MOUSESENSORMODE);
00091         
00092         SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
00093                                         int startx,int starty,
00094                                    short int mousemode,
00095                                    SCA_IObject* gameobj);
00096 
00097         virtual ~SCA_MouseSensor();
00098         virtual CValue* GetReplica();
00099         virtual bool Evaluate();
00100         virtual void Init();
00101         virtual bool IsPositiveTrigger();
00102         short int GetModeKey();
00103         SCA_IInputDevice::KX_EnumInputs GetHotKey();
00104         void setX(short x);
00105         void setY(short y);
00106 
00107         static void UpdateHotkey(void *self);
00108 
00109 
00110 #ifdef WITH_PYTHON
00111         /* --------------------------------------------------------------------- */
00112         /* Python interface ---------------------------------------------------- */
00113         /* --------------------------------------------------------------------- */
00114         
00115         static int UpdateHotkeyPy(void *self, const PyAttributeDef *);
00116 
00117         // get button status
00118         KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus);
00119 #endif
00120 };
00121 
00122 #endif //__KX_MOUSESENSOR
00123