build/.libs/SDL_hidapi.o: In function `SDL_EnableGameCubeAdaptors':
src/hidapi/SDL_hidapi.c:1593: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1594: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1596: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1604: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1608: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1614: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1623: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1626: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1628: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1609: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1620: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1615: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1616: undefined reference to `libusb_release_interface'
build/.libs/SDL_hidapi.o: In function `SDL_hid_init_REAL':
src/hidapi/SDL_hidapi.c:1086: undefined reference to `libusb_init'
src/hidapi/SDL_hidapi.c:1087: undefined reference to `libusb_exit'
src/hidapi/SDL_hidapi.c:1088: undefined reference to `libusb_get_device_list'
src/hidapi/SDL_hidapi.c:1089: undefined reference to `libusb_free_device_list'
src/hidapi/SDL_hidapi.c:1090: undefined reference to `libusb_get_device_descriptor'
src/hidapi/SDL_hidapi.c:1091: undefined reference to `libusb_get_active_config_descriptor'
src/hidapi/SDL_hidapi.c:1092: undefined reference to `libusb_get_config_descriptor'
src/hidapi/SDL_hidapi.c:1093: undefined reference to `libusb_free_config_descriptor'
src/hidapi/SDL_hidapi.c:1094: undefined reference to `libusb_get_bus_number'
src/hidapi/SDL_hidapi.c:1095: undefined reference to `libusb_get_device_address'
src/hidapi/SDL_hidapi.c:1096: undefined reference to `libusb_open'
src/hidapi/SDL_hidapi.c:1097: undefined reference to `libusb_close'
src/hidapi/SDL_hidapi.c:1098: undefined reference to `libusb_claim_interface'
src/hidapi/SDL_hidapi.c:1099: undefined reference to `libusb_release_interface'
src/hidapi/SDL_hidapi.c:1100: undefined reference to `libusb_kernel_driver_active'
src/hidapi/SDL_hidapi.c:1101: undefined reference to `libusb_detach_kernel_driver'
src/hidapi/SDL_hidapi.c:1102: undefined reference to `libusb_attach_kernel_driver'
src/hidapi/SDL_hidapi.c:1103: undefined reference to `libusb_set_interface_alt_setting'
src/hidapi/SDL_hidapi.c:1104: undefined reference to `libusb_alloc_transfer'
src/hidapi/SDL_hidapi.c:1105: undefined reference to `libusb_submit_transfer'
src/hidapi/SDL_hidapi.c:1106: undefined reference to `libusb_cancel_transfer'
src/hidapi/SDL_hidapi.c:1107: undefined reference to `libusb_free_transfer'
src/hidapi/SDL_hidapi.c:1108: undefined reference to `libusb_control_transfer'
src/hidapi/SDL_hidapi.c:1109: undefined reference to `libusb_interrupt_transfer'
src/hidapi/SDL_hidapi.c:1110: undefined reference to `libusb_handle_events'
src/hidapi/SDL_hidapi.c:1111: undefined reference to `libusb_handle_events_completed'
collect2: ld returned 1 exit status
These report their VID/PID as a Nintendo Switch Pro controller, but they are actually left/right Joy-Cons. We'll fix up the joystick GUID so applications can handle them appropriately.
This reverts commit ff233fe306.
This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
This makes the joystick locking more robust by holding the lock while updating joysticks.
The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().
It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.
Fixes https://github.com/libsdl-org/SDL/issues/6063
In order to inhibit the screen saver, SDL currently uses
`org.freedesktop.ScreenSaver.Inhibit()` and, as a fallback, a protocol
specific method for X11 or Wayland.
Accessing `org.freedesktop.ScreenSaver` is usually not allowed when
inside a sandbox like Flatpak, unless the permission has been explicitly
granted to the application.
Another issue is that the Wayland protocol "Idle inhibit" is relatively
new and not yet widely adopted. For example Mutter still doesn't support
it.
For those reasons, when running under Flatpak or Snap, we should try to
inhibit the screen saver by using xdg-desktop-portal instead. This
should give us an higher chance of success.
Fixes: https://github.com/libsdl-org/SDL/issues/6075
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
Refactor the previous sandbox check in a standalone function that also
includes Snap support.
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
SDL_DBus_CallWithBasicReply() allows us to send a DBus message and get
its result, if it is a basic type, e.g. integer or string.
With this function we avoid duplicating code.
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
Adjust candidate count so list is not draw bigger that needed. This also fix potential uninitialised read of variable `candsize[i]` if `vertical` is false.
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.
Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.
sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.
Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
This will make it possible to have mappings for different controllers
that have the same VID/PID. This happens frequently with some generic
controller boards that have been reused in many products.
Fixes https://github.com/libsdl-org/SDL/issues/6004
Update the Wayland core protocol spec file and add support for the new axis_value120 event to handle high resolution scroll wheels.
The axis_value120 replaces the axis_discrete event, which is no longer sent as of version 8 of the protocol. Note that unlike the axis_discrete event, no mention in the spec is made regarding how many axis_value120 events may occur per-axis per-frame, so the values are accumulated and committed when the pointer frame event occurs.
The libdecor header internally includes wayland-client.h, which pulls in the wayland-client-protocol.h file from the system include path and overrides the local one generated from the included Wayland protocol spec files. Move the Wayland protocol header inclusion above the libdecor header inclusion to ensure that the locally generated protocol header is used instead.
When minimizing a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_WINDOWPOSCHANGED - IsIconic() is true
WM_MOVE
WM_SIZE - SDL sees minimized state here
When restoring a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED - IsIconic() is false
WM_MOVE
WM_SIZE - SDL sees restored state here
On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message.
The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
Uses VK_EXT_metal_surface (vkCreateMetalSurfaceEXT)
when possible, otherwise falls back to the obsoleted
VK_MVK_macos_surface and VK_MVK_ios_surface.
Fixes#3906
If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
This prevents crashes when calling SDL joystick API functions from a different thread while disconnection is happening.
See https://github.com/libsdl-org/SDL/issues/6063 for a more thorough review of joystick locking.
Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks.
These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it. GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen.
With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks.
This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend. Helper functions have also been added to simplify reading the flag states.
If the D-Bus subsystem is shutdown and restarted mid-execution, the cached connection will be invalid. Fetch it each time that it is used to ensure that the connection is always from the current context.
Don't call the roundtrip in ShowWindow unless restoring a previously hidden window. This fixes a regression in GNOME when creating a window with the fullscreen flag set, as the fullscreen window will be positioned down the screen by the height of the top bar if the window is made fullscreen on the primary display and the roundtrip is called when initially displaying the window.
SDL_CreateWindow() may call GetWindowDisplayIndex() to compute the position
of a new window that the caller has requested to be placed on a certain
display. Since we haven't fully constructed the window yet, our driverdata
will be nil and we will fail to get the NSScreen (which is fine). However,
we need to return an error (not 0, which is a valid display index) for
SDL_GetWindowDisplayIndex() to know to figure out the display index itself.
Fixes positioning new windows on secondary displays when using
SDL_WINDOWPOS_CENTERED_DISPLAY() and SDL_WINDOWPOS_UNDEFINED_DISPLAY().
OpenGL windows don't actually get the WM_WINDOWPOSCHANGED event in the SetWindowPos() call in WIN_SetWindowFullscreen(), so setting the window size to zero never gets reset and we're stuck with a zero sized window.
Instead, just force the resize event in WM_DPICHANGED handling, where we know we need it. If we end up needing to force it in WIN_SetWindowFullscreen(), just set a flag in the window data and respond to that in WM_WINDOWPOSCHANGED, but that's a fairly risky behavior change as suddenly all applications would start getting SDL_WINDOWEVENT_SIZE_CHANGED when going fullscreen, and they may respond to that in expensive and potentially disruptive ways.
For later we'll probably create a DPI changed event and respond to that in the renderer instead of this window size changed hack.
This fixes https://github.com/libsdl-org/SDL/issues/6033 @ericwa
The video core assumes that window->w/h will be updated before returning
from SetWindowFullscreen(). This is needed to generate a resize event
with the correct window size when exiting fullscreen.
The roundtrip allows us to receive the configure callback that informs
us of the new window size before returning.
Fixes#6043
We really only care about DPI changes here, so this both reduces work and also avoids weird cases where viewport state can be corrupted by trivial window events. This doesn't _completely_ get rid of the issue but this is somewhat intentional, since apps will definitely want to do a full reset when changing displays anyhow (otherwise DPI/adapter changes will screw things up, and that's out of our control as long as both window size and drawable size are exposed at the same time.
Note that OpenGL still captures window events because of weird platform-specific issues like macOS and viewport stretching!
Fixes#5949
- This allows looking up the display index for an arbitrary location rather than requiring an active window to do so.
- This change also reimplements the fallback display lookup that found the display with center closest to the window's center to instead find the display rect edge
closest to the window center (this was done in the almost identical display lookup used in SDL_windowsmodes.c, which now uses `SDL_GetPointDisplayIndex`). In
practice this should almost never be hit as it requires the window's center to not be enclosed by any display rect.
The current method of toggling the libdecor window visibility by destroying and recreating the frame results in a race where a use-after-free bug can manifest itself within libdecor when window visibility is toggled quickly. Instead, use the libdecor function for toggling visibility instead of destroying and recreating the frame every time.
Wayland works like SDL's "auto capture" feature already, tracking the mouse
globally only while a drag is occuring, and this is the only way to get mouse
input outside the window.
Setting this flag ourselves lets SDL_CaptureMouse() work in the most common
use case without actually implementing CaptureMouse for the backend, including
SDL's auto capture feature.
Fixes#6010.
This controller actually comes in at least two flavors: a GameCube controller and an arcade pad, neither of which should have the face buttons remapped.
This controller looks like a GameCube controller, is actually a Nintendo Switch controller, and shows up as an XInput device on Windows with the buttons already in the correct location.
The Nintendo Online Sega Genesis controller reports the SNES VID/PID over Bluetooth. This is a more robust way of handling future controllers as well, so let's go with this instead.
Also use full reports over Bluetooth, and don't report gyro for Nintendo Online classic controllers.