12
12
#error Python headers needed to compile C extensions, please install development version of Python.
13
13
#endif
14
14
15
+ struct android_app * g_state = NULL ;
16
+
17
+
18
+ static PyObject * androidembed_poll (PyObject * self , PyObject * args ) {
19
+ int indent ;
20
+ int events ;
21
+ struct android_poll_source * source ;
22
+ int timeout ;
23
+
24
+ if (!PyArg_ParseTuple (args , "i" , & timeout )) {
25
+ return NULL ;
26
+ }
27
+
28
+ while ((indent = ALooper_pollAll (
29
+ timeout , NULL , & events , (void * * )& source )) >= 0 ) {
30
+
31
+ // Process this event
32
+ if (source != NULL ) {
33
+ source -> process (g_state , source );
34
+ }
35
+
36
+ // Check if we are exiting.
37
+ if (g_state -> destroyRequested != 0 ) {
38
+ Py_RETURN_FALSE ;
39
+ }
40
+ }
41
+
42
+ Py_RETURN_TRUE ;
43
+ }
44
+
15
45
static PyObject * androidembed_log (PyObject * self , PyObject * args ) {
16
46
char * logstr = NULL ;
17
47
if (!PyArg_ParseTuple (args , "s" , & logstr )) {
@@ -22,8 +52,8 @@ static PyObject *androidembed_log(PyObject *self, PyObject *args) {
22
52
}
23
53
24
54
static PyMethodDef AndroidEmbedMethods [] = {
25
- {"log" , androidembed_log , METH_VARARGS ,
26
- "Log on android platform " },
55
+ {"log" , androidembed_log , METH_VARARGS , "Log on android platform" },
56
+ { "poll" , androidembed_poll , METH_VARARGS , "Poll the android events " },
27
57
{NULL , NULL , 0 , NULL }
28
58
};
29
59
@@ -55,7 +85,9 @@ int asset_extract(AAssetManager *am, char *src_file, char *dst_file) {
55
85
56
86
void android_main (struct android_app * state ) {
57
87
app_dummy ();
88
+
58
89
LOGI ("Starting minimal bootstrap." );
90
+ g_state = state ;
59
91
60
92
char * env_argument = NULL ;
61
93
int fd = -1 ;
0 commit comments