Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4761467b2e | ||
|
|
cd662ceb54 | ||
|
|
7207f5155b | ||
|
|
5d9013beb9 | ||
|
|
4af1f6ed0c | ||
|
|
446fb3028e | ||
|
|
ba170daf84 | ||
|
|
7fa2ddb0de | ||
|
|
9aca2a4339 | ||
|
|
491fba1d06 | ||
|
|
c27f3ead7c | ||
|
|
1429e525fb | ||
|
|
de6963ea99 | ||
|
|
ffa78e6bea | ||
|
|
4ce5c3a694 | ||
|
|
a3d4fd71c3 | ||
|
|
d97423ebab | ||
|
|
333a03f1ec | ||
|
|
5b8fc907df | ||
|
|
76392f4fe1 | ||
|
|
3a5abee512 | ||
|
|
e7ee375f22 | ||
|
|
4aec54988c | ||
|
|
271e03f0d7 |
No files matched your search
+1
-1
@@ -83,7 +83,7 @@ endif()
|
|||||||
|
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
set(SDL_MAJOR_VERSION 2)
|
set(SDL_MAJOR_VERSION 2)
|
||||||
set(SDL_MINOR_VERSION 27)
|
set(SDL_MINOR_VERSION 28)
|
||||||
set(SDL_MICRO_VERSION 1)
|
set(SDL_MICRO_VERSION 1)
|
||||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
LIBNAME = SDL2
|
LIBNAME = SDL2
|
||||||
MAJOR_VERSION = 2
|
MAJOR_VERSION = 2
|
||||||
MINOR_VERSION = 27
|
MINOR_VERSION = 28
|
||||||
MICRO_VERSION = 1
|
MICRO_VERSION = 1
|
||||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||||
DESCRIPTION = Simple DirectMedia Layer 2
|
DESCRIPTION = Simple DirectMedia Layer 2
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
LIBNAME = SDL2
|
LIBNAME = SDL2
|
||||||
MAJOR_VERSION = 2
|
MAJOR_VERSION = 2
|
||||||
MINOR_VERSION = 27
|
MINOR_VERSION = 28
|
||||||
MICRO_VERSION = 1
|
MICRO_VERSION = 1
|
||||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>FMWK</string>
|
<string>FMWK</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.27.1</string>
|
<string>2.28.1</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>SDLX</string>
|
<string>SDLX</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>2.27.1</string>
|
<string>2.28.1</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -9528,8 +9528,8 @@
|
|||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEPLOYMENT_POSTPROCESSING = YES;
|
DEPLOYMENT_POSTPROCESSING = YES;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2801.1.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
GCC_ALTIVEC_EXTENSIONS = YES;
|
GCC_ALTIVEC_EXTENSIONS = YES;
|
||||||
@@ -9570,7 +9570,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||||
MARKETING_VERSION = 2.27.1;
|
MARKETING_VERSION = 2.28.1;
|
||||||
OTHER_LDFLAGS = "-liconv";
|
OTHER_LDFLAGS = "-liconv";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
@@ -9613,8 +9613,8 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2801.1.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
@@ -9656,7 +9656,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||||
MARKETING_VERSION = 2.27.1;
|
MARKETING_VERSION = 2.28.1;
|
||||||
OTHER_LDFLAGS = "-liconv";
|
OTHER_LDFLAGS = "-liconv";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -9862,8 +9862,8 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = "";
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2801.1.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
@@ -9914,8 +9914,8 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = "";
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2801.1.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Title SDL 2.27.1
|
Title SDL 2.28.1
|
||||||
Version 1
|
Version 1
|
||||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||||
DefaultLocation /Library/Frameworks
|
DefaultLocation /Library/Frameworks
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import java.util.Locale;
|
|||||||
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
||||||
private static final String TAG = "SDL";
|
private static final String TAG = "SDL";
|
||||||
private static final int SDL_MAJOR_VERSION = 2;
|
private static final int SDL_MAJOR_VERSION = 2;
|
||||||
private static final int SDL_MINOR_VERSION = 27;
|
private static final int SDL_MINOR_VERSION = 28;
|
||||||
private static final int SDL_MICRO_VERSION = 1;
|
private static final int SDL_MICRO_VERSION = 1;
|
||||||
/*
|
/*
|
||||||
// Display InputType.SOURCE/CLASS of events and devices
|
// Display InputType.SOURCE/CLASS of events and devices
|
||||||
|
|||||||
@@ -3506,7 +3506,7 @@ orig_CFLAGS="$CFLAGS"
|
|||||||
|
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
SDL_MAJOR_VERSION=2
|
SDL_MAJOR_VERSION=2
|
||||||
SDL_MINOR_VERSION=27
|
SDL_MINOR_VERSION=28
|
||||||
SDL_MICRO_VERSION=1
|
SDL_MICRO_VERSION=1
|
||||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ orig_CFLAGS="$CFLAGS"
|
|||||||
dnl Set various version strings - taken gratefully from the GTk sources
|
dnl Set various version strings - taken gratefully from the GTk sources
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
SDL_MAJOR_VERSION=2
|
SDL_MAJOR_VERSION=2
|
||||||
SDL_MINOR_VERSION=27
|
SDL_MINOR_VERSION=28
|
||||||
SDL_MICRO_VERSION=1
|
SDL_MICRO_VERSION=1
|
||||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ typedef struct SDL_version
|
|||||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||||
*/
|
*/
|
||||||
#define SDL_MAJOR_VERSION 2
|
#define SDL_MAJOR_VERSION 2
|
||||||
#define SDL_MINOR_VERSION 27
|
#define SDL_MINOR_VERSION 28
|
||||||
#define SDL_PATCHLEVEL 1
|
#define SDL_PATCHLEVEL 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -1342,7 +1342,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
|
|||||||
*
|
*
|
||||||
* \param window the window to update
|
* \param window the window to update
|
||||||
* \param rects an array of SDL_Rect structures representing areas of the
|
* \param rects an array of SDL_Rect structures representing areas of the
|
||||||
* surface to copy
|
* surface to copy, in pixels
|
||||||
* \param numrects the number of rectangles
|
* \param numrects the number of rectangles
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ static SDL_DBusContext dbus;
|
|||||||
|
|
||||||
static int LoadDBUSSyms(void)
|
static int LoadDBUSSyms(void)
|
||||||
{
|
{
|
||||||
|
#define SDL_DBUS_SYM2_OPTIONAL(x, y) \
|
||||||
|
dbus.x = SDL_LoadFunction(dbus_handle, #y)
|
||||||
|
|
||||||
#define SDL_DBUS_SYM2(x, y) \
|
#define SDL_DBUS_SYM2(x, y) \
|
||||||
if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) \
|
if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) \
|
||||||
return -1
|
return -1
|
||||||
@@ -43,6 +46,9 @@ static int LoadDBUSSyms(void)
|
|||||||
#define SDL_DBUS_SYM(x) \
|
#define SDL_DBUS_SYM(x) \
|
||||||
SDL_DBUS_SYM2(x, dbus_##x)
|
SDL_DBUS_SYM2(x, dbus_##x)
|
||||||
|
|
||||||
|
#define SDL_DBUS_SYM_OPTIONAL(x) \
|
||||||
|
SDL_DBUS_SYM2_OPTIONAL(x, dbus_##x)
|
||||||
|
|
||||||
SDL_DBUS_SYM(bus_get_private);
|
SDL_DBUS_SYM(bus_get_private);
|
||||||
SDL_DBUS_SYM(bus_register);
|
SDL_DBUS_SYM(bus_register);
|
||||||
SDL_DBUS_SYM(bus_add_match);
|
SDL_DBUS_SYM(bus_add_match);
|
||||||
@@ -80,6 +86,7 @@ static int LoadDBUSSyms(void)
|
|||||||
SDL_DBUS_SYM(error_is_set);
|
SDL_DBUS_SYM(error_is_set);
|
||||||
SDL_DBUS_SYM(error_free);
|
SDL_DBUS_SYM(error_free);
|
||||||
SDL_DBUS_SYM(get_local_machine_id);
|
SDL_DBUS_SYM(get_local_machine_id);
|
||||||
|
SDL_DBUS_SYM_OPTIONAL(try_get_local_machine_id);
|
||||||
SDL_DBUS_SYM(free);
|
SDL_DBUS_SYM(free);
|
||||||
SDL_DBUS_SYM(free_string_array);
|
SDL_DBUS_SYM(free_string_array);
|
||||||
SDL_DBUS_SYM(shutdown);
|
SDL_DBUS_SYM(shutdown);
|
||||||
@@ -493,6 +500,40 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
|||||||
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the machine ID if possible. Result must be freed with dbus->free().
|
||||||
|
*/
|
||||||
|
char *SDL_DBus_GetLocalMachineId(void)
|
||||||
|
{
|
||||||
|
DBusError err;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
dbus.error_init(&err);
|
||||||
|
|
||||||
|
if (dbus.try_get_local_machine_id) {
|
||||||
|
/* Available since dbus 1.12.0, has proper error-handling */
|
||||||
|
result = dbus.try_get_local_machine_id(&err);
|
||||||
|
} else {
|
||||||
|
/* Available since time immemorial, but has no error-handling:
|
||||||
|
* if the machine ID can't be read, many versions of libdbus will
|
||||||
|
* treat that as a fatal mis-installation and abort() */
|
||||||
|
result = dbus.get_local_machine_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbus.error_is_set(&err)) {
|
||||||
|
SDL_SetError("%s: %s", err.name, err.message);
|
||||||
|
dbus.error_free(&err);
|
||||||
|
} else {
|
||||||
|
SDL_SetError("Error getting D-Bus machine ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
@@ -72,6 +72,7 @@ typedef struct SDL_DBusContext
|
|||||||
dbus_bool_t (*error_is_set)(const DBusError *);
|
dbus_bool_t (*error_is_set)(const DBusError *);
|
||||||
void (*error_free)(DBusError *);
|
void (*error_free)(DBusError *);
|
||||||
char *(*get_local_machine_id)(void);
|
char *(*get_local_machine_id)(void);
|
||||||
|
char *(*try_get_local_machine_id)(DBusError *);
|
||||||
void (*free)(void *);
|
void (*free)(void *);
|
||||||
void (*free_string_array)(char **);
|
void (*free_string_array)(char **);
|
||||||
void (*shutdown)(void);
|
void (*shutdown)(void);
|
||||||
@@ -95,6 +96,8 @@ extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const c
|
|||||||
extern void SDL_DBus_ScreensaverTickle(void);
|
extern void SDL_DBus_ScreensaverTickle(void);
|
||||||
extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit);
|
extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit);
|
||||||
|
|
||||||
|
extern char *SDL_DBus_GetLocalMachineId(void);
|
||||||
|
|
||||||
#endif /* HAVE_DBUS_DBUS_H */
|
#endif /* HAVE_DBUS_DBUS_H */
|
||||||
|
|
||||||
#endif /* SDL_dbus_h_ */
|
#endif /* SDL_dbus_h_ */
|
||||||
|
|||||||
@@ -410,7 +410,12 @@ static char *IBus_GetDBusAddressFilename(void)
|
|||||||
(void)SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env);
|
(void)SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
key = dbus->get_local_machine_id();
|
key = SDL_DBus_GetLocalMachineId();
|
||||||
|
|
||||||
|
if (key == NULL) {
|
||||||
|
SDL_free(display);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_memset(file_path, 0, sizeof(file_path));
|
SDL_memset(file_path, 0, sizeof(file_path));
|
||||||
(void)SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
|
(void)SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s",
|
||||||
|
|||||||
@@ -277,8 +277,9 @@ windows_file_write(SDL_RWops *context, const void *ptr, size_t size,
|
|||||||
|
|
||||||
/* if in append mode, we must go to the EOF before write */
|
/* if in append mode, we must go to the EOF before write */
|
||||||
if (context->hidden.windowsio.append) {
|
if (context->hidden.windowsio.append) {
|
||||||
if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
|
LARGE_INTEGER windowsoffset;
|
||||||
INVALID_SET_FILE_POINTER) {
|
windowsoffset.QuadPart = 0;
|
||||||
|
if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, FILE_END)) {
|
||||||
SDL_Error(SDL_EFWRITE);
|
SDL_Error(SDL_EFWRITE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -729,6 +729,8 @@ hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const
|
|||||||
|
|
||||||
hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
|
hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
|
||||||
{
|
{
|
||||||
|
const int MAX_ATTEMPTS = 10;
|
||||||
|
int attempt;
|
||||||
hid_device *dev = NULL;
|
hid_device *dev = NULL;
|
||||||
|
|
||||||
hid_init();
|
hid_init();
|
||||||
@@ -736,7 +738,15 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
|
|||||||
dev = new_hid_device();
|
dev = new_hid_device();
|
||||||
|
|
||||||
/* OPEN HERE */
|
/* OPEN HERE */
|
||||||
|
for (attempt = 1; attempt <= MAX_ATTEMPTS; ++attempt) {
|
||||||
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
|
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
|
||||||
|
if (dev->device_handle < 0 && errno == EACCES) {
|
||||||
|
/* udev might be setting up permissions, wait a bit and try again */
|
||||||
|
usleep(1 * 1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we have a good handle, return it. */
|
/* If we have a good handle, return it. */
|
||||||
if (dev->device_handle >= 0) {
|
if (dev->device_handle >= 0) {
|
||||||
|
|||||||
@@ -572,11 +572,23 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
|
|||||||
/* GameCube driver has 12 buttons and 6 axes */
|
/* GameCube driver has 12 buttons and 6 axes */
|
||||||
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", sizeof(mapping_string));
|
||||||
} else if (vendor == USB_VENDOR_NINTENDO &&
|
} else if (vendor == USB_VENDOR_NINTENDO &&
|
||||||
guid.data[15] != k_eSwitchDeviceInfoControllerType_Unknown &&
|
(guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft ||
|
||||||
guid.data[15] != k_eSwitchDeviceInfoControllerType_ProController &&
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight ||
|
||||||
guid.data[15] != k_eWiiExtensionControllerType_Gamepad &&
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_NESLeft ||
|
||||||
guid.data[15] != k_eWiiExtensionControllerType_WiiUPro) {
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_NESRight ||
|
||||||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_SNES ||
|
||||||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_N64 ||
|
||||||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_SEGA_Genesis ||
|
||||||
|
guid.data[15] == k_eWiiExtensionControllerType_None ||
|
||||||
|
guid.data[15] == k_eWiiExtensionControllerType_Nunchuk ||
|
||||||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConLeft ||
|
||||||
|
guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConRight)) {
|
||||||
switch (guid.data[15]) {
|
switch (guid.data[15]) {
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||||
|
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||||
|
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,", sizeof(mapping_string));
|
||||||
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
||||||
case k_eSwitchDeviceInfoControllerType_NESRight:
|
case k_eSwitchDeviceInfoControllerType_NESRight:
|
||||||
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
|
||||||
|
|||||||
@@ -660,6 +660,7 @@ static const char *s_ControllerMappings[] = {
|
|||||||
"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,",
|
"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,",
|
||||||
"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
|
"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
|
||||||
"030000006f0e00000103000000020000,Logic3 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,",
|
"030000006f0e00000103000000020000,Logic3 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,",
|
||||||
|
"030000006d040000d1ca000011010000,Logitech Chillstream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||||
"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||||
"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||||
"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||||
|
|||||||
@@ -221,10 +221,10 @@ static int SDL_FindFreePlayerIndex()
|
|||||||
|
|
||||||
for (player_index = 0; player_index < SDL_joystick_player_count; ++player_index) {
|
for (player_index = 0; player_index < SDL_joystick_player_count; ++player_index) {
|
||||||
if (SDL_joystick_players[player_index] == -1) {
|
if (SDL_joystick_players[player_index] == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return player_index;
|
return player_index;
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
|
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ typedef enum
|
|||||||
k_eSwitchDeviceInfoControllerType_JoyConLeft = 1,
|
k_eSwitchDeviceInfoControllerType_JoyConLeft = 1,
|
||||||
k_eSwitchDeviceInfoControllerType_JoyConRight = 2,
|
k_eSwitchDeviceInfoControllerType_JoyConRight = 2,
|
||||||
k_eSwitchDeviceInfoControllerType_ProController = 3,
|
k_eSwitchDeviceInfoControllerType_ProController = 3,
|
||||||
|
k_eSwitchDeviceInfoControllerType_LicProController = 6,
|
||||||
|
k_eSwitchDeviceInfoControllerType_HVCLeft = 7,
|
||||||
|
k_eSwitchDeviceInfoControllerType_HVCRight = 8,
|
||||||
k_eSwitchDeviceInfoControllerType_NESLeft = 9,
|
k_eSwitchDeviceInfoControllerType_NESLeft = 9,
|
||||||
k_eSwitchDeviceInfoControllerType_NESRight = 10,
|
k_eSwitchDeviceInfoControllerType_NESRight = 10,
|
||||||
k_eSwitchDeviceInfoControllerType_SNES = 11,
|
k_eSwitchDeviceInfoControllerType_SNES = 11,
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ typedef enum
|
|||||||
{
|
{
|
||||||
k_eSwitchInputReportIDs_SubcommandReply = 0x21,
|
k_eSwitchInputReportIDs_SubcommandReply = 0x21,
|
||||||
k_eSwitchInputReportIDs_FullControllerState = 0x30,
|
k_eSwitchInputReportIDs_FullControllerState = 0x30,
|
||||||
|
k_eSwitchInputReportIDs_FullControllerAndMcuState = 0x31,
|
||||||
k_eSwitchInputReportIDs_SimpleControllerState = 0x3F,
|
k_eSwitchInputReportIDs_SimpleControllerState = 0x3F,
|
||||||
k_eSwitchInputReportIDs_CommandAck = 0x81,
|
k_eSwitchInputReportIDs_CommandAck = 0x81,
|
||||||
} ESwitchInputReportIDs;
|
} ESwitchInputReportIDs;
|
||||||
@@ -619,8 +620,6 @@ static SDL_bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx)
|
|||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->device->is_bluetooth = SDL_FALSE;
|
|
||||||
|
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,13 +719,35 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx)
|
||||||
|
{
|
||||||
|
Uint8 input_mode;
|
||||||
|
|
||||||
|
/* Determine the desired input mode */
|
||||||
|
if (ctx->device->is_bluetooth) {
|
||||||
|
input_mode = k_eSwitchInputReportIDs_SimpleControllerState;
|
||||||
|
} else {
|
||||||
|
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The official Nintendo Switch Pro Controller supports FullControllerState over Bluetooth
|
||||||
|
* just fine. We really should use that, or else the epowerlevel code in HandleFullControllerState
|
||||||
|
* is completely pointless. We need full state if we want battery level and we only care about
|
||||||
|
* battery level over Bluetooth anyway.
|
||||||
|
*/
|
||||||
|
if (ctx->device->vendor_id == USB_VENDOR_NINTENDO) {
|
||||||
|
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
||||||
|
}
|
||||||
|
return input_mode;
|
||||||
|
}
|
||||||
|
|
||||||
static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, SDL_bool enabled)
|
static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, SDL_bool enabled)
|
||||||
{
|
{
|
||||||
Uint8 imu_data = enabled ? 1 : 0;
|
Uint8 imu_data = enabled ? 1 : 0;
|
||||||
return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL);
|
return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_mode)
|
static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
{
|
{
|
||||||
Uint8 *pLeftStickCal;
|
Uint8 *pLeftStickCal;
|
||||||
Uint8 *pRightStickCal;
|
Uint8 *pRightStickCal;
|
||||||
@@ -740,9 +761,8 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_
|
|||||||
readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset;
|
readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset;
|
||||||
readUserParams.ucLength = k_unSPIStickUserCalibrationLength;
|
readUserParams.ucLength = k_unSPIStickUserCalibrationLength;
|
||||||
|
|
||||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readUserParams, sizeof(readUserParams), &user_reply)) {
|
/* This isn't readable on all controllers, so ignore failure */
|
||||||
return SDL_FALSE;
|
WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readUserParams, sizeof(readUserParams), &user_reply);
|
||||||
}
|
|
||||||
|
|
||||||
/* Read Factory Calibration Info */
|
/* Read Factory Calibration Info */
|
||||||
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
|
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
|
||||||
@@ -753,13 +773,13 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Automatically select the user calibration if magic bytes are set */
|
/* Automatically select the user calibration if magic bytes are set */
|
||||||
if (user_reply->stickUserCalibration.rgucLeftMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucLeftMagic[1] == 0xA1) {
|
if (user_reply && user_reply->stickUserCalibration.rgucLeftMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucLeftMagic[1] == 0xA1) {
|
||||||
pLeftStickCal = user_reply->stickUserCalibration.rgucLeftCalibration;
|
pLeftStickCal = user_reply->stickUserCalibration.rgucLeftCalibration;
|
||||||
} else {
|
} else {
|
||||||
pLeftStickCal = factory_reply->stickFactoryCalibration.rgucLeftCalibration;
|
pLeftStickCal = factory_reply->stickFactoryCalibration.rgucLeftCalibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_reply->stickUserCalibration.rgucRightMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucRightMagic[1] == 0xA1) {
|
if (user_reply && user_reply->stickUserCalibration.rgucRightMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucRightMagic[1] == 0xA1) {
|
||||||
pRightStickCal = user_reply->stickUserCalibration.rgucRightCalibration;
|
pRightStickCal = user_reply->stickUserCalibration.rgucRightCalibration;
|
||||||
} else {
|
} else {
|
||||||
pRightStickCal = factory_reply->stickFactoryCalibration.rgucRightCalibration;
|
pRightStickCal = factory_reply->stickFactoryCalibration.rgucRightCalibration;
|
||||||
@@ -821,29 +841,16 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_
|
|||||||
|
|
||||||
static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
{
|
{
|
||||||
Uint8 *pIMUScale;
|
|
||||||
SwitchSubcommandInputPacket_t *reply = NULL;
|
SwitchSubcommandInputPacket_t *reply = NULL;
|
||||||
Sint16 sAccelRawX, sAccelRawY, sAccelRawZ, sGyroRawX, sGyroRawY, sGyroRawZ;
|
|
||||||
|
|
||||||
/* Read Calibration Info */
|
/* Read Calibration Info */
|
||||||
SwitchSPIOpData_t readParams;
|
SwitchSPIOpData_t readParams;
|
||||||
readParams.unAddress = k_unSPIIMUScaleStartOffset;
|
readParams.unAddress = k_unSPIIMUScaleStartOffset;
|
||||||
readParams.ucLength = k_unSPIIMUScaleLength;
|
readParams.ucLength = k_unSPIIMUScaleLength;
|
||||||
|
|
||||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply)) {
|
if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply)) {
|
||||||
const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE;
|
Uint8 *pIMUScale;
|
||||||
const float gyroScale = (float)M_PI / 180.0f / SWITCH_GYRO_SCALE;
|
Sint16 sAccelRawX, sAccelRawY, sAccelRawZ, sGyroRawX, sGyroRawY, sGyroRawZ;
|
||||||
|
|
||||||
ctx->m_IMUScaleData.fAccelScaleX = accelScale;
|
|
||||||
ctx->m_IMUScaleData.fAccelScaleY = accelScale;
|
|
||||||
ctx->m_IMUScaleData.fAccelScaleZ = accelScale;
|
|
||||||
|
|
||||||
ctx->m_IMUScaleData.fGyroScaleX = gyroScale;
|
|
||||||
ctx->m_IMUScaleData.fGyroScaleY = gyroScale;
|
|
||||||
ctx->m_IMUScaleData.fGyroScaleZ = gyroScale;
|
|
||||||
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* IMU scale gives us multipliers for converting raw values to real world values */
|
/* IMU scale gives us multipliers for converting raw values to real world values */
|
||||||
pIMUScale = reply->spiReadData.rgucReadData;
|
pIMUScale = reply->spiReadData.rgucReadData;
|
||||||
@@ -877,10 +884,23 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
|||||||
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
||||||
|
|
||||||
/* Gyro scale */
|
/* Gyro scale */
|
||||||
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * (float)M_PI / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * (float)M_PI / 180.0f;
|
||||||
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * (float)M_PI / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * (float)M_PI / 180.0f;
|
||||||
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (float)(SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * (float)M_PI / 180.0f;
|
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * (float)M_PI / 180.0f;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* Use default values */
|
||||||
|
const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE;
|
||||||
|
const float gyroScale = (float)M_PI / 180.0f / SWITCH_GYRO_SCALE;
|
||||||
|
|
||||||
|
ctx->m_IMUScaleData.fAccelScaleX = accelScale;
|
||||||
|
ctx->m_IMUScaleData.fAccelScaleY = accelScale;
|
||||||
|
ctx->m_IMUScaleData.fAccelScaleZ = accelScale;
|
||||||
|
|
||||||
|
ctx->m_IMUScaleData.fGyroScaleX = gyroScale;
|
||||||
|
ctx->m_IMUScaleData.fGyroScaleY = gyroScale;
|
||||||
|
ctx->m_IMUScaleData.fGyroScaleZ = gyroScale;
|
||||||
|
}
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,7 +998,9 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
|
|||||||
ctx->m_bSyncWrite = SDL_TRUE;
|
ctx->m_bSyncWrite = SDL_TRUE;
|
||||||
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
||||||
|
|
||||||
for (attempts = 0; attempts < MAX_ATTEMPTS; ++attempts) {
|
for ( ; ; ) {
|
||||||
|
++attempts;
|
||||||
|
device->is_bluetooth = SDL_FALSE;
|
||||||
if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) {
|
if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) {
|
||||||
SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0];
|
SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0];
|
||||||
|
|
||||||
@@ -991,13 +1013,12 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
|
|||||||
eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType);
|
eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown) {
|
if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown && attempts < MAX_ATTEMPTS) {
|
||||||
/* Wait a bit and try again */
|
/* Wait a bit and try again */
|
||||||
SDL_Delay(100);
|
SDL_Delay(100);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
SDL_free(ctx);
|
SDL_free(ctx);
|
||||||
}
|
}
|
||||||
@@ -1019,6 +1040,12 @@ static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Third party controllers don't have a home LED and will shut off if we try to set it */
|
||||||
|
if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_Unknown ||
|
||||||
|
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_LicProController) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* The Nintendo Online classic controllers don't have a Home LED */
|
/* The Nintendo Online classic controllers don't have a Home LED */
|
||||||
if (vendor_id == USB_VENDOR_NINTENDO &&
|
if (vendor_id == USB_VENDOR_NINTENDO &&
|
||||||
ctx->m_eControllerType > k_eSwitchDeviceInfoControllerType_ProController) {
|
ctx->m_eControllerType > k_eSwitchDeviceInfoControllerType_ProController) {
|
||||||
@@ -1032,6 +1059,8 @@ static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInf
|
|||||||
{
|
{
|
||||||
/* These controllers don't have a diamond button configuration, so always use labels */
|
/* These controllers don't have a diamond button configuration, so always use labels */
|
||||||
switch (eControllerType) {
|
switch (eControllerType) {
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||||
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
||||||
case k_eSwitchDeviceInfoControllerType_NESRight:
|
case k_eSwitchDeviceInfoControllerType_NESRight:
|
||||||
case k_eSwitchDeviceInfoControllerType_N64:
|
case k_eSwitchDeviceInfoControllerType_N64:
|
||||||
@@ -1078,7 +1107,8 @@ static SDL_bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device
|
|||||||
{
|
{
|
||||||
if (vendor_id == USB_VENDOR_NINTENDO) {
|
if (vendor_id == USB_VENDOR_NINTENDO) {
|
||||||
if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) {
|
if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) {
|
||||||
if (SDL_strncmp(name, "NES Controller", 14) == 0) {
|
if (SDL_strncmp(name, "NES Controller", 14) == 0 ||
|
||||||
|
SDL_strncmp(name, "HVC Controller", 14) == 0) {
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1179,19 +1209,28 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
|||||||
switch (ctx->m_eControllerType) {
|
switch (ctx->m_eControllerType) {
|
||||||
case k_eSwitchDeviceInfoControllerType_JoyConLeft:
|
case k_eSwitchDeviceInfoControllerType_JoyConLeft:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)");
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT);
|
||||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
||||||
break;
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_JoyConRight:
|
case k_eSwitchDeviceInfoControllerType_JoyConRight:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)");
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT);
|
||||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
|
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
|
||||||
break;
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_ProController:
|
case k_eSwitchDeviceInfoControllerType_ProController:
|
||||||
|
case k_eSwitchDeviceInfoControllerType_LicProController:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller");
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_SWITCH_PRO);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_PRO);
|
||||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
|
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
|
||||||
break;
|
break;
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||||
|
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (1)");
|
||||||
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||||
|
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (2)");
|
||||||
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (L)");
|
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (L)");
|
||||||
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
@@ -1202,20 +1241,24 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
|||||||
break;
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_SNES:
|
case k_eSwitchDeviceInfoControllerType_SNES:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo SNES Controller");
|
HIDAPI_SetDeviceName(device, "Nintendo SNES Controller");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_SNES_CONTROLLER);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SNES_CONTROLLER);
|
||||||
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_N64:
|
case k_eSwitchDeviceInfoControllerType_N64:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo N64 Controller");
|
HIDAPI_SetDeviceName(device, "Nintendo N64 Controller");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_N64_CONTROLLER);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_N64_CONTROLLER);
|
||||||
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case k_eSwitchDeviceInfoControllerType_SEGA_Genesis:
|
case k_eSwitchDeviceInfoControllerType_SEGA_Genesis:
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo SEGA Genesis Controller");
|
HIDAPI_SetDeviceName(device, "Nintendo SEGA Genesis Controller");
|
||||||
HIDAPI_SetDeviceProduct(device, USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER);
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER);
|
||||||
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
|
case k_eSwitchDeviceInfoControllerType_Unknown:
|
||||||
|
/* We couldn't read the device info for this controller, might not be fully compliant */
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
|
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
device->guid.data[15] = ctx->m_eControllerType;
|
device->guid.data[15] = ctx->m_eControllerType;
|
||||||
@@ -1257,12 +1300,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
|||||||
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]);
|
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]);
|
||||||
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]);
|
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]);
|
||||||
|
|
||||||
if (!BReadDeviceInfo(ctx)) {
|
BReadDeviceInfo(ctx);
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
|
||||||
"HIDAPI_DriverSwitch_InitDevice(): Couldn't read device info");
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateDeviceIdentity(device);
|
UpdateDeviceIdentity(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1298,7 +1336,6 @@ static void HIDAPI_DriverSwitch_SetDevicePlayerIndex(SDL_HIDAPI_Device *device,
|
|||||||
static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
||||||
Uint8 input_mode;
|
|
||||||
|
|
||||||
SDL_AssertJoysticksLocked();
|
SDL_AssertJoysticksLocked();
|
||||||
|
|
||||||
@@ -1318,28 +1355,19 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the desired input mode (needed before loading stick calibration) */
|
if (!LoadStickCalibration(ctx)) {
|
||||||
if (device->is_bluetooth) {
|
SDL_SetError("Couldn't load stick calibration");
|
||||||
input_mode = k_eSwitchInputReportIDs_SimpleControllerState;
|
return SDL_FALSE;
|
||||||
} else {
|
|
||||||
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The official Nintendo Switch Pro Controller supports FullControllerState over bluetooth
|
if (ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCLeft &&
|
||||||
* just fine. We really should use that, or else the epowerlevel code in
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCRight &&
|
||||||
* HandleFullControllerState is completely pointless. We need full state if we want battery
|
|
||||||
* level and we only care about battery level over bluetooth anyway.
|
|
||||||
*/
|
|
||||||
if (device->vendor_id == USB_VENDOR_NINTENDO) {
|
|
||||||
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_mode == k_eSwitchInputReportIDs_FullControllerState &&
|
|
||||||
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESLeft &&
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESLeft &&
|
||||||
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESRight &&
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESRight &&
|
||||||
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SNES &&
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SNES &&
|
||||||
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_N64 &&
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_N64 &&
|
||||||
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SEGA_Genesis) {
|
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SEGA_Genesis) {
|
||||||
|
if (LoadIMUCalibration(ctx)) {
|
||||||
/* Use the right sensor in the combined Joy-Con pair */
|
/* Use the right sensor in the combined Joy-Con pair */
|
||||||
if (!device->parent ||
|
if (!device->parent ||
|
||||||
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
||||||
@@ -1357,15 +1385,6 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
|
|||||||
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_R, 200.0f);
|
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_R, 200.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LoadStickCalibration(ctx, input_mode)) {
|
|
||||||
SDL_SetError("Couldn't load stick calibration");
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LoadIMUCalibration(ctx)) {
|
|
||||||
SDL_SetError("Couldn't load sensor calibration");
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetVibrationEnabled(ctx, 1)) {
|
if (!SetVibrationEnabled(ctx, 1)) {
|
||||||
@@ -1374,7 +1393,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set desired input mode */
|
/* Set desired input mode */
|
||||||
if (!SetInputMode(ctx, input_mode)) {
|
if (!SetInputMode(ctx, GetDefaultInputMode(ctx))) {
|
||||||
SDL_SetError("Couldn't set input mode");
|
SDL_SetError("Couldn't set input mode");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
@@ -1573,6 +1592,14 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL
|
|||||||
static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled)
|
static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled)
|
||||||
{
|
{
|
||||||
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
||||||
|
Uint8 input_mode;
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
||||||
|
} else {
|
||||||
|
input_mode = GetDefaultInputMode(ctx);
|
||||||
|
}
|
||||||
|
SetInputMode(ctx, input_mode);
|
||||||
|
|
||||||
SetIMUEnabled(ctx, enabled);
|
SetIMUEnabled(ctx, enabled);
|
||||||
ctx->m_bReportSensors = enabled;
|
ctx->m_bReportSensors = enabled;
|
||||||
@@ -2153,6 +2180,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
|
|||||||
HandleSimpleControllerState(joystick, ctx, (SwitchSimpleStatePacket_t *)&ctx->m_rgucReadBuffer[1]);
|
HandleSimpleControllerState(joystick, ctx, (SwitchSimpleStatePacket_t *)&ctx->m_rgucReadBuffer[1]);
|
||||||
break;
|
break;
|
||||||
case k_eSwitchInputReportIDs_FullControllerState:
|
case k_eSwitchInputReportIDs_FullControllerState:
|
||||||
|
case k_eSwitchInputReportIDs_FullControllerAndMcuState:
|
||||||
HandleFullControllerState(joystick, ctx, (SwitchStatePacket_t *)&ctx->m_rgucReadBuffer[1]);
|
HandleFullControllerState(joystick, ctx, (SwitchStatePacket_t *)&ctx->m_rgucReadBuffer[1]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -657,10 +657,10 @@ void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 product_id)
|
void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 vendor_id, Uint16 product_id)
|
||||||
{
|
{
|
||||||
/* Don't set the device product ID directly, or we'll constantly re-enumerate this device */
|
/* Don't set the device product ID directly, or we'll constantly re-enumerate this device */
|
||||||
SDL_SetJoystickGUIDProduct(&device->guid, product_id);
|
device->guid = SDL_CreateJoystickGUID(device->guid.data[0], vendor_id, product_id, device->version, device->name, 'h', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HIDAPI_UpdateJoystickSerial(SDL_HIDAPI_Device *device)
|
static void HIDAPI_UpdateJoystickSerial(SDL_HIDAPI_Device *device)
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ extern SDL_GameControllerType HIDAPI_GetGameControllerTypeFromGUID(SDL_JoystickG
|
|||||||
|
|
||||||
extern void HIDAPI_UpdateDevices(void);
|
extern void HIDAPI_UpdateDevices(void);
|
||||||
extern void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name);
|
extern void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name);
|
||||||
extern void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 product_id);
|
extern void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 vendor_id, Uint16 product_id);
|
||||||
extern void HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial);
|
extern void HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial);
|
||||||
extern SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial);
|
extern SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial);
|
||||||
extern void HIDAPI_DisconnectBluetoothDevice(const char *serial);
|
extern void HIDAPI_DisconnectBluetoothDevice(const char *serial);
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 2,27,1,0
|
FILEVERSION 2,28,1,0
|
||||||
PRODUCTVERSION 2,27,1,0
|
PRODUCTVERSION 2,28,1,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
FILEFLAGS 0x0L
|
FILEFLAGS 0x0L
|
||||||
FILEOS 0x40004L
|
FILEOS 0x40004L
|
||||||
@@ -23,12 +23,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "\0"
|
VALUE "CompanyName", "\0"
|
||||||
VALUE "FileDescription", "SDL\0"
|
VALUE "FileDescription", "SDL\0"
|
||||||
VALUE "FileVersion", "2, 27, 1, 0\0"
|
VALUE "FileVersion", "2, 28, 1, 0\0"
|
||||||
VALUE "InternalName", "SDL\0"
|
VALUE "InternalName", "SDL\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0"
|
VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0"
|
||||||
VALUE "OriginalFilename", "SDL2.dll\0"
|
VALUE "OriginalFilename", "SDL2.dll\0"
|
||||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||||
VALUE "ProductVersion", "2, 27, 1, 0\0"
|
VALUE "ProductVersion", "2, 28, 1, 0\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (renderer->window) {
|
if (renderer->window) {
|
||||||
SDL_GetWindowSize(renderer->window, w, h);
|
SDL_GetWindowSizeInPixels(renderer->window, w, h);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,24 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -61,6 +79,25 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = bit;
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
@@ -79,6 +116,7 @@ static void BlitBto1(SDL_BlitInfo *info)
|
|||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto2(SDL_BlitInfo *info)
|
static void BlitBto2(SDL_BlitInfo *info)
|
||||||
@@ -99,6 +137,24 @@ static void BlitBto2(SDL_BlitInfo *info)
|
|||||||
map = (Uint16 *)info->table;
|
map = (Uint16 *)info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -115,6 +171,7 @@ static void BlitBto2(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto3(SDL_BlitInfo *info)
|
static void BlitBto3(SDL_BlitInfo *info)
|
||||||
@@ -134,6 +191,27 @@ static void BlitBto3(SDL_BlitInfo *info)
|
|||||||
map = info->table;
|
map = info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
o = bit * 4;
|
||||||
|
dst[0] = map[o++];
|
||||||
|
dst[1] = map[o++];
|
||||||
|
dst[2] = map[o++];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -153,6 +231,7 @@ static void BlitBto3(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto4(SDL_BlitInfo *info)
|
static void BlitBto4(SDL_BlitInfo *info)
|
||||||
@@ -173,6 +252,24 @@ static void BlitBto4(SDL_BlitInfo *info)
|
|||||||
map = (Uint32 *)info->table;
|
map = (Uint32 *)info->table;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
*dst = map[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -189,6 +286,7 @@ static void BlitBto4(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto1Key(SDL_BlitInfo *info)
|
static void BlitBto1Key(SDL_BlitInfo *info)
|
||||||
@@ -207,6 +305,24 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
if (palmap) {
|
if (palmap) {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dst = palmap[bit];
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -223,6 +339,25 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dst = bit;
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
byte >>= 1;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
@@ -241,6 +376,7 @@ static void BlitBto1Key(SDL_BlitInfo *info)
|
|||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto2Key(SDL_BlitInfo *info)
|
static void BlitBto2Key(SDL_BlitInfo *info)
|
||||||
@@ -259,6 +395,24 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
|||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 2;
|
dstskip /= 2;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dstp = ((Uint16 *)palmap)[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dstp++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dstp += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -275,6 +429,7 @@ static void BlitBto2Key(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dstp += dstskip;
|
dstp += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto3Key(SDL_BlitInfo *info)
|
static void BlitBto3Key(SDL_BlitInfo *info)
|
||||||
@@ -292,6 +447,24 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
|||||||
/* Set up some basic variables */
|
/* Set up some basic variables */
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
SDL_memcpy(dst, &palmap[bit * 4], 3);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -308,6 +481,7 @@ static void BlitBto3Key(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBto4Key(SDL_BlitInfo *info)
|
static void BlitBto4Key(SDL_BlitInfo *info)
|
||||||
@@ -326,6 +500,24 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
|||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
dstskip /= 4;
|
dstskip /= 4;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
*dstp = ((Uint32 *)palmap)[bit];
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dstp++;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dstp += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -342,6 +534,7 @@ static void BlitBto4Key(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dstp += dstskip;
|
dstp += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||||
@@ -365,6 +558,29 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (1) {
|
||||||
|
sR = srcpal[bit].r;
|
||||||
|
sG = srcpal[bit].g;
|
||||||
|
sB = srcpal[bit].b;
|
||||||
|
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||||
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += dstbpp;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -386,6 +602,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||||
@@ -411,6 +628,29 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
dstbpp = dstfmt->BytesPerPixel;
|
dstbpp = dstfmt->BytesPerPixel;
|
||||||
srcskip += width - (width + 7) / 8;
|
srcskip += width - (width + 7) / 8;
|
||||||
|
|
||||||
|
if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) {
|
||||||
|
while (height--) {
|
||||||
|
Uint8 byte = 0, bit;
|
||||||
|
for (c = 0; c < width; ++c) {
|
||||||
|
if (!(c & 7)) {
|
||||||
|
byte = *src++;
|
||||||
|
}
|
||||||
|
bit = (byte & 0x01);
|
||||||
|
if (bit != ckey) {
|
||||||
|
sR = srcpal[bit].r;
|
||||||
|
sG = srcpal[bit].g;
|
||||||
|
sB = srcpal[bit].b;
|
||||||
|
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||||
|
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
|
||||||
|
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||||
|
}
|
||||||
|
byte >>= 1;
|
||||||
|
dst += dstbpp;
|
||||||
|
}
|
||||||
|
src += srcskip;
|
||||||
|
dst += dstskip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (height--) {
|
while (height--) {
|
||||||
Uint8 byte = 0, bit;
|
Uint8 byte = 0, bit;
|
||||||
for (c = 0; c < width; ++c) {
|
for (c = 0; c < width; ++c) {
|
||||||
@@ -432,6 +672,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
|||||||
src += srcskip;
|
src += srcskip;
|
||||||
dst += dstskip;
|
dst += dstskip;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const SDL_BlitFunc bitmap_blit[] = {
|
static const SDL_BlitFunc bitmap_blit[] = {
|
||||||
|
|||||||
@@ -852,6 +852,10 @@ void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alph
|
|||||||
/* Find the opaque pixel value corresponding to an RGB triple */
|
/* Find the opaque pixel value corresponding to an RGB triple */
|
||||||
Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
|
Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
|
||||||
{
|
{
|
||||||
|
if (!format) {
|
||||||
|
SDL_InvalidParamError("format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (format->palette == NULL) {
|
if (format->palette == NULL) {
|
||||||
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask;
|
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask;
|
||||||
} else {
|
} else {
|
||||||
@@ -862,6 +866,10 @@ Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
|
|||||||
/* Find the pixel value corresponding to an RGBA quadruple */
|
/* Find the pixel value corresponding to an RGBA quadruple */
|
||||||
Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
|
if (!format) {
|
||||||
|
SDL_InvalidParamError("format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (format->palette == NULL) {
|
if (format->palette == NULL) {
|
||||||
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
|
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+16
-7
@@ -219,6 +219,9 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
|||||||
SDL_RendererInfo info;
|
SDL_RendererInfo info;
|
||||||
SDL_WindowTextureData *data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
SDL_WindowTextureData *data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
||||||
int i;
|
int i;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
SDL_Renderer *renderer = NULL;
|
SDL_Renderer *renderer = NULL;
|
||||||
@@ -301,7 +304,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
|||||||
|
|
||||||
data->texture = SDL_CreateTexture(data->renderer, *format,
|
data->texture = SDL_CreateTexture(data->renderer, *format,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
window->w, window->h);
|
w, h);
|
||||||
if (!data->texture) {
|
if (!data->texture) {
|
||||||
/* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_WINDOWTEXTUREDATA and not leaked here. */
|
/* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_WINDOWTEXTUREDATA and not leaked here. */
|
||||||
return -1; /* NOLINT(clang-analyzer-unix.Malloc) */
|
return -1; /* NOLINT(clang-analyzer-unix.Malloc) */
|
||||||
@@ -309,11 +312,11 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
|||||||
|
|
||||||
/* Create framebuffer data */
|
/* Create framebuffer data */
|
||||||
data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
|
data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
|
||||||
data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
|
data->pitch = (((w * data->bytes_per_pixel) + 3) & ~3);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Make static analysis happy about potential SDL_malloc(0) calls. */
|
/* Make static analysis happy about potential SDL_malloc(0) calls. */
|
||||||
const size_t allocsize = (size_t)window->h * data->pitch;
|
const size_t allocsize = (size_t)h * data->pitch;
|
||||||
data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
|
data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
|
||||||
if (!data->pixels) {
|
if (!data->pixels) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
@@ -337,6 +340,9 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window,
|
|||||||
SDL_WindowTextureData *data;
|
SDL_WindowTextureData *data;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
void *src;
|
void *src;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
||||||
if (data == NULL || !data->texture) {
|
if (data == NULL || !data->texture) {
|
||||||
@@ -344,7 +350,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update a single rect that contains subrects for best DMA performance */
|
/* Update a single rect that contains subrects for best DMA performance */
|
||||||
if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) {
|
if (SDL_GetSpanEnclosingRect(w, h, numrects, rects, &rect)) {
|
||||||
src = (void *)((Uint8 *)data->pixels +
|
src = (void *)((Uint8 *)data->pixels +
|
||||||
rect.y * data->pitch +
|
rect.y * data->pitch +
|
||||||
rect.x * data->bytes_per_pixel);
|
rect.x * data->bytes_per_pixel);
|
||||||
@@ -2584,6 +2590,9 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
|||||||
int bpp;
|
int bpp;
|
||||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||||
SDL_bool created_framebuffer = SDL_FALSE;
|
SDL_bool created_framebuffer = SDL_FALSE;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
/* This will switch the video backend from using a software surface to
|
/* This will switch the video backend from using a software surface to
|
||||||
using a GPU texture through the 2D render API, if we think this would
|
using a GPU texture through the 2D render API, if we think this would
|
||||||
@@ -2662,7 +2671,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
|
return SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_HasWindowSurface(SDL_Window *window)
|
SDL_bool SDL_HasWindowSurface(SDL_Window *window)
|
||||||
@@ -2695,8 +2704,8 @@ int SDL_UpdateWindowSurface(SDL_Window *window)
|
|||||||
|
|
||||||
full_rect.x = 0;
|
full_rect.x = 0;
|
||||||
full_rect.y = 0;
|
full_rect.y = 0;
|
||||||
full_rect.w = window->w;
|
SDL_GetWindowSizeInPixels(window, &full_rect.w, &full_rect.h);
|
||||||
full_rect.h = window->h;
|
|
||||||
return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
|
return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
SDL_DUMMY_DestroyWindowFramebuffer(_this, window);
|
SDL_DUMMY_DestroyWindowFramebuffer(_this, window);
|
||||||
|
|
||||||
/* Create a new one */
|
/* Create a new one */
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format
|
|||||||
|
|
||||||
/* Create a new one */
|
/* Create a new one */
|
||||||
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ CreateNewWindowFramebuffer(SDL_Window *window)
|
|||||||
int w, h, bpp;
|
int w, h, bpp;
|
||||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||||
SDL_PixelFormatEnumToMasks(FRAMEBUFFER_FORMAT, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
SDL_PixelFormatEnumToMasks(FRAMEBUFFER_FORMAT, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
return SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
return SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
SDL_NGAGE_DestroyWindowFramebuffer(_this, window);
|
SDL_NGAGE_DestroyWindowFramebuffer(_this, window);
|
||||||
|
|
||||||
/* Create a new one */
|
/* Create a new one */
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for
|
|||||||
SDL_OFFSCREEN_DestroyWindowFramebuffer(_this, window);
|
SDL_OFFSCREEN_DestroyWindowFramebuffer(_this, window);
|
||||||
|
|
||||||
/* Create a new one */
|
/* Create a new one */
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
|
|||||||
_kernel_swi_regs regs;
|
_kernel_swi_regs regs;
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
int size;
|
int size;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
/* Free the old framebuffer surface */
|
/* Free the old framebuffer surface */
|
||||||
RISCOS_DestroyWindowFramebuffer(_this, window);
|
RISCOS_DestroyWindowFramebuffer(_this, window);
|
||||||
@@ -54,10 +57,10 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate pitch */
|
/* Calculate pitch */
|
||||||
*pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
*pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
||||||
|
|
||||||
/* Allocate the sprite area */
|
/* Allocate the sprite area */
|
||||||
size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * window->h);
|
size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h);
|
||||||
driverdata->fb_area = SDL_malloc(size);
|
driverdata->fb_area = SDL_malloc(size);
|
||||||
if (!driverdata->fb_area) {
|
if (!driverdata->fb_area) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
@@ -73,8 +76,8 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
|
|||||||
regs.r[1] = (int)driverdata->fb_area;
|
regs.r[1] = (int)driverdata->fb_area;
|
||||||
regs.r[2] = (int)sprite_name;
|
regs.r[2] = (int)sprite_name;
|
||||||
regs.r[3] = 0;
|
regs.r[3] = 0;
|
||||||
regs.r[4] = window->w;
|
regs.r[4] = w;
|
||||||
regs.r[5] = window->h;
|
regs.r[5] = h;
|
||||||
regs.r[6] = sprite_mode;
|
regs.r[6] = sprite_mode;
|
||||||
error = _kernel_swi(OS_SpriteOp, ®s, ®s);
|
error = _kernel_swi(OS_SpriteOp, ®s, ®s);
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_
|
|||||||
enum libdecor_window_state *))
|
enum libdecor_window_state *))
|
||||||
SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int))
|
SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int))
|
||||||
|
|
||||||
|
#if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || defined(SDL_HAVE_LIBDECOR_GET_MIN_MAX)
|
||||||
/* Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. */
|
/* Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. */
|
||||||
SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (struct libdecor_frame *,\
|
SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (struct libdecor_frame *,\
|
||||||
int *,\
|
int *,\
|
||||||
@@ -226,6 +227,8 @@ SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (struct libdecor_
|
|||||||
int *))
|
int *))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef SDL_WAYLAND_MODULE
|
#undef SDL_WAYLAND_MODULE
|
||||||
#undef SDL_WAYLAND_SYM
|
#undef SDL_WAYLAND_SYM
|
||||||
#undef SDL_WAYLAND_SYM_OPT
|
#undef SDL_WAYLAND_SYM_OPT
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void
|
|||||||
size_t size;
|
size_t size;
|
||||||
LPBITMAPINFO info;
|
LPBITMAPINFO info;
|
||||||
HBITMAP hbm;
|
HBITMAP hbm;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
/* Free the old framebuffer surface */
|
/* Free the old framebuffer surface */
|
||||||
if (data->mdc) {
|
if (data->mdc) {
|
||||||
@@ -78,10 +81,10 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the size information */
|
/* Fill in the size information */
|
||||||
*pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
*pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
||||||
info->bmiHeader.biWidth = window->w;
|
info->bmiHeader.biWidth = w;
|
||||||
info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */
|
info->bmiHeader.biHeight = -h; /* negative for topdown bitmap */
|
||||||
info->bmiHeader.biSizeImage = (DWORD)window->h * (*pitch);
|
info->bmiHeader.biSizeImage = (DWORD)h * (*pitch);
|
||||||
|
|
||||||
data->mdc = CreateCompatibleDC(data->hdc);
|
data->mdc = CreateCompatibleDC(data->hdc);
|
||||||
data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0);
|
data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0);
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ static void WIN_WarpMouse(SDL_Window *window, int x, int y)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WIN_ClientPointFromSDL(window, &x, &y);
|
||||||
pt.x = x;
|
pt.x = x;
|
||||||
pt.y = y;
|
pt.y = y;
|
||||||
ClientToScreen(hwnd, &pt);
|
ClientToScreen(hwnd, &pt);
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
Display *display = data->videodata->display;
|
Display *display = data->videodata->display;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XVisualInfo vinfo;
|
XVisualInfo vinfo;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|
||||||
/* Free the old framebuffer surface */
|
/* Free the old framebuffer surface */
|
||||||
X11_DestroyWindowFramebuffer(_this, window);
|
X11_DestroyWindowFramebuffer(_this, window);
|
||||||
@@ -76,14 +79,14 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate pitch */
|
/* Calculate pitch */
|
||||||
*pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
*pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
||||||
|
|
||||||
/* Create the actual image */
|
/* Create the actual image */
|
||||||
#ifndef NO_SHARED_MEMORY
|
#ifndef NO_SHARED_MEMORY
|
||||||
if (have_mitshm(display)) {
|
if (have_mitshm(display)) {
|
||||||
XShmSegmentInfo *shminfo = &data->shminfo;
|
XShmSegmentInfo *shminfo = &data->shminfo;
|
||||||
|
|
||||||
shminfo->shmid = shmget(IPC_PRIVATE, (size_t)window->h * (*pitch), IPC_CREAT | 0777);
|
shminfo->shmid = shmget(IPC_PRIVATE, (size_t)h * (*pitch), IPC_CREAT | 0777);
|
||||||
if (shminfo->shmid >= 0) {
|
if (shminfo->shmid >= 0) {
|
||||||
shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0);
|
shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0);
|
||||||
shminfo->readOnly = False;
|
shminfo->readOnly = False;
|
||||||
@@ -107,7 +110,7 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
data->ximage = X11_XShmCreateImage(display, data->visual,
|
data->ximage = X11_XShmCreateImage(display, data->visual,
|
||||||
vinfo.depth, ZPixmap,
|
vinfo.depth, ZPixmap,
|
||||||
shminfo->shmaddr, shminfo,
|
shminfo->shmaddr, shminfo,
|
||||||
window->w, window->h);
|
w, h);
|
||||||
if (!data->ximage) {
|
if (!data->ximage) {
|
||||||
X11_XShmDetach(display, shminfo);
|
X11_XShmDetach(display, shminfo);
|
||||||
X11_XSync(display, False);
|
X11_XSync(display, False);
|
||||||
@@ -123,14 +126,14 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
|
|||||||
}
|
}
|
||||||
#endif /* not NO_SHARED_MEMORY */
|
#endif /* not NO_SHARED_MEMORY */
|
||||||
|
|
||||||
*pixels = SDL_malloc((size_t)window->h * (*pitch));
|
*pixels = SDL_malloc((size_t)h * (*pitch));
|
||||||
if (*pixels == NULL) {
|
if (*pixels == NULL) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ximage = X11_XCreateImage(display, data->visual,
|
data->ximage = X11_XCreateImage(display, data->visual,
|
||||||
vinfo.depth, ZPixmap, 0, (char *)(*pixels),
|
vinfo.depth, ZPixmap, 0, (char *)(*pixels),
|
||||||
window->w, window->h, 32, 0);
|
w, h, 32, 0);
|
||||||
if (!data->ximage) {
|
if (!data->ximage) {
|
||||||
SDL_free(*pixels);
|
SDL_free(*pixels);
|
||||||
return SDL_SetError("Couldn't create XImage");
|
return SDL_SetError("Couldn't create XImage");
|
||||||
@@ -146,6 +149,10 @@ int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects
|
|||||||
Display *display = data->videodata->display;
|
Display *display = data->videodata->display;
|
||||||
int i;
|
int i;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
|
int window_w, window_h;
|
||||||
|
|
||||||
|
SDL_GetWindowSizeInPixels(window, &window_w, &window_h);
|
||||||
|
|
||||||
#ifndef NO_SHARED_MEMORY
|
#ifndef NO_SHARED_MEMORY
|
||||||
if (data->use_mitshm) {
|
if (data->use_mitshm) {
|
||||||
for (i = 0; i < numrects; ++i) {
|
for (i = 0; i < numrects; ++i) {
|
||||||
@@ -166,11 +173,11 @@ int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects
|
|||||||
y += h;
|
y += h;
|
||||||
h += rects[i].y;
|
h += rects[i].y;
|
||||||
}
|
}
|
||||||
if (x + w > window->w) {
|
if (x + w > window_w) {
|
||||||
w = window->w - x;
|
w = window_w - x;
|
||||||
}
|
}
|
||||||
if (y + h > window->h) {
|
if (y + h > window_h) {
|
||||||
h = window->h - y;
|
h = window_h - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage,
|
X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage,
|
||||||
@@ -197,11 +204,11 @@ int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects
|
|||||||
y += h;
|
y += h;
|
||||||
h += rects[i].y;
|
h += rects[i].y;
|
||||||
}
|
}
|
||||||
if (x + w > window->w) {
|
if (x + w > window_w) {
|
||||||
w = window->w - x;
|
w = window_w - x;
|
||||||
}
|
}
|
||||||
if (y + h > window->h) {
|
if (y + h > window_h) {
|
||||||
h = window->h - y;
|
h = window_h - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
X11_XPutImage(display, data->xwindow, data->gc, data->ximage,
|
X11_XPutImage(display, data->xwindow, data->gc, data->ximage,
|
||||||
|
|||||||
Reference in new issue
Block a user