From a09487b720a5c7ee2e95c6a6a265528642585525 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 17 May 2022 02:33:39 +0200 Subject: [PATCH] From dhewm3: Add absolute mouse mode and refactor mouse grabbing code The only change really is adding SE_MOUSE_ABS to sysEventType_t. In theory this breaks the ABI, but in practice I don't think mods use sysEventType_t, and certainly not the ones above SE_MOUSE (SE_JOYSTICK_AXIS doesn't make sense as Doom3 never supported Joysticks, SE_CONSOLE is for input from TTY or whatever, and doesn't make sense for mods to use in any way) The change in Stub_SDL_endian.h is just me being paranoid. (side-note: it *might* make sense to replace all that inline-asm in Stub_SDL_endian.h with compiler intrinsics like GCC/clangs __builtin_bswap* and MSVCs _byteswap_* - if they are supported in all relevant compiler versions. GCC supports 32 and 64 bit swaps since 4.3, 16bit since 4.8 and 128bit since 11.x; clang supports 32 and 64 bit swaps at least since 3.0 and 16bit swaps since 3.2; VS introduced _byteswap_ushort, .._ulong and .._uint64 in VS2003) --- sys/Stub_SDL_endian.h | 4 ++++ sys/sys_public.h | 1 + 2 files changed, 5 insertions(+) diff --git a/sys/Stub_SDL_endian.h b/sys/Stub_SDL_endian.h index 0a1743a..ec3934a 100644 --- a/sys/Stub_SDL_endian.h +++ b/sys/Stub_SDL_endian.h @@ -34,6 +34,10 @@ #define SDL_LIL_ENDIAN 1234 #define SDL_BIG_ENDIAN 4321 +#ifndef BUILD_IS_BIG_ENDIAN + #error BUILD_IS_BIG_ENDIAN should be defined! +#endif + #if BUILD_IS_BIG_ENDIAN // this is from config.h, set by cmake #define SDL_BYTEORDER SDL_BIG_ENDIAN #else diff --git a/sys/sys_public.h b/sys/sys_public.h index fbac1a8..b1d68e2 100644 --- a/sys/sys_public.h +++ b/sys/sys_public.h @@ -58,6 +58,7 @@ typedef enum { SE_KEY, // evValue is a key code, evValue2 is the down flag SE_CHAR, // evValue is an ascii char SE_MOUSE, // evValue and evValue2 are reletive signed x / y moves + SE_MOUSE_ABS, // evValue and evValue2 are absolute x / y coordinates in the window SE_JOYSTICK_AXIS, // evValue is an axis number and evValue2 is the current state (-127 to 127) SE_CONSOLE // evPtr is a char*, from typing something at a non-game console } sysEventType_t;