Commit graph

11847 commits

Author SHA1 Message Date
Sam Lantinga
901b499fef Fixed bug 4709 - incorrect (not) handling of windows on-screen cursor keys
Alex Denisov

When using Win10 on-screen keyboard (tooltip.exe), the left and right cursor keys in it do not produce SDLK_LEFT and SDLK_RIGHT events.

Windows messages generated by the on-screen keyboard, for some reason, have their scancodes set to zeroes. Here is the log from Spy++:

WM_KEYDOWN nVirtKey:VK_LEFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
WM_KEYUP nVirtKey:VK_LEFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1

Regular physical keyboard produces VK_LEFT (ScanCode:4B) and VK_RIGHT (ScanCode:4D) which are interpreted correctly.

With on-screen keyboard, the switch statement in VKeytoScancode() does not check for VK_LEFT and VK_RIGHT, returning SDL_SCANCODE_UNKNOWN, which in turn does not get mapped to anything (because the scan codes are zeroes).
2020-02-11 08:36:13 -08:00
Sam Lantinga
fbf6d7e237 Make it possible for the application to use different C runtime begin/end thread functions 2020-02-11 08:26:46 -08:00
Sam Lantinga
25ff055ca2 Make sure SDL_CreateThread has the same signature regardless of how the DLL was created. 2020-02-11 08:01:44 -08:00
Ryan C. Gordon
1beeec74ae wayland: Fix building with -fno-common (which is now the default in GCC 10).
Fixes Bugzilla #4957.

--HG--
extra : rebase_source : 64466e107af6f0a6c825ba2e89fb45c30b531fd5
2020-02-10 23:48:06 -05:00
Sam Lantinga
6d2f81225b Fixed compile warning 2020-02-10 13:59:05 -08:00
Fabrice Fontaine
856c909a25 src/core/linux/SDL_threadprio.c: fix build without threads
Add an include on SDL_error.h to avoid the following build failure
without threads:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabihf/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabihf/bin/ld: build/.libs/SDL_threadprio.o: in function `SDL_LinuxSetThreadPriority_REAL':
SDL_threadprio.c:(.text+0x0): undefined reference to `SDL_Unsupported'

Fixes:
 - http://autobuild.buildroot.org/results/7f7712c5bd47de4a3fcec1e0d0526fd5a3ecd532

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-02-10 13:56:53 -08:00
Ryan C. Gordon
a76b80af17 opengl: Build out full GL_LINES and respect the diamond-exit rule.
Likewise for the GLES1 and GLES2 renderers.

This solves the missing pixel at the end of a line and removes all the
heuristics for various platforms/drivers. It's possible we could still use
GL_LINE_STRIP with this and save some vertex buffer space, assuming this
doesn't upset some driver somewhere, but this seems to be a clean fix that
makes the GL renderers match the software renderer output.

Diamond-exit rule explanation:
http://graphics-software-engineer.blogspot.com/2012/04/rasterization-rules.html

Fixes Bugzilla #3182.

--HG--
extra : rebase_source : c1728587ab719e93fc95e8b8af79413b3cae93b6
2020-02-10 12:53:54 -05:00
Sam Lantinga
8077909889 The scissor rect needs to be updated when the viewport changes in the Metal renderer 2020-02-10 09:42:53 -08:00
Sam Lantinga
0f44ae0f88 Fixed bug 4966 - KMSDRM: Add dynamic modeset support
Anthony Pesch

* Remove triple buffering support. As far as I can tell, this goes against the libdrm API; the EGL implementations themselves control the buffering. Removing it isn't absolutely necessary as it seemingly works on the Pi at least, but I noticed this while doing my work and explained my reasoning in the commit.

* Replace the crtc_ready logic which allocates an extra bo to perform the initial CRTC configuration (which is required before calling drmModePageFlip) with a call to drmModeSetCrtc after the front and back buffers are allocated, avoiding this allocation.

* Standardized the SDL_*Data variable names and null checks to improve readability. Given that there were duplicate fields in each SDL_*Data structure, having generic names such as "data" at times was very confusing.

* Removed unused fields from the SDL_*Data structures and moves all display related fields out of SDL_VideoData and into SDL_DisplayData. Not required since the code only supports a single display right now, but this was helpful in reading and understanding the code initially.

* Implement KMSDRM_GetDisplayModes / KMSDRM_SetDisplayMode to provide dynamic modeset support.

These changes have been tested on a Raspberry Pi 4 and a Dell XPS laptop with an HD 520.

As an update, I went back over the triple buffer changes and left them in. I didn't entirely get the code originally, I had just seen it calling KMSDRM_gbm_surface_lock_front_buffer twice for a single swap and had removed it because I was paranoid of bugs stemming from it while working on the modeset changes.

I've made a few small changes to the logic that had thrown me off originally and rebased the changes:
* The condition wrapping the call to release buffer was incorrect.
* The first call to KMSDRM_gbm_surface_lock_front_buffer has been removed. I don't understand why it existed.
* Added additional comments describing what was going on in the code (as it does fix the buffer release pattern of the original code before it).
2020-02-09 11:44:22 -08:00
Sam Lantinga
b727f93948 Fixed NullPointerException 2020-02-07 20:20:37 -08:00
Sam Lantinga
a345c092da Removed VID/PID 0x1532/0x0037, which was listed in the Linux kernel as a Razer Sabertooth, because at least one variant of the Razer DeathAdder mouse shows up with this VID/PID.
Specifically the Razer DeathAdder 2013 has this VID/PID
2020-02-07 20:19:32 -08:00
Sam Lantinga
66548a8bff Fixed bug 4968 - NULL passed to memcpy in WriteProprietary in SDL_hidapi_switch.c
meyraud705

In SDL_hidapi_switch.c

line 443: Function BTrySetupUSB call WriteProprietary with pBuf=NULL and ucLen=0
line 376: WriteProprietary check its input (!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData): ucLen is 0 so it passes
line 382: WriteProprietary call memcpy with pBuf=NULL
2020-02-07 11:49:56 -08:00
Sam Lantinga
39547c8367 Use the triggers to test rumble for more fine grained vibration feedback 2020-02-07 11:45:32 -08:00
Sam Lantinga
ee7b76f6ad Use the asynchronous HIDAPI rumble code for Nintendo Switch Pro controllers 2020-02-07 11:44:57 -08:00
Sam Lantinga
65ee09a29d Update for bug 4923 - Calling SDL_GameControllerRumble() often takes 8 ms
meyraud705

Dualshock4 on bluetooth need 78 bytes for the rumble data while SDL_HIDAPI_RumbleRequest can only hold 64 bytes.

'volatile' is not meant for thread synchronization.

The list of rumble request could grow infinitely if user call SDL_JoystickRumble too much. The documentation says "Each call to this function cancels any previous rumble effect", so overwriting pending request seem like a good idea.
2020-02-07 11:02:34 -08:00
David Ludwig
fdfa4783eb macOS: fix crash if and when joystick-init-on-add fails 2020-02-05 13:16:17 -05:00
Sam Lantinga
a8c1a21887 Updated the Android Xbox One Wireless Controller mapping for the latest Xbox controller firmware update 2020-02-05 09:29:46 -08:00
Sam Lantinga
6cd18f7cb9 Catch both PS3 and PS4 motion controls and don't treat them as a game controller 2020-02-04 18:36:23 -08:00
Sam Lantinga
12b7c0a718 Fixed Visual Studio build 2020-02-04 16:05:39 -08:00
Sam Lantinga
033cbd059b Added SDL_hidapi_rumble.c to the macOS, iOS and tvOS builds 2020-02-04 15:42:49 -08:00
Sam Lantinga
c9f0264cf3 Added SDL_hidapi_rumble.c to the Visual Studio project 2020-02-04 15:35:01 -08:00
David Ludwig
4ec6f86dcc FIX for SDL-4927: CFRetain+CFRelease a game controller's IOKit object
This fixes a crash whereby SDL could crash on macOS/Darwin, if and when a
USB game controller gets unplugged.  SDL was not retaining a reference
to the controller's OS/IOKit-provided 'device object', and was capable
of trying to use it, after a device was hot-unplugged.
2020-01-30 18:03:34 -05:00
Sam Lantinga
df5bd6eab0 Added missing files from previous commit 2020-02-04 15:27:25 -08:00
Sam Lantinga
af5eac78cd Fixed long delay on main thread caused by blocking rumble writes in HIDAPI drivers
There is now a thread that handles all HIDAPI rumble requests and a lock that guarantees that we're not reading and writing the device at the same time.
2020-02-04 15:26:56 -08:00
Sam Lantinga
e42b19fbe7 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests. 2020-02-04 12:48:53 -08:00
Sjoerd Simons
fd93d66339 Correct joystick hat indexes on linux
The index and indices were swapped; Which is fine as long as there are
no gaps in the ABS_HAT* event availability but otherwise things do get confused.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
2020-02-04 07:23:44 -08:00
Sam Lantinga
d996900e94 Fixed bug 4965 - Update the .hgignore file
Cameron Cawley

This adds a number of files used by the build systems to the .hgignore file. Most of them are for CMake, but there are other additions as well.
2020-02-03 16:38:07 -08:00
Sam Lantinga
6afe8a7c68 Fixed bug 4758 - hgignore clion build artifacts
Malte

clion builds into cmake-build-debug, cmake-build-release etc. by default. Also, it creates the .idea forlder in wich it places some (mostly local) config.

Since SDL is perfectly buildable from within the IDE, i think it'd be nice to have the build and ide artifacts ignored by hg.
2020-02-03 16:34:33 -08:00
Sam Lantinga
abc7ba38df Fixed bug 4833 - Use EGL for X11?
Martin Fiedler

To be precise, this is about *desktop OpenGL* on X11. For OpenGL ES, EGL is already used (as it's the only way to get an OpenGL ES context), as Sylvain noted above.

To shine some light on why this is needed:
In 99% of all cases, using GLX on X11 is fine, even though it's effectively deprecated in favor of EGL [1]. However, there's at least one use case that *requires* the OpenGL context being created with EGL instead of GLX, and that's DRM_PRIME interoperability: The function glEGLImageTargetTexture2DOES simply doesn't work with GLX. (Currently, Mesa actually crashes when trying that.)
Some example code:
https://gist.github.com/kajott/d1b29c613be30893c855621edd1f212e
Runs on Intel and open-source AMD drivers just fine (others unconfirmed), but with #define USE_EGL 0 (i.e. forcing it to GLX), it crashes. The same happens when using SDL for window and context creation.

The good news is that most of the pieces for EGL support on X11 are already in place: SDL_egl.c is pretty complete (and used for desktop OpenGL on Wayland, for example), and SDL_x11opengl.c has the aforementioned OpenGL-ES-on-EGL support. However, when it comes to desktop OpenGL, it's hardcoded to fall back to GLX.

I'm not advocating to make EGL the default for desktop OpenGL on X11; don't fix what ain't broken. But something like an SDL_HINT_VIDEO_X11_FORCE_EGL would be very appreciated to make use cases like the above work with SDL.


[1] source: Eric Anholt, major Linux graphics stack developer, 7 years ago already - see last paragraph of https://www.phoronix.com/scan.php?page=news_item&px=MTE3MTI
2020-02-03 08:06:52 -08:00
Sam Lantinga
03d12f8b27 Fixed bug 4917 - Wayland: handle discrete pointer axis events
Luis Caceres

The current handling of Wayland mouse pointer events only handles wl_pointer.axis events, which, according to the Wayland documentation, deal with mouse wheel scroll events on a continuous scale. While this is reasonable for some input sources (e.g. touchpad two-finger scrolling), it is not for mouse wheel clicks which generate wl_pointer.axis events with large deltas.

This patch adds handling for wl_pointer.axis_discrete and wl_pointer.frame events and prefers to report SDL_MouseWheelEvent in discrete units if they are available. This means that for mouse wheel scrolling we count in clicks, but for touchpad two-finger scrolling we still use whatever units Wayland uses. This behaviour is closer to that of the X11 backend.

Since these events are only available since version 5 of the wl_seat interface, this patch also checks for this and falls back to the previous behaviour if its not available. I also had to add definitions for some of the pointer and keyboard events specified in versions 2-5 but these are just stubs and do nothing.
2020-02-03 00:57:12 -08:00
Sam Lantinga
a36dd13a17 Fixed the hidapi Info.plist for submission to the Apple App Store 2020-02-03 00:51:35 -08:00
Sam Lantinga
cfd79a1d7d Fixed build warnings on Android 2020-02-01 09:23:04 -08:00
Sam Lantinga
fc2b49e423 Map the right pad on the Steam Controller to the right stick in the game controller API 2020-01-31 14:09:23 -08:00
Sam Lantinga
cc3c1b3a14 Build the hidapi framework and weak link it on Mac OS X 2020-01-31 13:09:20 -08:00
Sam Lantinga
170f13b447 Weak link the hidapi framework on iOS and tvOS 2020-01-31 10:45:04 -08:00
Sam Lantinga
4d8d167149 Build hidapi as a framework on iOS, so it can be linked by the application as well. 2020-01-30 16:02:56 -08:00
Sam Lantinga
2b5945f9e8 Fixed build 2020-01-30 14:58:41 -08:00
Sam Lantinga
4c9d146dd8 More Xcode project improvements 2020-01-30 14:53:18 -08:00
Sam Lantinga
1ea93f060e Export SDL functions for iOS application delegates 2020-01-30 14:51:33 -08:00
Ryan C. Gordon
b0b11fbda9 test: Common framework now accepts --usable-bounds command line argument. 2020-01-30 13:47:48 -05:00
Ryan C. Gordon
20bbf48239 test: change path in a comment from '\\' to '/' char. Nothing serious here. 2020-01-30 13:47:19 -05:00
Sam Lantinga
3d0db544bf Added missing file from previous commit 2020-01-29 20:09:59 -08:00
Sam Lantinga
6a79b6a734 Added a unified Xcode project for macOS, iOS and tvOS 2020-01-29 20:09:18 -08:00
Sam Lantinga
3b021949fa Fixed compiler warning 2020-01-29 20:09:16 -08:00
Sam Lantinga
455ec28f0f Added SDL_hidapi_steam.c to the iOS and tvOS dylib build targets 2020-01-29 20:09:14 -08:00
Sam Lantinga
1e33532e50 There are lots of unused macros in the Steam controller code 2020-01-29 20:09:12 -08:00
Sam Lantinga
8a6c3acb7e Added support for the Steam Controller on mobile devices 2020-01-29 20:09:11 -08:00
Sam Lantinga
443729e39d Miscellaneous pending fixes 2020-01-29 20:09:08 -08:00
Sam Lantinga
b3e4cf8e4f Fixed member order to make more sense 2020-01-28 21:41:13 -08:00
Sam Lantinga
a8f3dbf7be Fixed wired PS4 controller support on Android 2020-01-28 17:11:17 -08:00