diff options
author | twinaphex | 2013-03-18 01:16:31 +0100 |
---|---|---|
committer | twinaphex | 2013-03-18 01:16:31 +0100 |
commit | 22dade5ca95efa7fb3530023dbab77f8516bfed7 (patch) | |
tree | 40a660c1e7a806abe03b2c9f2e6389073894877b /maemo/maemo_xkb.c | |
parent | 24f4865eff11beb6348d9e0e310d593477359afe (diff) | |
parent | 101e053c72e9299bfbd1cbf6a8de9ba6cff11e4c (diff) | |
download | pcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.tar.gz pcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.tar.bz2 pcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.zip |
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'maemo/maemo_xkb.c')
-rw-r--r-- | maemo/maemo_xkb.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/maemo/maemo_xkb.c b/maemo/maemo_xkb.c new file mode 100644 index 0000000..52af2ca --- /dev/null +++ b/maemo/maemo_xkb.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses>. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/keysym.h> +#include <X11/XKBlib.h> + +#include "../frontend/main.h" +#include "../frontend/plugin_lib.h" + +static Atom wmprotocols, wmdelwindow; +static int initialized; + + + +static void InitKeyboard(void) { + Display *disp = (Display *)gpuDisp; + if (disp){ + wmprotocols = XInternAtom(disp, "WM_PROTOCOLS", 0); + wmdelwindow = XInternAtom(disp, "WM_DELETE_WINDOW", 0); + XkbSetDetectableAutoRepeat(disp, 1, NULL); + } +} + +static void DestroyKeyboard(void) { + Display *disp = (Display *)gpuDisp; + if (disp) + XkbSetDetectableAutoRepeat(disp, 0, NULL); +} +#include "maemo_common.h" + +int maemo_x11_update_keys() { + + XEvent evt; + XClientMessageEvent *xce; + int leave = 0; + Display *disp = (Display *)gpuDisp; + + if (!disp) + return 0; + + if (!initialized) { + initialized++; + InitKeyboard(); + } + + while (XPending(disp)>0) { + XNextEvent(disp, &evt); + switch (evt.type) { + case KeyPress: + case KeyRelease: + key_press_event(evt.xkey.keycode, evt.type==KeyPress ? 1 : (evt.type==KeyRelease ? 2 : 0) ); + break; + + case ClientMessage: + xce = (XClientMessageEvent *)&evt; + if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow) + leave = 1; + break; + } + } + + if (leave) { + DestroyKeyboard(); + exit(1); + } + + return 0; +} |