diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2010-10-05 09:44:15 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2010-10-05 09:44:15 +0400 |
commit | 3cf2d2fd4ec7bfafc86fe2a288e4143544e6b781 (patch) | |
tree | d9db75c91b4f79157b2cafb02b5c87df558ecca0 /source/gameengine | |
parent | 9f3d203acbc267063f274209b460dc5f059100e6 (diff) |
A bit of bge.events work:
* A few places in the bge.events docs mentioned bge.keys, when it should have been bge.events
* Created two aliases to bge.events.RETKEY: ENTERKEY and RETURNKEY
* ENTERKEY and RETURNKEY have been added to the docs and RETKEY marked as deprecated
* Added an example of using bge.logic.keyboard to the bge.events docs
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/PyDoc/bge.events.rst | 36 |
2 files changed, 31 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a6b2453f0c5..473e6fc9265 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -2214,6 +2214,8 @@ PyObject* initGameKeys() KX_MACRO_addTypesToDict(d, ESCKEY, SCA_IInputDevice::KX_ESCKEY); KX_MACRO_addTypesToDict(d, TABKEY, SCA_IInputDevice::KX_TABKEY); KX_MACRO_addTypesToDict(d, RETKEY, SCA_IInputDevice::KX_RETKEY); + KX_MACRO_addTypesToDict(d, ENTERKEY, SCA_IInputDevice::KX_RETKEY); + KX_MACRO_addTypesToDict(d, RETURNKEY, SCA_IInputDevice::KX_RETKEY); KX_MACRO_addTypesToDict(d, SPACEKEY, SCA_IInputDevice::KX_SPACEKEY); KX_MACRO_addTypesToDict(d, LINEFEEDKEY, SCA_IInputDevice::KX_LINEFEEDKEY); KX_MACRO_addTypesToDict(d, BACKSPACEKEY, SCA_IInputDevice::KX_BACKSPACEKEY); diff --git a/source/gameengine/PyDoc/bge.events.rst b/source/gameengine/PyDoc/bge.events.rst index f642291fe97..5738e7a0f48 100644 --- a/source/gameengine/PyDoc/bge.events.rst +++ b/source/gameengine/PyDoc/bge.events.rst @@ -18,7 +18,7 @@ This module holds key constants for the SCA_KeyboardSensor. co = bge.logic.getCurrentController() # 'Keyboard' is a keyboard sensor sensor = co.sensors["Keyboard"] - sensor.key = bge.keys.F1KEY + sensor.key = bge.events.F1KEY .. code-block:: python @@ -30,17 +30,37 @@ This module holds key constants for the SCA_KeyboardSensor. sensor = co.sensors["Keyboard"] for key,status in sensor.events: - # key[0] == bge.keys.keycode, key[1] = status + # key[0] == bge.events.keycode, key[1] = status if status == bge.logic.KX_INPUT_JUST_ACTIVATED: - if key == bge.keys.WKEY: + if key == bge.events.WKEY: # Activate Forward! - if key == bge.keys.SKEY: + if key == bge.events.SKEY: # Activate Backward! - if key == bge.keys.AKEY: + if key == bge.events.AKEY: # Activate Left! - if key == bge.keys.DKEY: + if key == bge.events.DKEY: # Activate Right! +.. code-block:: python + + # The all keys thing without a keyboard sensor (but you will + # need an always sensor with pulse mode on) + import bge + + # Just shortening names here + keyboard = bge.logic.keyboard + JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED + + if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED: + print("Activate Forward!") + if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED: + print("Activate Backward!") + if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED: + print("Activate Left!") + if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED: + print("Activate Right!") + + ********* Functions ********* @@ -222,7 +242,9 @@ Other Keys .. data:: PERIODKEY .. data:: QUOTEKEY .. data:: RIGHTBRACKETKEY -.. data:: RETKEY +.. data:: RETKEY (Deprecated: use bge.events.ENTERKEY or bge.events.RETURNKEY) +.. data:: ENTERKEY +.. data:: RETURNKEY .. data:: SEMICOLONKEY .. data:: SLASHKEY .. data:: SPACEKEY |