aboutsummaryrefslogtreecommitdiff
path: root/src/rinput.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-03-10 02:37:19 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-06 16:41:13 +0100
commit244fea664121acf12871ab5858a5fe95a2606b52 (patch)
treee42b1990ef97adc0f0ab48b9be7e11de7fee0558 /src/rinput.c
parentd86b7b41453c69b3854baa7cdc05a79a3cdfe092 (diff)
downloadsst-244fea664121acf12871ab5858a5fe95a2606b52.tar.gz
sst-244fea664121acf12871ab5858a5fe95a2606b52.zip
Rewrite and redesign codegen and feature system
Also switch to somewhat proper C23 flags while we're at it. This is a huge change. It took me forever, in between being really busy. Sorry about that. But the good news is I'm now free to start integrating the various patches that have accumulated since last release. Well, at least in between still being really busy. Gotta manage expectations. The main benefit of introducing GAMESPECIFIC() is that features that don't apply to a particular game no longer show up *at all*, and less time is wasted on init. It also enables a cool optimisation wherein unnecessary REQUIRE_GAMEDATA() checks can elided at compile time whenever the gamedata is known up-front to always exist in supported games. The DEF_FEAT_CVAR macro family meanwhile makes it easier to manage the lifecycle of cvars/ccmds, with less manual registering, unhiding and such. Originally I was going to try and just hack these features into the existing codegen abomination, but it just got too terrible. This rewrite should make it easier to continue tweaking codegen behaviour in future. It also has slightly better error messages.
Diffstat (limited to 'src/rinput.c')
-rw-r--r--src/rinput.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rinput.c b/src/rinput.c
index 1187e15..6d568f3 100644
--- a/src/rinput.c
+++ b/src/rinput.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2025 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -68,7 +68,7 @@ DEF_CVAR_MINMAX(sst_mouse_factor, "Number of hardware mouse counts per step",
static ssize __stdcall inproc(void *wnd, uint msg, usize wp, ssize lp) {
switch (msg) {
- case WM_INPUT:;
+ case WM_INPUT:
char buf[ssizeof(RAWINPUTHEADER) + ssizeof(RAWMOUSE) /* = 40 */];
uint sz = sizeof(buf);
if_hot (GetRawInputData((void *)lp, RID_INPUT, buf, &sz,
@@ -133,7 +133,7 @@ INIT {
if_cold (!os_mprot(vtable_insys + vtidx_GetRawMouseAccumulators,
ssizeof(void *), PAGE_READWRITE)) {
errmsg_errorx("couldn't make virtual table writable");
- return false;
+ return FEAT_FAIL;
}
orig_GetRawMouseAccumulators = (GetRawMouseAccumulators_func)hook_vtable(
vtable_insys, vtidx_GetRawMouseAccumulators,
@@ -141,7 +141,7 @@ INIT {
}
else {
// create cvar hidden so config is still preserved if we fail to init
- con_reg(m_rawinput);
+ con_regvar(m_rawinput);
}
WNDCLASSEXW wc = {
.cbSize = sizeof(wc),
@@ -172,7 +172,7 @@ INIT {
con_colourmsg(&blue, ", you can scale down the sensor input with ");
con_colourmsg(&gold, "sst_mouse_factor");
con_colourmsg(&blue, "!\n");
- return false;
+ return FEAT_INCOMPAT;
}
if (has_rawinput) {
// no real reason to keep this around receiving useless window messages
@@ -209,13 +209,13 @@ INIT {
ok: m_rawinput->base.flags &= ~CON_HIDDEN;
sst_mouse_factor->base.flags &= ~CON_HIDDEN;
- return true;
+ return FEAT_OK;
e3: DestroyWindow(inwin);
e2: unhook_inline((void *)orig_SetCursorPos);
e1: unhook_inline((void *)orig_GetCursorPos);
e0: UnregisterClassW(L"RInput", 0);
- return false;
+ return FEAT_FAIL;
}
END {