Commit graph

4576 commits

Author SHA1 Message Date
Bill Currie
6dc90c5497 [x11] Remove key focus and destination handling
I'm undecided on how to handle application focus (probably gain/lose
events), and the destination handler has been a stub for a while. One less
dependency on the "old" key handling code.
2021-11-05 14:56:27 +09:00
Bill Currie
31c1eae1ec [x11] Send key events for pasted text
I'm undecided if the pasted text should be sent as a string rather than
individual key events, but this will do the job for now as it gets me
closer to being able to test everything.
2021-11-05 14:54:33 +09:00
Bill Currie
0c8fbf0ce4 [x11] Don't use select for checking for events
It seems that under certain circumstances (window managers?), select is not
reliable for getting key events, so use of select has been disabled until I
figure out what's going on and how to fix it.
2021-11-05 13:30:01 +09:00
Bill Currie
63f5c738ca [x11] Send cooked keyboard and mouse events
For the mouse in x11, I'm not sure which is more cooked: deltas or
window-relative coordinates, but I don't imagine that really matters too
much. However, keyboard and mouse events suitable for 2D user interfaces
are sent at the same time as the more game oriented button and axis events.
2021-11-05 13:26:44 +09:00
Bill Currie
0a885fe704 [x11] Rename x11 input devices to core
The x11 keyboard and mouse devices are really core input devices rather
than x11 input devices in that keyboard and mouse will be present on most
systems and thus not specific to the main user interface (x11, windows,
etc).
2021-11-05 10:02:21 +09:00
Bill Currie
7d022db702 [util] Avoid Sys_Shutdown for IO signals
It turns out that calling Sys_Shutdown in the signal handler can cause
lockups due to the signal occurring at unsafe times. Fortunately, this is
just the IO related signals (INT, HUP, TERM, QUIT) as the others are
usually caused by actual errors and should not occur in system code thus
timing should not be an issue. However, care will need to be taken when it
comes to handling SIGINT or similar for breaking runaway progs code when
that time comes.
2021-11-05 09:56:08 +09:00
Bill Currie
af56e9242b [x11] Clean up duplicate code in software updates
The actual x11 update code was identical between all versions, so it was
moved into the one function.
2021-11-03 22:22:37 +09:00
Bill Currie
16d1232b91 [x11] Connect the X11 input driver to input events
Now nothing works at all ;) However, that's only because the binding
system is incomplete: the X11 input events are getting through to the
binding system, so now it's just a matter of getting that to work.
2021-11-03 22:20:17 +09:00
Bill Currie
825d8b7a49 [input] Make a start on the new binding system
Input Mapping Tables are still at the core as they are a good concept,
however they include both axis and button mappings, and the size is not
hard-coded, but dependent on the known devices. Not much actually works
yet (nq segfaults when a key is pressed).
2021-11-03 19:02:39 +09:00
Bill Currie
14a5ec7b41 [input] Make device add/remove events broadcast
It proved necessary to support broadcasting events to all event
handlers, with device add/remove being the first such events.
2021-11-03 14:08:41 +09:00
Bill Currie
fae9e043df [input] Move button name and description
This puts the name and description into the button itself, making it much
easier to look them up.
2021-11-01 13:54:16 +09:00
Bill Currie
09e3e62a0a [input] Move in_event.h and binding defs
They now live in the include QF/input directory. This cleans up include/QF
a little, and input.h as well.
2021-11-01 13:05:05 +09:00
Bill Currie
665790f562 [video] Remove libQFjs
It is now redundant with the libQFinput, though nothing actually works yet.
2021-11-01 12:30:45 +09:00
Bill Currie
36f6dcc65e [input] Add logical axes
Like logical buttons, logical axes are engine-defined destinations to
which input ("physical") axes can be bound.
2021-10-01 15:38:48 +09:00
Bill Currie
a4f71cb4d5 [renderer] Clean out unneeded input.h includes
I really don't know how it goot into the gl/glsl vid_common files, but I
imagine it propogated to vulkan because I copied one then cloned from
there.
2021-10-01 13:11:14 +09:00
Bill Currie
63c2f829b3 [input] Fix a cut-and-paste error
Just the name of a static function, but still...
2021-10-01 12:10:26 +09:00
Bill Currie
fed8f66824 [input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.

Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 09:16:31 +09:00
Bill Currie
c6a073c1f3 [win] Hook up windows input
Not sure it actually works yet (can't test right now), but since the x11
switch-over worked, it should.
2021-09-28 12:48:47 +09:00
Bill Currie
7fcf6bfef5 [build] Autoconfiscate evdev 2021-09-28 10:57:12 +09:00
Bill Currie
cacf0be7f6 [util] Wrap fd_set
While select itself is reasonably portable, it turns out that including
the declaration for fd_set makes a bit of a mess for QF's clean headers.
2021-09-28 10:53:51 +09:00
Bill Currie
29f8ed388e [x11] Clean up some formatting 2021-09-27 19:54:08 +09:00
Bill Currie
144a83d761 [input] Free phys and uniq device strings
Forgot to do so when I added the strings.
2021-09-27 19:53:16 +09:00
Bill Currie
9732952709 [x11] Use select for checking input
It seems that there's always some incoming event anyway (possibly due to
the constant screen updates) so it doesn't make much difference
currently.
2021-09-27 11:24:35 +09:00
Bill Currie
7f408351b9 [input] Use a single select call for all drivers
For drivers that support it. Polling is still supported and forces the
select timeout to 0 if any driver requires polling. For now, the default
timeout when all drivers use select is 10ms.
2021-09-26 15:11:07 +09:00
Bill Currie
940d824be0 [util] Split out the select code to Sys_Select
While select itself is fairly portable, it's not super convenient.
2021-09-26 14:54:24 +09:00
Bill Currie
349f8067c3 [gamecode] Conform with libc malloc for pr zone
Allocating 0 bytes returns null and freeing a null pointer is safe.
2021-09-26 12:03:44 +09:00
Bill Currie
192b76ddc6 [input] Remove closed device in correct place
Removing the device from the devices list after closing the device
could cause the device to be double-freed if something went wrong in the
device removal callback resulting in system shutdown which would then
close all open devices.

The device is removed from the list before the callback is called.

There's still a small opportunity for such in a multi-threaded
environment, but that would take device removal occurring at the same
time as the input system is shut down. Probably the responsibility of
the threaded environment rather than inputlib.
2021-09-25 16:43:03 +09:00
Bill Currie
13bc38a55b [input,ruamoko,qwaq] Fix incorrect use of PR_RESMAP
I had forgotten that _size was the number of rows in the map, not the
number of objects (1024 objects per row). This fixes the missed device
removal messages. And probably a slew of other bugs I'd yet to encounter
:P
2021-09-25 15:50:16 +09:00
Bill Currie
2119688b48 [gamecode] Use a flag for format width
This ensures caller specified width always gets through to libc's
printf, even if the caller specifies 0. More importantly, * works
correctly.
2021-09-25 13:24:48 +09:00
Bill Currie
cc730c90b4 [input] Rework device registration
And provide functions for collecting axis and button information from a
device id.
2021-09-20 15:21:11 +09:00
Bill Currie
70812b3c49 [input] Hook up low level input to events
This includes device add and remove events, and axis and buttons for
evdev. Will need to sort out X11 input later, but next is getting qwaq
responding.
2021-08-30 14:40:19 +09:00
Bill Currie
5d1e515e9e [qwaq] Hook up input to a certain extent
Really, just enough to show that the initialization process and hotplug
are working. The qwaq input driver is not yet properly integrated.
2021-08-30 09:59:30 +09:00
Bill Currie
b39b6031e8 [input] Give input drivers a private data pointer
The pointer can be updated at any time using the driver handle (returned
by IN_RegisterData).
2021-08-30 09:54:36 +09:00
Bill Currie
05215e0295 [util] Add functions to help convert external times 2021-08-27 12:10:05 +09:00
Bill Currie
5d4013b485 [util] Use clock_gettime for Sys_LongTime
While QF doesn't currently use nanoseconds, having access to a clock
that is not affected by setting system time is nice, and as a bonus, can
handle suspends should the need arise.
2021-08-27 11:22:57 +09:00
Bill Currie
a91dac60d9 [input] Start work on improved input system
The common input code (input outer loop and event handling) has been
moved into libQFinput, and modified to have the concept of input drivers
that are registered by the appropriate system-level code (x11, win,
etc).

As well, my evdev input library code (with hotplug support) has been
added, but is not yet fully functional. However, the idea is that it
will be available on all systems that support evdev (Linux, and from
what I've read, FreeBSD).
2021-08-27 09:10:21 +09:00
Bill Currie
8a5c3c1ac1 [util] Add sys function to get cpu count
And use it in qfvis.
2021-08-13 21:26:48 +09:00
Bill Currie
a01cafe972 [util] Minimize set growth
At the low level, only unions can cause a set to grow. Of course, things
get interesting at the higher level when infinite (inverted) sets are
mixed in.
2021-08-11 12:31:03 +09:00
Bill Currie
37a5b475c0 [util] Minimize the string for infinite sets
Instead of printing every representable member of an infinite set (ie,
up to element 63 in a set that can hold 64 elements), only those
elements up to one after the last non-member are listed. For example,

    {...} - {2 3} -> {0 1 4 ...}

This makes reading (and testing!) infinite sets much easier.
2021-08-11 12:31:03 +09:00
Bill Currie
a6a273bb07 [vulkan] Fix up test function api
Whil I can't automatically run the tests in windows builds, at least I
can make sure they build (and run individual ones by hand as necessary).
2021-08-11 12:31:03 +09:00
Bill Currie
aa72f1dc31 [util] Fix reversed finite-infinite set union ops
It looks like I tried to test it, but my tests weren't so good This
seems to cover everything for the three main set ops.
2021-08-11 12:31:03 +09:00
Bill Currie
c81f2d4b52 [video] Mark dga funcs as const when dga not available
Fixes a compile issue (warning about attribute const) when dga is not
available, thanks to spiritiit for finding it :)
2021-08-11 12:09:07 +09:00
Bill Currie
b320c3352f [util] Make set_t endian-agnostic
Most of the set ops were always endian-agnostic since they were simply
operating on multiple bits in parallel, but individual element
add/remove/test was very endian-dependent. For the most part, this
didn't matter, but it does matter very much when loading external data
into a set or writing the data out (eg, for PVS).
2021-08-08 12:34:18 +09:00
Bill Currie
42dc30ec29 [vulkan] Increase main staging buffer to 32MB
1k 32bpp sky textures need 24MB to load. Though there's always better
handling of running out of stating buffer (ie, flushing and trying
again).
2021-08-02 23:17:55 +09:00
Bill Currie
d56d8ac707 [util] Loosen up the epsilon on simd seb tests
It seems my eeepc's SSE units don't get quite the same answers as does
my i7's (maybe due to lack of hadd?).
2021-08-02 23:15:20 +09:00
Bill Currie
80b17623b1 [util] Fix an out-by-one in pqueue tests
Showed up only when the data arrays were packed.
2021-08-02 23:08:14 +09:00
Bill Currie
ec54c54226 [build] Fix some windows bitrot 2021-08-02 14:02:41 +09:00
Bill Currie
d99fb01b65 [build] Fix some distcheck bitrot 2021-08-02 13:47:00 +09:00
Bill Currie
f76964b86b [util] Add an priority queue implementation
Done via macros (like darray and ringbuffer). Might prove useful for
qfvis and maybe dynamic lights.
2021-08-02 13:29:55 +09:00
Bill Currie
4f2113bc05 [util] Enable accidentally disabled seb tests 2021-08-02 12:44:08 +09:00