2019-09-01 20:53:16 +02:00
|
|
|
#ifndef __INCLUDED_X11_HOOK_H__
|
|
|
|
#define __INCLUDED_X11_HOOK_H__
|
|
|
|
|
|
|
|
#include "../Base_Hook.h"
|
|
|
|
|
|
|
|
#ifdef __LINUX__
|
2020-01-19 12:55:14 -05:00
|
|
|
#ifdef EMU_OVERLAY
|
2019-09-01 20:53:16 +02:00
|
|
|
|
|
|
|
#include <X11/X.h> // XEvent types
|
|
|
|
#include <X11/Xlib.h> // XEvent structure
|
|
|
|
|
2019-11-08 15:54:48 +01:00
|
|
|
extern "C" int XEventsQueued(Display *display, int mode);
|
|
|
|
extern "C" int XPending(Display *display);
|
|
|
|
|
2019-09-01 20:53:16 +02:00
|
|
|
class X11_Hook : public Base_Hook
|
|
|
|
{
|
|
|
|
public:
|
2019-11-08 15:54:48 +01:00
|
|
|
friend int XEventsQueued(Display *display, int mode);
|
|
|
|
friend int XPending(Display *display);
|
2019-09-01 20:53:16 +02:00
|
|
|
static constexpr const char* DLL_NAME = "libX11.so";
|
|
|
|
|
|
|
|
private:
|
|
|
|
static X11_Hook* _inst;
|
|
|
|
|
|
|
|
// Variables
|
|
|
|
bool hooked;
|
|
|
|
bool initialized;
|
2019-09-03 10:32:32 +02:00
|
|
|
Window game_wnd;
|
2019-09-01 20:53:16 +02:00
|
|
|
|
|
|
|
// Functions
|
|
|
|
X11_Hook();
|
2019-09-03 17:24:34 +02:00
|
|
|
int check_for_overlay(Display *d, int num_events);
|
2019-09-01 20:53:16 +02:00
|
|
|
|
|
|
|
// Hook to X11 window messages
|
2019-09-03 10:32:32 +02:00
|
|
|
decltype(XEventsQueued)* _XEventsQueued;
|
2019-09-01 20:53:16 +02:00
|
|
|
decltype(XPeekEvent)* _XPeekEvent;
|
|
|
|
decltype(XNextEvent)* _XNextEvent;
|
2019-09-03 10:32:32 +02:00
|
|
|
decltype(XPending)* _XPending;
|
|
|
|
//decltype(XKeysymToKeycode)* _XKeysymToKeycode;
|
|
|
|
//decltype(XLookupKeysym)* _XLookupKeysym;
|
|
|
|
//decltype(XGetGeometry)* _XGetGeometry;
|
2019-09-01 20:53:16 +02:00
|
|
|
|
2019-09-03 10:32:32 +02:00
|
|
|
static int MyXEventsQueued(Display * display, int mode);
|
|
|
|
static int MyXNextEvent(Display* display, XEvent *event);
|
|
|
|
static int MyXPeekEvent(Display* display, XEvent *event);
|
|
|
|
static int MyXPending(Display* display);
|
|
|
|
|
2019-11-08 15:54:48 +01:00
|
|
|
public:
|
2019-09-01 20:53:16 +02:00
|
|
|
virtual ~X11_Hook();
|
|
|
|
|
|
|
|
void resetRenderState();
|
2019-09-03 10:32:32 +02:00
|
|
|
void prepareForOverlay(Display *display, Window wnd);
|
|
|
|
|
|
|
|
Window get_game_wnd() const{ return game_wnd; }
|
2019-09-01 20:53:16 +02:00
|
|
|
|
|
|
|
bool start_hook();
|
|
|
|
static X11_Hook* Inst();
|
|
|
|
virtual const char* get_lib_name() const;
|
|
|
|
};
|
|
|
|
|
2020-01-19 12:55:14 -05:00
|
|
|
#endif//EMU_OVERLAY
|
2019-09-01 20:53:16 +02:00
|
|
|
#endif//__LINUX__
|
|
|
|
#endif//__INCLUDED_X11_HOOK_H__
|