TeaSpeak-Client/native/ppt/src/Win32KeyboardHook.h

48 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include "./KeyboardHook.h"
#include <condition_variable>
#include <Windows.h>
namespace hooks {
extern KeyboardHook::KeyType key_type_from_vk(DWORD vk_code);
extern std::string key_string_from_vk(DWORD code, bool extended);
extern std::string key_string_from_sc(USHORT code);
class Win32RawHook : public KeyboardHook {
public:
Win32RawHook();
2020-08-23 21:52:57 +02:00
~Win32RawHook() override;
bool attach() override;
void detach() override;
2020-08-23 11:35:52 +02:00
[[nodiscard]] bool keytype_supported() const override { return true; }
private:
static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
2020-08-23 21:52:57 +02:00
void do_detach();
2020-08-23 11:35:52 +02:00
std::thread window_thread;
void window_loop();
enum struct WorkerStatus {
STOPPED,
DIED,
INITIALIZING,
RUNNING
};
bool wactive{false};
WorkerStatus wstatus{WorkerStatus::STOPPED};
std::mutex wstatus_mutex{};
std::condition_variable wstatus_changed_cv{};
std::string worker_died_reason{};
void set_wstatus(WorkerStatus);
void handle_raw_input(RAWINPUT&);
2020-08-23 11:35:52 +02:00
HWND hwnd{nullptr};
};
}