[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32311] trunk/blender/source/gameengine: A bit of bge.events work:
Dalai Felinto
dfelinto at gmail.com
Tue Oct 5 17:17:42 CEST 2010
Intersting, I thought about that this week. In that case I think we should
have KX_PADRETURN too (since KX_PADENTER is already there). I can add it
later today.
Cheers,
Dalai
2010/10/4 Mitchell Stokes <mogurijin at gmail.com>
> Revision: 32311
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32311
> Author: moguri
> Date: 2010-10-05 07:44:15 +0200 (Tue, 05 Oct 2010)
>
> Log Message:
> -----------
> 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
>
> Modified Paths:
> --------------
> trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
> trunk/blender/source/gameengine/PyDoc/bge.events.rst
>
> Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2010-10-05
> 00:49:39 UTC (rev 32310)
> +++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2010-10-05
> 05:44:15 UTC (rev 32311)
> @@ -2214,6 +2214,8 @@
> 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);
>
> Modified: trunk/blender/source/gameengine/PyDoc/bge.events.rst
> ===================================================================
> --- trunk/blender/source/gameengine/PyDoc/bge.events.rst 2010-10-05
> 00:49:39 UTC (rev 32310)
> +++ trunk/blender/source/gameengine/PyDoc/bge.events.rst 2010-10-05
> 05:44:15 UTC (rev 32311)
> @@ -18,7 +18,7 @@
> 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 @@
> 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 @@
> .. 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
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
More information about the Bf-committers
mailing list