[refactor] add namespace 'crossdesk' to codebase

This commit is contained in:
dijunkun
2025-10-27 21:09:39 +08:00
parent 3b34c26555
commit 401bfe4483
68 changed files with 313 additions and 606 deletions

View File

@@ -3,6 +3,8 @@
#include "keyboard_converter.h"
#include "rd_log.h"
namespace crossdesk {
static OnKeyAction g_on_key_action = nullptr;
static void* g_user_ptr = nullptr;
@@ -67,3 +69,4 @@ int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
}
return 0;
}
} // namespace crossdesk

View File

@@ -13,20 +13,22 @@
#include "device_controller.h"
namespace crossdesk {
class KeyboardCapturer : public DeviceController {
public:
KeyboardCapturer();
virtual ~KeyboardCapturer();
public:
virtual int Hook(OnKeyAction on_key_action, void *user_ptr);
virtual int Hook(OnKeyAction on_key_action, void* user_ptr);
virtual int Unhook();
virtual int SendKeyboardCommand(int key_code, bool is_down);
private:
Display *display_;
Display* display_;
Window root_;
bool running_;
};
} // namespace crossdesk
#endif

View File

@@ -3,12 +3,14 @@
#include "keyboard_converter.h"
#include "rd_log.h"
namespace crossdesk {
static OnKeyAction g_on_key_action = nullptr;
static void *g_user_ptr = nullptr;
static void* g_user_ptr = nullptr;
CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type,
CGEventRef event, void *userInfo) {
KeyboardCapturer *keyboard_capturer = (KeyboardCapturer *)userInfo;
CGEventRef event, void* userInfo) {
KeyboardCapturer* keyboard_capturer = (KeyboardCapturer*)userInfo;
if (!keyboard_capturer) {
LOG_ERROR("keyboard_capturer is nullptr");
return event;
@@ -91,7 +93,7 @@ KeyboardCapturer::KeyboardCapturer() {}
KeyboardCapturer::~KeyboardCapturer() {}
int KeyboardCapturer::Hook(OnKeyAction on_key_action, void *user_ptr) {
int KeyboardCapturer::Hook(OnKeyAction on_key_action, void* user_ptr) {
g_on_key_action = on_key_action;
g_user_ptr = user_ptr;
@@ -164,4 +166,5 @@ int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
}
return 0;
}
}
} // namespace crossdesk

View File

@@ -11,13 +11,15 @@
#include "device_controller.h"
namespace crossdesk {
class KeyboardCapturer : public DeviceController {
public:
KeyboardCapturer();
virtual ~KeyboardCapturer();
public:
virtual int Hook(OnKeyAction on_key_action, void *user_ptr);
virtual int Hook(OnKeyAction on_key_action, void* user_ptr);
virtual int Unhook();
virtual int SendKeyboardCommand(int key_code, bool is_down);
@@ -33,5 +35,5 @@ class KeyboardCapturer : public DeviceController {
bool command_flag_ = false;
int fn_key_code_ = 0x3F;
};
} // namespace crossdesk
#endif

View File

@@ -2,6 +2,8 @@
#include "rd_log.h"
namespace crossdesk {
static OnKeyAction g_on_key_action = nullptr;
static void* g_user_ptr = nullptr;
@@ -53,4 +55,5 @@ int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
SendInput(1, &input, sizeof(INPUT));
return 0;
}
}
} // namespace crossdesk

View File

@@ -11,18 +11,21 @@
#include "device_controller.h"
namespace crossdesk {
class KeyboardCapturer : public DeviceController {
public:
KeyboardCapturer();
virtual ~KeyboardCapturer();
public:
virtual int Hook(OnKeyAction on_key_action, void *user_ptr);
virtual int Hook(OnKeyAction on_key_action, void* user_ptr);
virtual int Unhook();
virtual int SendKeyboardCommand(int key_code, bool is_down);
private:
HHOOK keyboard_hook_ = nullptr;
};
} // namespace crossdesk
#endif