| 
					
				 | 
			
			
				@@ -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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-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 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Display* display; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     int screen; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Window main_window; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     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) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // https://tronche.com/gui/x/xlib/events/keyboard-pointer/keyboard-pointer.html#XKeyEvent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // https://tronche.com/gui/x/xlib/utilities/keyboard/XLookupKeysym.html 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         KeySym key_symbol = XLookupKeysym(key_event, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const char* key_str = XKeysymToString(key_symbol); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         printf( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "%s %d %lu %d\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "%s %d %lu %s %d\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             (key_event->type == KeyPress) ? "p" : "r", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             key_event->keycode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             key_symbol, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            key_str, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             key_event->state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(key_event->state == ControlMask && key_symbol == XStringToKeysym("c")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return false; // Ctrl-c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(key_event->type == KeyPress) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                send_keys(key_str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |