Commit Graph

1857 Commits

Author SHA1 Message Date
Sam Lantinga
f35e97ba8a Fixed Windows build 2018-08-09 16:03:29 -07:00
Sam Lantinga
d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Ryan C. Gordon
ba90412cda libm: Don't let Visual Studio generate an implicit memset() call. 2018-08-08 15:39:20 -04:00
Ryan C. Gordon
4cb84b8f4b backout INFINITY change...of course Visual Studio doesn't have it. 2018-08-08 12:36:54 -04:00
Ryan C. Gordon
257071fc20 e_exp: One more compiler warning. 2018-08-08 12:19:01 -04:00
Ryan C. Gordon
550437edbe libm: Fixed all static analysis warnings. 2018-08-08 12:13:56 -04:00
Ryan C. Gordon
c0aa626ba3 e_exp: Fixed compiler warning on Visual Studio. 2018-08-08 10:26:22 -04:00
Ryan C. Gordon
941c5b4760 haiku: Rename internal functions from BE_* to HAIKU_*
Fixes Bugzilla #2349.
2018-08-07 18:07:11 -04:00
Ryan C. Gordon
f59b0056d3 evdev: On sudden termination, make sure keyboard isn't lost (thanks, Tadek!)
"In release 2.0.6, when Linux evdev keyboard support has been moved to a
separate source file, a feature was added to disable normal keyboard event
processing to prevent "spilling" keystrokes to background virtual console.

This feature has one unpleasant side effect: if application fails to call
`SDL_Exit` before termination or crashes with fatal signal, console is left
in unusable state with keyboard not working and no possibility to switch
virtual console. If user has a chance, he can login remotely and restore
keyboard with `kbd_mode`, otherwise the only option is to reboot the machine.

This patch fixes that problem by intercepting fatal signals (with `sigaction`)
and process termination (with `atexit`), to restore keyboard state, if it
wasn't properly restored with `SDL_Exit`.

The function registered with `atexit` also restores original signal handlers,
to prevent leaving invalid handlers after SDL library is unloaded, if it was
loaded dynamically with `dlopen`.

No signal handlers or `atexit` function are installed if SDL boolean hint
`SDL_HINT_NO_SIGNAL_HANDLERS` is `SDL_TRUE`.

Additionally, if environment variable `SDL_INPUT_LINUX_KEEP_KBD` exists,
keyboard initialization function completely skips disabling keyboard. This
can be useful for debugging."

Fixes Bugzilla #4193.
2018-08-07 16:56:46 -04:00
Ryan C. Gordon
623a6defd3 alsa: optionally run entire pipeline non-blocking. 2018-08-07 16:49:18 -04:00
Ryan C. Gordon
56f44cfa0f audio: Deal with device shutdown more carefully.
This would cause problems in various ways, but specifically triggers an
assert when you close a WASAPI capture device in an app running over RDP.

Related to (but not the actual bug) in Bugzilla #3924.
2018-08-07 13:04:15 -04:00
Mai Lavelle
e714f6590e haptic: Fix initial detection of haptic devices on Linux system
SDL_UDEV_Scan must be called during SDL_SYS_HapticInit to ensure devices
outside of the 0-31 range are added to the list of haptic devices.

Fixes Bugzilla #3923.
2018-08-07 12:06:31 -04:00
Sam Lantinga
a37d3e0b1e Backed out changeset 794a209b2270
It turns out the mapping is correct, just the name was confusing
2018-08-06 13:00:11 -07:00
Sam Lantinga
cc682f2013 Removed mapping for VID/PID 0x0079/0x0006, which is a generic PCB used in many different devices
Different device with same vid/pic that is kind of a Saitek shape:
https://www.trust.com/en/product/17416-gxt-24-runa-compact-gamepad

n64 with same ID
https://bbs.archlinux.org/viewtopic.php?id=163488

PS shaped with numbers for buttons
https://pineight.com/mw/index.php?title=USB_game_controller#DragonRise_Inc._Generic_USB_Joystick

fightstick with same vid/pid
https://retropie.org.uk/forum/topic/7594/bartop-2-player-zero-delay-encoders-not-working
2018-08-06 11:58:08 -07:00
Ozkan Sezer
f45f33bdc0 SDL_expf: return SDL_exp() instead of SDL_uclibc_exp() for consistency. 2018-08-05 10:01:01 +03:00
Ethan Lee
b4fe7412f9 SDL_exp 2018-08-04 11:52:46 -04:00
Ryan C. Gordon
e061a92dc9 Some drag'and'drop improvements.
First: disable d'n'd events by default; most apps don't need these at all, and
if an app doesn't explicitly handle these, each drop on the window will cause
a memory leak if the events are enabled. This follows the guidelines we have
for SDL_TEXTINPUT events already.

Second: when events are enabled or disabled, signal the video layer, as it
might be able to inform the OS, causing UI changes or optimizations (for
example, dropping a file icon on a Cocoa app that isn't accepting drops will
cause macOS to show a rejection animation instead of the drop operation just
vanishing into the ether, X11 might show a different cursor when dragging
onto an accepting window, etc).

Third: fill in the drop event details in the test library and enable the
events in testwm.c for making sure this all works as expected.
2018-08-02 16:03:47 -04:00
Ryan C. Gordon
8f0cc4a4b7 Backed out changeset 2e42ec46061e.
This change isn't correct. See comments in Bugzilla #4183.
2018-07-22 19:42:08 -04:00
Ryan C. Gordon
1089944bee libm: Fixed signature mismatches for __ieee754_rem_pio2 and __kernel_rem_pio2.
Fixes Bugzilla #4201.
2018-07-22 19:40:42 -04:00
Ryan C. Gordon
862aa4b47d windows: Fixed some Visual Studio warnings about shadowed variables.
Fixes Bugzilla #4118.
2018-07-22 19:28:27 -04:00
Marc Di Luzio
c3178e67ca Ensure we still clear the X locale modifiers even if not compiled with ibus or fcitx support 2018-07-12 16:52:45 +01:00
Ryan C. Gordon
b5a420cb11 dbus: Deal with undefined behavior with va_args.
Parse out a copy of the varargs ourselves to get to the reply portion, since
the original passed to D-Bus might modify or not modify the caller's copy,
depending on system ABI.
2018-07-13 17:53:24 -04:00
Sam Lantinga
df0d3f1364 More controller drivers support CARTESIAN coordinates.
This fixes rumble on the Saitek Cyborg V.3 Rumble Pad
2018-07-12 13:28:15 -07:00
Sam Lantinga
ff8c9538bc Allow trapping the back button so right mouse click can work on some Android systems (thanks Rachel!)
Also, added a function SDL_AndroidBackButton() so applications can respond to the back button directly
2018-07-12 13:28:13 -07:00
Wohlstand
ff8c62f227 Fixed bug 4210 - SSE2-based converter makes junk result of S32 -> Float
At the HG state abdd17144682, 64-bit assemblies are using SSE2-based resampler, produces junk sound when converting the S32 -> Float32 -> S16 chain. The `NEED_SCALAR_CONVERTER_FALLBACKS` thing works perfectly.

If I will find a reason that caused this mistake, I'll send a patch by myself.
2018-07-02 03:53:57 +03:00
Ozkan Sezer
013b146de9 SDL_windowstaskdialog.h (struct _TASKDIALOGCONFIG): make unions anonymous
otherwise build fails. (at least with my VS2005. and the code accesses the
arms of the unions anonymously anyway.)
2018-06-30 20:55:51 +03:00
Ozkan Sezer
949b8bd8c5 correct the comment correction.. 2018-06-30 20:10:40 +03:00
Ozkan Sezer
67f18a1973 comment correction 2018-06-30 20:04:01 +03:00
Ryan C. Gordon
7c2028f8e9 Attempt to fix "cast from pointer to integer of different size" warnings. 2018-06-29 16:56:11 -04:00
Ryan C. Gordon
52857de251 Corrected a comment. 2018-06-29 16:55:55 -04:00
Ryan C. Gordon
3b173f818d Patched to compile on Visual Studio (typo). 2018-06-25 23:00:38 -04:00
Ryan C. Gordon
58168a8c3c atomic: Fight with all the assemblers that don't like REP NOP. :/ 2018-06-25 16:34:16 -04:00
Ryan C. Gordon
5f123e31a3 atomic: Spin locks now try to use the x86 PAUSE instruction for short waits.
Fixes Bugzilla #4151.
2018-06-25 15:58:35 -04:00
Ryan C. Gordon
5a8ecf4e79 yuv: Patched to make static analysis happy (warned about unused variable). 2018-06-25 13:14:52 -04:00
Ryan C. Gordon
4773690d0f Deal with possible malloc(0) calls, as pointed out by static analysis. 2018-06-25 12:55:23 -04:00
Ryan C. Gordon
915a7e0341 gles2: Whoops, overzealous copy/paste on my part. :) 2018-06-25 01:57:28 -04:00
Ryan C. Gordon
c8ac909674 wayland: Implemented xdg-wm-base support.
This is just in parity with the existing zxdg-shell-unstable-v6 code. Making
the Wayland target robust (and uh, with title bars) is going to take a lot
of work on top of this.
2018-06-24 22:42:36 -07:00
Anthony Pesch
c591429542 alsa: avoid hardware parameters with an excessive number of periods.
The previous code attempted to use set_buffer_size / set_period_size
discretely, favoring the parameters which generated a buffer size that was
exactly 2x the requested buffer size. This solution ultimately prioritizes
only the buffer size, which comes at a large performance cost on some machines
where this results in an excessive number of periods. In my case, for a 4096
sample buffer, this configured the device to use 37 periods with a period size
of 221 samples and a buffer size of 8192 samples. With 37 periods, the SDL
Audio thread was consuming 25% of the CPU.

This code has been refactored to use set_period_size and set_buffer_size
together. set_period_size is called first to attempt to set the period to
exactly match the requested buffer size, and set_buffer_size is called second
to further refine the parameters to attempt to use only 2 periods. The
fundamental change here is that the period size / count won't go to extreme
values if the buffer size can't be exactly matched, the buffer size should
instead just increase to the next closest multiple of the target period size
that is supported. After changing this, for a 4096 sample buffer, the device
is configured to use 3 periods with a period size of 4096 samples and a buffer
size of 12288 samples. With only 3 periods, the SDL Audio thread doesn't even
show up when profiling.

Fixes Bugzilla #4156.
2018-05-04 21:21:32 -04:00
Ryan C. Gordon
59574fe2f0 x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).
"Applications (such as SDL's testgesture) do "event.tfinger.x * window_width"
to find window coord. Currently the X11 XInput2 backend expects application
to do "event.tfinger.x * (window_width-1)" instead.

X11 XInput2 touch events are normalized so x is 1.0 at "width - 1" but other
SDL backends appear to have x be 1.0 at "width". Same issue for touch event
y with regards to height."

Fixes Bugzilla #4183.
2018-06-24 13:57:22 -04:00
Tomeu Vizoso
fe6828272a egl: Don't change context when deleting current.
If we change the current context behind the app's back, those tracking
the current context to minimize context changes are going to get
confused.

This brings the EGL backend in line with the GLX one.

Fixes Bugzilla #4199.
2018-06-14 06:12:12 +00:00
Ryan C. Gordon
5308a245a4 Fixed some possible malloc(0) calls reported by static analysis. 2018-06-24 12:16:58 -04:00
Sam Lantinga
88dfa46644 Use a blank cursor instead of PointerIcon.TYPE_NULL since that shows the default cursor on Samsung DeX 2018-06-18 13:14:04 -07:00
Sam Lantinga
a515853569 Added support for external mouse in Samsung DeX mode
relative mode doesn't work, but absolute coordinates are functional
2018-06-18 13:14:02 -07:00
Sam Lantinga
74ec7cabdb Fixed race condition where Android touch events could get scaled by a render target's viewport 2018-06-18 13:13:56 -07:00
Sam Lantinga
9924a8e392 Fixed bug 4094 - No SDL_TEXTEDITING after pressing Alt key on Raspberry Pi Linux
This was reproducible by running an SDL app on the console from an ssh login. In this case the terminal wasn't owned by the user running the app, so we were using the default keymap, which didn't have state transitions defined for ctrl and alt, so once we entered that state keypresses would no longer transition out of that state, nor would they generate text.

As a workaround, we'll just reset to the default shift state if that happens, which means we'll get text for keys pressed while ctrl is held down, but I don't think that's a big problem.

Note that in this case we also can't mute the keyboard, so the keypresses go to the console, which probably isn't what you want...
2018-06-14 00:51:45 -07:00
Ozkan Sezer
08de74ec49 use the 'aborts' pragma of Watcom for SDL_NORETURN functions
SDL_ExitProcess(), SDL_AbortAssertion() and SDLTest_BailOut().

(Commit 303c1e0fb0cf for bug #4100 removed SDL_NORETURN from
SDL_ExitProcess() and SDL_AbortAssertion() in order to avoid
warnings from windows builds, but that's temporary I guess..)
2018-06-13 14:45:02 +03:00
Sam Lantinga
4a4bac95eb Deal with fullscreen limitations under windowed Android environments (Chromebook, DeX, etc.) (Thanks Rachel!) 2018-06-12 13:22:58 -07:00
Sam Lantinga
864b8f89fa Merged in community contributed controller mappings from https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt 2018-06-12 01:04:26 -07:00
Sam Lantinga
1205978244 Added common controllers used with Steam Big Picture
These are entirely untested
Several USB ids refer to multiple packaged products. In those cases I tried to use the most common name, or a general name (e.g. PS3 Controller), or a completely generic name (e.g. USB gamepad) if it wasn't clear what type of controller it was.
Patches welcome!
2018-06-12 00:18:10 -07:00
Sam Lantinga
fe196db774 Track android device panel width & height as well as window surface & height.
Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails.

Add Android_DeviceWidth/Android_DeviceHeight globals to native code.
Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight
Use device width/height for all display mode settings.
2018-06-07 17:07:03 -07:00