Each axis can act as two buttons in both ways.
For example, a player might map slide left and slide right to J1 -A1 and J1 +A1 as button presses instead of the slide L/R axis.
This is mostly to fix XBox 360 Controller Left and Right triggers. But it can work on every axis if the player wishes to bind them.
The subcanvas is positioned based on the dimensions of the containing
window, so it must be repositioned if the outer window is resized.
Reported-by: vLKp <https://github.com/dxx-rebirth/dxx-rebirth/issues/394>
Fixes: f491059ed7 ("Enable building with SDL2")
gcc-7 needs an additional cf_assert to inform it that e.idx is
constrained. Without this, it assumes e.idx could have any positive
value, then issues a fatal warning when INT_MAX does not fit in the
provided buffer.
common/arch/sdl/joy.cpp: In function 'void dcx::joy_init()':
common/arch/sdl/joy.cpp:281:6: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 4 [-Werror=format-truncation=]
common/arch/sdl/joy.cpp:281:6: note: directive argument in the range [1, 2147483647]
common/arch/sdl/joy.cpp:333:13: note: 'snprintf' output between 6 and 24 bytes into a destination of size 8
Add configuration file entries for number of chips, bank index, and
whether to use ADL MIDI. Currently, there is no GUI for this.
Interested users must enable it via direct configuration file editing.
A menu interface will come later.
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it. These domains were converted:
* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible. Use it to avoid generating range checks for
situations that never happen. If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
gcc-7 allows `constexpr auto X = std::initializer_list<unsigned>{A1, A2,
...};`. gcc-8 rejects it:
```
common/arch/sdl/key.cpp:583:105: error: 'const std::initializer_list<const SDL_Scancode>{((const SDL_Scancode*)(&<anonymous>)), 3}' is not a constant expression
constexpr auto sticky_keys = {SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_NUMLOCKCLEAR};
```
Switch to a macro and a fully anonymous list, which is accepted by both
versions.
Fixes: f491059ed7 ("Enable building with SDL2")
This commit enables Rebirth to build with SDL2, but the result is not
perfect.
- SDL2 removed some sticky key support. Rebirth may behave differently
now in this area.
- SDL2 removed some key-repeat related support. Rebirth may behave
differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
the desktop instead of by changing the desktop resolution. Rebirth
uses this, and it mostly works.
- Resizing while in the automap does not notify the automap code, so
the view is wrong until the player switches out of automap mode and
back in.
- SDL2 changed how to enumerate available resolutions. Since
fitting the window to the desktop is generally more useful than
fitting the desktop to the window, I chose to drop support for
enumerating resolutions instead of porting to the new API. Users can
now enter an arbitrary window dimension and Rebirth will make an
attempt to use it.
- It might be useful to cap the window dimension at the desktop
dimension, but that is not done yet.
- Entering fullscreen mode through the Controls->Graphics submenu
failed to notify the relevant subsystems, causing the rendered
content not to rescale. For now, compile out the option to toggle
full screen through that menu. Toggling through Alt+Enter works
properly.
Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all. The remaining issues can be
resolved in future work.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
gcc-8 adds a new warning controlled by -Wcast-function-type, which is
implied on by Rebirth's default options. This new warning rejects
attempts to reinterpret_cast between function pointer types. While this
might provide some value when the function pointer was derived by taking
the address of a properly declared function provided elsewhere in the
same program, it is wrong when the function pointer is returned by an
external library call, such as GetProcAddress, which always returns a
placeholder type instead of the actual type of the target function.
Switch to using a union with type-punning, which achieves the same
effect as the cast, but does not count as a cast, and therefore does not
provoke the warning.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
Users with disabled VSync might not expect any forced waiting on the GPU,
and the GL sync methods were intented to fix issues with VSync only,
so the new heuristic for SYNC_GL_AUTO is to enable GL sync only if
VSync is enabled, too.
Users can still request to use a specific GL sync method via the
-gl_syncmethod switch, independent of the VSync setting.
[Kp: folded `else { if () }` into `else if ()` to avoid moving
`ogl_have_ARB_sync` lines. Original change visible at
<https://github.com/dxx-rebirth/dxx-rebirth/pull/381>.]
This mirrors the logic from calc_frame_time(). When VSync is enabled,
waiting for the previous frame to complete might induce long wait periods,
up to the complete frame time, so we should also handle multiplayer there.
For the other sync modes, the GL calls will simply block, so we can't do
anything about that (except going multithreaded, but that's a totally
different can of worms). Note that even without sync, the SwapBuffers()
call in gr_flip() may also block if VSync is on (and enough frames are
queued up), so the issue is not the GL sync code itself.
SYNC_GL_FENCE_SLEEP is now probably the nicest mode for multiplayer
with VSsync, as it is the only one which has the potential to continue
handling multiplayer packets during the wait for VBlank time.
The Windows exception handler probes the stack to determine how much can
be safely dumped, up to a fixed maximum number of bytes. A logic error
caused the probe function to start its stack probe lower than intended,
so the eventual dump code logs fewer pre-exception bytes than intended.
Fix that error so that the dump shows more pre-exception bytes.
Also, log the address of the ud2 instruction, so that the effective load
address of the module can be determined. Without this, ASLR makes
reading the dumps needlessly difficult.
Some Linux libraries print their own messages to stdout/stderr,
particularly in case of severe errors. Decorate messages generated by
Rebirth to distinguish them from library generated messages.
For specific blacklisted renderers, add a message informing the user
that the blacklist matched and changed settings.
Delete stub "compiler-type_traits.h" header. Redirect all uses to the
standard <type_traits> header.
git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
BEGIN {
$i = 0;
}
if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
# First blank line or first user-include after a system-include.
# Print, then never again for this file.
print "#include <type_traits>\n";
$i = 2;
} elsif ($i == 0) {
$i = 1 if (/^#include </);
} elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
# Remove this line if found.
$_ = '';
}
# Reset state machine when moving to next file.
$i = 0 if eof;
EOF
The dump logger probes for the end of the stack, then rounds down to the
nearest paragraph boundary to simplify the logic in the hexdump routine.
The termination condition in the hexdump code assumed that there would
exist an integer N such that (`start` + (16 * N) == `end`). Since `end`
is rounded to a multiple of 16, this held if and only if `start` is also
a multiple of 16. In practice, this tended to happen, but it was not
guaranteed by the code. If it ever failed to happen, then the hexdump
routine would not terminate and would instead perform an invalid read
beyond the edge of the stack.
Modify the hexdump routine to round `start` to a multiple of 16 so that
the termination condition works as intended. This has the useful side
effect that hex dumps now always start paragraph aligned. When the
stack was not paragraph aligned, this change will cause the hexdump to
show bytes below the stack pointer at the time of the fault. However,
the stack requirements of the handler itself ensure that these bytes
will be valid.
Various points in the game code call `hide_menus()`, then later use
`show_menus()` to reverse the effect. If the forcibly hidden window is
deleted before `show_menus()` is called, the attempt to show it would
write to freed memory. Add a hook to forget those windows when they are
deleted, so that `show_menus()` does not try to make them visible later.
Split ogl_get_verinfo() into ogl_tune_for_current() and
ogl_extensions_init(), and consolidate all the OpenGL extension handling
into ogl_extensions.cpp. Unify the code paths for texture anisotropy and
GPU synchronization for OpenGL and OpenGL ES.
Currently, our renderer only uses GLES 1.0, so no real world implementation
will support sync objects for such an old context, but the logic is valid,
and this way, the GLES specific code paths are reduced.
This patch also fixes an issue where the old ogl_get_verinfo() did modify
the texture filtering mode if no anisotropic filter was available. This
was some leftover from the time when the anisotropic filter was a just
a specific CGameConfig.TexFilt mode, and not a separate, orthogonal setting
CGameCfg.TexAnisotropy that it is now.