refactor: Entire code base, thread and log usage
Boils down to: - Include headers - Reduce boiler plate with helpers - Swap out explicit usages with core API layer and ensure the right API is configured beforehand
This commit is contained in:
@@ -5,6 +5,7 @@ ldflags_geninput := \
|
||||
-lsetupapi \
|
||||
|
||||
libs_geninput := \
|
||||
core \
|
||||
util \
|
||||
|
||||
src_geninput := \
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/dev-list.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
void dev_list_init(struct dev_list *devs, const GUID *class_guid)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <hidsdi.h>
|
||||
// clang-format on
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-generic-strings.h"
|
||||
#include "geninput/hid-generic.h"
|
||||
#include "geninput/hid-meta-in.h"
|
||||
@@ -19,7 +21,6 @@
|
||||
#include "geninput/hid.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-meta-in.h"
|
||||
#include "geninput/hid-report-in.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
static bool
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-meta-out.h"
|
||||
#include "geninput/hid-report-out.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
static bool
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-mgr.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-report-in.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
void hid_report_in_init(
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-report-out.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
bool hid_report_out_init(
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/dev-list.h"
|
||||
#include "geninput/hid.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
wchar_t *hid_ri_init_name(const GUID *class_guid, const char *dev_node)
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/hotplug.h"
|
||||
#include "geninput/io-thread.h"
|
||||
#include "geninput/ri.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
static HDEVNOTIFY hotplug_handle;
|
||||
|
||||
void hotplug_init(HWND wnd)
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "bemanitools/glue.h"
|
||||
#include "bemanitools/input.h"
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/thread.h"
|
||||
|
||||
#include "geninput/hid-mgr.h"
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/io-thread.h"
|
||||
@@ -14,10 +17,8 @@
|
||||
#include "geninput/mapper.h"
|
||||
|
||||
#include "util/fs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/msg-thread.h"
|
||||
#include "util/str.h"
|
||||
#include "util/thread.h"
|
||||
|
||||
static HINSTANCE input_hinst;
|
||||
static volatile long input_init_count;
|
||||
@@ -47,7 +48,7 @@ void input_set_loggers(
|
||||
log_formatter_t warning,
|
||||
log_formatter_t fatal)
|
||||
{
|
||||
log_to_external(misc, info, warning, fatal);
|
||||
core_log_impl_set(misc, info, warning, fatal);
|
||||
}
|
||||
|
||||
void input_init(
|
||||
@@ -63,7 +64,7 @@ void input_init(
|
||||
|
||||
mapper_inst = mapper_impl_create();
|
||||
|
||||
thread_api_init(create, join, destroy);
|
||||
core_thread_impl_set(create, join, destroy);
|
||||
msg_thread_init(input_hinst);
|
||||
io_thread_init();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/thread.h"
|
||||
|
||||
#include "geninput/dev-list.h"
|
||||
#include "geninput/hid-generic.h"
|
||||
#include "geninput/hid-mgr.h"
|
||||
@@ -10,9 +13,7 @@
|
||||
#include "geninput/pacdrive.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/thread.h"
|
||||
|
||||
enum io_thread_cmd {
|
||||
IO_THREAD_CMD_STOP,
|
||||
@@ -172,7 +173,7 @@ void io_thread_init(void)
|
||||
|
||||
barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
io_thread_id = thread_create(io_thread_proc, barrier, 16384, 0);
|
||||
io_thread_id = core_thread_create(io_thread_proc, barrier, 16384, 0);
|
||||
|
||||
WaitForSingleObject(barrier, INFINITE);
|
||||
CloseHandle(barrier);
|
||||
@@ -200,6 +201,6 @@ void io_thread_fini(void)
|
||||
|
||||
PostQueuedCompletionStatus(io_thread_cp, 0, (uintptr_t) &msg, NULL);
|
||||
|
||||
thread_join(io_thread_id, NULL);
|
||||
thread_destroy(io_thread_id);
|
||||
core_thread_join(io_thread_id, NULL);
|
||||
core_thread_destroy(io_thread_id);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/kbd-data.h"
|
||||
#include "geninput/kbd.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-mgr.h"
|
||||
#include "geninput/mapper.h"
|
||||
|
||||
#include "util/array.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
struct action_iter {
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/mouse.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hotplug.h"
|
||||
#include "geninput/ri.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/msg-thread.h"
|
||||
|
||||
void msg_window_setup(HWND hwnd)
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/io-thread.h"
|
||||
#include "geninput/pacdrive.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
/* The PacDrive appears to have a malformed descriptor for its OUT report.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "geninput/hid-mgr.h"
|
||||
#include "geninput/hid.h"
|
||||
#include "geninput/kbd.h"
|
||||
@@ -7,7 +9,6 @@
|
||||
#include "geninput/ri.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
struct ri_handle {
|
||||
|
||||
Reference in New Issue
Block a user