blender/source/gameengine/GameLogic
Dalai Felinto 795b438bf5 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.
2010-04-17 06:52:14 +00:00
..
Joystick correct fsf address 2010-02-12 13:34:04 +00:00
CMakeLists.txt BGE 2D Filters: slightly change dfelinto patch to use SCA_IScene instead of KX_Scene. It is rather anecdotic since KX_Scene is the only implementation of SCA_IScene but it's better to keep GameLogic and Ketsji separated. 2010-03-06 21:22:09 +00:00
Makefile Make memstat easier to read, add missing Intel ID and cleanups. 2010-04-14 21:12:05 +00:00
SCA_2DFilterActuator.cpp BGE 2D Filters: slightly change dfelinto patch to use SCA_IScene instead of KX_Scene. It is rather anecdotic since KX_Scene is the only implementation of SCA_IScene but it's better to keep GameLogic and Ketsji separated. 2010-03-06 21:22:09 +00:00
SCA_2DFilterActuator.h BGE 2D Filters: slightly change dfelinto patch to use SCA_IScene instead of KX_Scene. It is rather anecdotic since KX_Scene is the only implementation of SCA_IScene but it's better to keep GameLogic and Ketsji separated. 2010-03-06 21:22:09 +00:00
SCA_ActuatorEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ActuatorEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ActuatorSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ActuatorSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_AlwaysEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_AlwaysEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_AlwaysSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_AlwaysSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ANDController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ANDController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_BasicEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_BasicEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_DelaySensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_DelaySensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_EventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_EventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ExpressionController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ExpressionController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IActuator.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IActuator.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IInputDevice.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IInputDevice.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ILogicBrick.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ILogicBrick.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IObject.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IObject.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IScene.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_IScene.h BGE 2D Filters: slightly change dfelinto patch to use SCA_IScene instead of KX_Scene. It is rather anecdotic since KX_Scene is the only implementation of SCA_IScene but it's better to keep GameLogic and Ketsji separated. 2010-03-06 21:22:09 +00:00
SCA_ISensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ISensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_JoystickManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_JoystickManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_JoystickSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_JoystickSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_KeyboardManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_KeyboardManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_KeyboardSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_KeyboardSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_LogicManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_LogicManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_MouseManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_MouseManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_MouseSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_MouseSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_NANDController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_NANDController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_NORController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_NORController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ORController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_ORController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PropertyActuator.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PropertyActuator.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PropertyEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PropertyEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PropertySensor.cpp BGE: fix for [#21180] - missing min and max values in the API + mode fix (interval wasn't working) 2010-03-26 07:21:48 +00:00
SCA_PropertySensor.h BGE: fix for [#21180] - missing min and max values in the API + mode fix (interval wasn't working) 2010-03-26 07:21:48 +00:00
SCA_PythonController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PythonController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_PythonKeyboard.cpp Patch #21789 - BGE Keyboard and Mouse Python types - by Mitchell Stokes(Moguri) 2010-04-17 06:52:14 +00:00
SCA_PythonKeyboard.h Patch #21789 - BGE Keyboard and Mouse Python types - by Mitchell Stokes(Moguri) 2010-04-17 06:52:14 +00:00
SCA_PythonMouse.cpp Patch #21789 - BGE Keyboard and Mouse Python types - by Mitchell Stokes(Moguri) 2010-04-17 06:52:14 +00:00
SCA_PythonMouse.h Patch #21789 - BGE Keyboard and Mouse Python types - by Mitchell Stokes(Moguri) 2010-04-17 06:52:14 +00:00
SCA_RandomActuator.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomActuator.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomNumberGenerator.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomNumberGenerator.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomSensor.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_RandomSensor.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_TimeEventManager.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_TimeEventManager.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_XNORController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_XNORController.h correct fsf address 2010-02-12 13:34:04 +00:00
SCA_XORController.cpp correct fsf address 2010-02-12 13:34:04 +00:00
SCA_XORController.h correct fsf address 2010-02-12 13:34:04 +00:00
SConscript BGE 2D Filters: slightly change dfelinto patch to use SCA_IScene instead of KX_Scene. It is rather anecdotic since KX_Scene is the only implementation of SCA_IScene but it's better to keep GameLogic and Ketsji separated. 2010-03-06 21:22:09 +00:00