Commit graph

700 commits

Author SHA1 Message Date
Bill Currie
67ec9bfb47 [vid] Initialize x event before sending
Quietens valgrind nicely (though it gave a weird source of the memory).
2020-03-08 21:30:08 +09:00
Bill Currie
9ff4eefe65 Merge branch 'master' into vulkan 2020-02-16 18:17:50 +09:00
Bill Currie
de64be1d67 Show more info when dumping x11 video modes
Found in an old stash. Probably the start of xrandr support.
2020-02-12 11:04:28 +09:00
Bill Currie
4e4d1b99b4 Clean up all the system shutdown calls
I added Sys_RegisterShutdown years ago and never really did anything
with it: now any system that needs to be shutdown can ensure it gets
shutdown on program exit, and in the correct order (ie, reverse to init
order).
2019-07-12 23:15:26 +09:00
Bill Currie
75f19f7243 Completely rework the vulkan related api
Things don't work yet, but this feels much cleaner.
2019-07-12 13:34:31 +09:00
Bill Currie
302a462c32 Make SetMouse timeout after 2 seconds
This makes sure that some unchecked event doesn't cause a lockup.
However, blocking input is really not the way to go: need to implement a
state machine and use non-blocking event reads.
2019-07-10 22:28:33 +09:00
Bill Currie
980cf58ac5 Wait for the window to be visible before mouse warping
This fixes the hang during fullscreen startup on my system (the motion
events weren't being generated because there was no window to see the
motion).
2019-07-10 22:28:33 +09:00
Bill Currie
a4f963f67b Add a cvar to block use of x11 vidmode
Or really, allow it if the user specifically requests it: the default is
blocked. Modern systems (particularly displays) do not really like
changing resolution, so doing so by default seems rather wrong.
2019-07-10 22:28:33 +09:00
Bill Currie
4eb6cf6f9e Make SetMouse timeout after 2 seconds
This makes sure that some unchecked event doesn't cause a lockup.
However, blocking input is really not the way to go: need to implement a
state machine and use non-blocking event reads.
2019-07-10 22:24:11 +09:00
Bill Currie
203d981675 Wait for the window to be visible before mouse warping
This fixes the hang during fullscreen startup on my system (the motion
events weren't being generated because there was no window to see the
motion).
2019-07-10 22:18:51 +09:00
Bill Currie
d5cb432911 Add a cvar to block use of x11 vidmode
Or really, allow it if the user specifically requests it: the default is
blocked. Modern systems (particularly displays) do not really like
changing resolution, so doing so by default seems rather wrong.
2019-07-10 22:15:39 +09:00
Bill Currie
2771e9c573 Correct extension handling
I had missed a critical bit from the cookbook.
2019-07-10 13:16:46 +09:00
Bill Currie
68449d0f6f Create a window and a surface for vulkan
Yay, segfaults in R_Init :)
2019-07-09 16:33:44 +09:00
Bill Currie
8ee06d75a9 Separate render and presentation initialization
This paves the way for clean initialization of the Vulkan renderer, and
very much cleans up the older renderer initialization code as gl and sw
are no longer intertwined.
2019-07-09 01:00:47 +09:00
Bill Currie
cb10175824 Pass vid_internal to R_LoadModule
This fixes the segfault and pushes things very much in the desired
direction of proper system independence for rendering and presentation
separation (though things were headed in the right direction before).
2019-07-08 14:04:03 +09:00
Bill Currie
6ee2df8445 Move vid callbacks into vid_internal
Currently segfaults because viddef is an alias for *r_data->vid, which
has not yet been initialized (chicken and egg).
2019-07-08 13:40:29 +09:00
Bill Currie
3e1520c246 Move vid callback access into vid
The plan is to move the callbacks into a "private" struct.
2019-07-08 12:46:22 +09:00
Bill Currie
34bcf7faab Do a pure/const/noreturn/format attribute pass.
I always wanted these, but as gcc now provides warnings for functions that
could do with such attributes, finding all the functions is much easier.
2018-10-09 12:42:21 +09:00
Bill Currie
59e85b7d5e Fix a pile of dead assignments.
Some were actual bugs!
2018-09-08 22:23:57 +09:00
Bill Currie
1eb1622420 Fix some strncat issues. 2018-09-07 21:27:34 +09:00
Bill Currie
2329fb1885 Fix some warnings and bitrot. 2016-10-25 00:10:30 +09:00
Bill Currie
bd52e46adf Merge branch 'master' into win 2016-01-22 01:10:49 +09:00
Bill Currie
f163e35f21 Add a builtin to get keydown. 2016-01-10 13:33:05 +09:00
Bill Currie
9cb23ba67e Clean up some error messages.
The contractions took the emphasis off where it needed to be.
2016-01-04 16:12:36 +09:00
Bill Currie
aecea5c350 Document most of they key binding system. 2016-01-04 16:11:15 +09:00
Bill Currie
59f60d1ba7 Enable the Key_StringToKeynum builtin.
I don't know why I didn't do it earlier other than lack of need.
2016-01-04 16:10:22 +09:00
Bill Currie
7c16acf4aa Make Key_GetBinding take an imt instead of a name. 2016-01-04 16:06:48 +09:00
Bill Currie
331b054d4a Fix an inappropriate reuse of a variable.
Using "ax"is for the joystick "var"iable is a bit confusing.
2015-06-18 21:22:31 +09:00
Bill Currie
d1f1375df5 Increase number of supported joystick buttons.
Also fix a bug where despite supporting 32 buttons, only 18 were actually
supported, and a similar issue for the number of axes.

My saitek x52 has 34 buttons and 10 axes. Whee.
2014-08-17 11:35:40 +09:00
Bill Currie
f5501fbf24 Fix a pile of automake deprecation warnings.
s/INCLUDES/AM_CPPFLAGS/g

I <3 sed :)
2013-11-24 13:11:50 +09:00
Bill Currie
0f75bdce17 Set the default joystick preamp to 0.01.
At the request of johnnyonflame. I probably should have done this when I
removed the builtin 1/100 scaling from the joystick code.
2013-04-19 13:54:30 +09:00
Bill Currie
9047c3e4ad Fix the invalid keydest errors.
Once and for all: remove the default and move the Sys_Error outside the
switch (changing appropriate breaks to returns). Now gcc will let me know
when I forget to update the switch statements.
2013-02-02 15:22:09 +09:00
Bill Currie
37dfad8e04 Add a command to simulate typing.
It doesn't support backspace or enter yet, but it got the job done for now.
2013-01-29 14:44:33 +09:00
Bill Currie
8de4db0e2d Fix some sizeof snafus.
I'd failed to notice these earlier.
2013-01-28 21:52:18 +09:00
Bill Currie
bc2fa38468 Provide support for axis names.
x/y/z and pitch/yaw/roll (or p/y/r). Johnny's numbers still work, too, of
course.
2013-01-28 21:09:21 +09:00
Bill Currie
9a24c99cf6 Remove the force 1/100 scaling.
That's part of amp's (or preamp's) job.
2013-01-28 19:37:48 +09:00
Bill Currie
5c08e97b0b Ensure the axis button's state starts at 0.
realloc doesn't do that for us.
2013-01-28 19:37:12 +09:00
Bill Currie
1811d00568 Use the correct index for pressing an axis button.
Oops.
2013-01-28 19:36:25 +09:00
Bill Currie
4163a3a8f2 Reduce the default deadzone to 500.
12500 seems a tad high when the range is +/- 32767.
2013-01-28 18:10:49 +09:00
Bill Currie
0ff66268e7 Redo the button axis setup to use key names.
Johnny's number->J_AXISn mapping is preserved, but I had intended for any
key to be supported (J_AXISn was just to ensure free keys were available).
This gives both methods (and some range checking on the axis button
number).
2013-01-28 18:06:30 +09:00
Bill Currie
42c2666036 Clear out some old cruft.
With the new joystic axis system, those cvars are no longer needed.
2013-01-28 18:06:06 +09:00
Bill Currie
475d90e96f Expose Key_StringToKeynum. 2013-01-28 16:34:29 +09:00
Bill Currie
2336b0bcc8 Do some more code split-up. 2013-01-28 16:02:33 +09:00
Bill Currie
3e27689ca8 Begin splitting the code into more easily digested chunks.
While MH's code certainly does the job, it's rather hard to follow with
functions doing different jobs on different calls.
2013-01-27 20:04:34 +09:00
Bill Currie
1740e14d2a Do a const-correctness run on palettes. 2013-01-27 19:57:40 +09:00
Bill Currie
173af3a992 Tweak the deadzone code to work better with pre-amp.
Everthing was fine with pre-amp == 1, but if it was anything else, the
offset would become invalid.
2013-01-27 14:30:13 +09:00
Bill Currie
f5e1983e0f Produce prettier floats in the output. 2013-01-27 14:09:48 +09:00
Bill Currie
dfbb68d573 Terminate the option arrays.
Before they terminate QF.
2013-01-27 14:08:01 +09:00
Bill Currie
1a33d2f682 Do a whitespace run.
Just for long-term sanity's sake.
2013-01-27 14:05:24 +09:00
Johnny on Flame
e3e0d6aaa9 Add menu commands + fixes 2013-01-27 13:17:13 +09:00
Johnny on Flame
ee436d89f6 More in-game console command documentation for in_joy 2013-01-27 13:17:13 +09:00
Johnny on Flame
86e7392e7a A few fixes + boundary checks 2013-01-27 13:17:12 +09:00
Johnny on Flame
637d751aa7 Saves axes behaviours on the config file. 2013-01-27 13:17:12 +09:00
Johnny on Flame
4f92bceb4f Joystick configuration commands. 2013-01-27 13:17:12 +09:00
Bill Currie
c56a075199 Get MH's vid_win.c mostly working for sw and sw32.
There are still a great many problems, but pixels get to the screen in the
right place (for windowed mode, anyway).
2013-01-27 12:53:58 +09:00
Bill Currie
a35f6cadf7 Use the cvar's int_val rather than coverting its value.
Let the cvar system to its job :)
2013-01-25 16:36:00 +09:00
Bill Currie
b3a7ed8a62 Use vid_win.c from engoo as a basis.
Thanks to leilei being a diehard sw quake fan, and MH being the hacker he
is, engoo's vid_win.c drops Scitech's MGL :) (I really did not want to
resurrect that). However, I've modified it so it /compiles/ in QF: ripped
out the menu code, ripped out the input handling (that's in in_win.c) and
started trying to get it to work for vid_render. The clients at least link,
but I'm certain they'll segfault (GPF?).
2013-01-24 21:11:33 +09:00
Bill Currie
d6766a07c5 Use a saner default video resolution.
320x200 is way too small these days.
2013-01-24 15:43:04 +09:00
Bill Currie
4d6fe3694d Add the missing function required for -win.
They're just stubs for now, but nq-win.exe and qw-client-win.exe build. I'm
99.999% certain they won't work, though :P
2013-01-24 12:36:14 +09:00
Bill Currie
d7e98dcd6d Build libvid_win.la.
Now libQFwin.la builds. Once I get nq-win and qw-client-win building, the
"fun" begins.
2013-01-24 12:36:14 +09:00
Bill Currie
bd537ac1b1 Fix vid_win.c compilation.
It will not work yet.
2013-01-24 12:36:14 +09:00
Bill Currie
b0ec63ac56 Remove a dead var.
vid_colormap died with the vid_render plugin birth.
2013-01-24 12:36:14 +09:00
Bill Currie
ae6dfd8cb6 Move the mouse activation/deactivation into in_win.c.
It now gets handled by the keydest callback (I hope it still works).
2013-01-24 12:36:14 +09:00
Bill Currie
40af4bb986 Make vid.width/height unsigned and clean up the mess. 2013-01-24 12:36:14 +09:00
Bill Currie
8153646eda Use a callback for in-game keystate detection.
Yay bitrot :P
2013-01-24 12:36:14 +09:00
Bill Currie
23bd3d99f8 Fix the two unsigned/signed comparison warnings.
Now just for the real error in in_win.c: key_dest.
2013-01-24 12:36:14 +09:00
Bill Currie
d14da7f34a Enable the "win" clients.
The win clients are the native windows (NOT sdl!! *twitch*). Things are
already looking on the up: only three errors in in_win.c. I'm not looking
forward to vid_win.c (ex vid_wgl.c), though.
2013-01-24 12:36:14 +09:00
Bill Currie
b2e92c2864 Rewrite joy_axis and JOY_Move for axis buttons.
First, this completely smashes joystick input: it will not work (though it
doesn't crash). This is because there is, as of yet, no means to configure
the system.

Each joystick axis has:
    - per-axis amplification (both pre and post).
    - per-axis offset (offset applied after pre-amp but before post amp)
    - selectable destination:
        - linear delta: position and angles (as before)
        - axis button: if the value crosses the threshold, the given key is
          pressed or released as appropriate.

The axis amplification still uses joy_amp and joy_pre_amp (and
in_amp/in_pre_amp), but now also has the per-axis settings.

The per-axis offset is most useful for axis buttons. For example, the xbox
360 controller triggers are analong but go "all the way to negative on 0
state". Offsetting the input keeps axis button thresholds simple.

Amplification and offset is applied before anything is done with the axis
value. The formula is:

    joy_amp * in_amp * axis-amp *
        (offset + value * joy_pre_amp * in_pre_amp * axis-pre_amp)

Axis button thresholds are very simple: if the sign of the value is the
same as the sign of the threshold and abs(value) >= abs(threshold), the
button is pressed. While multiple thresholds and keys can be placed on an
axis, only one can be pressed at a time. The threshold furthest from 0
wins.
2013-01-23 13:15:02 +09:00
Bill Currie
35edfae2a0 Add keys for joystick axis buttons.
The idea is to allow a joystick axis to be mapped to button presses. These
allow the buttons to be bound without consuming other possibly valid keys.
2013-01-23 13:15:02 +09:00
Bill Currie
e27d7cbd2d Handle alloca "correctly".
Use AC_FUNC_ALLOCA and the #ifdef mess suggested by the autoconf docs
(hidden in qfalloca.h).
2013-01-22 21:02:50 +09:00
Bill Currie
22ca96ea46 Put the key_dest default back to key_console.
For now, anyway. This is a quick emergency fix for qw-client crashing when
a key is pressed while the client is waiting at the console on startup.
2013-01-19 12:17:57 +09:00
Bill Currie
ace8d9ebc5 Implement dynamic IMTs.
Now the user can create and destroy IMTs at will, though currently
destroying IMTs is currently all or nothing (imt_drop_all).

An IMT is created via imt_create which takes the keydest name (key_game
etc), the name of the IMT (must be unique for all IMTs) and optionally the
name of the IMT to which the key binding search will fall back if there is
no binding in the current IMT, but must be already defined and on the same
keydest. This means that IMTs now have user determined fallback paths. The
requirements for the fallback IMT prevent loops and other weird behaviour.

Actual key binding via in_bind is unaffected. This is why the IMT name must
be unique across all IMTs.

The "imt" command works with the key_game keydest, but imt_keydest is
provided for specifying the active IMT for a specific keydest.

At startup, default IMTs are setup to emulate the previous static IMTs so
old configs will continue to work (mostly). New config files will be
written with commands to drop all of the current IMTs and build new ones,
with the bindings and active IMT set as well.
2013-01-16 19:48:54 +09:00
Bill Currie
ec6ba8a03c Make key_dest private to keys.c
This has the bonus feature of making nq pause the game when input focus is
lost (same conditions as dropping the console or bringing up the menu).
2013-01-16 19:48:54 +09:00
Bill Currie
2a3986368e Use callbacks for key repeat control. 2013-01-16 19:48:54 +09:00
Bill Currie
cf0729c818 Support more than one keydest callback. 2013-01-16 19:48:54 +09:00
Bill Currie
3cb0f3e183 Remove viddef in favor of vid in the renderers.
This fixes the status bar refresh issues in sw. The problem was that with
two viddef's hanging around, things got a little confused and recalc_refdef
wasn't getting into the renderer.
2013-01-16 11:23:47 +09:00
Bill Currie
a8542c2d48 Correct the spelling of QFK_HIRAGANA_KATAKANA.
'twas QFK_HIRAGANA_kATAKANA. Took a while to spot it :P
2013-01-13 18:54:23 +09:00
Bill Currie
e3b8157469 Create a new imt_menu imt.
It seems to work nicely as F10 no longer tries to quit while the menu is
displayed.
2013-01-13 18:19:00 +09:00
Bill Currie
b18305351e Rename game_target to key_target.
Much better name :P
2013-01-13 18:14:16 +09:00
Bill Currie
b1ddae927b Add a command to clear specific IMTs.
in_clear <imt>... where each argument to in_clear is an imt identifier. If
any identifiers are incorrect, the incorrect ones will be displayed and no
tables will be cleared. All or nothing.
2013-01-13 18:05:41 +09:00
Bill Currie
ed8b289315 Make sdl's VID_SetPalette only queue a palette change.
It seems that SDL_SetColors causes a page flip, so VID_SetPalette only
queue a palette change (by checking for the need to change and storing the
requested palete) and VID_Update now checks for a queued palette change and
updates SDL's palette if required. This fixes the flickering console in sw
-sdl introduced by the cshift/centerprint change.
2013-01-13 14:55:15 +09:00
Bill Currie
7206756952 Produce a vidmode list for developer output.
vidmode is starting to show its age. Modern X doesn't need a config file,
and when one is not available, the list of available resolutions is quite
strange. Time to look into randr support.
2013-01-01 15:13:27 +09:00
Bill Currie
ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Ozkan Sezer
6e04fd5ff6 signed int viddef_t members
The attached patch (against quakeforge git) changes the [con]width,
[con]height, and most importantly the rowbytes members of viddef_t
from unsigned to signed int, like in q2.  This allows for a properly
negative vid.rowbytes which may be needed in, e.g. a DIB sections
windows driver if needed.  Along with it, I changed a few places
where unsigned int is used along with comparisons against the relevant
vid.* members.
One thing I am not 100% sure is the signedness requirements of
d_zrowbytes and d_zwidth: q2 has them as unsigned but I am not sure
whether that is because they are needed as unsigned or it was just an
oversight of the id developers. They do look like they should be OK
as signed int to me, though: comments?

==
Note from Bill Currie: I had to do some extra changes as many
signed/unsigned comparisons were somehow missed.
2012-10-21 09:00:50 +09:00
Bill Currie
78f7604efc Evil hack to handle duplicated sdl key syms. 2012-08-18 21:44:51 +09:00
Bill Currie
9250eb83bf Yet more char index issues.
Should be getting near the end of these as qfcc tries to link in my hacked
up tree :)
2012-08-18 21:42:49 +09:00
Sander van Dijk
3c04de1116 Better default vid_gamma value. 2012-07-17 06:30:01 +09:00
Bill Currie
134f9b0e9e Force pr_keys.c to get linked in.
Nothing in the main program currently uses Key_Progs_Init, so the object
file wasn't getting pulled into the link. However, it's quite necessary for
the client console plugin :/
2012-07-16 18:18:13 +09:00
Bill Currie
0f34ab8762 Move pr_keys.c from console to video/targets.
It wasn't very accessible/usable in the client console plugin.
2012-07-15 07:39:50 +09:00
Bill Currie
fcf7150c62 Remove some old renderer specific files. 2012-07-14 07:32:53 +09:00
Bill Currie
a6d9f5d931 Fix a parallel make issue. 2012-07-06 12:35:50 +09:00
Bill Currie
8fa92bf206 Add 32 button support to sdl and win as well.
The world isn't x11 (much as I'd like it to be)
2012-07-02 16:51:14 +09:00
Bill Currie
7cd8806ec0 Add support for up to 32 mouse buttons.
My new mouse reports only up to 9 (skipping 6 and 9, it seems), but I
/have/ seen 32 button mice...
2012-07-02 16:33:57 +09:00
Bill Currie
603fe92cba Add a callback for when key_dest is set. 2012-06-29 18:00:21 +09:00
Bill Currie
3406cad99a Many distcheck fixes.
Yay, bitrot :P
2012-06-29 10:49:21 +09:00
Bill Currie
dbc203b625 And a few more bits of whitespace. 2012-05-23 08:21:27 +09:00
Bill Currie
23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie
bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie
7fc99f9c60 Fix gl and glsl support in sdl. 2012-04-12 16:47:37 +09:00
Bill Currie
8401704c4e Connect up palette setting for gl and glsl.
The GL plugin now seems to work. GLSL still segs :(
2012-04-12 13:57:05 +09:00