26
26
#define PYGAMEAPI_EVENT_INTERNAL
27
27
#include "pygame.h"
29
// FIXME: The system message code is only tested on windows, so only
30
// include it there for now.
32
#include <SDL_syswm.h>
30
36
/*this user event object is for safely passing
31
37
*objects through the event queue.
113
static int PyEvent_FillUserEvent(PyEventObject *e, SDL_Event *event) {
114
UserEventObject *userobj = user_event_addobject(e->dict);
118
event->type = e->type;
119
event->user.code = USEROBJECT_CHECK1;
120
event->user.data1 = (void*)USEROBJECT_CHECK2;
121
event->user.data2 = userobj;
109
125
staticforward PyTypeObject PyEvent_Type;
110
126
static PyObject* PyEvent_New(SDL_Event*);
283
299
case SDL_VIDEORESIZE:
284
300
obj = Py_BuildValue("(ii)", event->resize.w, event->resize.h);
285
301
insobj(dict, "size", obj);
302
insobj(dict, "w", PyInt_FromLong(event->resize.w));
303
insobj(dict, "h", PyInt_FromLong(event->resize.h));
307
insobj(dict, "hwnd", PyInt_FromLong((long)(event-> syswm.msg->hwnd)));
308
insobj(dict, "msg", PyInt_FromLong(event-> syswm.msg->msg));
309
insobj(dict, "wparam", PyInt_FromLong(event-> syswm.msg->wParam));
310
insobj(dict, "lparam", PyInt_FromLong(event-> syswm.msg->lParam));
287
313
/* SDL_VIDEOEXPOSE and SDL_QUIT have no attributes */
609
635
/*DOC*/ "queue for too long, the system may decide your program has locked up.\n"
612
static PyObject* pump(PyObject* self, PyObject* args)
638
static PyObject* pygame_pump(PyObject* self, PyObject* args)
614
640
if(!PyArg_ParseTuple(args, ""))
664
690
/*DOC*/ "queue, this will return an event with type NOEVENT.\n"
667
static PyObject* poll(PyObject* self, PyObject* args)
693
static PyObject* pygame_poll(PyObject* self, PyObject* args)
880
906
PyEventObject* e;
882
UserEventObject* userobj;
884
909
if(!PyArg_ParseTuple(args, "O!", &PyEvent_Type, &e))
887
912
VIDEO_INIT_CHECK();
889
userobj = user_event_addobject(e->dict);
914
if (PyEvent_FillUserEvent(e, &event))
893
event.type = e->type;
894
event.user.code = USEROBJECT_CHECK1;
895
event.user.data1 = (void*)USEROBJECT_CHECK2;
896
event.user.data2 = userobj;
898
917
if(SDL_PushEvent(&event) == -1)
899
918
return RAISE(PyExc_SDLError, "Event queue full");
1040
1059
{ "set_grab", set_grab, 1, doc_set_grab },
1041
1060
{ "get_grab", get_grab, 1, doc_get_grab },
1043
{ "pump", pump, 1, doc_pump },
1062
{ "pump", pygame_pump, 1, doc_pump },
1044
1063
{ "wait", pygame_wait, 1, doc_wait },
1045
{ "poll", poll, 1, doc_poll },
1064
{ "poll", pygame_poll, 1, doc_poll },
1046
1065
{ "clear", event_clear, 1, doc_event_clear },
1047
1066
{ "get", event_get, 1, doc_event_get },
1048
1067
{ "peek", event_peek, 1, doc_peek },
1064
1083
/*DOC*/ "the display has not been initialized and a video mode not set,\n"
1065
1084
/*DOC*/ "the event queue will not really work.\n"
1067
/*DOC*/ "The queue is a stack of Event objects, there are a variety of\n"
1068
/*DOC*/ "ways to access the data on the queue. From simply checking for\n"
1086
/*DOC*/ "The queue is a regular queue of Event objects, there are a variety of\n"
1087
/*DOC*/ "ways to access the events it contains. From simply checking for\n"
1069
1088
/*DOC*/ "the existance of events, to grabbing them directly off the stack.\n"
1071
1090
/*DOC*/ "All events have a type identifier. This event type is in between\n"
1111
1130
/* export the c api */
1112
1131
c_api[0] = &PyEvent_Type;
1113
1132
c_api[1] = PyEvent_New;
1133
c_api[2] = PyEvent_New2;
1134
c_api[3] = PyEvent_FillUserEvent;
1114
1135
apiobj = PyCObject_FromVoidPtr(c_api, NULL);
1115
1136
PyDict_SetItemString(dict, PYGAMEAPI_LOCAL_ENTRY, apiobj);
1116
1137
Py_DECREF(apiobj);