Forums » Linux

sending events to Vendetta

Mar 29, 2004 red cactus link
Well, I FINALLY got the answers I needed from #debian. Here's a tip for all those who ever want to get help in an IRC channel: be a horribly sarcastic asshole. They will accept you as one of them, and then help you. Anyway, to send events to Vendetta, use Xlib's XSendEvent(). Here are two links to good sites on this:

http://www.ac3.edu.au/SGI_Developer/books/XLib_WinSys/sgi_html/ch04.html
http://member.nifty.ne.jp/tsato/xvkbd/events.html

I hope this helps someone...
Note: I haven't actually tried this out yet...so I don't know for sure whether it works. I would imagine that it does, however.

-rc
Apr 08, 2004 andreas link
Here is how I do it: I wrote a little library that replaces XNextEvent, XPeekEvent and XPending. You have to link that statically to xlib or do some major dlopen tricks to make sure you still can call the original implementations of those methods from your own code (if you want to be able to close vendetta manually). Then you make sure vendetta uses that library and not xlib directly (LD_PRELOAD etc). I tried to intercept calls to OpenGL as well, but thats really tricky.
Apr 08, 2004 red cactus link
Eh? Would you like to elaborate on that a bit? Because all that terminology has me confused...
Apr 09, 2004 andreas link
Lol, ok, but just a little bit as we are going to bore lots of people. xlib has a few functions that deal with receiving events (keyboard events, mouse events, etc). Noteworthy are XPending (how many events are there), XNextEvent (fetch next event) and XPeekEvent (get next but don't remove from queue). Vendetta calls these more or less directly to receive keyboard and mouse events. You can use an environment variable LD_PRELOAD to load a library that has these functions. When vendetta requests them it will call your implementation of them, not the original xlib implementation. Thus, every time vendetta wants to read a key from the keyboard or see what the mouse does your function is called. Thats were you can start to inject keystrokes or mouse movements. In the other direction vendetta calls OpenGL to do most of the gfx output. However, OpenGL is anything but a trivial interface for performance reasons. Its possible to intercept most things, but to understand what is being drawn at the moment is very difficult.