Committing patch [#23489] add method getEventStatus() to PythonKeyboard and PythonMouse by Geoff Gollmer (gomer)

This patch makes SCA_PythonKeyboard.events and SCA_PythonMouse.events return a dictionary of all inputs (including inactive) instead of a list of active inputs.

Example usage:
import bge

if bge.logic.keyboard.events[bge.events.SPACEBAR] = bge.logic.KX_INPUT_JUST_ACTIVATED:
  print("Spacebar pressed!")

A couple of changes to the patch:
  * Wrap python stuff in #ifndef DISABLE_PYTHON
  * Clear and decref m_event_dict in the destructors

A couple of things not related to the patch:
  * Made member variables private
  * Removed a commented out (and no longer used) method (SCA_PythonMouse.show())
This commit is contained in:
2010-08-30 00:18:50 +00:00
parent cb786f0022
commit 57e0d677c6
5 changed files with 34 additions and 32 deletions

View File

@@ -30,8 +30,12 @@
class SCA_PythonMouse : public PyObjectPlus
{
Py_Header;
private:
class SCA_IInputDevice *m_mouse;
class RAS_ICanvas *m_canvas;
#ifndef DISABLE_PYTHON
PyObject* m_event_dict;
#endif
public:
SCA_PythonMouse(class SCA_IInputDevice* mouse, class RAS_ICanvas* canvas);
virtual ~SCA_PythonMouse();