rename and negate DISABLE_PYTHON --> WITH_PYTHON
[blender.git] / source / gameengine / GameLogic / SCA_PythonMouse.cpp
index 041a01698798a528a195f6aad3b7f646c2ddf42d..7267eb74594d5f83820d14ed1c59fd15346c5084 100644 (file)
@@ -35,14 +35,20 @@ SCA_PythonMouse::SCA_PythonMouse(SCA_IInputDevice* mouse, RAS_ICanvas* canvas)
 m_mouse(mouse),
 m_canvas(canvas)
 {
+#ifdef WITH_PYTHON
+       m_event_dict = PyDict_New();
+#endif
 }
 
 SCA_PythonMouse::~SCA_PythonMouse()
 {
-       /* intentionally empty */
+#ifdef WITH_PYTHON
+       PyDict_Clear(m_event_dict);
+       Py_DECREF(m_event_dict);
+#endif
 }
 
-#ifndef DISABLE_PYTHON
+#ifdef WITH_PYTHON
 
 /* ------------------------------------------------------------------------- */
 /* Python functions                                                          */
@@ -72,7 +78,6 @@ PyTypeObject SCA_PythonMouse::Type = {
 };
 
 PyMethodDef SCA_PythonMouse::Methods[] = {
-//     KX_PYMETHODTABLE(SCA_PythonMouse, show),
        {NULL,NULL} //Sentinel
 };
 
@@ -86,26 +91,18 @@ PyAttributeDef SCA_PythonMouse::Attributes[] = {
 PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
-
-       PyObject* resultlist = PyList_New(0);
-
+       
        for (int i=SCA_IInputDevice::KX_BEGINMOUSE; i<=SCA_IInputDevice::KX_ENDMOUSE; i++)
        {
                const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
                
-               
-               if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
-               {
-                       PyObject* keypair = PyTuple_New(2);
-                       PyTuple_SET_ITEM(keypair, 0, PyLong_FromSsize_t(i));
-                       PyTuple_SET_ITEM(keypair, 1, PyLong_FromSsize_t(inevent.m_status));
-                       PyList_Append(resultlist, keypair);
-               }
+               PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status));
        }
-
-       return resultlist;
+       Py_INCREF(self->m_event_dict);
+       return self->m_event_dict;
 }
 
+
 PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
        SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);