|
@@ -22,41 +22,46 @@ void search_windows_by_name(const xdo_t* xdo, const char* name_regex, Window** w
|
|
xdo_search_windows(xdo, &search, windowlist_ret, nwindows_ret);
|
|
xdo_search_windows(xdo, &search, windowlist_ret, nwindows_ret);
|
|
}
|
|
}
|
|
|
|
|
|
-void search_toontown_windows(const xdo_t* xdo, Window** windowlist_ret, unsigned int* nwindows_ret) {
|
|
|
|
- search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void send_keysequence(const xdo_t* xdo) {
|
|
|
|
- Window* windows;
|
|
|
|
- unsigned int nwindows;
|
|
|
|
- search_toontown_windows(xdo, &windows, &nwindows);
|
|
|
|
- for(unsigned int i=0; i<nwindows; i++) {
|
|
|
|
- // http://www.cl.cam.ac.uk/~mgk25/ucs/keysymdef.h
|
|
|
|
- xdo_send_keysequence_window(xdo, windows[i], "Left", KEY_DELAY);
|
|
|
|
- xdo_send_keysequence_window(xdo, windows[i], "Right", KEY_DELAY);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
class ToontownKeyboardManager {
|
|
class ToontownKeyboardManager {
|
|
Display* display;
|
|
Display* display;
|
|
int screen;
|
|
int screen;
|
|
Window main_window;
|
|
Window main_window;
|
|
xdo_t* xdo;
|
|
xdo_t* xdo;
|
|
|
|
|
|
|
|
+ void search_toontown_windows(Window** windowlist_ret, unsigned int* nwindows_ret) {
|
|
|
|
+ search_windows_by_name(xdo, "Toontown.*", windowlist_ret, nwindows_ret);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void send_keys(const char* keysequence) {
|
|
|
|
+ Window* windows;
|
|
|
|
+ unsigned int nwindows;
|
|
|
|
+ search_toontown_windows(&windows, &nwindows);
|
|
|
|
+ for(unsigned int i=0; i<nwindows; i++) {
|
|
|
|
+ // file:///usr/share/doc/libxdo-dev/html/xdo_8h.html
|
|
|
|
+ // http://www.cl.cam.ac.uk/~mgk25/ucs/keysymdef.h
|
|
|
|
+ xdo_send_keysequence_window(xdo, windows[i], keysequence, KEY_DELAY);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
bool key_event(XKeyEvent* key_event) {
|
|
bool key_event(XKeyEvent* key_event) {
|
|
// https://tronche.com/gui/x/xlib/events/keyboard-pointer/keyboard-pointer.html#XKeyEvent
|
|
// https://tronche.com/gui/x/xlib/events/keyboard-pointer/keyboard-pointer.html#XKeyEvent
|
|
// https://tronche.com/gui/x/xlib/utilities/keyboard/XLookupKeysym.html
|
|
// https://tronche.com/gui/x/xlib/utilities/keyboard/XLookupKeysym.html
|
|
KeySym key_symbol = XLookupKeysym(key_event, 0);
|
|
KeySym key_symbol = XLookupKeysym(key_event, 0);
|
|
|
|
+ const char* key_str = XKeysymToString(key_symbol);
|
|
printf(
|
|
printf(
|
|
- "%s %d %lu %d\n",
|
|
|
|
|
|
+ "%s %d %lu %s %d\n",
|
|
(key_event->type == KeyPress) ? "p" : "r",
|
|
(key_event->type == KeyPress) ? "p" : "r",
|
|
key_event->keycode,
|
|
key_event->keycode,
|
|
key_symbol,
|
|
key_symbol,
|
|
|
|
+ key_str,
|
|
key_event->state
|
|
key_event->state
|
|
);
|
|
);
|
|
if(key_event->state == ControlMask && key_symbol == XStringToKeysym("c")) {
|
|
if(key_event->state == ControlMask && key_symbol == XStringToKeysym("c")) {
|
|
return false; // Ctrl-c
|
|
return false; // Ctrl-c
|
|
} else {
|
|
} else {
|
|
|
|
+ if(key_event->type == KeyPress) {
|
|
|
|
+ send_keys(key_str);
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|