mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Update: update and remove some old code
This commit is contained in:
parent
6fa2f418fa
commit
5c3cbd6e17
@ -87,9 +87,8 @@ static io_connect_t _getAuxiliaryKeyDriver(void) {
|
|||||||
}
|
}
|
||||||
return sEventDrvrRef;
|
return sEventDrvrRef;
|
||||||
}
|
}
|
||||||
#endif
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
#if defined(IS_WINDOWS)
|
|
||||||
void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid) {
|
void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid) {
|
||||||
int scan = MapVirtualKey(key & 0xff, MAPVK_VK_TO_VSC);
|
int scan = MapVirtualKey(key & 0xff, MAPVK_VK_TO_VSC);
|
||||||
|
|
||||||
@ -284,38 +283,8 @@ void toggleUnicode(UniChar ch, const bool down, uintptr pid) {
|
|||||||
|
|
||||||
SendTo(pid, keyEvent);
|
SendTo(pid, keyEvent);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
#define toggleUniKey(c, down) toggleKey(c, down, MOD_NONE, 0)
|
#define toggleUniKey(c, down) toggleKey(c, down, MOD_NONE, 0)
|
||||||
|
|
||||||
int input_utf(const char *utf) {
|
|
||||||
Display *dpy = XOpenDisplay(NULL);
|
|
||||||
KeySym sym = XStringToKeysym(utf);
|
|
||||||
// KeySym sym = XKeycodeToKeysym(dpy, utf);
|
|
||||||
|
|
||||||
int min, max, numcodes;
|
|
||||||
XDisplayKeycodes(dpy, &min, &max);
|
|
||||||
KeySym *keysym;
|
|
||||||
keysym = XGetKeyboardMapping(dpy, min, max-min+1, &numcodes);
|
|
||||||
keysym[(max-min-1)*numcodes] = sym;
|
|
||||||
XChangeKeyboardMapping(dpy, min, numcodes, keysym, (max-min));
|
|
||||||
XFree(keysym);
|
|
||||||
XFlush(dpy);
|
|
||||||
|
|
||||||
KeyCode code = XKeysymToKeycode(dpy, sym);
|
|
||||||
XTestFakeKeyEvent(dpy, code, True, 1);
|
|
||||||
XTestFakeKeyEvent(dpy, code, False, 1);
|
|
||||||
|
|
||||||
XFlush(dpy);
|
|
||||||
XCloseDisplay(dpy);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_X11)
|
|
||||||
int input_utf(const char *utf){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// unicode type
|
// unicode type
|
||||||
@ -355,3 +324,32 @@ void unicodeType(const unsigned value, uintptr pid, int8_t isPid){
|
|||||||
toggleUniKey(value, false);
|
toggleUniKey(value, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_X11)
|
||||||
|
int input_utf(const char *utf) {
|
||||||
|
Display *dpy = XOpenDisplay(NULL);
|
||||||
|
KeySym sym = XStringToKeysym(utf);
|
||||||
|
// KeySym sym = XKeycodeToKeysym(dpy, utf);
|
||||||
|
|
||||||
|
int min, max, numcodes;
|
||||||
|
XDisplayKeycodes(dpy, &min, &max);
|
||||||
|
KeySym *keysym;
|
||||||
|
keysym = XGetKeyboardMapping(dpy, min, max-min+1, &numcodes);
|
||||||
|
keysym[(max-min-1)*numcodes] = sym;
|
||||||
|
XChangeKeyboardMapping(dpy, min, numcodes, keysym, (max-min));
|
||||||
|
XFree(keysym);
|
||||||
|
XFlush(dpy);
|
||||||
|
|
||||||
|
KeyCode code = XKeysymToKeycode(dpy, sym);
|
||||||
|
XTestFakeKeyEvent(dpy, code, True, 1);
|
||||||
|
XTestFakeKeyEvent(dpy, code, False, 1);
|
||||||
|
|
||||||
|
XFlush(dpy);
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int input_utf(const char *utf){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
@ -54,7 +54,8 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id,
|
|||||||
|
|
||||||
MMPointInt32 o = rect.origin; MMSizeInt32 s = rect.size;
|
MMPointInt32 o = rect.origin; MMSizeInt32 s = rect.size;
|
||||||
XImage *image = XGetImage(display, XDefaultRootWindow(display),
|
XImage *image = XGetImage(display, XDefaultRootWindow(display),
|
||||||
(int)o.x, (int)o.y, (unsigned int)s.w, (unsigned int)s.h, AllPlanes, ZPixmap);
|
(int)o.x, (int)o.y, (unsigned int)s.w, (unsigned int)s.h,
|
||||||
|
AllPlanes, ZPixmap);
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
if (image == NULL) { return NULL; }
|
if (image == NULL) { return NULL; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user