3 * Python Input Module for NumptyPhysics
4 * Copyright (c) 2009 Thomas Perl <thpinfo.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
28 PyThreadState
* m_python_threadstate
;
32 PyObject
* create_module();
33 static PyObject
* post_event(PyObject
* self
, PyObject
*event
);
35 PythonInput(int width
, int height
)
36 : m_width(width
), m_height(height
)
38 PyObject
* numpty_module
;
39 PyObject
* input_module
;
41 /* Initialize the Python Interpreter */
42 setenv("PYTHONPATH", ".", 1);
46 /* Add the glue module and load tuioinput */
47 numpty_module
= create_module();
48 input_module
= PyImport_ImportModule("tuioinput");
49 if (input_module
== NULL
) {
52 Py_DECREF(input_module
);
53 Py_DECREF(numpty_module
);
55 m_python_threadstate
= PyEval_SaveThread();
60 PyEval_RestoreThread(m_python_threadstate
);
61 /* Could/should call Py_Finalize() here, but crashes */
65 #endif /* HAVE_PYTHON */