forgot to add the new files

git-svn-id: svn+ssh://svn.code.sf.net/p/spacenav/code/trunk/spacenavd@138 ef983eb1-d774-4af8-acfd-baaf7b16a646
pull/1/head
John Tsiombikas 2012-05-05 05:22:41 +00:00
rodzic fa6bc12d9e
commit 0f5d96c69f
2 zmienionych plików z 91 dodań i 0 usunięć

62
src/kbemu.c 100644
Wyświetl plik

@ -0,0 +1,62 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2012 John Tsiombikas <nuclear@member.fsf.org>
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 3 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 "config.h"
#ifdef USE_X11
#include <stdio.h>
#include <string.h>
#include "kbemu.h"
static Display *dpy;
void kbemu_set_display(Display *d)
{
dpy = d;
}
KeySym kbemu_keysym(const char *str)
{
return XStringToKeysym(str);
}
void send_kbevent(KeySym key, int press)
{
XEvent xevent;
Window win;
int rev_state;
if(!dpy) return;
XGetInputFocus(dpy, &win, &rev_state);
xevent.type = press ? KeyPress : KeyRelease;
xevent.xkey.display = dpy;
xevent.xkey.root = DefaultRootWindow(dpy);
xevent.xkey.window = win;
xevent.xkey.subwindow = None;
xevent.xkey.keycode = XKeysymToKeycode(dpy, key);
xevent.xkey.state = 0;
xevent.xkey.time = CurrentTime;
xevent.xkey.x = xevent.xkey.y = 1;
xevent.xkey.x_root = xevent.xkey.y_root = 1;
XSendEvent(dpy, win, True, press ? KeyPressMask : KeyReleaseMask, &xevent);
XFlush(dpy);
}
#endif /* USE_X11 */

29
src/kbemu.h 100644
Wyświetl plik

@ -0,0 +1,29 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2012 John Tsiombikas <nuclear@member.fsf.org>
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 3 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/>.
*/
#ifndef KBEMU_H_
#define KBEMU_H_
#include <X11/Xlib.h>
#include <X11/keysym.h>
void kbemu_set_display(Display *dpy);
KeySym kbemu_keysym(const char *str);
void send_kbevent(KeySym key, int press);
#endif /* KBEMU_H_ */