static PyObject* key_get_focused (PyObject* self) { VIDEO_INIT_CHECK (); return PyInt_FromLong ((SDL_GetAppState () & SDL_APPINPUTFOCUS) != 0); }
static PyObject* key_get_pressed (PyObject* self) { int num_keys; Uint8* key_state; PyObject* key_tuple; int i; VIDEO_INIT_CHECK (); key_state = SDL_GetKeyState (&num_keys); if (!key_state || !num_keys) Py_RETURN_NONE; if (!(key_tuple = PyTuple_New (num_keys))) return NULL; for (i = 0;i < num_keys;i++) { PyObject* key_elem; key_elem = PyInt_FromLong (key_state[i]); if (!key_elem) { Py_DECREF (key_tuple); return NULL; } PyTuple_SET_ITEM (key_tuple, i, key_elem); } return key_tuple; }
static PyObject* key_get_mods (PyObject* self) { VIDEO_INIT_CHECK (); return PyInt_FromLong (SDL_GetModState ()); }
static PyObject* key_get_repeat (PyObject* self, PyObject* args) { int delay = 0, interval = 0; VIDEO_INIT_CHECK (); #if SDL_VERSION_ATLEAST(1, 2, 10) SDL_GetKeyRepeat (&delay, &interval); return Py_BuildValue ("(ii)", delay, interval); #else Py_RETURN_NONE; #endif }
static PyObject* key_set_mods (PyObject* self, PyObject* args) { int mods; if (!PyArg_ParseTuple (args, "i", &mods)) return NULL; VIDEO_INIT_CHECK (); SDL_SetModState (mods); Py_RETURN_NONE; }
/* * Initializes the pygame scrap module. */ static PyObject* _scrap_init (PyObject *self, PyObject *args) { VIDEO_INIT_CHECK (); _clipdata = PyDict_New (); _selectiondata = PyDict_New (); /* In case we've got not video surface, we won't initialize * anything. */ if (!SDL_GetVideoSurface()) return RAISE (PyExc_SDLError, "No display mode is set"); if (!pygame_scrap_init ()) return RAISE (PyExc_SDLError, SDL_GetError ()); Py_RETURN_NONE; }
/* keyboard module functions */ static PyObject* key_set_repeat (PyObject* self, PyObject* args) { int delay = 0, interval = 0; if (!PyArg_ParseTuple (args, "|ii", &delay, &interval)) return NULL; VIDEO_INIT_CHECK (); if (delay && !interval) interval = delay; if (SDL_EnableKeyRepeat (delay, interval) == -1) return RAISE (PyExc_SDLError, SDL_GetError ()); Py_RETURN_NONE; }