Various constants in ANGLE/WinRT, both in MSOpenTech's ms-master branch, and
in Google's branch, were changed again. This change makes SDL/WinRT work with
them.
To note, the ms-master branch (of ANGLE) was updated via this merge:
bbd2eb0a9c (diff-d1377fbe747de154e1bfcf7221d3de67)
If the function WIN_ConvertUTF32toUTF8() failed (should currently not be
possible) a not terminated string would have been sent as text input event.
This also fixed converting characters more often than needed on key repetition.
If the function Emscripten_ConvertUTF32toUTF8() failed (should currently not be
possible) a not terminated string would have been sent as text input event.
The key event callbacks were always removed from the same target although it is
possible to set them to different targets using the hint. This is only a partial
fix because it assumes that the hint is not changed to a different value later.
- fix crash on OSX when removing a device. If the remove happened due to the CFRunLoopRunInMode call in SDL_SYS_JoystickDetect then we would delete the device right away, before SDL_SYS_JoystickUpdate could clean it up. So move the CFRunLoopRunInMode to after the cleanup logic, preventing this case. This does mean that adds and removes of joysticks now take 1 extra frame to show up.
After disconnecting a joystick the remaining kept their original device index.
This was not correct because the device index must be a number between 0 and
SDL_NumJoysticks(). It was fixed with ideas from SDL's joystick implementation
for Android. Some range checks were removed as the caller already checks them.
SDL_SYS_JoystickUpdate() was implemented incorrectly. For every call to it all
attached joysticks were checked. But actually only the given SDL_Joystick should
be checked then. This allowed sending broken events for attached but not opened
joysticks. It also checked the opened joysticks more often than actually needed.
This allows for this kind of code in an application:
int monitorID = 1; // the second monitor!
SDL_SetWindowPosition(sdlWin,
SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID),
SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID));
Fixes Bugzilla #2849.
The callbacks used to receive the HTML events were not removed if the joystick
subsystem initialization failed or if the joystick subsystem was quit. Also, the
already connected joysticks were not deleted if the initialization failed later.
It's slightly faster than failing later, after a strchr() call, since this
will get called multiple times with a NULL string if the system totally
fails elsewhere.
This change integrates initialization settings for ANGLE/WinRT, as suggested in
MSOpenTech's latest ANGLE template-projects (for MSVC).
This should fix some OpenGL initialization issues on WinPhone 8.1 on ARM, and
on the 1st-generation Surface RT.
SDL_JOYDEVICEADDED events must contain the device index which is a value between
0 and the number of connected joysticks. The old implementation included a value
based on the instance id instead. It worked in some cases because the values are
similar initially. But after disconnecting joysticks this is no more the case
and the always increasing instance id becomes larger than number of joysticks.
Windows Phone does not appear to allow VSync to be turned off. Doing so appears
to either result in content not getting drawn (when the D3D debug runtime is
turned off), or forcing VSync back on and logging an error (when the D3D debug
runtime is turned on).
VSync had been getting turned on anyways, this change just notes such:
- via the WinRT README
- by always setting the SDL_RENDERER_PRESENTVSYNC flag when creating an
SDL_Renderer on Windows Phone
- Don't create a temporary context first; this was probably due to Windows
needing one to get the address of wglCreateContextAttribsARB(), but that's
a unique quirk of WGL, and doesn't apply to glX. The glX spec explicitly says
you have to get a function pointer that works with any context from
glXGetProcAddress(), including when no context exists.
- Properly check for the GLX_ARB_create_context instead of just looking for a
non-NULL glXCreateContextAttribsARB()...some implementations, like Mesa,
never return NULL for function lookups (Mesa returns pointers into a jump
table that is filled out when the GL is initialized; since you can look up
functions before you have a valid context, it can't definitely say a function
isn't valid at that point).