Use X11 loader functions instead of linking to X11 libs
parent
71b37906da
commit
2f034c6d1e
@ -1,18 +1,23 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <iostream>
|
||||
#include "X11/keysym.h"
|
||||
#include <functional>
|
||||
#pragma once
|
||||
#include "shared_x11.h"
|
||||
#include "loaders/loader_x11.h"
|
||||
|
||||
#ifndef KeySym
|
||||
typedef unsigned long KeySym;
|
||||
#endif
|
||||
|
||||
double elapsedF2, elapsedF12, elapsedReloadCfg;
|
||||
uint64_t last_f2_press, last_f12_press, reload_cfg_press;
|
||||
pthread_t f2;
|
||||
char *displayid = getenv("DISPLAY");
|
||||
std::unique_ptr<Display, std::function<void(Display*)>> dpy(XOpenDisplay(displayid), [](Display* d) { XCloseDisplay(d); });
|
||||
|
||||
bool key_is_pressed(KeySym ks) {
|
||||
|
||||
if (!init_x11())
|
||||
return false;
|
||||
|
||||
char keys_return[32];
|
||||
XQueryKeymap(dpy.get(), keys_return);
|
||||
KeyCode kc2 = XKeysymToKeycode(dpy.get(), ks);
|
||||
g_x11->XQueryKeymap(get_xdisplay(), keys_return);
|
||||
KeyCode kc2 = g_x11->XKeysymToKeycode(get_xdisplay(), ks);
|
||||
bool isPressed = !!(keys_return[kc2 >> 3] & (1 << (kc2 & 7)));
|
||||
return isPressed;
|
||||
}
|
||||
|
Loading…
Reference in New Issue