summaryrefslogtreecommitdiff
path: root/tools/test-webcam-button.c
blob: b055c03d52fd7bfcba116b1420a3bf96a7d4db8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* emit foo webcam button event */
/* gcc -o test-webcam-button test-webcam-button.c -lX11 -lXtst */

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
#include <X11/XF86keysym.h>

int main (void)
{
  Display *dpy;
  dpy = XOpenDisplay (NULL);

  printf ("Emitting fake Webcam button press in 2 seconds...\n");
  printf ("Focus Cheese window to make it receive the event\n");

  XTestFakeKeyEvent (dpy, XKeysymToKeycode(dpy, XF86XK_WebCam), True, 2000);
  XTestFakeKeyEvent (dpy, XKeysymToKeycode(dpy, XF86XK_WebCam), False, CurrentTime);

  XCloseDisplay (dpy);
}