Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 184f6095b1
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (31 sloc) 0.773 kb
#include "key_event.h"
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/** this is here because of
* error: initializer element is not constant
*/
Display* x11_get_display() {
static int initialized = 0;
static Display *d = NULL;
if ( !initialized ) {
d = XOpenDisplay(0);
initialized = 1;
}
return d;
}
void send_key_event( const char* keycode , int keydown )
{
Display* d = x11_get_display();
int code = XStringToKeysym(keycode);
if ( code == NoSymbol ) {
printf("No symbol");
return;
}
printf("CODE: %x\nLULZ: %s\n",code, XKeysymToString(XKeycodeToKeysym(d,code,0)));
// (display , keycode , is_pressed , delay )
XTestFakeKeyEvent(d, code , keydown , 0);
XFlush(d);
}
Jump to Line
Something went wrong with that request. Please try again.