Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2010-04-17 10:52:14 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-04-17 10:52:14 +0400
commit795b438bf5565a87765edb880318b7e241714270 (patch)
treec76292cfa5e11b1eab41484342fb04b5e9fb2a06 /source/gameengine/Rasterizer
parent6562e6a4d1c12166b53322de131ed65867eb026d (diff)
Patch #21789 - BGE Keyboard and Mouse Python types - by Mitchell Stokes(Moguri)
The patch exposes mouse and keyboard read-only properties in the GameLogic module Also renames bge.keys to bge.events (* Note: name of bge submodules (logic, render, ...) may change before 2.5 final release [right Campbell?]). """ This patch adds two new types to the BGE: SCA_PythonKeyboard SCA_PythonMouse These two types allow users to make use of the keyboard and mouse without the need for a keyboard or mouse sensor. SCA_PythonKeyboard has an events property that acts just like SCA_KeyboardSensor.events. SCA_PythonMouse also has an events property to check for mouse events. Further more it supports getting and setting normalized cursor position (from 0.0 to 1.0) with SCA_PythonMouse.position. The cursor can be shown/hidden using SCA_PythonMouse.visible. """ Its use is similar with current mouse and keyboard controllers. With the exception of mouse position being normalized and writable as well (replacing Rasterizer.setMousePosition). Code Sample: ###### from bge import logic, events mouse = logic.mouse keyboard = logic.keyboard for key,status in keyboard.events: if status == logic.KX_INPUT_JUST_ACTIVATED: if key == events.WKEY: print(mouse.position) # move_forward() mouse.visible = True # turn cursor visible mouse.position = 0.5,0.5 # centralize mouse - use tuple ###### * Important Note: mouse.position still will not work properly for Letterbox mode. In order to fix letterboxing I may need to move the set x,y mouse function to inside the canvas code (to avoid duplicated code between mouse sensor and bge.logic.mouse). I'll leave this for another commit though. Thanks Mitchell for the work on that.
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index 2ab06be26e7..0821e369f75 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -172,12 +172,21 @@ public:
int y
)=0;
+ virtual
+ RAS_MouseState
+ GetMouseState()
+ {
+ return m_mousestate;
+ }
+
virtual
void
MakeScreenShot(
const char* filename
)=0;
+protected:
+ RAS_MouseState m_mousestate;
#ifdef WITH_CXX_GUARDEDALLOC
public: