This property can be used for selecting which display dosbox should
initially use. Number 0 can be either primary display or left-most
display, depending on OS and user settings.
This fixes mouse visibility issues on the Raspberry Pi,
which uses an older customized version of SDL2. SDL2 on
the Pi fires different windows events in a different
order, making dealing with states challenging.
To handle this generically, we additionally assess the
mouse capture state after the Window has gained focus.
We also add a "has_focus" state tracking boolean to the
SDL object, which protects against general SDL mouse
trigger events from changing the mouse state before the
Window has "risen" and delivered us an EXPOSED or FOCUS
event. In the prior code rapidly clicking the mouse while
DOSBox was starting could freeze the mouse cursor in
place on the Pi.
We still also assess the mouse state on EXPOSE events,
which is fired after full - windowed modes are toggled.
The EXPOSE even occurs reliably on OSX, X11, Wayland, and
Windows after the window has settled (but is never fired
on the Pi).
vsync is an option introduced by SDL2 patch, but the testing indicates,
that it very rarely (if ever) works. We still want to support it, but
this might require serious implementation effort, so for the time being
we're removing broken option to prevent confusing the users.
It's the easiest way to prevent problems when user wants to play the
game using fullscreen while explicitly setting tiny resolution
for a specific game (e.g. 320x200).
All rendering backends except output=surface assume input buffer row
with the same length as output buffer row. Surface is "special" and in
fullscreen uses pitch equal to *screen* width instead. Padding the
output rows with black pixels is necessary for splash screen to show up
correctly.
SCREEN_SURFACE is no longer the default option, and it's usable only for
debugging purposes. Move it to the last position in switches, to make
texture and opengl a little bit faster.
Usually, when window is being created without SDL_WINDOW_OPENGL flag,
SDL2 internally re-creates it to support OpenGL during
SDL_CreateRenderer if needed.
This leads to crash in AMD OpenGL drivers (Windows only), which happens
for drivers: "opengl", "opengles", "opengles2".
When the window is created with correct flag from the get-go, the crash
does not happen.
On Linux, the code does not crash either way (at least not when using
Mesa and AMDGPU open source driver), so there's no point in propagating
the hack.
Also, remove a comment that is no longer relevant to the code below.
Lock/UnlockTexture is stable and works very well on Linux and with
OpenGL texture driver and on Linux and Windows, but it's usage caused
problems with content of updated texture when used with drivers:
'direct3d11' on Windows and 'metal' on macOS.
Also, Lock/Unlock turned out to be the root cause of deadlocks for
'opengl' driver on AmigaOS.
According to SDL2 documentation, using Lock/UnlockTexture is supposed to
be faster, but in DOSBox usecase we couldn't confirm significant
performance change - there are some community reports indicating, that
UpdateTexture might be actually faster (but we couldn't confirm it
either).
Discussion on this topic can be found on SDL forum:
https://forums.libsdl.org/viewtopic.php?t=9728
In our case, switch to UpdateTexture has no serious negative impact, but
makes the behaviour more robust across the board.
Make the user settings affect splash screen as well as emulator; this
way, when user wants to start in fullscreen, the splash screen will be
displayed in fullscreen - making the startup process more streamlined.
This fixes long-standing problem on SteamOS (or Steam in Big Picture
mode), when starting dosbox moves the user out of fullscreen to window
(to show tiny splash screen), and then back to fullscreen.
Simplify the code displaying the splash screen and extract it to a new
function. Using GFX_* functions avoids the problem of re-creating
the window from scratch after splash is shown, which solves a lot of
problems:
- application window is always visible on screen, it does not disappear
for a moment between closing splash and starting emulator.
- seriously reduces resolution trashing on start
- user will not experience loss of window focus due to splash screen
disappearing (this was happening e.g. on AmigaOS)
Usage of this function depends on the state of global sdl struct; and
it's very easy to make a mistake - documentation should lower this risk.
Change the type of output parameter 'pitch' and assure type safety with
internal SDL types via static asserts.
This used to have meaning for Windows 9x support via SDL 1.2; the issue
described in README was never mentioned in the context of SDL2.
Add missing include to video header while we're at it.
The previous function could only be effectively run one because
it changes the value of the global 'joytype' to something other
than AUTO, which is what this function looks for to re-query
the joysticks.
Second, if this function is run more than once, then it clobbers
the prior set number of joysticks back to zero (without
re-requerying for the actual quantity), rendering the joysticks
unuseable.
Finally, this function depends on several SDL calls to the joystick
subsystem, but fails to check or initialize it.
The commit:
- Checks for an initializes the joystick subsystem before using it
- Always re-queries the current state of the joystick (re-runnable)
- Simplifies the logic to determine useability (retains criteria)
- Conservatively writes the joysticks quantities at the end
The new output type `texturepp' was added, which implements
pixel-perfect scaling using SDL's hardware-accelerated texture output.
In pixel-pefect mode, each original pixel is displayed as a rectangle m
by n pixels, so that m:n yields a reasonably good approximation of the
pixel aspect ratio (PAR) of the emulated graphical mode while using as
much screen space as possible. The balance between the precision of
aspect ratio and the utilisation of screen space is specified as the
`parweight' parameter to pp_getscale() and is currently hard-coded in
sdlmain.cpp.
This implementation emulatates pixel-perfect mode as a special case of
nearest-neighbor interpolation when the horisontal and vertical scaling
factors are integers.