mirror of
https://github.com/love2d/megasource.git
synced 2026-08-18 11:44:19 +02:00
Updated SDL2 to the latest code from Mercurial.
This commit is contained in:
Regular → Executable
@@ -66,14 +66,11 @@
|
||||
in the Windows SDK, v.10.0.10240.0 (Win 10's initial SDK)
|
||||
*/
|
||||
#else
|
||||
/* XAudio2 exists as of the March 2008 DirectX SDK
|
||||
The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
|
||||
If you want to build SDL with XAudio2 support you should install the DirectX SDK.
|
||||
/* XAudio2 exists in the last DirectX SDK as well as the latest Windows SDK.
|
||||
To enable XAudio2 support, you will need to add the location of your DirectX SDK headers to
|
||||
the SDL projects additional include directories and then set SDL_XAUDIO2_HAS_SDK=1 as a
|
||||
preprocessor define
|
||||
*/
|
||||
/* Disable compiling in the XAudio2 support pending fixes to dynamically load the XAudio2
|
||||
entry points so we can be robust to user configuration. Also needs to be fixed to build
|
||||
with the Windows 10 SDK.
|
||||
*/
|
||||
#if 0 /* See comment above */
|
||||
#include <dxsdkver.h>
|
||||
#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
|
||||
|
||||
@@ -218,7 +218,14 @@ WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing in
|
||||
}
|
||||
#endif
|
||||
|
||||
WINRT_UpdateWindowFlags(window, SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
const Uint32 latestFlags = WINRT_DetectWindowFlags(window);
|
||||
if (latestFlags & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
|
||||
} else {
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
}
|
||||
|
||||
WINRT_UpdateWindowFlags(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
|
||||
/* The window can move during a resize event, such as when maximizing
|
||||
or resizing from a corner */
|
||||
@@ -364,7 +371,10 @@ void SDL_WinRTApp::SetWindow(CoreWindow^ window)
|
||||
window->CharacterReceived +=
|
||||
ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &SDL_WinRTApp::OnCharacterReceived);
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10
|
||||
Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested +=
|
||||
ref new EventHandler<BackRequestedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
|
||||
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
HardwareButtons::BackPressed +=
|
||||
ref new EventHandler<BackPressedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
|
||||
#endif
|
||||
@@ -618,6 +628,15 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow^ sender, WindowActivatedEventArg
|
||||
// * FIXME: Update keyboard state
|
||||
// */
|
||||
//WIN_CheckClipboardUpdate(data->videodata);
|
||||
|
||||
// HACK: Resetting the mouse-cursor here seems to fix
|
||||
// https://bugzilla.libsdl.org/show_bug.cgi?id=3217, whereby a
|
||||
// WinRT app's mouse cursor may switch to Windows' 'wait' cursor,
|
||||
// after a user alt-tabs back into a full-screened SDL app.
|
||||
// This bug does not appear to reproduce 100% of the time.
|
||||
// It may be a bug in Windows itself (v.10.0.586.36, as tested,
|
||||
// and the most-recent as of this writing).
|
||||
SDL_SetCursor(NULL);
|
||||
} else {
|
||||
if (SDL_GetKeyboardFocus() == window) {
|
||||
SDL_SetKeyboardFocus(NULL);
|
||||
@@ -785,8 +804,8 @@ void SDL_WinRTApp::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Wi
|
||||
WINRT_ProcessCharacterReceivedEvent(args);
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
|
||||
template <typename BackButtonEventArgs>
|
||||
static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args)
|
||||
{
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
|
||||
@@ -798,5 +817,18 @@ void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NTDDI_VERSION == NTDDI_WIN10
|
||||
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args)
|
||||
|
||||
{
|
||||
WINRT_OnBackButtonPressed(args);
|
||||
}
|
||||
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
|
||||
|
||||
{
|
||||
WINRT_OnBackButtonPressed(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -74,7 +74,9 @@ protected:
|
||||
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
||||
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10
|
||||
void OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args);
|
||||
#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -735,7 +735,7 @@ SDL_GetSystemRAM(void)
|
||||
#endif
|
||||
#ifdef HAVE_SYSCTLBYNAME
|
||||
if (SDL_SystemRAM <= 0) {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
#ifdef HW_REALMEM
|
||||
int mib[2] = {CTL_HW, HW_REALMEM};
|
||||
#else
|
||||
|
||||
Regular → Executable
@@ -845,6 +845,19 @@ SDL_SetModState(SDL_Keymod modstate)
|
||||
keyboard->modstate = modstate;
|
||||
}
|
||||
|
||||
/* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */
|
||||
void
|
||||
SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
if (toggle) {
|
||||
keyboard->modstate |= modstate;
|
||||
} else {
|
||||
keyboard->modstate &= ~modstate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_Keycode
|
||||
SDL_GetKeyFromScancode(SDL_Scancode scancode)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,9 @@ extern void SDL_KeyboardQuit(void);
|
||||
/* Convert to UTF-8 */
|
||||
extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst);
|
||||
|
||||
/* Toggle on or off pieces of the keyboard mod state. */
|
||||
extern void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle);
|
||||
|
||||
#endif /* _SDL_keyboard_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -127,6 +127,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
return 0;
|
||||
}
|
||||
window->flags &= ~SDL_WINDOW_MAXIMIZED;
|
||||
window->flags |= SDL_WINDOW_MINIMIZED;
|
||||
SDL_OnWindowMinimized(window);
|
||||
break;
|
||||
@@ -134,6 +135,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
|
||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
return 0;
|
||||
}
|
||||
window->flags &= ~SDL_WINDOW_MINIMIZED;
|
||||
window->flags |= SDL_WINDOW_MAXIMIZED;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
|
||||
@@ -254,36 +254,6 @@ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *gu
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to determine pre-calculated offset to certain joystick mappings
|
||||
*/
|
||||
ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||
{
|
||||
SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
|
||||
ControllerMapping_t *mapping;
|
||||
|
||||
mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
||||
#if SDL_JOYSTICK_XINPUT
|
||||
if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) {
|
||||
mapping = s_pXInputMapping;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_JOYSTICK_EMSCRIPTEN)
|
||||
if (!mapping && s_pEmscriptenMapping) {
|
||||
mapping = s_pEmscriptenMapping;
|
||||
}
|
||||
#endif
|
||||
if (!mapping) {
|
||||
const char *name = SDL_JoystickNameForIndex(device_index);
|
||||
if (name) {
|
||||
if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box")) {
|
||||
mapping = s_pXInputMapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
static const char* map_StringForControllerAxis[] = {
|
||||
"leftx",
|
||||
"lefty",
|
||||
@@ -581,6 +551,9 @@ char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMapping)
|
||||
return SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to refresh a mapping
|
||||
*/
|
||||
void SDL_PrivateGameControllerRefreshMapping(ControllerMapping_t *pControllerMapping)
|
||||
{
|
||||
SDL_GameController *gamecontrollerlist = SDL_gamecontrollers;
|
||||
@@ -599,6 +572,102 @@ void SDL_PrivateGameControllerRefreshMapping(ControllerMapping_t *pControllerMap
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to add a mapping for a guid
|
||||
*/
|
||||
static ControllerMapping_t *
|
||||
SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing)
|
||||
{
|
||||
char *pchName;
|
||||
char *pchMapping;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
|
||||
pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString);
|
||||
if (!pchName) {
|
||||
SDL_SetError("Couldn't parse name from %s", mappingString);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString);
|
||||
if (!pchMapping) {
|
||||
SDL_free(pchName);
|
||||
SDL_SetError("Couldn't parse %s", mappingString);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
||||
if (pControllerMapping) {
|
||||
/* Update existing mapping */
|
||||
SDL_free(pControllerMapping->name);
|
||||
pControllerMapping->name = pchName;
|
||||
SDL_free(pControllerMapping->mapping);
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
/* refresh open controllers */
|
||||
SDL_PrivateGameControllerRefreshMapping(pControllerMapping);
|
||||
*existing = SDL_TRUE;
|
||||
} else {
|
||||
pControllerMapping = SDL_malloc(sizeof(*pControllerMapping));
|
||||
if (!pControllerMapping) {
|
||||
SDL_free(pchName);
|
||||
SDL_free(pchMapping);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
pControllerMapping->guid = jGUID;
|
||||
pControllerMapping->name = pchName;
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
pControllerMapping->next = s_pSupportedControllers;
|
||||
s_pSupportedControllers = pControllerMapping;
|
||||
*existing = SDL_FALSE;
|
||||
}
|
||||
return pControllerMapping;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to determine pre-calculated offset to certain joystick mappings
|
||||
*/
|
||||
ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||
{
|
||||
SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
|
||||
ControllerMapping_t *mapping;
|
||||
|
||||
mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
||||
#if SDL_JOYSTICK_XINPUT
|
||||
if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) {
|
||||
mapping = s_pXInputMapping;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_JOYSTICK_EMSCRIPTEN)
|
||||
if (!mapping && s_pEmscriptenMapping) {
|
||||
mapping = s_pEmscriptenMapping;
|
||||
}
|
||||
#endif
|
||||
#ifdef __LINUX__
|
||||
if (!mapping) {
|
||||
const char *name = SDL_JoystickNameForIndex(device_index);
|
||||
if (name) {
|
||||
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
||||
/* The Linux driver xpad.c maps the wireless dpad to buttons */
|
||||
SDL_bool existing;
|
||||
mapping = SDL_PrivateAddMappingForGUID(jGUID,
|
||||
"none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
&existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
if (!mapping) {
|
||||
const char *name = SDL_JoystickNameForIndex(device_index);
|
||||
if (name) {
|
||||
if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box")) {
|
||||
mapping = s_pXInputMapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add or update an entry into the Mappings Database
|
||||
*/
|
||||
@@ -677,12 +746,11 @@ int
|
||||
SDL_GameControllerAddMapping(const char *mappingString)
|
||||
{
|
||||
char *pchGUID;
|
||||
char *pchName;
|
||||
char *pchMapping;
|
||||
SDL_JoystickGUID jGUID;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
SDL_bool is_xinput_mapping = SDL_FALSE;
|
||||
SDL_bool is_emscripten_mapping = SDL_FALSE;
|
||||
SDL_bool existing = SDL_FALSE;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
|
||||
if (!mappingString) {
|
||||
return SDL_InvalidParamError("mappingString");
|
||||
@@ -701,46 +769,20 @@ SDL_GameControllerAddMapping(const char *mappingString)
|
||||
jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
|
||||
SDL_free(pchGUID);
|
||||
|
||||
pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString);
|
||||
if (!pchName) {
|
||||
return SDL_SetError("Couldn't parse name from %s", mappingString);
|
||||
pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing);
|
||||
if (!pControllerMapping) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString);
|
||||
if (!pchMapping) {
|
||||
SDL_free(pchName);
|
||||
return SDL_SetError("Couldn't parse %s", mappingString);
|
||||
}
|
||||
|
||||
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
||||
|
||||
if (pControllerMapping) {
|
||||
/* Update existing mapping */
|
||||
SDL_free(pControllerMapping->name);
|
||||
pControllerMapping->name = pchName;
|
||||
SDL_free(pControllerMapping->mapping);
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
/* refresh open controllers */
|
||||
SDL_PrivateGameControllerRefreshMapping(pControllerMapping);
|
||||
if (existing) {
|
||||
return 0;
|
||||
} else {
|
||||
pControllerMapping = SDL_malloc(sizeof(*pControllerMapping));
|
||||
if (!pControllerMapping) {
|
||||
SDL_free(pchName);
|
||||
SDL_free(pchMapping);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (is_xinput_mapping) {
|
||||
s_pXInputMapping = pControllerMapping;
|
||||
}
|
||||
if (is_emscripten_mapping) {
|
||||
s_pEmscriptenMapping = pControllerMapping;
|
||||
}
|
||||
pControllerMapping->guid = jGUID;
|
||||
pControllerMapping->name = pchName;
|
||||
pControllerMapping->mapping = pchMapping;
|
||||
pControllerMapping->next = s_pSupportedControllers;
|
||||
s_pSupportedControllers = pControllerMapping;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,6 @@ static const char *s_ControllerMappings [] =
|
||||
"050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
|
||||
"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e040000d102000001010000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
#endif
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
|
||||
#define MAX_UHID_JOYS 16
|
||||
#define MAX_UHID_JOYS 64
|
||||
#define MAX_JOY_JOYS 2
|
||||
#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS)
|
||||
|
||||
@@ -286,7 +286,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
|
||||
struct joystick_hwdata *hw;
|
||||
struct hid_item hitem;
|
||||
struct hid_data *hdata;
|
||||
struct report *rep;
|
||||
struct report *rep = NULL;
|
||||
int fd;
|
||||
int i;
|
||||
|
||||
@@ -337,6 +337,38 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
|
||||
#endif
|
||||
rep->rid = -1; /* XXX */
|
||||
}
|
||||
#if defined(__NetBSD__)
|
||||
usb_device_descriptor_t udd;
|
||||
struct usb_string_desc usd;
|
||||
if (ioctl(fd, USB_GET_DEVICE_DESC, &udd) == -1)
|
||||
goto desc_failed;
|
||||
|
||||
/* Get default language */
|
||||
usd.usd_string_index = USB_LANGUAGE_TABLE;
|
||||
usd.usd_language_id = 0;
|
||||
if (ioctl(fd, USB_GET_STRING_DESC, &usd) == -1 || usd.usd_desc.bLength < 4) {
|
||||
usd.usd_language_id = 0;
|
||||
} else {
|
||||
usd.usd_language_id = UGETW(usd.usd_desc.bString[0]);
|
||||
}
|
||||
|
||||
usd.usd_string_index = udd.iProduct;
|
||||
if (ioctl(fd, USB_GET_STRING_DESC, &usd) == 0) {
|
||||
char str[128];
|
||||
char *new_name = NULL;
|
||||
int i;
|
||||
for (i = 0; i < (usd.usd_desc.bLength >> 1) - 1 && i < sizeof(str) - 1; i++) {
|
||||
str[i] = UGETW(usd.usd_desc.bString[i]);
|
||||
}
|
||||
str[i] = '\0';
|
||||
asprintf(&new_name, "%s @ %s", str, path);
|
||||
if (new_name != NULL) {
|
||||
free(joydevnames[SDL_SYS_numjoysticks]);
|
||||
joydevnames[SDL_SYS_numjoysticks] = new_name;
|
||||
}
|
||||
}
|
||||
desc_failed:
|
||||
#endif
|
||||
if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
|
||||
goto usberr;
|
||||
}
|
||||
@@ -409,9 +441,21 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
|
||||
if (hw->axis_map[i] > 0)
|
||||
hw->axis_map[i] = joy->naxes++;
|
||||
|
||||
if (joy->naxes == 0 && joy->nbuttons == 0 && joy->nhats == 0 && joy->nballs == 0) {
|
||||
SDL_SetError("%s: Not a joystick, ignoring", hw->path);
|
||||
goto usberr;
|
||||
}
|
||||
|
||||
usbend:
|
||||
/* The poll blocks the event thread. */
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#ifdef __NetBSD__
|
||||
/* Flush pending events */
|
||||
if (rep) {
|
||||
while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
usberr:
|
||||
|
||||
@@ -247,6 +247,8 @@ AddHIDElement(const void *value, void *parameter)
|
||||
case kHIDUsage_GD_DPadDown:
|
||||
case kHIDUsage_GD_DPadRight:
|
||||
case kHIDUsage_GD_DPadLeft:
|
||||
case kHIDUsage_GD_Start:
|
||||
case kHIDUsage_GD_Select:
|
||||
if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) {
|
||||
element = (recElement *) SDL_calloc(1, sizeof (recElement));
|
||||
if (element) {
|
||||
|
||||
@@ -116,6 +116,10 @@ SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *contr
|
||||
device->nbuttons = 7; /* ABXY, shoulder buttons, pause button */
|
||||
}
|
||||
/* TODO: Handle micro profiles on tvOS. */
|
||||
|
||||
/* This will be set when the first button press of the controller is
|
||||
* detected. */
|
||||
controller.playerIndex = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -361,26 +365,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||
} else {
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
GCController *controller = device->controller;
|
||||
BOOL usedPlayerIndexSlots[4] = {NO, NO, NO, NO};
|
||||
|
||||
/* Find the player index of all other connected controllers. */
|
||||
for (GCController *c in [GCController controllers]) {
|
||||
if (c != controller && c.playerIndex >= 0) {
|
||||
usedPlayerIndexSlots[c.playerIndex] = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set this controller's player index to the first unused index.
|
||||
* FIXME: This logic isn't great... but SDL doesn't expose this
|
||||
* concept in its external API, so we don't have much to go on. */
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!usedPlayerIndexSlots[i]) {
|
||||
controller.playerIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
controller.controllerPausedHandler = ^(GCController *controller) {
|
||||
controller.controllerPausedHandler = ^(GCController *c) {
|
||||
if (joystick->hwdata) {
|
||||
++joystick->hwdata->num_pause_presses;
|
||||
}
|
||||
@@ -475,53 +460,102 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
|
||||
GCController *controller = joystick->hwdata->controller;
|
||||
Uint8 hatstate = SDL_HAT_CENTERED;
|
||||
int i;
|
||||
int updateplayerindex = 0;
|
||||
|
||||
if (controller.extendedGamepad) {
|
||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||
|
||||
/* Axis order matches the XInput Windows mappings. */
|
||||
SDL_PrivateJoystickAxis(joystick, 0, (Sint16) (gamepad.leftThumbstick.xAxis.value * 32767));
|
||||
SDL_PrivateJoystickAxis(joystick, 1, (Sint16) (gamepad.leftThumbstick.yAxis.value * -32767));
|
||||
SDL_PrivateJoystickAxis(joystick, 2, (Sint16) ((gamepad.leftTrigger.value * 65535) - 32768));
|
||||
SDL_PrivateJoystickAxis(joystick, 3, (Sint16) (gamepad.rightThumbstick.xAxis.value * 32767));
|
||||
SDL_PrivateJoystickAxis(joystick, 4, (Sint16) (gamepad.rightThumbstick.yAxis.value * -32767));
|
||||
SDL_PrivateJoystickAxis(joystick, 5, (Sint16) ((gamepad.rightTrigger.value * 65535) - 32768));
|
||||
Sint16 axes[] = {
|
||||
(Sint16) (gamepad.leftThumbstick.xAxis.value * 32767),
|
||||
(Sint16) (gamepad.leftThumbstick.yAxis.value * -32767),
|
||||
(Sint16) ((gamepad.leftTrigger.value * 65535) - 32768),
|
||||
(Sint16) (gamepad.rightThumbstick.xAxis.value * 32767),
|
||||
(Sint16) (gamepad.rightThumbstick.yAxis.value * -32767),
|
||||
(Sint16) ((gamepad.rightTrigger.value * 65535) - 32768),
|
||||
};
|
||||
|
||||
/* Button order matches the XInput Windows mappings. */
|
||||
Uint8 buttons[] = {
|
||||
gamepad.buttonA.isPressed, gamepad.buttonB.isPressed,
|
||||
gamepad.buttonX.isPressed, gamepad.buttonY.isPressed,
|
||||
gamepad.leftShoulder.isPressed,
|
||||
gamepad.rightShoulder.isPressed,
|
||||
};
|
||||
|
||||
hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad);
|
||||
|
||||
/* Button order matches the XInput Windows mappings. */
|
||||
SDL_PrivateJoystickButton(joystick, 0, gamepad.buttonA.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 1, gamepad.buttonB.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 2, gamepad.buttonX.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 3, gamepad.buttonY.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 4, gamepad.leftShoulder.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 5, gamepad.rightShoulder.isPressed);
|
||||
for (i = 0; i < SDL_arraysize(axes); i++) {
|
||||
/* The triggers (axes 2 and 5) are resting at -32768 but SDL
|
||||
* initializes its values to 0. We only want to make sure the
|
||||
* player index is up to date if the user actually moves an axis. */
|
||||
if ((i != 2 && i != 5) || axes[i] != -32768) {
|
||||
updateplayerindex |= (joystick->axes[i] != axes[i]);
|
||||
}
|
||||
SDL_PrivateJoystickAxis(joystick, i, axes[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_arraysize(buttons); i++) {
|
||||
updateplayerindex |= (joystick->buttons[i] != buttons[i]);
|
||||
SDL_PrivateJoystickButton(joystick, i, buttons[i]);
|
||||
}
|
||||
} else if (controller.gamepad) {
|
||||
GCGamepad *gamepad = controller.gamepad;
|
||||
|
||||
/* Button order matches the XInput Windows mappings. */
|
||||
Uint8 buttons[] = {
|
||||
gamepad.buttonA.isPressed, gamepad.buttonB.isPressed,
|
||||
gamepad.buttonX.isPressed, gamepad.buttonY.isPressed,
|
||||
gamepad.leftShoulder.isPressed,
|
||||
gamepad.rightShoulder.isPressed,
|
||||
};
|
||||
|
||||
hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad);
|
||||
|
||||
/* Button order matches the XInput Windows mappings. */
|
||||
SDL_PrivateJoystickButton(joystick, 0, gamepad.buttonA.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 1, gamepad.buttonB.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 2, gamepad.buttonX.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 3, gamepad.buttonY.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 4, gamepad.leftShoulder.isPressed);
|
||||
SDL_PrivateJoystickButton(joystick, 5, gamepad.rightShoulder.isPressed);
|
||||
for (i = 0; i < SDL_arraysize(buttons); i++) {
|
||||
updateplayerindex |= (joystick->buttons[i] != buttons[i]);
|
||||
SDL_PrivateJoystickButton(joystick, i, buttons[i]);
|
||||
}
|
||||
}
|
||||
/* TODO: Handle micro profiles on tvOS. */
|
||||
|
||||
SDL_PrivateJoystickHat(joystick, 0, hatstate);
|
||||
if (joystick->nhats > 0) {
|
||||
updateplayerindex |= (joystick->hats[0] != hatstate);
|
||||
SDL_PrivateJoystickHat(joystick, 0, hatstate);
|
||||
}
|
||||
|
||||
for (i = 0; i < joystick->hwdata->num_pause_presses; i++) {
|
||||
/* The pause button is always last. */
|
||||
Uint8 pausebutton = joystick->nbuttons - 1;
|
||||
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, 1);
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, 0);
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, SDL_PRESSED);
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, SDL_RELEASED);
|
||||
|
||||
updateplayerindex = YES;
|
||||
}
|
||||
|
||||
joystick->hwdata->num_pause_presses = 0;
|
||||
|
||||
if (updateplayerindex && controller.playerIndex == -1) {
|
||||
BOOL usedPlayerIndexSlots[4] = {NO, NO, NO, NO};
|
||||
|
||||
/* Find the player index of all other connected controllers. */
|
||||
for (GCController *c in [GCController controllers]) {
|
||||
if (c != controller && c.playerIndex >= 0) {
|
||||
usedPlayerIndexSlots[c.playerIndex] = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set this controller's player index to the first unused index.
|
||||
* FIXME: This logic isn't great... but SDL doesn't expose this
|
||||
* concept in its external API, so we don't have much to go on. */
|
||||
for (i = 0; i < SDL_arraysize(usedPlayerIndexSlots); i++) {
|
||||
if (!usedPlayerIndexSlots[i]) {
|
||||
controller.playerIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -566,6 +600,7 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
GCController *controller = device->controller;
|
||||
controller.controllerPausedHandler = nil;
|
||||
controller.playerIndex = -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
@@ -158,7 +158,8 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||
}
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
|
||||
renderer->hidden = SDL_TRUE;
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
|
||||
event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
|
||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
|
||||
renderer->hidden = SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
const char *hint;
|
||||
GLint value;
|
||||
Uint32 window_flags;
|
||||
int profile_mask, major, minor;
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
SDL_bool changed_window = SDL_FALSE;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
|
||||
@@ -1052,7 +1052,7 @@ GL_UpdateClipRect(SDL_Renderer * renderer)
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, (h - renderer->viewport.y - renderer->viewport.h) + rect->y, rect->w, rect->h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
@@ -285,7 +285,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
GLES_RenderData *data;
|
||||
GLint value;
|
||||
Uint32 window_flags;
|
||||
int profile_mask, major, minor;
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
SDL_bool changed_window = SDL_FALSE;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
|
||||
@@ -721,7 +721,7 @@ GLES_UpdateClipRect(SDL_Renderer * renderer)
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, (h - renderer->viewport.y - renderer->viewport.h) + rect->y, rect->w, rect->h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
@@ -418,7 +418,7 @@ GLES2_UpdateClipRect(SDL_Renderer * renderer)
|
||||
int w, h;
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, (h - renderer->viewport.y - renderer->viewport.h) + rect->y, rect->w, rect->h);
|
||||
data->glScissor(renderer->viewport.x + rect->x, h - renderer->viewport.y - rect->y - rect->h, rect->w, rect->h);
|
||||
}
|
||||
} else {
|
||||
data->glDisable(GL_SCISSOR_TEST);
|
||||
@@ -1956,7 +1956,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
Uint32 window_flags;
|
||||
GLint window_framebuffer;
|
||||
GLint value;
|
||||
int profile_mask, major, minor;
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
SDL_bool changed_window = SDL_FALSE;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
|
||||
|
||||
@@ -143,7 +143,11 @@ SDL_SYS_SetupThread(const char *name)
|
||||
#endif
|
||||
}
|
||||
#elif HAVE_PTHREAD_SETNAME_NP
|
||||
#if defined(__NETBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", name);
|
||||
#else
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
#endif
|
||||
#elif HAVE_PTHREAD_SET_NAME_NP
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
@@ -1488,6 +1488,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
}
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
@@ -2913,18 +2914,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
||||
void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
|
||||
GLenum attachment = GL_BACK_LEFT;
|
||||
GLenum attachmentattrib = 0;
|
||||
|
||||
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
|
||||
if (!glGetStringFunc) {
|
||||
return SDL_SetError("Failed getting OpenGL glGetString entry point");
|
||||
}
|
||||
#endif
|
||||
|
||||
glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
|
||||
if (!glGetErrorFunc) {
|
||||
return SDL_SetError("Failed getting OpenGL glGetError entry point");
|
||||
}
|
||||
|
||||
/* Clear value in any case */
|
||||
*value = 0;
|
||||
|
||||
@@ -3095,6 +3086,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
|
||||
if (!glGetStringFunc) {
|
||||
return SDL_SetError("Failed getting OpenGL glGetString entry point");
|
||||
}
|
||||
|
||||
if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
|
||||
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
|
||||
|
||||
@@ -3115,6 +3111,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
||||
}
|
||||
}
|
||||
|
||||
glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
|
||||
if (!glGetErrorFunc) {
|
||||
return SDL_SetError("Failed getting OpenGL glGetError entry point");
|
||||
}
|
||||
|
||||
error = glGetErrorFunc();
|
||||
if (error != GL_NO_ERROR) {
|
||||
if (error == GL_INVALID_ENUM) {
|
||||
|
||||
@@ -33,25 +33,27 @@
|
||||
/*#define DEBUG_IME NSLog */
|
||||
#define DEBUG_IME(...)
|
||||
|
||||
@interface SDLTranslatorResponder : NSView <NSTextInput> {
|
||||
@interface SDLTranslatorResponder : NSView <NSTextInputClient> {
|
||||
NSString *_markedText;
|
||||
NSRange _markedRange;
|
||||
NSRange _selectedRange;
|
||||
SDL_Rect _inputRect;
|
||||
}
|
||||
- (void) doCommandBySelector:(SEL)myselector;
|
||||
- (void) setInputRect:(SDL_Rect *) rect;
|
||||
- (void)doCommandBySelector:(SEL)myselector;
|
||||
- (void)setInputRect:(SDL_Rect *)rect;
|
||||
@end
|
||||
|
||||
@implementation SDLTranslatorResponder
|
||||
|
||||
- (void) setInputRect:(SDL_Rect *) rect
|
||||
- (void)setInputRect:(SDL_Rect *)rect
|
||||
{
|
||||
_inputRect = *rect;
|
||||
}
|
||||
|
||||
- (void) insertText:(id) aString
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
/* TODO: Make use of replacementRange? */
|
||||
|
||||
const char *str;
|
||||
|
||||
DEBUG_IME(@"insertText: %@", aString);
|
||||
@@ -67,7 +69,15 @@
|
||||
SDL_SendKeyboardText(str);
|
||||
}
|
||||
|
||||
- (void) doCommandBySelector:(SEL) myselector
|
||||
- (void)insertText:(id)insertString
|
||||
{
|
||||
/* This method is part of NSTextInput and not NSTextInputClient, but
|
||||
* apparently it still might be called in OS X 10.5 and can cause beeps if
|
||||
* the implementation is missing: http://crbug.com/47890 */
|
||||
[self insertText:insertString replacementRange:NSMakeRange(0, 0)];
|
||||
}
|
||||
|
||||
- (void)doCommandBySelector:(SEL)myselector
|
||||
{
|
||||
/* No need to do anything since we are not using Cocoa
|
||||
selectors to handle special keys, instead we use SDL
|
||||
@@ -75,23 +85,22 @@
|
||||
*/
|
||||
}
|
||||
|
||||
- (BOOL) hasMarkedText
|
||||
- (BOOL)hasMarkedText
|
||||
{
|
||||
return _markedText != nil;
|
||||
}
|
||||
|
||||
- (NSRange) markedRange
|
||||
- (NSRange)markedRange
|
||||
{
|
||||
return _markedRange;
|
||||
}
|
||||
|
||||
- (NSRange) selectedRange
|
||||
- (NSRange)selectedRange
|
||||
{
|
||||
return _selectedRange;
|
||||
}
|
||||
|
||||
- (void) setMarkedText:(id) aString
|
||||
selectedRange:(NSRange) selRange
|
||||
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange;
|
||||
{
|
||||
if ([aString isKindOfClass: [NSAttributedString class]]) {
|
||||
aString = [aString string];
|
||||
@@ -107,17 +116,17 @@
|
||||
_markedText = [aString retain];
|
||||
}
|
||||
|
||||
_selectedRange = selRange;
|
||||
_selectedRange = selectedRange;
|
||||
_markedRange = NSMakeRange(0, [aString length]);
|
||||
|
||||
SDL_SendEditingText([aString UTF8String],
|
||||
selRange.location, selRange.length);
|
||||
selectedRange.location, selectedRange.length);
|
||||
|
||||
DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
|
||||
selRange.location, selRange.length);
|
||||
}
|
||||
|
||||
- (void) unmarkText
|
||||
- (void)unmarkText
|
||||
{
|
||||
[_markedText release];
|
||||
_markedText = nil;
|
||||
@@ -125,29 +134,38 @@
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
- (NSRect) firstRectForCharacterRange: (NSRange) theRange
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange;
|
||||
{
|
||||
NSWindow *window = [self window];
|
||||
NSRect contentRect = [window contentRectForFrameRect: [window frame]];
|
||||
NSRect contentRect = [window contentRectForFrameRect:[window frame]];
|
||||
float windowHeight = contentRect.size.height;
|
||||
NSRect rect = NSMakeRect(_inputRect.x, windowHeight - _inputRect.y - _inputRect.h,
|
||||
_inputRect.w, _inputRect.h);
|
||||
|
||||
if (actualRange) {
|
||||
*actualRange = aRange;
|
||||
}
|
||||
|
||||
DEBUG_IME(@"firstRectForCharacterRange: (%d, %d): windowHeight = %g, rect = %@",
|
||||
theRange.location, theRange.length, windowHeight,
|
||||
aRange.location, aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
rect.origin = [[self window] convertBaseToScreen: rect.origin];
|
||||
|
||||
if ([[self window] respondsToSelector:@selector(convertRectToScreen:)]) {
|
||||
rect = [[self window] convertRectToScreen:rect];
|
||||
} else {
|
||||
rect.origin = [[self window] convertBaseToScreen:rect.origin];
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSAttributedString *) attributedSubstringFromRange: (NSRange) theRange
|
||||
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange;
|
||||
{
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", theRange.location, theRange.length);
|
||||
DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", aRange.location, aRange.length);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSInteger) conversationIdentifier
|
||||
- (NSInteger)conversationIdentifier
|
||||
{
|
||||
return (NSInteger) self;
|
||||
}
|
||||
@@ -155,7 +173,7 @@
|
||||
/* This method returns the index for character that is
|
||||
* nearest to thePoint. thPoint is in screen coordinate system.
|
||||
*/
|
||||
- (NSUInteger) characterIndexForPoint:(NSPoint) thePoint
|
||||
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
|
||||
{
|
||||
DEBUG_IME(@"characterIndexForPoint: (%g, %g)", thePoint.x, thePoint.y);
|
||||
return 0;
|
||||
@@ -166,7 +184,7 @@
|
||||
* NSInputServer examines the return value of this
|
||||
* method & constructs appropriate attributed string.
|
||||
*/
|
||||
- (NSArray *) validAttributesForMarkedText
|
||||
- (NSArray *)validAttributesForMarkedText
|
||||
{
|
||||
return [NSArray array];
|
||||
}
|
||||
@@ -479,6 +497,12 @@ Cocoa_InitKeyboard(_THIS)
|
||||
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
|
||||
|
||||
/* On pre-10.6, you might have the initial capslock key state wrong. */
|
||||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
|
||||
data->modifierFlags = [NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -504,7 +528,7 @@ Cocoa_StartTextInput(_THIS)
|
||||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
}
|
||||
|
||||
if (![[data->fieldEdit superview] isEqual: parentView]) {
|
||||
if (![[data->fieldEdit superview] isEqual:parentView]) {
|
||||
/* DEBUG_IME(@"add fieldEdit to window contentView"); */
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data->fieldEdit];
|
||||
@@ -535,7 +559,7 @@ Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
return;
|
||||
}
|
||||
|
||||
[data->fieldEdit setInputRect: rect];
|
||||
[data->fieldEdit setInputRect:rect];
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -588,6 +588,13 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
||||
if ((isFullscreenSpace) && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
|
||||
[NSMenu setMenuBarVisible:NO];
|
||||
}
|
||||
|
||||
/* On pre-10.6, you might have the capslock key state wrong now because we can't check here. */
|
||||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
|
||||
const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
|
||||
_data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
|
||||
SDL_ToggleModState(KMOD_CAPS, newflags != 0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)aNotification
|
||||
@@ -816,7 +823,14 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
||||
|
||||
/* Ignore events that aren't inside the client area (i.e. title bar.) */
|
||||
if ([theEvent window]) {
|
||||
const NSRect windowRect = [[[theEvent window] contentView] frame];
|
||||
NSRect windowRect = [[[theEvent window] contentView] frame];
|
||||
|
||||
/* add one to size, since NSPointInRect is exclusive of the bottom
|
||||
edges, which mean it misses the top of the window by one pixel
|
||||
(as the origin is the bottom left). */
|
||||
windowRect.size.width += 1;
|
||||
windowRect.size.height += 1;
|
||||
|
||||
if (!NSPointInRect([theEvent locationInWindow], windowRect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Regular → Executable
@@ -415,12 +415,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
* FIXME: Update keyboard state
|
||||
*/
|
||||
WIN_CheckClipboardUpdate(data->videodata);
|
||||
|
||||
SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) != 0);
|
||||
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
|
||||
} else {
|
||||
data->in_window_deactivation = SDL_TRUE;
|
||||
|
||||
if (SDL_GetKeyboardFocus() == data->window) {
|
||||
SDL_SetKeyboardFocus(NULL);
|
||||
}
|
||||
|
||||
ClipCursor(NULL);
|
||||
|
||||
data->in_window_deactivation = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
returnCode = 0;
|
||||
|
||||
@@ -42,6 +42,9 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
||||
/* Find out the format of the screen */
|
||||
size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
|
||||
info = (LPBITMAPINFO)SDL_stack_alloc(Uint8, size);
|
||||
if (!info) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_memset(info, 0, size);
|
||||
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
|
||||
@@ -102,6 +102,10 @@ WIN_InitKeyboard(_THIS)
|
||||
SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
|
||||
|
||||
/* Are system caps/num/scroll lock active? Set our state to match. */
|
||||
SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) != 0);
|
||||
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -666,29 +666,29 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
|
||||
0
|
||||
};
|
||||
int iattr = 4;
|
||||
int iattr = 4;
|
||||
|
||||
/* SDL profile bits match WGL profile bits */
|
||||
if( _this->gl_config.profile_mask != 0 ) {
|
||||
attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
attribs[iattr++] = _this->gl_config.profile_mask;
|
||||
}
|
||||
/* SDL profile bits match WGL profile bits */
|
||||
if (_this->gl_config.profile_mask != 0) {
|
||||
attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
attribs[iattr++] = _this->gl_config.profile_mask;
|
||||
}
|
||||
|
||||
/* SDL flags match WGL flags */
|
||||
if( _this->gl_config.flags != 0 ) {
|
||||
attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
|
||||
attribs[iattr++] = _this->gl_config.flags;
|
||||
}
|
||||
/* SDL flags match WGL flags */
|
||||
if (_this->gl_config.flags != 0) {
|
||||
attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
|
||||
attribs[iattr++] = _this->gl_config.flags;
|
||||
}
|
||||
|
||||
/* only set if wgl extension is available */
|
||||
if( _this->gl_data->HAS_WGL_ARB_context_flush_control ) {
|
||||
attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB;
|
||||
attribs[iattr++] = _this->gl_config.release_behavior ?
|
||||
/* only set if wgl extension is available */
|
||||
if (_this->gl_data->HAS_WGL_ARB_context_flush_control) {
|
||||
attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB;
|
||||
attribs[iattr++] = _this->gl_config.release_behavior ?
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB :
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB;
|
||||
}
|
||||
}
|
||||
|
||||
attribs[iattr++] = 0;
|
||||
attribs[iattr++] = 0;
|
||||
|
||||
/* Create the GL 3.x context */
|
||||
context = wglCreateContextAttribsARB(hdc, share_context, attribs);
|
||||
|
||||
@@ -559,7 +559,25 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display,
|
||||
y = bounds.y;
|
||||
w = bounds.w;
|
||||
h = bounds.h;
|
||||
|
||||
/* Unset the maximized flag. This fixes
|
||||
https://bugzilla.libsdl.org/show_bug.cgi?id=3215
|
||||
*/
|
||||
if (style & WS_MAXIMIZE) {
|
||||
data->windowed_mode_was_maximized = SDL_TRUE;
|
||||
style &= ~WS_MAXIMIZE;
|
||||
}
|
||||
} else {
|
||||
/* Restore window-maximization state, as applicable.
|
||||
Special care is taken to *not* do this if and when we're
|
||||
alt-tab'ing away (to some other window; as indicated by
|
||||
in_window_deactivation), otherwise
|
||||
https://bugzilla.libsdl.org/show_bug.cgi?id=3215 can reproduce!
|
||||
*/
|
||||
if (data->windowed_mode_was_maximized && !data->in_window_deactivation) {
|
||||
style |= WS_MAXIMIZE;
|
||||
data->windowed_mode_was_maximized = SDL_FALSE;
|
||||
}
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = window->windowed.w;
|
||||
|
||||
@@ -42,6 +42,8 @@ typedef struct
|
||||
SDL_bool in_border_change;
|
||||
SDL_bool in_title_click;
|
||||
SDL_bool focus_click_pending;
|
||||
SDL_bool windowed_mode_was_maximized;
|
||||
SDL_bool in_window_deactivation;
|
||||
struct SDL_VideoData *videodata;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
|
||||
@@ -315,6 +315,61 @@ WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterInd
|
||||
|
||||
for (int outputIndex = 0; ; ++outputIndex) {
|
||||
if (WINRT_AddDisplaysForOutput(_this, dxgiAdapter1, outputIndex) < 0) {
|
||||
/* HACK: The Windows App Certification Kit 10.0 can fail, when
|
||||
running the Store Apps' test, "Direct3D Feature Test". The
|
||||
certification kit's error is:
|
||||
|
||||
"Application App was not running at the end of the test. It likely crashed or was terminated for having become unresponsive."
|
||||
|
||||
This was caused by SDL/WinRT's DXGI failing to report any
|
||||
outputs. Attempts to get the 1st display-output from the
|
||||
1st display-adapter can fail, with IDXGIAdapter::EnumOutputs
|
||||
returning DXGI_ERROR_NOT_FOUND. This could be a bug in Windows,
|
||||
the Windows App Certification Kit, or possibly in SDL/WinRT's
|
||||
display detection code. Either way, try to detect when this
|
||||
happens, and use a hackish means to create a reasonable-as-possible
|
||||
'display mode'. -- DavidL
|
||||
*/
|
||||
if (adapterIndex == 0 && outputIndex == 0) {
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayMode mode;
|
||||
#if SDL_WINRT_USE_APPLICATIONVIEW
|
||||
ApplicationView ^ appView = ApplicationView::GetForCurrentView();
|
||||
#endif
|
||||
CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread();
|
||||
SDL_zero(display);
|
||||
SDL_zero(mode);
|
||||
display.name = "DXGI Display-detection Workaround";
|
||||
|
||||
/* HACK: ApplicationView's VisibleBounds property, appeared, via testing, to
|
||||
give a better approximation of display-size, than did CoreWindow's
|
||||
Bounds property, insofar that ApplicationView::VisibleBounds seems like
|
||||
it will, at least some of the time, give the full display size (during the
|
||||
failing test), whereas CoreWindow might not. -- DavidL
|
||||
*/
|
||||
|
||||
#if (NTDDI_VERSION >= NTDDI_WIN10) || (SDL_WINRT_USE_APPLICATIONVIEW && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Width);
|
||||
mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Height);
|
||||
#else
|
||||
/* On platform(s) that do not support VisibleBounds, such as Windows 8.1,
|
||||
fall back to CoreWindow's Bounds property.
|
||||
*/
|
||||
mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Width);
|
||||
mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Height);
|
||||
#endif
|
||||
|
||||
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
if ((SDL_AddDisplayMode(&display, &mode) < 0) ||
|
||||
(SDL_AddVideoDisplay(&display) < 0))
|
||||
{
|
||||
return SDL_SetError("Failed to apply DXGI Display-detection workaround");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -341,7 +396,6 @@ WINRT_InitModes(_THIS)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int adapterIndex = 0;
|
||||
for (int adapterIndex = 0; ; ++adapterIndex) {
|
||||
if (WINRT_AddDisplaysForAdapter(_this, dxgiFactory2, adapterIndex) < 0) {
|
||||
break;
|
||||
@@ -438,6 +492,7 @@ WINRT_DetectWindowFlags(SDL_Window * window)
|
||||
return latestFlags;
|
||||
}
|
||||
|
||||
// TODO, WinRT: consider removing WINRT_UpdateWindowFlags, and just calling WINRT_DetectWindowFlags as-appropriate (with appropriate calls to SDL_SendWindowEvent)
|
||||
void
|
||||
WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask)
|
||||
{
|
||||
@@ -451,6 +506,32 @@ WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow)
|
||||
{
|
||||
/* WinRT does not appear to offer API(s) to determine window-activation state,
|
||||
at least not that I am aware of in Win8 - Win10. As such, SDL tracks this
|
||||
itself, via window-activation events.
|
||||
|
||||
If there *is* an API to track this, it should probably get used instead
|
||||
of the following hack (that uses "SDLHelperWindowActivationState").
|
||||
-- DavidL.
|
||||
*/
|
||||
if (coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) {
|
||||
CoreWindowActivationState activationState = \
|
||||
safe_cast<CoreWindowActivationState>(coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState"));
|
||||
return (activationState != CoreWindowActivationState::Deactivated);
|
||||
}
|
||||
|
||||
/* Assume that non-SDL tracked windows are active, although this should
|
||||
probably be avoided, if possible.
|
||||
|
||||
This might not even be possible, in normal SDL use, at least as of
|
||||
this writing (Dec 22, 2015; via latest hg.libsdl.org/SDL clone) -- DavidL
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
WINRT_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@@ -591,12 +672,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
|
||||
);
|
||||
|
||||
/* Try detecting if the window is active */
|
||||
bool isWindowActive = true; /* Presume the window is active, unless we've been told otherwise */
|
||||
if (data->coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) {
|
||||
CoreWindowActivationState activationState = \
|
||||
safe_cast<CoreWindowActivationState>(data->coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState"));
|
||||
isWindowActive = (activationState != CoreWindowActivationState::Deactivated);
|
||||
}
|
||||
bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
|
||||
if (isWindowActive) {
|
||||
SDL_SetKeyboardFocus(window);
|
||||
}
|
||||
@@ -627,13 +703,16 @@ WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||
{
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10
|
||||
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
|
||||
if (fullscreen) {
|
||||
if (!data->appView->IsFullScreenMode) {
|
||||
data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
|
||||
}
|
||||
} else {
|
||||
if (data->appView->IsFullScreenMode) {
|
||||
data->appView->ExitFullScreenMode();
|
||||
bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
|
||||
if (isWindowActive) {
|
||||
if (fullscreen) {
|
||||
if (!data->appView->IsFullScreenMode) {
|
||||
data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
|
||||
}
|
||||
} else {
|
||||
if (data->appView->IsFullScreenMode) {
|
||||
data->appView->ExitFullScreenMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -348,27 +348,10 @@ X11_ReconcileKeyboardState(_THIS)
|
||||
|
||||
X11_XQueryKeymap(display, keys);
|
||||
|
||||
/* Get the keyboard modifier state */
|
||||
/* Sync up the keyboard modifier state */
|
||||
if (X11_XQueryPointer(display, DefaultRootWindow(display), &junk_window, &junk_window, &x, &y, &x, &y, &mask)) {
|
||||
unsigned num_mask = X11_GetNumLockModifierMask(_this);
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(NULL);
|
||||
Uint8 capslockState = keystate[SDL_SCANCODE_CAPSLOCK];
|
||||
Uint8 numlockState = keystate[SDL_SCANCODE_NUMLOCKCLEAR];
|
||||
|
||||
/* Toggle key mod state if needed */
|
||||
if (!!(mask & LockMask) != !!(SDL_GetModState() & KMOD_CAPS)) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
if (capslockState == SDL_RELEASED) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
if (!!(mask & num_mask) != !!(SDL_GetModState() & KMOD_NUM)) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
if (numlockState == SDL_RELEASED) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
}
|
||||
}
|
||||
SDL_ToggleModState(KMOD_CAPS, (mask & LockMask) != 0);
|
||||
SDL_ToggleModState(KMOD_NUM, (mask & X11_GetNumLockModifierMask(_this)) != 0);
|
||||
}
|
||||
|
||||
for (keycode = 0; keycode < 256; ++keycode) {
|
||||
|
||||
@@ -376,8 +376,7 @@ X11_InitModes_XRandR(_THIS)
|
||||
for (screen = 0; screen < screencount; screen++) {
|
||||
|
||||
/* we want the primary output first, and then skipped later. */
|
||||
if ((looking_for_primary && (screen != default_screen)) ||
|
||||
(!looking_for_primary && (screen == default_screen))) {
|
||||
if (looking_for_primary && (screen != default_screen)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -421,7 +420,7 @@ X11_InitModes_XRandR(_THIS)
|
||||
XRRCrtcInfo *crtc;
|
||||
|
||||
/* The primary output _should_ always be sorted first, but just in case... */
|
||||
if ((looking_for_primary && ((screen != default_screen) || (res->outputs[output] != primary))) ||
|
||||
if ((looking_for_primary && (res->outputs[output] != primary)) ||
|
||||
(!looking_for_primary && (screen == default_screen) && (res->outputs[output] == primary))) {
|
||||
continue;
|
||||
}
|
||||
@@ -491,11 +490,11 @@ X11_InitModes_XRandR(_THIS)
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
}
|
||||
|
||||
X11_XRRFreeScreenResources(res);
|
||||
}
|
||||
}
|
||||
|
||||
X11_XRRFreeScreenResources(res);
|
||||
|
||||
if (_this->num_displays == 0) {
|
||||
return SDL_SetError("No available displays");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user