[Bf-committers] Patch for BGE Keyboard and Mouse Python types

Dalai Felinto dfelinto at gmail.com
Sun Apr 4 12:05:40 CEST 2010


Hi Mitchell.
(same message sent to the patch tracker)

The code looks correct. My only concern is with the usability of it:

1) What is the advantage of this over mouse and keyboard sensors?
You will still need to check the events every frame and will end up having
to reproduce the same functionality present in the sensors (mouse over,
mouse click, ...). I may be missing something here.

2) I was thinking if it would be possible/interesting to have callback
functions to be linked with the events. E.g.
bge.events.keyboard.addListener('QKEY', quit_function),
bge.events.mouse.addListener('LEFTCLICK', mouse_click).

Something similar with having the sensor linked to a module, but 100% done
in python. That would justify to have the keyboard and mouse exposed in my
opinion.

3) (code specific)

4) bge.events.mouse/keyboard does sound neat ;) On the other hand
GameLogic.getMouse/Keyboard() looks odd to me ...

* - (code specific)

Cheers,
Dalai

2010/3/27 Mitchell Stokes <mogurijin at gmail.com>

> Hello,
>
> I've submitted a patch to the tracker to add some new Python
> Objects/Types to the BGE Python API. Here is the description from the
> tracker entry:
>
> "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
> the cursor position with SCA_PythonMouse.position. The cursor can be
> shown/hidden using SCA_PythonMouse.show(bool).
>
> To get these new objects I've added two methods to GameLogic:
> GameLogic.getKeyboard()
> GameLogic.getMouse()
>
> PyDocs has also been updated.
>
> The only thing missing now is constants for SCA_PythonMouse.event like
> the ones in GameKeys. In fact, the mouse events
> would extend the constants (starting at 180), but mouse buttons aren't
> exactly "keys". Should the constants
> be put there anyways?"
>
> The link:
> https://projects.blender.org/tracker/index.php?func=detail&aid=21789&group_id=9&atid=127
>
> On a slightly related note, there is a patch to bring back all but the
> copy buttons of the old texface panel here:
>
> https://projects.blender.org/tracker/index.php?func=detail&aid=21780&group_id=9&atid=127
>
> Cheers,
> Mitchell Stokes (Moguri)
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list