Commit Graph

190 Commits (1a348aac4f858939b0ef7d72aab66b8dacfb877a)

Author SHA1 Message Date
Philipp Wiesemann 1a348aac4f Android: Fixed two warnings. 2015-06-17 21:05:25 +02:00
Ryan C. Gordon 40244dc1a9 Whitespace fix. 2015-06-17 13:02:41 -04:00
Ryan C. Gordon d002d6bf9f Removed Edgar's name from SDL_haptic.h at his request. 2015-06-17 12:59:12 -04:00
Sam Lantinga 4598903548 Partial fix for bug 2758 - Android issues with NDK r10c and API-21
Sylvain

When using API 21 and running on an old device (android < 5.0 ?) some function are missing.

functions are (at least) : signal, sigemptyset, atof, stpcpy (strcat and strcpy), srand, rand.


Very few modifications on SDL to get this working :

on SDL
======

Undefine android configuration :

HAVE_SIGNAL
HAVE_SIGACTION
HAVE_ATOF

In "SDL_systrhead.c", comment out the few block of lines with "sigemptyset".

Android.mk:
remove the compilation of "test" directory because it contains a few rand/srand calls

Also, there are more discussions about this in internet :
https://groups.google.com/forum/#!topic/android-ndk/RjO9WmG9pfE
http://stackoverflow.com/questions/25475055/android-ndk-load-library-cannot-locate-srand
2015-06-17 00:07:45 -07:00
Sam Lantinga 3779bf3845 Fixed bug 2948 - [Android] Arrow keys from external keyboard are not received
Sylvain

http://developer.android.com/reference/android/view/InputDevice.html
 int SOURCE_CLASS_JOYSTICK   Constant Value: 16       (0x00000010)

 int SOURCE_JOYSTICK         Constant Value: 16777232 (0x01000010)
 int SOURCE_KEYBOARD         Constant Value: 257      (0x00000101)
 int SOURCE_GAMEPAD          Constant Value: 1025     (0x00000401)
 int SOURCE_DPAD             Constant Value:  513     (0x00000201)


I have an a PC keyboard that I connect to an android device.
The issue is that "arrow" keys gets lost.

More explanation:

This device gets detected twice by the java "pollInputDevices()" both as SOURCE_KEYBOARD and as a composite (0x1000311 == SOURCE_JOYSTICK | SOURCE_KEYBOARD | SOURCE_DPAD).
Because of being a SOURCE_CLASS_JOYSTICK, only the second entry is registered, and I opened it.


When I press one arrow key, the java method "onKey(...)" is called.
The Source "event.getSource()" is "SOURCE_KEYBOARD", so it enters this conditions :

   if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
      (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {


And then, it enters :

   SDLActivity.onNativePadDown() (native code in "SDL_sysjoystick.c")


Since the "arrows" are viewed as "D-PAD", it gets translated :

   int button = keycode_to_SDL(keycode);


But the android-java "event.getDeviceId()" is wrong: this is the one from the Keyboard, and not the one from the Joystick that I have opened.
So I don't get them through the Joystick interface.


And since, the keycode has been translated, it returns 0 and assume it was consumed.
So I lost the key in the function "Android_OnPadDown()"


Notice, It won't happen with other normal "letters" keys because they does not get translated by "keycode_to_SDL", so "Android_OnPadDown()" returns -1.
And then java code send the keys to "SDLActivity.onNativeKeyDown()".




Possible patch on "Android_OnPadDown" and also "Android_OnPadUp" (and maybe other functons):

85 int
186 Android_OnPadDown(int device_id, int keycode)
187 {
188     SDL_joylist_item *item;
189     int button = keycode_to_SDL(keycode);
190     if (button >= 0) {
191         item = JoystickByDeviceId(device_id);
192         if (item && item->joystick) {
193             SDL_PrivateJoystickButton(item->joystick, button , SDL_PRESSED);
194         }
+           else return -1;
195         return 0;
196     }
197
198     return -1;
199 }

It would allow the java caller function to send the key to "SDLActivity.onNativeKeyDown();"



Another solution, would be to replace:

 if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
      (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {

by

 if ( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0)

Because only "SOURCE_CLASS_JOYSTICK" devices are registered/opened.
2015-06-17 00:00:53 -07:00
Sam Lantinga 5db002bb1e Fixed bug 2949 - [Android] Virtual DPAD remote not registered
Sylvain

I have an android device to which I try to connect the google virtual remote application.
https://play.google.com/store/apps/details?id=com.google.android.tv.remote

The java method "pollInputDevices()" detects it as an input source 0x701 which is (SOURCE_KEYBOARD | SOURCE_GAMEPAD | SOURCE_DPAD).

It it not added because it does not AND-bitwise with "SOURCE_CLASS_JOYSTICK".
It's only a virtual DPAD and it works when checking also with SOURCE_CLASS_BUTTON
2015-06-16 23:58:09 -07:00
Sam Lantinga 33ed20fafa Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground
Sylvain

With a Landscape application.
Going to background with Home Key, then foreground.
The screen is distorted.

This has been reported by Samsung. It happens on S5 and Samsung Alpha, see the video attached.

I have captured the following logcat:

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
I/SDL     (20549): SDL_Android_Init()
I/SDL     (20549): SDL_Android_Init() finished!
V/SDL     (20549): SDL audio: opening device
V/SDL     (20549): SDL audio: wanted stereo 16-bit 22.05kHz, 256 frames buffer
V/SDL     (20549): SDL audio: got stereo 16-bit 22.05kHz, 1764 frames buffer
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): onWindowFocusChanged(): false
V/SDL     (20549): onPause()
V/SDL     (20549): nativePause()
V/SDL     (20549): surfaceDestroyed()

Background / Foreground

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1080x1920
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): nativeResume()



This seems to be related to the fact that I have in "AndroidManifest.xml":
android:configChanges="..."
Because of the fields: "orientation" and also "screenSize".


I have looked for another way to solve the issue. Discarding the "surfaceChanged" call, based on the "requestedOrientation" and the new Orientation. It seems to be better.


On my failing test case, the first "surfaceChanged()" is discarded. Sometimes the "focusChanged()" might appear between the two "surfaceChanged()", while the surface is not yet ready. Thus, discarding also the "nativeResume()".

So, for robustness, a call to "nativeResume()" is added at the end of "surfaceChanged()".

Some update:

1/ First I tried, to discard the surface using the current orientation (rather than width / heigh). -> that solve the issue sometimes, but not always.

2/ Samsung Certification now accepts my application that were previously failing.

3/ I personally now owns a Samsung S5, and was able to solve the issue on my side.

4/ I now use the patch and get no complaints from my users. (but I admit, nobody seemed to be complaining before neither...).

5/ I have added a v2 because of a new smart-phone called "Black Berry Passport" that has a square screen of 1440x1440. This screen has a "status bar" so the resolution is in fact : 1440x1308. (as reported by "surfaceChanged").

Problem is: the portrait resolution is in fact a Landscape!

So the "v1" patch is always discarding the "surface" of BlackBerry Passport. Which is terribly bad.


Hence, I added the "v2" patch not to discard the surface when aspect ratio is < 1.20. (BB 1440/1308 is : 1.1009). Which seems fair.
2015-06-16 22:16:35 -07:00
Philipp Wiesemann d29812d092 Moved entry in WhatsNew.txt because it was already in 2.0.0 for Android and iOS. 2015-06-16 20:28:21 +02:00
Philipp Wiesemann 58efd8e547 Fixed comment in test program. 2015-06-16 20:27:01 +02:00
Philipp Wiesemann ae60afce16 Excluded SDL_egl.h from doxygen input. 2015-06-16 20:25:53 +02:00
Sam Lantinga 59d34bc35d Fixed bug 3015 - grab mouse inconsistent state
Martin Gerhardy

Not sure - but I think there might be a logic flaw in SDL_SetWindowGrab.

The problem here is that this modifies the window flags and e.g. sets
SDL_WINDOW_INPUT_GRABBED - but the _this->grabbed_window pointer is not
yet set.

Then in SDL_UpdateWindowGrab the _this->grabbed_window pointer is only
set if the function pointer _this->SetWindowGrab is not NULL. But if
this is NULL, the _this->grabbed_window pointer is never set, but every
future call to any of the grab functions include an assert for:
SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags &
SDL_WINDOW_INPUT_GRABBED) != 0));

That means the first call works, the second always fails and triggers
the assert.
2015-06-15 23:44:08 -07:00
Colby Klein ccc12a3632 Implement repositioning the OS-rendered IME with SDL_SetTextInputRect on Windows. 2015-06-15 20:24:51 -07:00
Ryan C. Gordon 0c3830a9a9 Haptic/Linux: Keep track of device numbers properly to track duplicates.
Fixes Bugzilla #3014.
2015-06-16 00:57:45 -04:00
Sam Lantinga d797582376 Fixed style 2015-06-14 19:26:20 -07:00
Sam Lantinga 34634082ff Fixed bug 3012 - Android accelerometer joystick axis values overflow when values from Android are larger than gravity
Magnus Bjerke Vik

This causes issues when for instance using the joystick API to make an Android phone rotate an object by rotating the phone. When the absolute value of an axis reported by android is larger than earth gravity, SDL will overflow the Sint16 value used for joystick axes, causing sporadic movements when close to the gravity. Just holding the phone so that e.g. Y points directly upwards will make it unstable, and even more if you just tap the phone gently from below (increasing the acceleration).

More detailed: SDLActivity gets the accelerometer values in onSensorChanged and divides each axis by earth gravity. SDL_SYS_JoystickUpdate takes each of the axis values, multiplies them by 32767.0 (largest Sint16), and the casts them to Sint16. From this you can see that any value from Android that exceeds earth gravity will overflow the joystick axis.

A fix is to clamp the values so that they won't overflow the Sint16.
2015-06-14 19:25:12 -07:00
Sam Lantinga e3df6d5e66 Fixed bug 2953 - Crash due to a bad cleanup in the SDL_SYS_HapticQuit function
Technically this is caused by the haptic devices not being closed at quit time, which we need to fix anyway, but this is a bandaid for now.
2015-06-14 19:21:13 -07:00
Sam Lantinga a4eb0dea86 Fixed bug 2908 - Fix clang warnings
Simon Deschenes

My build system still shows warning as errors.

The first warning says that the member named instances can never be false (or NULL) as it is a static array, and we should check for instances[index] which we do anyway.
2015-06-14 19:10:51 -07:00
Sam Lantinga 564ece516e Only use explicit inlining - otherwise Visual Studio 2010 will inline SDL_zero(info) in SDL_vsnprintf() into a memset() call when compiling the Release x64 configuration. 2015-06-14 18:57:05 -07:00
Sam Lantinga c18e7724eb Fixed 2010 solution and removed Release_NoSTDIO build configuration 2015-06-14 18:37:43 -07:00
Sam Lantinga 4c48485681 Updated Visual Studio projects
There is now a single solution used by Visual Studio 2010 and newer
2015-06-14 18:21:04 -07:00
David Ludwig 0c9da0c855 WinRT: made sure build script generates Release-built binaries, by default
winrtbuild.bat/.ps1 were generating Debug-built binaries, in some cases.
This change makes sure that Release mode is the default.
2015-06-14 20:15:36 -04:00
Sam Lantinga 98f9b88cef Fixed bug 3011 - pthread/SDL_syssem.c requires _GNU_SOURCE
Ozkan Sezer

pthread/SDL_syssem.c requires _GNU_SOURCE predefined (like SDL_sysmutex.c),
otherwise sem_timedwait() prototype might not be available to it.  Problem
seen with glibc-2.3.4.
2015-06-13 13:36:47 -07:00
Sam Lantinga 9cf47d2f0d Fixed bug 3010 - SDL_x11messagebox.c needs including X11/keysym.h
Ozkan Sezer

SDL_x11messagebox.c needs including <X11/keysym.h> otherwise XK_Escape,
etc might not be available to it. Seen this with x.org-x11-6.8.2.
2015-06-13 13:34:30 -07:00
Sam Lantinga 8b737fa8f6 Updated WhatsNew.txt for 2.0.4 2015-06-13 13:19:31 -07:00
Sam Lantinga aee0552229 Fixed bug 3009 - Cannot compile SDL2 on Windows
CMakeLists.txt was missing handling for running CMake with -DDIRECTX=0
2015-06-13 10:47:55 -07:00
Philipp Wiesemann d8c2b36c21 Fixed crash if allocation for touch device failed.
If the allocation of an SDL_Touch failed, the number of touch devices was still
increased. Later access of the SDL_Touch would then have dereferenced the NULL.
2015-06-12 21:10:31 +02:00
Ryan C. Gordon 714687427a Make some string literals "const char *", not "char *" (thanks, Martin!).
Fixes Bugzilla #3007.
2015-06-12 11:58:31 -04:00
Sam Lantinga f29de0d324 Fixed bug 3005 - MOMO steering wheel not detected by SDL
Joe Thompson

This is a regression. The changes to fix #2460 cause the EnumJoysticksCallback() function to return without adding devices (Line 345 in SDL-0a2b6bc7005f\src\joystick\windows\SDL_dinputjoystick.c).
Looking at dinput.h on my system, at least DI8DEVTYPE_DRIVING and DI8DEVTYPE_FLIGHT need to be added to the test.
It might be better to check if (devtype == DI8DEVTYPE_SUPPLEMENTAL) rather than checking if it is NOT EQUAL to a long list of types. Or check if the device is already in the list.
2015-06-11 12:04:57 -07:00
Alex Szpakowski a86df3b7cf iOS: Fixed some cases where SDL_DestroyWindow or SDL_GL_DeleteContext can cause crashes. 2015-06-09 21:08:24 -03:00
Philipp Wiesemann cd1d7c94e9 Wayland: Fixed SDL_GetTouchDevice() returning 0 for the valid device index.
The single touch device gets SDL_TouchID 1 (like on Emscripten, iOS and WinRT).
2015-06-09 21:06:55 +02:00
Philipp Wiesemann 5d6aa08b28 Emscripten: Fixed SDL_GetTouchDevice() returning 0 for the valid device index.
The single touch device gets SDL_TouchID 1 (like on iOS and WinRT).
2015-06-09 21:06:29 +02:00
Philipp Wiesemann 86e9ab79ce Linux: Fixed not needed call to close() on error.
It was called if file descriptor was none and -1.
2015-06-08 20:46:09 +02:00
Ryan C. Gordon f1924a616d Normalized endlines. 2015-06-08 03:07:24 -04:00
Ryan C. Gordon 69bef005b5 Added LDFLAGS note to Raspberry Pi documentation (thanks, Michael!). 2015-06-08 03:07:16 -04:00
Ryan C. Gordon 50981d418a x11: Drop duplicate XInput2 XI_RawMotion events.
This happens when the pointer is grabbed, but it's not clear if this is a
bug in x.org or my misunderstanding of the XGrabPointer() documentation.

At any rate, we'll want to revisit this later for a better solution.

Fixes Bugzilla #2963.
2015-06-08 02:58:46 -04:00
Ryan C. Gordon 7232e51a68 Unix: Don't send quit events during signal handler.
Make note to send it, and send next time we SDL_PumpEvents().

Otherwise, we might be trying to use malloc() to push a new event on the
queue while a signal is interrupting malloc() elsewhere, usually causing a
crash.

Fixes Bugzilla #2870.
2015-06-08 01:52:43 -04:00
Ryan C. Gordon 8283abdb78 Updated configure script. 2015-06-08 01:17:58 -04:00
Ryan C. Gordon e3f4ca0d71 configure/cmake/x11: Removed SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 test.
This was the only thing that made SDL_config.h generate differently between
32 and 64-bit versions of Linux, so instead we force a function cast in our
X11 code to match our dynamic loader version, which removes the compile error
on some machines that prompted this test in the first place.

Xlib never wrote to this data, so if you're on an older Xlib where this param
wasn't const, your data should still be intact when we force the caller to
think it was actually const after all.

Fixes Bugzilla #1893.
2015-06-08 01:13:51 -04:00
Ryan C. Gordon f5dce3c63c CMake: default to shared library builds being enabled. 2015-06-07 20:15:09 -04:00
Ryan C. Gordon d98cfe1435 Let's assume that if VS2005 and VS2010 do it, VS2008 probably does, too. 2015-06-07 20:00:20 -04:00
Ryan C. Gordon 753f95c5dd VS2005 tweaks (thanks, Ozkan!).
Fixes Bugzilla #2895.

His notes:

The following trivial changes make SDL2 tree (mostly) compatible with Visual
Studio 2005:

* SDL_stdlib.c: Similar to VS2010 and newer, VS2005 also generates memcpy(),
  (it also generates memset(), see below), so propagate the #if condition to
  cover VS2005.

* SDL_pixels.c (SDL_CalculateGammaRamp): VS2005 generates a memset() call for
  gamma==0 case, so replace the if loop with SDL_memset().

* SDL_windowsvideo.h: Include msctf.h only with VS2008 and newer, otherwise
  include SDL_msctf.h

* SDL_windowskeyboard.c: Adjust the #ifdefs so that SDL_msctf.h inclusion is
  always recognized correctly.
2015-06-07 19:58:42 -04:00
Ryan C. Gordon 8bac796791 Maybe patched to compile on some Windows configurations.
(Maybe) Fixes Bugzilla #3001.
2015-06-07 18:29:23 -04:00
Ryan C. Gordon 141ac2b59d Backed out changeset c6d43e08be34
This caused Bugzilla #2963, so we'll find a better solution.
2015-06-07 17:59:31 -04:00
Ryan C. Gordon 699f879a8f Fixed a memory leak (thanks, Zack!).
We should probably rework this piece of code a little more after 2.0.4 ships,
though.

Fixes Bugzilla #3004.
2015-06-07 17:54:39 -04:00
Ryan C. Gordon 8a85084fc1 RPi: Patched to compile without OpenGL (thanks, Simon!), other cleanups.
Fixes Bugzilla #3003.
2015-06-06 22:45:22 -04:00
Philipp Wiesemann 5b2e7aab30 Fixed comments at conditional compilation macro in header file. 2015-06-05 19:41:34 +02:00
Philipp Wiesemann fd8b7c1ca3 Fixed comments at conditional compilation macros. 2015-06-05 19:41:18 +02:00
Philipp Wiesemann c3186d5ee9 Android: Added deactivated intent filter for testing drop file support. 2015-06-05 19:40:50 +02:00
Ryan C. Gordon f080ac3e6f Fixed docs path in RPM .spec file. 2015-06-04 19:05:01 -04:00
Ryan C. Gordon 360d05bf72 X11: Fixed SelectionRequest replies for target TARGETS.
Fixes Google Chrome, etc, freezing up when SDL owns the clipboard selection
and actually sends thems the correct text for pasting. Confirmed working with
Unicode strings in UTF-8 format.

There were a few tweaks in this patch, but the specific fix is that
event.xselection.target in the SelectionNotify event we send back in reply
must be set to the same atom as the request ("TARGETS" in this case), and
we failed to do that in this special case. Things that don't ask for a target,
like the Gnome Terminal app, worked fine because they don't ask for TARGETS
and just go right to asking for a UTF8_STRING, and Mozilla apparently just
was more liberal in what they accepted in reply.

Chrome would reject our wrong reply and freeze up waiting for a valid one.
Someone should fix that in Chrome, too.  :)

Fixes Bugzilla #2926.
2015-06-04 15:41:39 -04:00