Commit graph

4935 commits

Author SHA1 Message Date
Bill Currie
3c17efe91b [console] Unhook hooked functions on shutdown
Forgetting to unhook the functions (Sys_Printf and the client console's
input event handler) was not a problem for static builds because the
functions were always present, but in builds with dynamic plugins, the
client console's code got ripped away and thus Sys_Printf and the event
hander were being sent into invalid memory. Too much work, not enough
play (with a fully installed client).
2021-12-29 21:50:38 +09:00
Bill Currie
5f4a330b02 [console] Tweak the server status bar colors
Now the yellow stands out nicely.
2021-12-28 00:06:12 +09:00
Bill Currie
1be220559a [zone] Add function to retrieve memory usage 2021-12-27 20:12:03 +09:00
Bill Currie
65f78b43ac [gamecode] Try to set field def size
This fixes the edicts command not printing anything useful.
2021-12-27 19:02:39 +09:00
Bill Currie
94871671d2 [qw] Use a callback for netchan logging
This gets outgoing packet logging working again. Yay, fill my hard-drive
faster ;)
2021-12-27 17:54:58 +09:00
Bill Currie
cafc6a541f [gamecode] Get PR_Profile working
The switch from using pr_functions (dfunction_t) to function_table
(bfunction_t) for keeping track of the current function (and thus
profiling data) broke PR_Profile as it never saw anything but 0.
2021-12-27 13:50:49 +09:00
Bill Currie
6368791d2b [gamecode] Check entity_var is valid before display
Even NUM_FOR_BAD_EDICT will have a bad day if the edict pointer is
invalid, so make sure that the entity pointer is valid (within the edict
area AND a multiple of edict size).
2021-12-27 13:47:55 +09:00
Bill Currie
f373192a02 [gamecode] Set pr_string_resources in PR_Strings_Init
Like for debug, this is the most sensible place as the pointer will
never change.
2021-12-26 22:46:07 +09:00
Bill Currie
5588d0de60 [gamecode] Separate debug byte-swap and pointer init
PR_LoadDebug now does only the initial version and crc checks, and the
byte-swapping of the loaded symbols file. PR_DebugSetSym sets up all the
pointers.
2021-12-26 22:39:37 +09:00
Bill Currie
c9f372fa38 [gamecode] Set pr_debug_resources in PR_Debug_Init
And use the cached value in PR_LoadDebug.
2021-12-26 20:35:09 +09:00
Bill Currie
c163b311d0 [gamecode] Create hash tables in PR_Init
This makes much more sense than in PR_LoadProgsFile (and simplifies the
latter, too).
2021-12-26 20:33:37 +09:00
Bill Currie
c11a930436 [simd] Set the homogeneous coord in the csvf test
The homogeneous coord was not being initialized and thus was picking up
rubbish from the stack. This is why the test would succeed in some
circumstances but fail in others.
2021-12-26 12:25:06 +09:00
Bill Currie
8385046486 [qfcc] Warn when super dealloc invocation is missing
Forgetting to invoke [super dealloc] in a derived class's -dealloc
method has caused me to waste far too much time chasing down the
resulting memory leaks and crashes. This is actually the main focus of
issue #24, but I want to take care of multiple paths before I consider
the issue to be done.

However, as a bonus, four cases were found :)
2021-12-24 22:45:43 +09:00
Bill Currie
5bfe0e5d34 [sw] Update for changed particle field names
Fixes 32-bit x86 target builds.
2021-12-24 19:33:06 +09:00
Bill Currie
2b25748cc4 [ruamoko] Correct SetIterator memory handling
This makes SetIterator more compatible with autorelease.
2021-12-24 06:45:13 +09:00
Bill Currie
7571231100 [input] Get single axis info for unbound devices
This doesn't fix the problem of keyhelp not working for axes belonging
to unbound devices, but may be a step in the right direction.
2021-12-24 06:45:13 +09:00
Bill Currie
2e3e9ea7c0 [ruamoko] Actually save the cooke
This fixes the listener leak.
2021-12-24 06:45:13 +09:00
Bill Currie
f77da210ff [ruamoko] Merge listener cookie code
I know that duplication would turn around and bite me :P
2021-12-24 06:45:13 +09:00
Bill Currie
b726c24b05 [ruamoko] Reset parameters before setting in listener
It's right there in the docs, even (though only on the macro, which I'd
forgotten about). Fixes some nasty corruption.
2021-12-24 06:45:13 +09:00
Bill Currie
dad19aa2ad [input] Correct balanced range calculation
Fixes axis inputs being half what they should be. Can't quite get +1,
though (need to figure something out for the positive axis range being
slightly smaller than the negative range).
2021-12-24 06:45:13 +09:00
Bill Currie
f3918471d5 [ruamoko] Add bindings for the main IMT functions
IMT_SetContextCbuf is not bound as that requires cbuf to be bound.
However, imt contexts can be created, fetched and set.
2021-12-24 06:45:13 +09:00
Bill Currie
0c41c11f1d [gamecode] Use a new developer flag for builtin debug
rua_resolve works for now
2021-12-24 06:45:13 +09:00
Bill Currie
6d64b2c47c [vulkan] Build particle buffers 2021-12-24 06:45:13 +09:00
Bill Currie
a4c4155a51 [vulkan] Clean up packet submission
In the end, there's no need for the two paths and I want to be able to
submit empty packets with semaphores.
2021-12-24 06:45:13 +09:00
Bill Currie
dcd1fa28ba [ruamoko] Get the input bindings working
With some hacks that are not included (plan on handling events and
contexts properly), button inputs, including using listeners, are
working nicely: my little game is working again. While the trampoline
code was a bit repetitive (and I do want to clean that up), connecting
button listeners directly to Ruamoko instance methods proved to be quite
nice.
2021-12-24 06:45:13 +09:00
Bill Currie
23e3b4c2e5 [ruamoko] Retrieve a plitem_t from PropertyList
And also internally for cross-builtin use.
2021-12-24 06:45:13 +09:00
Bill Currie
f1d097c0c4 [ruamoko] Add bindings for Mercenne Twister 2021-12-24 06:45:13 +09:00
Bill Currie
91a686d1f5 [util] Add mtwist float random number functions
mtwist_rand_0_1 produces numbers in the range [0, 1) and
mtwist_rand_m1_1 produces numbers in the range (-1, 1). The numbers will
not be denormal, so the distribution should be fairly uniform (as much
as Mersenne Twister itself is), but this needs proper testing.

0 is included for the mtwist_rand_0_1 as it seems useful, but -1 is not
included in mtwist_rand_m1_1 in order to keep the extremes of the
distribution balanced around 0.
2021-12-24 06:45:13 +09:00
Bill Currie
6411518603 [ruamoko] Make some progress on the input bindings 2021-12-24 06:45:13 +09:00
Bill Currie
3cb93d4cbe [input] Add functions to get single axis/button info
Handy for retrieving the current state (raw) of a single axis or button.
2021-12-24 06:45:13 +09:00
Bill Currie
803c9defae [input] Clean out more keys.h refs 2021-12-24 06:45:13 +09:00
Bill Currie
33e48025dd [ruamoko] Replace rua_key with rua_input
And create rua_game to coordinate other game builtins.

Menus are broken for key handling, but have been since the input rewrite
anyway. rua_input adds the ability to create buttons and axes (but not
destroy them). More work needs to be done to flesh things out, though.
2021-12-24 06:45:13 +09:00
Bill Currie
2cb987fdb5 [build] Clean up a pile of distcheck issues 2021-12-24 06:45:13 +09:00
Bill Currie
2d109e615b [client] Clean up a stray reference to the renderer
Reaching into the renderer internals for r_worldmodel doesn't work when
the plugins are not static.
2021-12-24 06:45:13 +09:00
Bill Currie
194f958666 [console] Add a comment about skipping the first char
I had to dig through logs of deleted files to find out what was going
on. Forget six months later, twenty years...
2021-12-24 06:45:13 +09:00
Bill Currie
e0863ff067 [net_chan] Clean out unnecessary include
net_chan was still including client.h from qw when it no longer needed
it (I guess I forgot to clean that out when I resolved any last
dependencies).
2021-12-24 06:45:13 +09:00
Bill Currie
d70d72e6e4 [particles] Create a psystem object
This takes care of the global variables to a point (there is still the
global struct shared between the non-vulkan renderers), but it also
takes care of glsl's points-only rendering.
2021-12-24 06:45:13 +09:00
Bill Currie
372c89b479 [particles] Merge physics code
The particle physics is called by the renderer.
2021-12-24 06:45:13 +09:00
Bill Currie
8d2791752e [particles] Merge particle spawning into client
After yesterday's crazy marathon editing all the particles files, and
starting to do another big change to them today, I realized that I
really do need to merge them down. All the actual spawning is now in the
client library (though particle insertion will need to be moved). GLSL
particle rendering is semi-broken in that it now does only points (until
I come up with a way to select between points and quads (probably a
context object, which I need anyway for Vulkan)).
2021-12-24 06:45:13 +09:00
Bill Currie
81a5e076ac [vulkan] Move render pass array init
Having it in Vulkan_Init_Common means the array can be used in more
places than just Vulkan_CreateRenderPass (which probably needs a
rename).
2021-12-24 06:45:13 +09:00
Bill Currie
2be19046b6 [vulkan] Allow render passes to not have a render pass
This may seem a little contradictory, but it's due to the difference
between a high level (engine) render pass and a Vulkan render pass
object (and quite likely a poor choice in names for the high level
object). This is necessary for supporting compute shader dispatches as
they cannot be submitted inside a Vulkan render pass.
2021-12-24 06:45:13 +09:00
Bill Currie
43cdca330b [client] Add bindings for load and quickload in demos 2021-12-24 06:45:13 +09:00
Bill Currie
aacd2575d2 [sw,sw32] Ensure the particle system is initialized
This fixes the missing particles (because mtwist_rand was returning 0).
2021-12-24 06:45:13 +09:00
Bill Currie
ce4bb1d56c [renderer] Move particles over to simd
This has the advantage of getting entity_t out of the particle system,
and much easier to read math. Also, it served as a nice test for my
particle physics shaders (implemented the ideas in C). There's a lot of
code that needs merging down: all but the actual drawing can be merged.

There's some weirdness with color ramps, but I'll look into that later.
2021-12-24 06:45:13 +09:00
Bill Currie
4d1e8b2375 [vulkan] Update the number of drawn quads correctly
They should increment by one for each pic, not 4 (I think some fluff
remaining from copying glsl's draw code).

I noticed the problem when I saw large gaps of 0s in the vertex data in
renderdoc.
2021-12-24 06:45:13 +09:00
Bill Currie
be7216e660 [vulkan] Implement crosshair rendering
That makes quite the difference to playability.
2021-12-24 06:45:13 +09:00
Bill Currie
6b84ae5554 [renderer] Update crosshair color on palette changes
This gets the crosshair working in Vulkan (next commit) and fixes issues
with changing the palette (though I've never seen a different palette
for quate, there's still the change from "all black" to an actual
palette).
2021-12-24 06:45:13 +09:00
Bill Currie
83ec2be2a6 [vid] Add a listener set for palette changes
This was needed to get crosshaircolor working correctly, but is likely
another step towards resizable windows (the listener set types are
generic for any viddef event, not just palette changes).
2021-12-24 06:45:13 +09:00
Bill Currie
cd641e2b1c [vulkan] Clean up alias push-constants 2021-12-24 06:45:13 +09:00
Bill Currie
8b1eec08cf [scene] Provide direct access to the world matrix
Holding onto the pointer is not a good idea, and it is read-only as
direct manipulation of the world matrix is not supported. However, this
is useful for passing the matrix to the GPU.
2021-12-24 06:45:13 +09:00
Bill Currie
869cc4050c [vulkan] Flush bsp vertex indices after all drawing 2021-12-24 06:45:13 +09:00
Bill Currie
36e98f013e [vulkan] Clean up bsp push-constants. 2021-12-24 06:45:13 +09:00
Bill Currie
081c46da7a Clean up some white space 2021-12-24 06:45:13 +09:00
Bill Currie
b9bc3fa132 [vulkan] Split out the push constants helper
It proved to work well in the sprite pipeline, and should be useful for
cleaning up the magic numbers in bsp and alias.
2021-12-24 06:45:13 +09:00
Bill Currie
0b99ff104d [vulkan] Clear the color attachments
This means color, emission, and translucent. Fixes the HOM issues on my
VersaPro (but halves the frame-rate... definitely need to bring back the
forward renderer as an option).
2021-12-24 06:45:13 +09:00
Bill Currie
db6c76d583 [vulkan] Abandon bindless rendering
At least for now, it is more trouble than it is worth as it (or my
implementation of it) breaks lavapipe and renderdoc.
2021-12-24 06:45:13 +09:00
Bill Currie
8228146ac0 [vulkan] Use the particle system buffer for indirect draws
I realized I'd need to get the particle counts out to the draw commands
somehow, and this seemed to be the most natural way.
2021-12-24 06:45:13 +09:00
Bill Currie
6aaf5c3722 [vulkan] Start work on particles for Vulkan
This gets the pipelines loaded (and unloaded on shutdown). Probably the
easy part :P. Still need to sort out the command buffers,
synchronization, and particle generation (and probably a bunch else
that's not coming to mind).
2021-12-24 06:45:13 +09:00
Bill Currie
9dcaa98205 [vulkan] Clean up a pile of C&P fluff 2021-12-24 06:45:13 +09:00
Bill Currie
e0af6541e6 [vulkan] And a bunch of buffer barrier transitions
These seem to be the most likely ones for compute shaders (some based on
my ideas for particles).
2021-12-24 06:45:13 +09:00
Bill Currie
7901f87960 [vulkan] Add support for compute shaders
This needed changing Vulkan_CreatePipeline to
Vulkan_CreateGraphicsPipeline for consistency (and parsing the
difference from a plist seemed... not worth thinking about).
2021-12-24 06:45:13 +09:00
Bill Currie
0d4ece875d [vulkan] Use indexed initializers for barriers
This will make maintaining the arrays much easier: no worries about
getting things out of sync.
2021-12-24 06:45:13 +09:00
Bill Currie
6a7f78485a [zone] Use memccpy instead of strncpy
Probably the best way to tell gcc I know what I'm doing.
2021-12-24 06:45:13 +09:00
Bill Currie
f7c14a9b39 [sw32] Use the shared R_GetSpriteFrame
One less copy of near-identical code.
2021-12-24 06:45:13 +09:00
Bill Currie
5223752f9e [vulkan] Fix lighting size calculation
It turns out the required memory size is not guaranteed to be aligned.
2021-12-24 06:45:13 +09:00
Bill Currie
c366b1b7bb [vulkan] Implement the sprite render passes
It turned out the bindless approach wouldn't work too well for my design
of the sprite objects, but I don't think that's a big issue at this
stage (and it seems bindless is causing problems for brush/alias
rendering via renderdoc and on my versa pro). However, I have figured
out how to make effective use of descriptor sets (finally :P).

The actual normal still needs checking, but the sprites are currently
unlit so not an issue at this stage.
2021-12-24 06:45:13 +09:00
Bill Currie
dafe591446 [renderer] Start merging sprite frame calculation
This covers gl and sw. sw32 should be trivial (just haven't done it),
but glsl will take a little. Vulkan will use it.
2021-12-24 06:45:13 +09:00
Bill Currie
743a732bd7 [vulkan] Correct the semantics of QFV_NextOffset
I'm not at all sure what I was thinking when I designed it, but I
certainly designed it wrong (to the point of being fairly useless). It
turns out memory requirements are already aligned in size (so just
multiplying is fine), and what I really wanted was to get the next
offset aligned to the given requirements.
2021-12-24 06:45:13 +09:00
Bill Currie
36e0d857a2 [vulkan] Create the non-C side of the sprite pipeline
This adds the shaders and the pipeline specs. I'm not sure that the
deferred rendering side of the render pass is appropriate, but I thought
I'd give it a go, since quake sprites are really cutoff rather than
translucent.
2021-12-24 06:45:13 +09:00
Bill Currie
2db8d11dd0 [vulkan] Clean up some excessive descriptor sets
With the switch to multi-layer textures for brush models, the bsp and
alias texture descriptor sets became identical and thus the definitions
shareable. However, due to complications I don't want to address yet,
they're still separately identified, but I should be able to use the
texture set for most, if not all, pipelines.
2021-12-24 06:45:13 +09:00
Bill Currie
0eb556b8f9 [vulkan] Load sprite model data
The vertices and frame images are loaded into the one memory object,
with the vertices first followed by the images.

The vertices are 2D xy+uv sets meant to be applied to the model
transform frame, and are pre-computed for the sprite size (this part
does support sprites with varying frame image sizes).

The frame images are loaded into one image with each frame on its own
layer. This will cause some problems if any sprites with varying frame
image sizes are found, but the three sprites in quake are all uniform
size.
2021-12-24 06:45:13 +09:00
Bill Currie
c5cfcc7bfd [sprite] Separate model and texture loading
As much as it can be since the texture data is interleaved with the
model data in the files (I guess not that bad a design for 25 years ago
with the tight memory constraints), but this paves the way for
supporting sprites in Vulkan.
2021-12-24 06:45:13 +09:00
Bill Currie
e7e6dd87e8 [glsl] Fix some const-correct issues for textures 2021-12-24 06:45:13 +09:00
Bill Currie
2b332cfe4a [zone] Clean up some magic numbers 2021-12-24 06:45:13 +09:00
Bill Currie
854c92d10e [simd] Indicate when the circumsphere is degenerate
CircumSphere_vf sets the sphere radius to -1 when the points are
degenerate (co-linear for three points, co-planar for four points).
2021-12-24 06:45:13 +09:00
Bill Currie
eee25d21ba [zone] Clean out unnecessary memsets
As the cache blocks are always filled in with a memcpy, there's no need
to zero out the whole allocation, and the header is initialized anyway.
2021-12-24 06:45:13 +09:00
Bill Currie
ff40563fc0 [zone] Squeeze cache_system_t to fit into 64 bytes
The cache system pointers are now indices into an array of
cache_system_t blocks, allowing them to be 32 bits instead of 64, thus
allowing cache_system_t to fit into a single CPU cache line. This still
gives and effective 38 bits (256GB) of addressing for cache/hunk. This
does mean that the cache functions cannot work with more than 256GB, but
should that become a problem, cache and working hunking hunk can be
separate, and it should be possible to have multiple cache systems.
2021-12-24 06:45:13 +09:00
Bill Currie
d857bdea77 [vulkan] Fix a typo and gcc purity warning 2021-12-24 06:45:13 +09:00
Bill Currie
fde47d6983 [quakefs] Clean out some excess memsets
There's no point in zeroing out memory that is only going to be
overwritten by the loaded file (excess bytes beyond the end of a
massaged text file shouldn't be accessed anyway, and the terminating
null is still written).
2021-12-24 06:45:13 +09:00
Bill Currie
2086125e0b [quakefs] Take in the pointer to the global hunk
This is needed for cleaning up excess memsets when loading files because
Hunk_RawAllocName has nonnull on its hunk pointer (as the rest of the
hunk functions really should, but not just yet).
2021-12-24 06:45:13 +09:00
Bill Currie
39c020908c [zone] Return the pointer to the global hunk
In trying to reduce unnecessary memsets when loading files, I found that
Hunk_RawAllocName already had nonnull on it, so quakefs needed to know
the hunk it was to use. It seemed much better to to go this way (first
step in what is likely to be a lengthy process) than backtracking a
little and removing the nonnull attribute.
2021-12-24 06:45:13 +09:00
Bill Currie
0a5981878b [sprite] Clean up field names and casting
No wonder I hated the sprite code: I couldn't see the code for all the
casts (and hungarian warts).
2021-12-24 06:45:13 +09:00
Bill Currie
1df3c2eea0 [renderer] Make R_BillboarFrame's comments true
While they weren't entirely false, they were overly verbose and thus
clouded the point.
2021-12-24 06:45:13 +09:00
Bill Currie
3a17e062da [renderer] Merge sprite billboarding code
As the sw renderer's implementation was the closest to id's, it was used
as the model (thus a fair bit of cleanup is still needed). This fixes
some incorrect implementations in glsl and gl.
2021-12-24 06:45:13 +09:00
Bill Currie
8c5c39cbe4 [vulkan] Mix turb full-brights into main color
I'd forgotten (when doing the original brush texture loader) that
turbulent surfaces were unlit and thus always full-bright, then never
wrote the turb shader to take care of it. The best solution seems to be
to just mix the two colors in the shader as it will allow turb surfaces
to be lit in the future (probably with severely limited light counts due
to being a forward renderer).
2021-12-24 06:45:13 +09:00
Bill Currie
d5b824a47c [vulkan] Switch alias pipeline to multi-texture
This gets the alias pipeline in line with the bsp pipeline, and thus
everything is about as functional as it was before the rework (minus
dealing with large texture sets).
2021-12-24 06:45:13 +09:00
Bill Currie
11492d77ce [vulkan] Switch bsp renderer to multi-texture
I guess it's not quite bindless as the texture index is a push constant,
but it seems to work well (and I may have fixed some full-bright issues
by accident, though I suspect that's just my imagination, but they do
look good).
2021-12-24 06:45:13 +09:00
Bill Currie
6fbce335bb [vulkan] Add an array view for default_magenta
The validation layers get very picky about image view types (rightfully
so, I imagine).
2021-12-24 06:45:13 +09:00
Bill Currie
2740f6093b [vulkan] Update shaders and layouts for new scheme
Still need to work on the code, though.
2021-12-24 06:45:13 +09:00
Bill Currie
8422732505 [vulkan] Move matrices into per-frame buffers
This should fix the horrid frame rate dependent behavior of the view
model.

They are also in their own descriptor set so they can be easily shared
between pipelines. This has been verified to work for Draw.
2021-12-24 06:45:13 +09:00
Bill Currie
e8961342d5 [vulkan] Fix some mostly harmless typos 2021-12-24 06:45:13 +09:00
Bill Currie
d7f588ecfe [vulkan] Rework bsp texture loader
BSP textures are now two-layered with the albedo and emission in the two
layers rather than two separate images. While this does increase memory
usage for the textures themselves (most do not have fullbright pixels),
it cuts down on image and image view handles (and shader resources).
2021-12-24 06:45:13 +09:00
Bill Currie
ea4ac894d8 [model] Swap fullbright/top/bottom color func params
This makes them semantically compatible with memcpy.
2021-12-24 06:45:13 +09:00
Bill Currie
ff6d6f6dd6 [vulkan] Rework shaders and pipelines for bindless textures
Smashing everything in the process :P (need to work on the C side).
However, while bindless is supposedly good for performance, the biggest
gain this will bring is portability: the texture counts are
automatically limited to what the hardware can handle, and the reliance
on push descriptors is removed (though they were nice and did help get
things up and running).
2021-12-24 06:45:13 +09:00
Bill Currie
3a742f59f7 [vulkan] Copy array() parameters correctly
I had forgotten that the parameters are in reverse order, and even if I
had remembered, I forgot to reset offset before the second loop.
Pre-decrementing offset takes care of both issues at once.
2021-12-24 06:45:13 +09:00
Bill Currie
a0c935e8bc [vulkan] Make lighting samplers configurable
My VersaPro doesn't support more than 32 per-stage samplers (lavapipe).
This is a small part of getting Vulkan to run on lavapipe and even in
itself is rather incomplete.
2021-12-24 06:45:13 +09:00
Bill Currie
062f616548 [cexpr] Add support for casting plitems
This allows using references in expressions, eg:

    $frames.size * size_t($properties.limits.maxSamplers)

As references remain property list items until actually evaluated.
2021-12-24 06:45:13 +09:00
Bill Currie
e7b067d6a9 [cexpr] Add some functions for size_t and uint
Casting for size_t and uint, and min/max/bound for size_t.
2021-12-24 06:45:13 +09:00
Bill Currie
ee1c3e7db5 [cexpr] Clean up the macros a little 2021-12-24 06:45:13 +09:00
Bill Currie
f6cc138f48 [vulkan] Provide access to VkPhysicalDeviceLimits
Fixes the warning about parse_fixed_array not being used (oops, the
problem with partial commits), but more importantly, gives access to
things like maxDescriptorSetSamplers.
2021-12-24 06:45:13 +09:00
Bill Currie
cff23ac93c [vulkan] Connect up the cexpr library
This will make property list expressions easier to work with. The
library is rather limited right now (trig, dot, min/max/bound) but even
just min adds a lot of functionality.
2021-12-24 06:45:12 +09:00
Bill Currie
d2eb928210 [cexpr] Add a small library with some useful functions
For now, just dot product, trig, and min/max/bound, but it works well as
a proof of concept. The main goal was actually min. Only the list of
symbols is provided, it is the user's responsibility to set up the
symbol table and context.
2021-12-24 06:45:12 +09:00
Bill Currie
44102f2639 [cexpr] Support chained contexts for scoping
cexpr's symbol tables currently aren't readily extended, and dynamic
scoping is usually a good thing anyway. The chain of contexts is walked
when a symbol is not found in the current context's symtab, but minor
efforts are made to avoid checking the same symtab twice (usually cased
by cloning a context but not updating the symtab).
2021-12-24 06:45:12 +09:00
Bill Currie
049968b38e white space 2021-12-24 06:45:12 +09:00
Bill Currie
4e8718980f [cexpr] Remove some disabled code
It looks like a munged commit, but I think I had decided that it was
best to make cvar access explicit.
2021-12-24 06:45:12 +09:00
Bill Currie
8271860fb3 [vkgen] Add support for fixed arrays
I want to support reading VkPhysicalDeviceLimits but it has some arrays.
While I don't need to parse them (VkPhysicalDeviceLimits should be
treated as read-only), I do need to be able to access them in property
list expressions, and vkgen generates the cexpr type descriptors too.

However, I will probably want to parse arrays some time in the future.
2021-12-24 06:45:12 +09:00
Bill Currie
c8846f8007 [cexpr] Support array indexing
The index is currently limited to ints, and is bounds checked (the array
type has a size field indicating the number of elements).
2021-12-24 06:45:12 +09:00
Bill Currie
c73e4efcb7 [vkgen] Don't queue types for fields with custom parsers
This ensures that unused parser blocks do not get emitted. In the
testing of the upcoming support for fixed arrays, the blend color
constants were being double emitted (both as custom and normal parser)
due to being an array. gcc did not like that (what with all those
warning flags).
2021-12-24 06:45:12 +09:00
Bill Currie
a522464fc1 [vkgen] Clean up an unnecessary function redirect
I think it was mostly a holdover from early development, but it
certainly makes sense to tuck the functionality away in Struct.
2021-12-24 06:45:12 +09:00
Bill Currie
c402275112 [vulkan] Add some more debug stack contexts 2021-12-24 06:45:12 +09:00
Bill Currie
75d06c4f98 [vulkan] Clean out some expired FIXME comments 2021-12-24 06:45:12 +09:00
Bill Currie
928408bad9 [vulkan] Support multiple render passes
Multiple render passes are needed for supporting shadow mapping, and
this is a huge step towards breaking the Vulkan render free of Quake,
and hopefully will lead the way for breaking the GL renderers free as
well.
2021-12-24 06:45:12 +09:00
Bill Currie
84a24dbb34 [renderer] Make R_RenderView private
This is actually a better solution to the renderer directly accessing
client code than provided by 7e078c7f9c.

Essentially, V_RenderView should not have been calling R_RenderView, and
CL_UpdateScreen should have been calling V_RenderView directly. The
issue was that the renderers expected the world entity model to be valid
at all times. Now, R_RenderView checks the world entity model's validity
and immediately bails if it is not, and R_ClearState (which is called
whenever the client disconnects and thus no longer has a world to
render) clears the world entity model. Thus R_RenderView can (and is)
now called unconditionally from within the renderer, simplifying
renderer-specific variants.
2021-12-24 06:45:12 +09:00
Bill Currie
eb828007e9 [vulkan] Add a comment about next pass timing 2021-12-24 06:45:12 +09:00
Bill Currie
b1ba87e5aa [vulkan] Use the short name for the image types
Yay for coming up with a solution for enums short names that start with
a number, makes things more readable.
2021-12-24 06:45:12 +09:00
Bill Currie
614c744693 [cexpr] Use ` to allow identifiers to start with a number
The generated short names for a lot of Vulkan enums start with a number
(eg VK_IMAGE_TYPE_2D -> 2d). Having to prefix the short name with ` is a
tiny cost for the convenience.
2021-12-24 06:45:12 +09:00
Bill Currie
a6703c95cf [plist] Allow ` to be used without quotes
It has no special meaning when parsing property lists, so there's no
reason to require quotes around it.
2021-12-24 06:45:12 +09:00
Bill Currie
9e755f270e [vulkan] Set staging fence timeout to 5 seconds
0.5s seemes to be unreliable on my VersaPro, particularly after a large
build.
2021-12-24 06:45:12 +09:00
Bill Currie
02ba3da0ba [vulkan] Ease writing of specialization data
While using binary data objects for specialization data works for bools
(as they can be 0 or -1), they don't work so well for numeric values due
to having to get the byte order correct and thus are not portable, and
difficult to get right.

Binary data is still supported, but the data can be written as a string
with an array(...) "constructor" expression taking any number of
parameters, with each parameter itself being an expression (though
values are limited at this stage).

Due to the plist format, quotes are required around the expression
("array(...)")
2021-12-24 06:45:12 +09:00
Bill Currie
bd31f40c9b [cexpr] Support varargs functions
While there may be better solutions, I needed a varargs function for
building Vulkan specialization data. Like progs functions, negative
parameter counts indicate ellipsis with the number of fixed parameters
being equal to -param_count - 1.
2021-12-24 06:45:12 +09:00
Bill Currie
422ad2a6c9 [vulkan] Recreate lighting pvs sets when loading lights
Sets never shrink, so assigning a dynamically created set to a
statically created set after the working size has reduced (going from
demo2 to demo3) causes the set code to attempt to resize the statically
created set, which leads to libc having a bad time.
2021-12-24 06:45:12 +09:00
Bill Currie
0c0fce2f03 [vulkan] Drop lights with size 0
They can't contribute any light, so no point in keeping them. Fixes the
erroneous size-0 shadow maps in the second nq demo.
2021-12-24 06:45:12 +09:00
Bill Currie
08721f7a21 [vulkan] Destroy the right framebuffers
Why nvidia's drivers accepted double-destroyed framebuffers is beyond
me, but this fixes the Intel drivers complaining about such (and the
subsequent segfault).
2021-12-24 06:45:12 +09:00
Bill Currie
5b1052087a [vulkan] Calculate matrix offset correctly
When I changed the matrices from an array of floats to an array of
vec4f_t, I forgot to update the flush offsets. Yay for having a
Vulkan-capable Intel device with its different alignment requirements.
2021-12-24 06:45:12 +09:00
Bill Currie
25559243ae [vulkan] Add function to compute next offset
When allocating memory for multiple objects that have alignment
requirements, it gets tedious keeping track of the offset and the
alignment. This is a simple function for walking the offset respecting
size and alignment requirements, and doubles as a size calculator.
2021-12-24 06:45:12 +09:00
Bill Currie
8d58dee4b1 [input] Ensure button id is never 0
IN_ButtonAction treats id 0 as not pressed in its internal processing,
and the previous input implementation treated 0 as "no key", so this is
both the simplest and most correct fix.

Fixes mouse left button not working every second time the game is run
(due to keyboard and mouse bindings swapping places in the config file
(separate issue, if it really is one)).
2021-12-18 14:17:40 +09:00
Bill Currie
68de8615d6 [input] Set cbuf of correct imt context
This fixes key_demo bindings not working. Quite the face-palm.
2021-12-17 08:33:13 +09:00
Bill Currie
cbf84d815f [client] Add default bindings for key_demo
Just F10 (quite) and ` (toggleconsole) so the two can be used during
demos, but just this is a major improvement.
2021-12-17 08:33:02 +09:00
Bill Currie
9d4017885f [cvar] Preserve cvars loaded from config files
This restores the equivalent functionality that seta in config.cfg
provided (no more losing my volume setting after using -nosound).
2021-12-17 08:32:36 +09:00
Bill Currie
032f9971ed [plist] Remove incorrect const from PL_RemoveObjectForKey
I'm not sure what I was thinking when I made PL_RemoveObjectForKey take
a const plitem. One of those times where C could do with being a little
more strict.
2021-12-17 08:30:00 +09:00
Bill Currie
d76cf9202d [x11] Create barriers only when grabbing
While using barriers is a zillion times better than actually grabbing
the mouse and keyboard, they're still a pain when debugging as qf is not
able to respond to the barrier-hit events. All the other logic is still
there so even when "grabbing", the mouse will not be blocked if the
window doesn't have focus.
2021-12-06 07:27:08 +09:00
Bill Currie
8b85e422d7 [vulkan] Add a debug stack to the vulkan instance
The stack is arbitrary strings that the validation layer debug callback
prints in reverse order after each message. This makes it easy to work
out what nodes in a pipeline/render pass plist are causing validation
errors. Still have to narrow down the actual line, but the messages seem
to help with that.
Putting qfvPushDebug/qfvPopDebug around other calls to vulkan should
help out a lot, tool.
As a bonus, the stack is printed before debug_breakpoint is called, so
it's immediately visible in gdb.
2021-11-30 18:10:48 +09:00
Bill Currie
2334798432 [vulkan] Make vulkan_use_validation easier more useful
Rather than just 0/1, it now acts as flags to control what messages are
printed. In addition to the Vulkan enum names (long and short), none and
all are supported (as well as raw numbers, but they're not checked for
validity). This makes vulkan_use_validation a bit easier to use and less
verbose by default.

Now, if only it was easier to remember the name :P
2021-11-30 18:10:48 +09:00
Bill Currie
901619235b [vulkan] Split out cvar enum parsing code
Need to reuse it :)
2021-11-30 18:10:48 +09:00
Bill Currie
52f86adb84 [vulkan] Fail gracefully if vulkan driver init fails
Well, a little more gracefully than a segfault, at least.
2021-11-30 18:10:48 +09:00
Bill Currie
c9508f7261 [vkgen] Name-shorten extension enum flag bits
The prefix was being stripped, but not the _BIT_EXT suffix. This makes
extension flags a little easier to use.
2021-11-30 18:10:48 +09:00
Bill Currie
1efeac6d60 [vkgen] Support specifying enum "searches" directly
Being able to parse enums that aren't part of a specified struct is
handy for cvars.
2021-11-30 18:10:18 +09:00
Bill Currie
f36fa23666 [client] Block binding of the escape key
Id's binding of escape to togglemenu interfered with the hard-coding
(want escape to togglemenu (or console as a fallback) no matter what).
This idea was part of mercury's original design, too.
2021-11-28 23:22:11 +09:00
Bill Currie
b0447c1cf1 [console] Get message modes and menus working again
I'm not at all happy with con_message and con_menu, but fixing them
properly will take a rework of the menus (planned, though). Also, the
Menu_ console command implementations are a bit iffy and could also do
with a rewrite (probably part of the rest of the menu rework) or just
nuking (they were part of Johnny on Flame's work, so I suspect had
something to do with joystick bindings).
2021-11-28 23:21:55 +09:00
Bill Currie
376e838d1c [console] Remove togglechat implementation
It has always been just a clone of toggleconsole, so the command has
been linked to toggleconsole's implementation instead.
2021-11-28 21:17:06 +09:00
Bill Currie
652546a4fb [input] Clean out a lot of obsolete stuff from keys
The new binding system makes much of keys.[ch] obsolete leaving only the
key name translations.
2021-11-27 12:31:24 +09:00
Bill Currie
70c2fdce9e [client] Move default input config to its own file
This makes it much easier to maintain the config.
2021-11-25 20:23:18 +09:00
Bill Currie
b01c38903d [x11] Clamp barriers to the screen
It seems X11 does not like creating barriers entirely off the screen,
though the error seems to be a little unreliable (however, off the left
edge was definitely bad).
2021-11-25 20:23:18 +09:00
Bill Currie
d1153be594 [build] Move plist rules to root Makefile
They are globally useful rather than specific to the vulkan renderer.
2021-11-25 20:23:18 +09:00
Bill Currie
62f592b92c [input] Create an automatic imt switcher
An imt switcher automatically changes the context's active imt based on
a user specified list of binary inputs. The inputs may be either buttons
(indicated as +button) or cvars (bare name). For buttons, the
pressed/not pressed state is used, and cvars are interpreted as ints
being 0 or not 0. The order of the inputs determines the bit number of
the input, with the first input being bit 0, second bit 1, third bit 2
etc. A default imt is given so large switchers do not need to be fully
configured (the default imt is written to all states).

A context can have any number of switchers attached. The switchers can
wind up fighting over the active imt, but this seems to be something for
the "user" (eg, configuration system) to sort out rather than the
switcher code enforcing anything.

As a result of the inputs being treated as bits, a switcher with N
inputs will have 2**N states, thus there's a maximum of 16 inputs for
now as 65536 states is a lot of configuration.

Using a switcher, setting up a standard strafe/mouse look configuration
is fairly easy.

    imt_create key_game imt_mod
    imt_create key_game imt_mod_strafe imt_mod
    imt_create key_game imt_mod_freelook
    imt_create key_game imt_mod_lookstrafe imt_mod_freelook
    imt_switcher_create mouse key_game imt_mod_strafe +strafe lookstrafe +mlook freelook
    imt_switcher 0 imt_mod 2 imt_mod 4 imt_mod_freelook 8 imt_mod_freelook 12 imt_mod_freelook
    imt_switcher 6 imt_mod_lookstrafe 10 imt_mod_lookstrafe 14 imt_mod_lookstrafe
    in_bind imt_mod mouse axis 0 move.yaw
    in_bind imt_mod mouse axis 1 move.forward
    in_bind imt_mod_strafe mouse axis 0 move.side
    in_bind imt_mod_lookstrafe mouse axis 0 move.side
    in_bind imt_mod_freelook mouse axis 1 move.pitch

This takes advantage of imt chaining and the default imt for the
switcher (there are 8 states that use imt_mod_strafe).

The switcher name must be unique across all contexts, and every imt used
in a switcher must be in the switcher's context.
2021-11-25 20:23:18 +09:00
Bill Currie
1a79915d22 [input] Add axis listeners
The listener is invoked when the axis value changes due to IN_UpdateAxis
or IN_ClampAxis updating the axis. This does mean the listener
invocation make be somewhat delayed. I am a tad uncertain about this
design thus it being a separate commit.
2021-11-25 20:04:08 +09:00
Bill Currie
8e8a573876 [input] Add listeners to buttons
The listener is invoked when the button state changes.
2021-11-25 20:04:08 +09:00
Bill Currie
c4118a4bf1 [util] Add listeners to cvars
Listeners are separate to the main callback as listeners have only
read-only access to the objects, but the main callback is free to modify
the cvar and thus can act as a parser and validator. The listeners are
invoked after the main callback if the cvar is modified. There does not
need to be a main callback for the listeners to be invoked.
2021-11-25 17:46:16 +09:00
Bill Currie
3f299155a3 [client] Reimplement legacy bind and unbind commands
This allows id1/qw config files, and to a certain extent scripts, to
work with the new binding system. It does highlight just how limited the
original system was (many keys could not bound).

Mouse axis input does not work yet as that needs a little more work to
support +strafe and +mlook.
2021-11-25 13:36:02 +09:00
Bill Currie
6a395e3416 [input] Remove some cruft
The disabled commands were implemented elsewhere or are no longer
relevant.
2021-11-25 13:36:02 +09:00
Bill Currie
fba1a1ac6b [input] Rebuild the button binding string
I had forgotten that Cmd_Args() preserves quotes, which resulted in
button bindings having excess quotes when used to bind complex commands
(eg, the default quicksave and quickload bindings).
2021-11-25 13:36:02 +09:00
Bill Currie
3bd922e473 [input] Correct a typo in in_bind's help text 2021-11-25 13:36:02 +09:00
Bill Currie
c069e7754f [util] Add a listener object
I decided cvars and input buttons/axes need listeners so any changes to
them can be propagated. This will make using cvars in bindings feasible
and I have an idea for automatic imt switching that would benefit from
listeners attached to buttons and cvars.
2021-11-25 13:36:02 +09:00
Bill Currie
67735182d7 [x11] Protect XInput2 and XFixes code
This will allow QF to be built in the unlikely event XInput2 or XFixes
are not available. nq-x11 seemed to work nicely with both disabled.
2021-11-24 02:17:08 +09:00
Bill Currie
b45acf7974 [x11] Add a comment about grabbing design 2021-11-24 01:51:52 +09:00
Bill Currie
719525a4a1 [x11] Set backed mouse button state for raw presses
Fixes button press events being treated as button releases in the event
handlers.
2021-11-23 23:21:43 +09:00
Bill Currie
28b80d8bf8 [x11] Handle raw motion events (more) correctly
For now, only the first two axis (mouse X and Y) are supported (XInput
treats the scroll wheel events as axes too, so mice have up to 4!), but
most importantly, this prevents the scroll wheel from being seen as the
X axis. Oops.
2021-11-23 23:15:08 +09:00
Bill Currie
1ef99a9130 [input] Separate absolute and relative axis inputs
Combining absolute and relative inputs at the binding does not work well
because absolute inputs generally update only when the physical input
updates, so clearing the axis input each frame results in a brief pulse
from the physical input, but relative inputs must be cleared each frame
(where frame here is each time the axis is read) but must accumulate the
relative updates between frames.

Other than the axis mode being incorrect, this seems to work quite
nicely.
2021-11-23 22:04:17 +09:00
Bill Currie
78b4e8217e [x11] Fix a optimization compiler warning
With the old headers removed, X11_SetGamma became a stub and gcc
complained about it wanting the const attribute. On investigation, it
turned out the X_XF86VidModeSetGamma was a holdover from the initial
implementation of hardware gamma support.
2021-11-23 12:44:21 +09:00
Bill Currie
af5d92708d [x11] Implement raw keyboard input via XInput2
UI key presses are still handled by regular X events, but in-game
"button" presses arrive via raw keyboard events. This gives transparent
handling of keyboard repeat (UI keys see repeat, game keys do not),
without messing with the server's settings (yay, that was most annoying
when it came to debugging), and the keyboard is never grabbed, so this
is a fairly user-friendly setup.

At first, I wasn't too keen on capturing them from the root window
(thinking about the user's security), but after a lot of investigation,
I found a post by Peter Hutterer
(http://who-t.blogspot.com/2011/09/whats-new-in-xi-21-raw-events.html)
commenting that root window events were added to XInput2 specifically
for games. Since application focus is tracked and unfocused key events
are dropped very early on, there's no way for code further down the
food-chain to know there even was an event, abusing the access would
require modifying the x11 input code, in which case all bets are off
anyway and any attempt at security anywhere in the code will fail,
meaning that nefarious progs code and the like shouldn't be a problem.
2021-11-23 11:39:48 +09:00
Bill Currie
0c1927d631 [x11] Remove -nomouse handling
After a lot of thought, it really doesn't make sense to have an option
to block mouse input in x11 (not grabbing or similar does make sense, of
course). Not initializing mouse input made perfect sense in DOS and even
console Linux (SVGA) what with the low level access.
2021-11-22 23:54:31 +09:00
Bill Currie
c3ce12de4c [x11] Use root window for barriers
It turns out that if the barriers are set on the app window, and the app
grabs the pointer (even passively), barrier events will no longer be
sent to the app. However, creating the barriers on the root window and
the events are selected on the root window, the barrier events are sent
regardless of the grab state.
2021-11-22 15:42:22 +09:00
Bill Currie
d930a49de6 [console] Close console when escape key is pressed
I should have fixed this back when I got console working with the new
input system.
2021-11-22 14:59:32 +09:00
Bill Currie
bc0451634a [input] Drop unfocused evdev axis/button events
The kernel knows nothing about X11 application focus, so we need to take
care of it ourselves.

Device add/remove events are unaffected: the are always passed on.
2021-11-22 14:59:32 +09:00
Bill Currie
ce8eac5ca0 [x11] Send app focus loss/gain events
Other subsystems, especially low-level input drivers, need to know when
the app has input focus. eg, as the evdev driver uses the raw stream
from the kernel, which has no idea about X application focus (in fact,
it seems the events are shared across multiple apps without any issue),
the evdev driver sees all the events thus needs to know when to drop
them.
2021-11-22 14:59:32 +09:00
Bill Currie
67483eea37 [input] Make event names easy to print
Handy for debugging and testing.
2021-11-22 14:59:32 +09:00
Bill Currie
e8a7e8218e [x11] Check hit barrier is valid before releasing pointer
It turns out to be possible to get a barrier event at the same time as a
configure notify event (which rebuilds the barriers), and trying to
release the pointer at such a time results in a bad barrier error and
program crash. Thus check the event barrier against the currently
existing barriers before attempting to release the pointer.

This does mean that a better mechanism for sequencing window
repositioning and barrier creation may be required.
2021-11-22 14:59:32 +09:00
Bill Currie
3ac6d2aa22 [x11] Use barriers to trap the pointer in the window
This should be a much friendlier way of "grabbing" input, though I
suspect that using raw keyboard events will result in a keyboard grab,
which is part of the reason for wanting a friendly grab.

There does seem to be a problem with the mouse sneaking out of the
top-right and bottom-left corners. I currently suspect a bug in the X
server, but further investigation is needed.
2021-11-22 14:59:27 +09:00
Bill Currie
3af078b77a [x11] Send app_window event when window moves
This is needed for getting window position info into in_x11 without
exposing more globals, and is likely to be useful for other things,
especially as it doubles as a resize event when that's eventually
supported.
2021-11-22 13:20:13 +09:00
Bill Currie
4391b87d04 [x11] Grab focus when the pointer enters the window
This is necessary in focus-follows-mouse environments (at least for
openbox, but it wouldn't surprise me if most other WMs behave the same
way) because the WMs don't set focus when the pointer is grabbed (which
XInput does before the WM sees the enter event). This is especially
important when the window is fullscreen on a multi-monitor setup as
there is no border to *maybe* catch the mouse before it enters the
window.
2021-11-21 23:42:33 +09:00
Bill Currie
a32f83d50f whitespace 2021-11-21 23:42:33 +09:00
Bill Currie
e45d19835c [x11] Add initial support for XInput2
Right now, only raw pointer motion and button events are handled, and
the mouse escapes the window, and there are some issues with focus in
focus-follows-mouse environments. However, this should be a much nicer
setup than DGA.
2021-11-21 23:42:33 +09:00
Bill Currie
4944c40f86 [x11] Remove the magic number for mouse buttons
The current limit is still 32. Dealing with it properly will take some
rather advanced messing with XInput, and will be necessary assuming
non-XInput support is continued.
2021-11-21 22:16:08 +09:00
Bill Currie
26a1f66b4e [x11] Split up in_x11_init into three stages
There's now IN_X11_Preinit, IN_X11_Postinit (both for want of better
names), and in_x11_init. The first two are for taking care of
initialization that needs to be done before window creation and between
window creation and mapping (ie, are very specific to X11 stuff) while
in_x11_init takes care of the setup for the input system. This proved
necessary in my XInput experimentation: a passive enter grab takes
effect only when the pointer enters the window, thus setting up the grab
with the pointer already in the window has no effect until the pointer
leaves the window and returns.
2021-11-21 21:22:11 +09:00
Bill Currie
95becc5c05 [x11] Add some braces around an if block 2021-11-21 21:16:55 +09:00
Bill Currie
fe2dd013be [x11] Clean out some unnecessary includes 2021-11-21 21:16:55 +09:00
Bill Currie
8988008ad6 [x11] Don't mess with the mouse when going fullscreen
This was always a horrible hack just to get the screen centered on the
window back when we were doing fullscreen badly. With my experiments
with XInput, it has proven to be a liability (I'd forgotten it was even
there until it started imposing a 2s delay to QF's startup).
2021-11-21 20:59:49 +09:00
Bill Currie
925a55f6cc [input] Allow drivers to initialize cvars early
Input driver can now have an optional init_cvars function. This allows
them to create all their cvars before the actual init pass thus avoiding
some initialization order interdependency issues (in this case, fixing a
segfault when starting x11 clients fullscreen due to the in_dga cvar not
existing yet).
2021-11-21 11:33:58 +09:00
Bill Currie
88b3965794 [vulkan] Pick up vulkan.h from correct location
Well... it could be done better, but this works for now assuming it's in
/usr/include (and it's correct for mxe builts). Does need proper
autoconfiscation, though.
2021-11-19 22:36:19 +09:00
Bill Currie
e080bb333c [win] Update windows input for new binding system
Seems to work nicely for keyboard (though key bindings are not
cross-platform). Mouse not tested yet, and I expect there are problems
with it for absolute inputs (yay mouse warp :P).
2021-11-19 13:52:40 +09:00
Bill Currie
b1d388563e [input] Don't specify ld flags for evdev lib
libtool gets confused if the convenience library has normal library
linker flags and fails to properly relink the main library when
installing.
2021-11-19 12:08:58 +09:00
Bill Currie
48ecfcf411 [cexpr] Fix a naming issue with uint
I didn't notice that uint is defined somewhere on Linux... until I tried
compiling for windows (not defined). Use a define to keep the cast
function naming nice.
2021-11-19 08:58:02 +09:00
Bill Currie
b892ce637a [input] Nuke IN_Move from orbit
gotta be sure :)

On a serious note, it was always a problem in that it had
client-specific code and concepts embedded in the libraries.
2021-11-19 08:58:02 +09:00
Bill Currie
793914718f [x11] Implement input names
Mouse axis and button names are handled internally (and thus
case-insensitive).

Key names are handled by X11. Case-sensitivity is currently determined
by Xlib.
2021-11-18 13:01:33 +09:00
Bill Currie
84f746dab2 [input] Allow button and axis inputs to be named
keyhelp provides the input name if it is known, and in_bind tries to use
the provided input name if not a number. Case sensitivity for name
lookups is dependent on the input driver.
2021-11-18 12:59:18 +09:00
Bill Currie
f4c521d51d [input] Move in_devbindings_t definition
In the end, it doesn't need to be public, so move it into in_binding.c
2021-11-18 11:17:04 +09:00
Bill Currie
c3fa0d6464 [input] Fix incorrect arg count in in_unbind_f
Yay for copying and editing code :P
2021-11-16 20:14:33 +09:00
Bill Currie
1381932552 [input] Fix imt block management
Reset the blocks completely when loading configs and fix a leftover from
when I thought I'd expose the block numbers to bindings but then changed
my mind to simply track the base binding.
2021-11-16 20:12:53 +09:00
Bill Currie
111e5d923e [cexpr] Support casting to double
For int, uint and float, also add uint to float (not that it will do any
good for values over 16M).
2021-11-16 19:59:47 +09:00
Bill Currie
73ab33ba97 [input] Actually return the button in IN_FindButton
Returning the wrapper object makes for some weird behaviour.
2021-11-16 16:33:53 +09:00
Bill Currie
7739972f19 [x11] Block raw inputs if cooked inputs are handled
The cooked inputs (ie_key, ie_mouse) are intended for UI interaction, so
generally should have priority over the raw events, which are intended
for game interaction.
2021-11-16 12:55:55 +09:00
Bill Currie
b8baa04b2e [input] Split binding event handler
There's now an internal event handler for taking care of device addition
and removal, and a public event handler for dealing with device input
events in various contexts In particular, so the clients can check for
the escape key.
2021-11-16 12:54:23 +09:00
Bill Currie
b80c19bd77 [util] Save and load cvars to/from plist configs
Other than some backwards compatibility, this completes the
configuration updates for now.
2021-11-15 22:04:29 +09:00
Bill Currie
fede9125e1 [input] Save/load config to/from plist configs
While the console command line is quite good for setting everything up,
the devices being bound do need to be present when the commands are
executed (due to needing extra data provided by the devices). Thus
property lists that store the extra data (button and axis counts, device
names/ids, connection names, etc) seems to be the best solution.
2021-11-14 10:17:05 +09:00
Bill Currie
7c9f3a3b09 [util] Expose the quakerc check function
qargs probably needs to go away. It certainly needs to be rethought. For
now, this is good enough to get qw working with plist-based
quakeforge.cfg
2021-11-14 10:12:14 +09:00
Bill Currie
6a9e5f4970 [input] Fix incorrect placement of pure attribute
Should be on the prototype, not definition (for public functions).
2021-11-14 10:10:39 +09:00
Bill Currie
08083b8630 [input] Use double for recipe float values
Recipes themselves still use float, but using double in the cexpr values
allows bare floating point numbers (which parse as double) to be used,
making the bind command line a little more user-friendly.
2021-11-12 08:09:41 +09:00
Bill Currie
adaa3c5485 [input] Get bindings actually working
The mouse bound to movement axes works (though signs are all over the
place, so movement direction is a little off), and binding F10 (key 68)
to quit works :)
2021-11-12 00:24:04 +09:00
Bill Currie
6e85377d7a [cexpr] Support variable assignment
I might have to add code to block it when necessary, but it's needed for
axis recipe parsing.
2021-11-12 00:19:58 +09:00
Bill Currie
5557bf0b09 [input] Implement axis binding
Each axis binding has its own recipe (meaning the same input axis can be
interpreted differently for each binding)

Recipes are specified with field=value pairs after the axis name.
Valid fields are minzone, maxzone, deadzone, curve and scale, with
deadzone doubling as a balanced/unbalanced flag.

The default recipe has no zones, is balanced, and curve and scale are 1.
2021-11-11 15:51:47 +09:00