Commit Graph

6681 Commits (9e45372a2f735e7d73adf16608ffdde4b6dc26d8)

Author SHA1 Message Date
Sam Lantinga f0577bc9ea ControllerList: setup the ps5 default deadzone to match PS4 instead of defaulting to same a XboxOne/Switch 2020-12-18 10:09:06 -08:00
Sam Lantinga 5f7cd1fa88 Added hints to control whether SDL updates joystick and sensor state in the main event loop 2020-12-18 10:08:59 -08:00
Ozkan Sezer 6c4ab48471 SDL_kmsdrmvideo.c: check atomic modesetting in check_modesetting()
.. so that KMSDRM_CreateDevice() can fail and SDL_VideoInit() would
move on to next bootstrap member which is kmsdrm_legacy.  hopefully
fixes bug #5393.
2020-12-18 17:50:02 +03:00
Ozkan Sezer 5c654d0df4 tests: regenerate configure using autoconf patched for AC_PATH_X11
Specifically this patch which does not invoke _AC_PATH_X_XMKMF and
_AC_PATH_X_DIRECT internal autoconf routines when cross-compiling:
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=33c3a47c04ab70a4dd54963fe433a171bc03747f

Without this, CFLAGS would brokenly have system include paths like
-I/usr/include/X11 when cross-compiling e.g. for windows.  (And it
also resulted in annoying imake crashes for my setup...)
2020-12-18 17:00:00 +03:00
Sam Lantinga 6bd4c717a1 Fixed bug 5402 - ARM support little update proposal
David Carlier

No fix but mostly an update for ARM architecture.
2020-12-17 21:41:23 -08:00
Ozkan Sezer 10625f9d89 SDL_windowsmessagebox.c: go back to hg rev 14458 state.
encountering a NULL caption in AddDialogString() is intended, i.e.
AddDialogStaticIcon() sends it as NULL on purpose.
2020-12-17 23:50:00 +03:00
Ozkan Sezer 4d6eb30523 SDL_windowsmessagebox.c (AddDialogControl): add back NULL caption check.
because AddDialogStaticIcon() sends a NULL caption -- fixes bug #5401.
2020-12-17 23:28:20 +03:00
Ozkan Sezer 90456670b5 more "'for' loop initial declarations are only allowed in C99 mode" fixes 2020-12-17 14:11:00 +03:00
Ozkan Sezer ed4fcb2cfc kmsdrm_legacy build fixes:
- add missing '_LEGACY' to symbol names
- perform missing 2.0.14 portage
- fix 'for' loop initial declarations are only allowed in C99 mode errors
2020-12-16 03:24:10 +03:00
Sam Lantinga f484abbdc8 Added Android mapping for the Xbox One Series X controller over Bluetooth 2020-12-15 14:57:51 -08:00
Sam Lantinga cdd397118f Fixed the Xbox Series X controller showing up twice on Android 2020-12-15 14:57:49 -08:00
Sam Lantinga 14f977348d Fixed whitespace 2020-12-15 14:57:47 -08:00
Ozkan Sezer 9940e71088 Import two post-2.0.12 fixes to kmsdrm_legacy:
Fix build breakage without EGL:
https://hg.libsdl.org/SDL/rev/f2606fe53654e305ab9badb821d9d3afb7f92f49

Fix KMSDRM_CreateWindow segfault when starting L?VE2D engine (bug 5199)
https://hg.libsdl.org/SDL/rev/d2e69a78939463d9ff9448a5f4efd1e208bb97b0
2020-12-16 00:10:30 +03:00
Sam Lantinga f8839289b0 Potential fix for bug 5393 - KMSDRM: using atomic mode setting breaks GPU compatibility
Substring

I was trying the KMSDRM video backend with some very simple programs that were working ok on 2.0.12. The same code won?t work on the current dev branch and I get:

DEBUG: check_modesetting: probing ?/dev/dri/card0?
DEBUG: /dev/dri/card0 connector, encoder and CRTC counts are: 4 5 6
DEBUG: check_modesetting: probing ?/dev/dri/card0?
DEBUG: /dev/dri/card0 connector, encoder and CRTC counts are: 4 5 6
DEBUG: KMSDRM_VideoInit()
DEBUG: Opening device /dev/dri/card0
DEBUG: Opened DRM FD (3)
DEBUG: no atomic modesetting support.
DEBUG: Video subsystem has not been initialized
INFO: Using SDL video driver: (null)
DEBUG: Video subsystem has not been initialized

After carefully checking, the radeon driver doesn?t support atomic modesetting. That?s not the only problem : the same happens with the amdgpu driver if we disable Display Core (kernel parameter amdgpu.dc=0, which is required to get analogue outputs working).

This is a major regression in the KMSDRM driver.

Using atomic mode setting is great, but having no fallback to the "standard KMS" is bad.
2020-12-15 12:22:48 -08:00
Ozkan Sezer c02d88dd12 configury whitespace cleanup (no actual change.) 2020-12-15 23:01:10 +03:00
Sam Lantinga 6cb78120d4 Fixed bug 5399 - make install is broken as it depends on missing rule `build`
Stephen Broadfoot

I've tracked this down to the following changeset bb65ba8e039b

https://hg.libsdl.org/SDL/diff/bb65ba8e039b/Makefile.in

this changeset renames the rule `build` to `build/.created` but the rule `install-lib` still depends on the rule `build`

This affects users who are trying to install via homebrew who are installing via source and not by the bottle as this invokes `make install`

To be clear, the error I was hitting when running make install is

make: *** No rule to make target `build', needed by `install-lib'.  Stop.
2020-12-15 00:42:17 -08:00
Ozkan Sezer 716ac535d8 test/acinclude.m4: rename SDL_CONFIG to SDL2_CONFIG, regenerate configure 2020-12-15 01:20:00 +03:00
Ozkan Sezer 637d425e3e whitespace. 2020-12-15 00:11:10 +03:00
Ethan Lee f1c7cc710b winrt: Buildfix for older UWP SDKs 2020-12-14 12:36:04 -05:00
Sam Lantinga e65e4fd3ef Fixed detecting the guide button on Xbox One S controllers over Bluetooth on Linux 2020-12-14 09:48:51 -08:00
Ethan Lee 169cfe5a7c winrt: EffectiveLocation still needs an ifdef, IsApiContractPresent is for runtime 2020-12-14 11:52:09 -05:00
Sam Lantinga bfffa275ef Fixed bug 5397 - Fcitx input is truncated
sowfelicity

Split the long text input event into multiple shorten text input event.
2020-12-14 09:23:53 -08:00
Sam Lantinga 8795ca7067 Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085

I added some printf to verify the math being done.  Of the three joysticks I have, it works correctly for at least two, and seems to work correctly for the third.  I say "seems to" because, for the third joystick, the values never go through the AxisCorrect function, and thus never hit my printf statements, even though they did in the version I wrote my patch against.  I'm not sure what's going on there, but it at least seems to be working correctly in as much as I can tell.

I note this result in particular, for an SNES Gamepad (min=0, max=255):

Joystick value 0 becomes -32768
Joystick value 127 becomes 0
Joystick value 255 becomes 32767

Without the code that forces a zero point, the 127 input value would become -129, so I think you see why I added that code to turn it into zero.  However, I think Kai Krakow has a point about how SDL shouldn't assume that there should be a center.

Obviously in the majority of cases there actually should be a center, and the code that turns that 127 into an actual 0 is creating only a 0.2% error over 0.4% of this joystick's range.  However, what if there is an axis that is some kind of special control, like a 4-position switch, and, for whatever reason, the joystick reports it as an axis with 4 possible values, 0 to 3?  In that case, mutilating the two center values to the same value is much more of an error and and turns that 4-position switch into a 3-position switch.  If any joystick does this with a 2-position switch, then this code would render that control entirely useless as it would report the same value with the switch in either position.  Obviously the code could require that there be at least N possible values, to guess whether something is a proper axis or just some kind of switch, but the choice of N would be arbitrary and that's ugly.

I guess the real problem here is that my gamepad is just kind of broken.  It should be reporting a range of -1 to +1 since that's what it actually does.  Also, as Kai Krakow points out, it's probably not SDL's place to fix broken hardware.  I'll add that, if SDL does fix broken hardware, it should probably actually know that it's broken rather than be merely guessing that it is.

So, to the extent that SDL is able to do stuff like this, perhaps it's something better left for the user to configure in some kind of config file.
2020-12-14 09:15:47 -08:00
Ozkan Sezer 44d4a61d92 minor cleanups to configure.ac to reduce autoconf-2.70 warnings a bit.
configure output is practically unchanged. there are still lots of
AC_TRY_COMPILE/AC_TRY_LINK replacements needed to really eliminate
the warnings, but that's for another time.
2020-12-14 08:11:40 +03:00
Ozkan Sezer f8078d3d6c configure.ac: use AC_DEFINE for SDL_VIDEO_DRIVER_ANDROID 2020-12-14 05:55:20 +03:00
Ozkan Sezer 3c2757ff89 windows SDL_LoadObject: fix warning after commit 2ff650230d96 2020-12-13 18:25:02 +03:00
Ozkan Sezer 15cbddf497 linux/SDL_threadprio.c: fix build on older systems:
SCHED_RESET_ON_FORK is in kernel >= 2.6.32.
2020-12-13 18:00:20 +03:00
Ozkan Sezer 3b92933ac6 SDL_LoadObject (windows, os/2): prevent crash if dll name is NULL. 2020-12-13 17:37:50 +03:00
Ozkan Sezer f674009c56 fix typo from commit 63349df2610a (fixes bug 5396) 2020-12-13 16:51:20 +03:00
Ozkan Sezer b6e63625c8 fix bug #5395: handle old systems where inotify_init1 is not available 2020-12-13 15:32:24 +03:00
Sam Lantinga ee85a41a32 Fixed compile warning 2020-12-13 02:10:46 -08:00
Sam Lantinga 64f448b26c libusb hid.c is already included in SDL_hidapi.c 2020-12-13 02:01:39 -08:00
Sam Lantinga 706f63759c Fixed build for platforms with only libusb hidapi implementations 2020-12-13 01:58:05 -08:00
Sam Lantinga 80e5c689eb Fixed the PS5 controller not disconnecting when powered off 2020-12-13 01:20:38 -08:00
Sam Lantinga c8ee06911b Added SDL_misc.h to the Xcode built frameworks 2020-12-13 00:15:54 -08:00
Sam Lantinga ce7c751c2c Document that the joystick deadzone hint defaults off 2020-12-12 23:54:40 -08:00
Sam Lantinga db0a2025c3 Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085

It occurred to me that my simple patch that comments out a few lines of code does not correctly remove the dead zone since the calculation presumably assumes the dead zone has been cut out of the range.  Then, while looking into how to make it output the correct range of values, I realized SDL wasn't returning the correct range of values to begin with.

This line of code was already present:

printf("Values = { %d, %d, %d, %d, %d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat);

For my joystick this yeilds:

Values = { 0, -127, 127, 0, 15 }

Then this code calculates the coefficients:

In SDL1:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
if ( t != 0 ) {
  joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
} else {
  joystick->hwdata->abs_correct[i].coef[2] = 0;
}

In SDL2:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) + 2 * absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) - 4 * absinfo.flat);
if (t != 0) {
  joystick->hwdata->abs_correct[i].coef[2] = (1 << 28) / t;
} else {
  joystick->hwdata->abs_correct[i].coef[2] = 0;
}

Neither calculates the correct coefficients for the code in the AxisCorrect function.

In SDL1:
if ( value > correct->coef[0] ) {
  if ( value < correct->coef[1] ) {
    return 0;
  }
  value -= correct->coef[1];
} else {
  value -= correct->coef[0];
}
value *= correct->coef[2];
value >>= 14;

In SDL2:
value *= 2;
if (value > correct->coef[0]) {
  if (value < correct->coef[1]) {
    return 0;
  }
  value -= correct->coef[1];
} else {
  value -= correct->coef[0];
}

In SDL1, the calculated coefficients are coef[0]=15, coef[1]=-15 and coef[2]=5534751.  So with a full-scale input of 127, it calculates an output value of 37835, which is considerably out of range.

In SDL2, the calculated coefficients are coef[0]=30, coef[1]=-30, and coef[2]=1383687.  So with a full-scale input of 127, it calculates the same output value of 37835.

I tested it with the 3 joysticks I have, and it produces out-of-range values for all of them.

Anyway, since dead zones are garbage, I just deleted all of that junk and wrote some code that takes the absinfo.minimum and absinfo.maximum values and uses them to scale the axis range to -32767 through +32767.

I also made it detect when a range doesn't have an integer center point, e.g. the center of -128 to + 127 is -0.5.  In such cases, if either value to the side of the center is provided, it zeros it, but it otherwise doesn't implement any kind of dead zone.  This seemed important with my gamepad which provides only the values of 0, 127, and 255, since without this hack it would never be centered.

Also, the previous minimum output value was -32768, but as that creates an output range that has no true center, I changed the minimum value to -32767.

I tested it with the 3 joystick devices I have and it seems to create correct values for all of them.
2020-12-12 23:48:02 -08:00
Sam Lantinga 0ccb3afd37 Fixed polling values after SYN_DROPPED event 2020-12-12 22:33:11 -08:00
Sam Lantinga 9ee0e8886c Whoops, make the hint actually default to false 2020-12-12 22:11:00 -08:00
Sam Lantinga 13a4caf1d7 Fixed bug 4286 - Joystick subsystem causes "not responding" when app is in the background
Added a hint to control whether a separate thread should be used for joystick events.
This is off by default because dispatching messages in other threads appears to cause problems on some versions of Windows.
2020-12-12 22:08:02 -08:00
Ozkan Sezer bca9decbda fix bug #5394 - define _DARWIN_C_SOURCE only if not already defined 2020-12-12 23:28:10 +03:00
Ozkan Sezer 5c212cb0c5 remove a few stale NULL message/title checks after commit e2b729b1756a
top-level guarantees non-NULL message / title passed in messageboxdata
2020-12-10 12:24:24 +03:00
Ozkan Sezer f1cab8aea6 fix bug #5253: handle NULL title or message fields in SDL_MessageBoxData
- SDL_video.c (SDL_ShowMessageBox): replace messageboxdata, set title
  or message field to "" if either of them is NULL.
- SDL_video.c (SDL_ShowSimpleMessageBox):  set title or message to ""
  if either of them is NULL for EMSCRIPTEN builds.
- SDL_bmessagebox.cc: add empty string check along with NULL check for
  title and message fields.
- SDL_windowsmessagebox.c (AddDialogString): remove NULL string check
- SDL_windowsmessagebox.c (AddDialogControl):  add empty string check
  along with the NULL check.
- SDL_x11messagebox.c: revert commit 677c4cd68069
- SDL_os2messagebox.c: revert commit 2c2a489d76e7
- test/testmessage.c: Add NULL title and NULL message tests.
2020-12-10 11:20:56 +03:00
Sam Lantinga eec73dfd20 configure.ac (CheckJoystickMFI): changed AC_TRY_COMPILE to AC_TRY_LINK
so as to discover GameController and CoreHaptics frameworks at compile
time.
2020-12-09 20:31:00 -08:00
Sam Lantinga 797a6910fd Fixed bug 5375 - WGI: Fix HSTRING memory leak.
Joel Linn

TLDR; https://godbolt.org/z/43fd8G

Let's deduce this from C++ reference code:

https://docs.microsoft.com/en-us/cpp/cppcx/wrl/how-to-activate-and-use-a-windows-runtime-component-using-wrl?view=msvc-160
At the bottom of the page there is this snippet:
```
int wmain()
{
    /* ... more code ... */

    // Get the domain part of the URI.
    HString domainName;
    hr = uri->get_Domain(domainName.GetAddressOf());
    if (FAILED(hr))
    {
        return PrintError(__LINE__, hr);
    }

    // Print the domain name and return.
    wprintf_s(L"Domain name: %s\n", domainName.GetRawBuffer(nullptr));

    // All smart pointers and RAII objects go out of scope here.
}
```

`HString` is defined in `corewrappers.h` and the call chain for the destructor is:
`~HString() -> Release() -> ::WindowsDeleteString()`

QED
2020-12-09 20:28:51 -08:00
Sam Lantinga d3d2aee7f4 Fixed the name of the PS5 hint 2020-12-09 10:39:36 -08:00
Sam Lantinga a77a07152a Disabled raw input debug output 2020-12-09 07:50:15 -08:00
Sam Lantinga d46dd103d9 Fixed typo in Vulkan load logic 2020-12-09 07:49:07 -08:00
Sam Lantinga 45e3521d0d Backed out changes for 5366 - cmake build doesn't detect Metal on macOS
These changes introduce regressions for other build environments, so I'm backing them out until we sort out the correct fix.
2020-12-09 07:32:10 -08:00
Sam Lantinga bd032c1f72 Fixed bug 5221 - libusb isn't detected correctly in CMake
Sven-Hendrik Haase

In CMake I currently have trouble activating hidapi support as libusb-1.0 isn't ever correctly detected as it's searched for by the wrong name.

configure.ac correctly does this:

PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)

However, sdlchecks.cmake does this:

pkg_check_modules(LIBUSB libusb)

but it needs to be:

pkg_check_modules(LIBUSB libusb-1.0)
2020-12-09 07:26:59 -08:00