CEBL  2.1
X11Controller.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
18 
19 
28 #ifndef X11CONTROLLER_H
29 #define X11CONTROLLER_H
30 
31 #include <X11/Xlib.h>
32 
34 {
35 private:
36  Display *display;
37  Window getWindowByNameRecursive(Window root,
38  const char *search_name,
39  int level);
40  int msleep(unsigned long milisec);
41  int randrange(int low, int high);
42  void pause();
43  KeyCode getKeyCodeFromString(const char *key);
44 
45 
46 public:
47  X11Controller();
49 
50  Window getWindowByName(const char *search_name);
51  bool getCursorXYAbsolute(int *x, int *y);
52  bool getWindowXYAbsolute(Window window, int *x, int *y);
53  bool getWindowSize(Window window, int *width, int *height);
54  bool moveCursorIntoWindow(Window window);
55  bool moveCursorAbsoluteInWindow(Window window, int x, int y);
56  bool moveCursorRelative(int x, int y);
57 
58  //clicking
59  bool buttonPress(unsigned int button);
60  bool buttonRelease(unsigned int button);
61  bool leftClick();
62  bool rightClick();
63  bool middleClick();
64  bool doubleClick();
65 
66  //keys
67  bool keyPress(const char * key);
68  bool keyRelease(const char *key);
69  bool keySend(const char *key);
70  bool stringSend(const char *string);
71 
72  bool displayIsOpen() { return display != NULL; }
73  void closeDisplay();
74 };
75 
76 #endif