early-access version 2281
This commit is contained in:
40
externals/SDL/src/core/android/SDL_android.c
vendored
40
externals/SDL/src/core/android/SDL_android.c
vendored
@@ -148,6 +148,10 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring name);
|
||||
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeGetHintBoolean)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring name, jboolean default_value);
|
||||
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring name, jstring value);
|
||||
@@ -189,6 +193,7 @@ static JNINativeMethod SDLActivity_tab[] = {
|
||||
{ "nativeResume", "()V", SDL_JAVA_INTERFACE(nativeResume) },
|
||||
{ "nativeFocusChanged", "(Z)V", SDL_JAVA_INTERFACE(nativeFocusChanged) },
|
||||
{ "nativeGetHint", "(Ljava/lang/String;)Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetHint) },
|
||||
{ "nativeGetHintBoolean", "(Ljava/lang/String;Z)Z", SDL_JAVA_INTERFACE(nativeGetHintBoolean) },
|
||||
{ "nativeSetenv", "(Ljava/lang/String;Ljava/lang/String;)V", SDL_JAVA_INTERFACE(nativeSetenv) },
|
||||
{ "onNativeOrientationChanged", "(I)V", SDL_JAVA_INTERFACE(onNativeOrientationChanged) },
|
||||
{ "nativeAddTouch", "(ILjava/lang/String;)V", SDL_JAVA_INTERFACE(nativeAddTouch) },
|
||||
@@ -1306,6 +1311,19 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)(
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeGetHintBoolean)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring name, jboolean default_value)
|
||||
{
|
||||
jboolean result;
|
||||
|
||||
const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
|
||||
result = SDL_GetHintBoolean(utfname, default_value);
|
||||
(*env)->ReleaseStringUTFChars(env, name, utfname);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring name, jstring value)
|
||||
@@ -2513,23 +2531,23 @@ SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
|
||||
SDL_bool Android_JNI_RequestPermission(const char *permission)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
const int requestCode = 1;
|
||||
const int requestCode = 1;
|
||||
|
||||
/* Wait for any pending request on another thread */
|
||||
while (SDL_AtomicGet(&bPermissionRequestPending) == SDL_TRUE) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_AtomicSet(&bPermissionRequestPending, SDL_TRUE);
|
||||
/* Wait for any pending request on another thread */
|
||||
while (SDL_AtomicGet(&bPermissionRequestPending) == SDL_TRUE) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_AtomicSet(&bPermissionRequestPending, SDL_TRUE);
|
||||
|
||||
jstring jpermission = (*env)->NewStringUTF(env, permission);
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midRequestPermission, jpermission, requestCode);
|
||||
(*env)->DeleteLocalRef(env, jpermission);
|
||||
|
||||
/* Wait for the request to complete */
|
||||
while (SDL_AtomicGet(&bPermissionRequestPending) == SDL_TRUE) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return bPermissionRequestResult;
|
||||
/* Wait for the request to complete */
|
||||
while (SDL_AtomicGet(&bPermissionRequestPending) == SDL_TRUE) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return bPermissionRequestResult;
|
||||
}
|
||||
|
||||
/* Show toast notification */
|
||||
|
@@ -238,7 +238,7 @@ SDL_EVDEV_kbd_init(void)
|
||||
kbd->npadch = -1;
|
||||
|
||||
/* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
|
||||
kbd->keyboard_fd = kbd->console_fd = open("/dev/tty", O_RDONLY);
|
||||
kbd->keyboard_fd = kbd->console_fd = open("/dev/tty", O_RDONLY | O_CLOEXEC);
|
||||
|
||||
kbd->shift_state = 0;
|
||||
|
||||
@@ -268,13 +268,13 @@ SDL_EVDEV_kbd_init(void)
|
||||
kbd->key_map = &keymap_default_us_acc;
|
||||
}
|
||||
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
|
||||
if (getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) {
|
||||
if (SDL_getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) {
|
||||
/* Take keyboard from console and open the actual keyboard device.
|
||||
* Ensures that the keystrokes do not leak through to the console.
|
||||
*/
|
||||
ioctl(kbd->console_fd, CONS_RELKBD, 1ul);
|
||||
asprintf(&devicePath, "/dev/kbd%d", kbd->kbInfo->kb_index);
|
||||
kbd->keyboard_fd = open(devicePath, O_WRONLY);
|
||||
SDL_asprintf(&devicePath, "/dev/kbd%d", kbd->kbInfo->kb_index);
|
||||
kbd->keyboard_fd = open(devicePath, O_WRONLY | O_CLOEXEC);
|
||||
if (kbd->keyboard_fd == -1)
|
||||
{
|
||||
// Give keyboard back.
|
||||
@@ -288,7 +288,7 @@ SDL_EVDEV_kbd_init(void)
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
|
||||
kbd_register_emerg_cleanup(kbd);
|
||||
}
|
||||
free(devicePath);
|
||||
SDL_free(devicePath);
|
||||
}
|
||||
else kbd->keyboard_fd = kbd->console_fd;
|
||||
}
|
||||
|
12
externals/SDL/src/core/linux/SDL_dbus.c
vendored
12
externals/SDL/src/core/linux/SDL_dbus.c
vendored
@@ -19,6 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_dbus.h"
|
||||
#include "SDL_atomic.h"
|
||||
|
||||
@@ -365,8 +366,15 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
const char *interface = "org.freedesktop.ScreenSaver";
|
||||
|
||||
if (inhibit) {
|
||||
const char *app = "My SDL application";
|
||||
const char *reason = "Playing a game";
|
||||
const char *app = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||
if (!app || !app[0]) {
|
||||
app = "My SDL application";
|
||||
}
|
||||
if (!reason || !reason[0]) {
|
||||
reason = "Playing a game";
|
||||
}
|
||||
|
||||
if (!SDL_DBus_CallMethod(node, path, interface, "Inhibit",
|
||||
DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||
|
9
externals/SDL/src/core/linux/SDL_evdev.c
vendored
9
externals/SDL/src/core/linux/SDL_evdev.c
vendored
@@ -218,8 +218,11 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
|
||||
|
||||
switch(udev_event) {
|
||||
case SDL_UDEV_DEVICEADDED:
|
||||
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD |
|
||||
SDL_UDEV_DEVICE_TOUCHSCREEN)))
|
||||
if (udev_class & SDL_UDEV_DEVICE_TOUCHPAD) {
|
||||
udev_class |= SDL_UDEV_DEVICE_TOUCHSCREEN;
|
||||
}
|
||||
|
||||
if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN)))
|
||||
return;
|
||||
|
||||
if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK))
|
||||
@@ -725,7 +728,7 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
item->fd = open(dev_path, O_RDONLY | O_NONBLOCK);
|
||||
item->fd = open(dev_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (item->fd < 0) {
|
||||
SDL_free(item);
|
||||
return SDL_SetError("Unable to open %s", dev_path);
|
||||
|
@@ -78,7 +78,7 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
|
||||
; /* ID_INPUT_TABLET */
|
||||
} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
|
||||
; /* ID_INPUT_TOUCHPAD */
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHPAD; /* ID_INPUT_TOUCHPAD */
|
||||
} else if (test_bit(BTN_MOUSE, bitmask_key)) {
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
|
||||
} else if (test_bit(BTN_TOUCH, bitmask_key)) {
|
||||
|
@@ -38,7 +38,8 @@ typedef enum
|
||||
SDL_UDEV_DEVICE_JOYSTICK = 0x0004,
|
||||
SDL_UDEV_DEVICE_SOUND = 0x0008,
|
||||
SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010,
|
||||
SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020
|
||||
SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020,
|
||||
SDL_UDEV_DEVICE_TOUCHPAD = 0x0040
|
||||
} SDL_UDEV_deviceclass;
|
||||
|
||||
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
|
||||
|
6
externals/SDL/src/core/linux/SDL_evdev_kbd.c
vendored
6
externals/SDL/src/core/linux/SDL_evdev_kbd.c
vendored
@@ -219,7 +219,7 @@ static void kbd_cleanup(void)
|
||||
ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
SDL_EVDEV_kbd_reraise_signal(int sig)
|
||||
{
|
||||
raise(sig);
|
||||
@@ -354,7 +354,7 @@ SDL_EVDEV_kbd_init(void)
|
||||
kbd->npadch = -1;
|
||||
|
||||
/* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
|
||||
kbd->console_fd = open("/dev/tty", O_RDONLY);
|
||||
kbd->console_fd = open("/dev/tty", O_RDONLY | O_CLOEXEC);
|
||||
|
||||
if (ioctl(kbd->console_fd, TIOCLINUX, shift_state) == 0) {
|
||||
kbd->shift_state = *shift_state;
|
||||
@@ -386,7 +386,7 @@ SDL_EVDEV_kbd_init(void)
|
||||
}
|
||||
|
||||
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
|
||||
if (getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
|
||||
if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
|
||||
/* Mute the keyboard so keystrokes only generate evdev events
|
||||
* and do not leak through to the console
|
||||
*/
|
||||
|
3
externals/SDL/src/core/linux/SDL_fcitx.c
vendored
3
externals/SDL/src/core/linux/SDL_fcitx.c
vendored
@@ -84,7 +84,8 @@ GetAppName()
|
||||
return SDL_strdup("SDL_App");
|
||||
}
|
||||
|
||||
size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
|
||||
static size_t
|
||||
Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
|
||||
char *text = NULL, *subtext;
|
||||
size_t text_bytes = 0;
|
||||
DBusMessageIter iter, array, sub;
|
||||
|
8
externals/SDL/src/core/linux/SDL_ime.c
vendored
8
externals/SDL/src/core/linux/SDL_ime.c
vendored
@@ -23,13 +23,13 @@
|
||||
#include "SDL_ibus.h"
|
||||
#include "SDL_fcitx.h"
|
||||
|
||||
typedef SDL_bool (*_SDL_IME_Init)();
|
||||
typedef void (*_SDL_IME_Quit)();
|
||||
typedef SDL_bool (*_SDL_IME_Init)(void);
|
||||
typedef void (*_SDL_IME_Quit)(void);
|
||||
typedef void (*_SDL_IME_SetFocus)(SDL_bool);
|
||||
typedef void (*_SDL_IME_Reset)();
|
||||
typedef void (*_SDL_IME_Reset)(void);
|
||||
typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32);
|
||||
typedef void (*_SDL_IME_UpdateTextRect)(SDL_Rect *);
|
||||
typedef void (*_SDL_IME_PumpEvents)();
|
||||
typedef void (*_SDL_IME_PumpEvents)(void);
|
||||
|
||||
static _SDL_IME_Init SDL_IME_Init_Real = NULL;
|
||||
static _SDL_IME_Quit SDL_IME_Quit_Real = NULL;
|
||||
|
@@ -108,7 +108,9 @@ rtkit_initialize_realtime_thread()
|
||||
int nLimit = RLIMIT_RTTIME;
|
||||
pid_t nPid = 0; //self
|
||||
int nSchedPolicy = sched_getscheduler(nPid) | SCHED_RESET_ON_FORK;
|
||||
struct sched_param schedParam = {};
|
||||
struct sched_param schedParam;
|
||||
|
||||
SDL_zero(schedParam);
|
||||
|
||||
// Requirement #1: Set RLIMIT_RTTIME
|
||||
err = getrlimit(nLimit, &rlimit);
|
||||
|
141
externals/SDL/src/core/linux/SDL_udev.c
vendored
141
externals/SDL/src/core/linux/SDL_udev.c
vendored
@@ -19,7 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* To list the properties of a device, try something like:
|
||||
* udevadm info -a -n snd/hwC0D0 (for a sound card)
|
||||
* udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc)
|
||||
@@ -103,7 +103,7 @@ SDL_UDEV_hotplug_update_available(void)
|
||||
{
|
||||
if (_this->udev_mon != NULL) {
|
||||
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
|
||||
if (SDL_IOReady(fd, SDL_FALSE, 0)) {
|
||||
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -115,23 +115,23 @@ int
|
||||
SDL_UDEV_Init(void)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
|
||||
if (_this == NULL) {
|
||||
_this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this));
|
||||
if(_this == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
||||
retval = SDL_UDEV_LoadLibrary();
|
||||
if (retval < 0) {
|
||||
SDL_UDEV_Quit();
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Set up udev monitoring
|
||||
|
||||
/* Set up udev monitoring
|
||||
* Listen for input devices (mouse, keyboard, joystick, etc) and sound devices
|
||||
*/
|
||||
|
||||
|
||||
_this->udev = _this->syms.udev_new();
|
||||
if (_this->udev == NULL) {
|
||||
SDL_UDEV_Quit();
|
||||
@@ -143,18 +143,18 @@ SDL_UDEV_Init(void)
|
||||
SDL_UDEV_Quit();
|
||||
return SDL_SetError("udev_monitor_new_from_netlink() failed");
|
||||
}
|
||||
|
||||
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL);
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
|
||||
_this->syms.udev_monitor_enable_receiving(_this->udev_mon);
|
||||
|
||||
|
||||
/* Do an initial scan of existing devices */
|
||||
SDL_UDEV_Scan();
|
||||
|
||||
}
|
||||
|
||||
|
||||
_this->ref_count += 1;
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -162,15 +162,15 @@ void
|
||||
SDL_UDEV_Quit(void)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
|
||||
|
||||
if (_this == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_this->ref_count -= 1;
|
||||
|
||||
|
||||
if (_this->ref_count < 1) {
|
||||
|
||||
|
||||
if (_this->udev_mon != NULL) {
|
||||
_this->syms.udev_monitor_unref(_this->udev_mon);
|
||||
_this->udev_mon = NULL;
|
||||
@@ -179,14 +179,14 @@ SDL_UDEV_Quit(void)
|
||||
_this->syms.udev_unref(_this->udev);
|
||||
_this->udev = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Remove existing devices */
|
||||
while (_this->first != NULL) {
|
||||
item = _this->first;
|
||||
_this->first = _this->first->next;
|
||||
SDL_free(item);
|
||||
}
|
||||
|
||||
|
||||
SDL_UDEV_UnloadLibrary();
|
||||
SDL_free(_this);
|
||||
_this = NULL;
|
||||
@@ -198,22 +198,22 @@ SDL_UDEV_Scan(void)
|
||||
{
|
||||
struct udev_enumerate *enumerate = NULL;
|
||||
struct udev_list_entry *devs = NULL;
|
||||
struct udev_list_entry *item = NULL;
|
||||
|
||||
struct udev_list_entry *item = NULL;
|
||||
|
||||
if (_this == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
enumerate = _this->syms.udev_enumerate_new(_this->udev);
|
||||
if (enumerate == NULL) {
|
||||
SDL_UDEV_Quit();
|
||||
SDL_SetError("udev_enumerate_new() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_this->syms.udev_enumerate_add_match_subsystem(enumerate, "input");
|
||||
_this->syms.udev_enumerate_add_match_subsystem(enumerate, "sound");
|
||||
|
||||
|
||||
_this->syms.udev_enumerate_scan_devices(enumerate);
|
||||
devs = _this->syms.udev_enumerate_get_list_entry(enumerate);
|
||||
for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) {
|
||||
@@ -228,6 +228,62 @@ SDL_UDEV_Scan(void)
|
||||
_this->syms.udev_enumerate_unref(enumerate);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version)
|
||||
{
|
||||
struct udev_enumerate *enumerate = NULL;
|
||||
struct udev_list_entry *devs = NULL;
|
||||
struct udev_list_entry *item = NULL;
|
||||
SDL_bool found = SDL_FALSE;
|
||||
|
||||
if (_this == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
enumerate = _this->syms.udev_enumerate_new(_this->udev);
|
||||
if (enumerate == NULL) {
|
||||
SDL_SetError("udev_enumerate_new() failed");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
_this->syms.udev_enumerate_scan_devices(enumerate);
|
||||
devs = _this->syms.udev_enumerate_get_list_entry(enumerate);
|
||||
for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) {
|
||||
const char *path = _this->syms.udev_list_entry_get_name(item);
|
||||
struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
|
||||
if (dev != NULL) {
|
||||
const char *val = NULL;
|
||||
const char *existing_path;
|
||||
|
||||
existing_path = _this->syms.udev_device_get_devnode(dev);
|
||||
if (existing_path && SDL_strcmp(device_path, existing_path) == 0) {
|
||||
found = SDL_TRUE;
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
|
||||
if (val != NULL) {
|
||||
*vendor = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID");
|
||||
if (val != NULL) {
|
||||
*product = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION");
|
||||
if (val != NULL) {
|
||||
*version = (Uint16)SDL_strtol(val, NULL, 16);
|
||||
}
|
||||
}
|
||||
_this->syms.udev_device_unref(dev);
|
||||
}
|
||||
}
|
||||
_this->syms.udev_enumerate_unref(enumerate);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
SDL_UDEV_UnloadLibrary(void)
|
||||
@@ -235,7 +291,7 @@ SDL_UDEV_UnloadLibrary(void)
|
||||
if (_this == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_this->udev_handle != NULL) {
|
||||
SDL_UnloadObject(_this->udev_handle);
|
||||
_this->udev_handle = NULL;
|
||||
@@ -246,11 +302,11 @@ int
|
||||
SDL_UDEV_LoadLibrary(void)
|
||||
{
|
||||
int retval = 0, i;
|
||||
|
||||
|
||||
if (_this == NULL) {
|
||||
return SDL_SetError("UDEV not initialized");
|
||||
}
|
||||
|
||||
|
||||
/* See if there is a udev library already loaded */
|
||||
if (SDL_UDEV_load_syms() == 0) {
|
||||
return 0;
|
||||
@@ -282,7 +338,7 @@ SDL_UDEV_LoadLibrary(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_this->udev_handle == NULL) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
@@ -352,26 +408,26 @@ guess_device_class(struct udev_device *dev)
|
||||
&bitmask_rel[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
static void
|
||||
device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
{
|
||||
const char *subsystem;
|
||||
const char *val = NULL;
|
||||
int devclass = 0;
|
||||
const char *path;
|
||||
SDL_UDEV_CallbackList *item;
|
||||
|
||||
|
||||
path = _this->syms.udev_device_get_devnode(dev);
|
||||
if (path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
subsystem = _this->syms.udev_device_get_subsystem(dev);
|
||||
if (SDL_strcmp(subsystem, "sound") == 0) {
|
||||
devclass = SDL_UDEV_DEVICE_SOUND;
|
||||
} else if (SDL_strcmp(subsystem, "input") == 0) {
|
||||
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
|
||||
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
@@ -381,13 +437,13 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
|
||||
val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE;
|
||||
}
|
||||
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN;
|
||||
@@ -396,7 +452,7 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
/* The undocumented rule is:
|
||||
- All devices with keys get ID_INPUT_KEY
|
||||
- From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD
|
||||
|
||||
|
||||
Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
|
||||
*/
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY");
|
||||
@@ -425,14 +481,14 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Process callbacks */
|
||||
for (item = _this->first; item != NULL; item = item->next) {
|
||||
item->callback(type, devclass, path);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
SDL_UDEV_Poll(void)
|
||||
{
|
||||
struct udev_device *dev = NULL;
|
||||
@@ -456,12 +512,12 @@ SDL_UDEV_Poll(void)
|
||||
device_event(SDL_UDEV_DEVICEREMOVED, dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_this->syms.udev_device_unref(dev);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
@@ -469,7 +525,7 @@ SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
if (item == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
||||
item->callback = cb;
|
||||
|
||||
if (_this->last == NULL) {
|
||||
@@ -478,11 +534,11 @@ SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
_this->last->next = item;
|
||||
_this->last = item;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
@@ -505,7 +561,6 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
}
|
||||
prev = item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const SDL_UDEV_Symbols *
|
||||
|
1
externals/SDL/src/core/linux/SDL_udev.h
vendored
1
externals/SDL/src/core/linux/SDL_udev.h
vendored
@@ -101,6 +101,7 @@ extern void SDL_UDEV_UnloadLibrary(void);
|
||||
extern int SDL_UDEV_LoadLibrary(void);
|
||||
extern void SDL_UDEV_Poll(void);
|
||||
extern void SDL_UDEV_Scan(void);
|
||||
extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version);
|
||||
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
|
||||
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
||||
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
||||
|
@@ -416,7 +416,7 @@ static SDL_WSCONS_input_data* SDL_WSCONS_Init_Keyboard(const char* dev)
|
||||
if (!input) {
|
||||
return input;
|
||||
}
|
||||
input->fd = open(dev,O_RDWR | O_NONBLOCK);
|
||||
input->fd = open(dev,O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (input->fd == -1) {
|
||||
free(input);
|
||||
input = NULL;
|
||||
@@ -509,7 +509,7 @@ static void put_utf8(SDL_WSCONS_input_data* input, uint c)
|
||||
static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym)
|
||||
{
|
||||
if (KS_GROUP(ksym) == KS_GROUP_Keypad) {
|
||||
if (isprint(ksym & 0xFF)) ksym &= 0xFF;
|
||||
if (SDL_isprint(ksym & 0xFF)) ksym &= 0xFF;
|
||||
}
|
||||
switch(ksym) {
|
||||
case KS_Escape:
|
||||
@@ -526,7 +526,7 @@ static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym)
|
||||
if (input->text_len > 0) {
|
||||
input->text[input->text_len] = '\0';
|
||||
SDL_SendKeyboardText(input->text);
|
||||
/*memset(input->text, 0, sizeof(input->text));*/
|
||||
/*SDL_memset(input->text, 0, sizeof(input->text));*/
|
||||
input->text_len = 0;
|
||||
input->text[0] = 0;
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse()
|
||||
SDL_WSCONS_mouse_input_data* mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data));
|
||||
|
||||
if (!mouseInputData) return NULL;
|
||||
mouseInputData->fd = open("/dev/wsmouse",O_RDWR | O_NONBLOCK);
|
||||
mouseInputData->fd = open("/dev/wsmouse",O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (mouseInputData->fd == -1) {free(mouseInputData); return NULL; }
|
||||
#ifdef WSMOUSEIO_SETMODE
|
||||
ioctl(mouseInputData->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT);
|
||||
|
2
externals/SDL/src/core/os2/geniconv/makefile
vendored
2
externals/SDL/src/core/os2/geniconv/makefile
vendored
@@ -11,7 +11,7 @@ LIBFILE = geniconv.lib
|
||||
|
||||
all: $(LIBFILE) test.exe .symbolic
|
||||
|
||||
CFLAGS = -I$(%WATCOM)/h/os2 -I$(%WATCOM)/h -I. -bt=os2 -q -d0 -w2
|
||||
CFLAGS = -I$(%WATCOM)/h/os2 -I$(%WATCOM)/h -I. -bt=os2 -q -d0 -w2 -DGENICONV_STANDALONE=1
|
||||
|
||||
SRCS = geniconv.c os2cp.c os2iconv.c
|
||||
SRCS+= sys2utf8.c
|
||||
|
30
externals/SDL/src/core/os2/geniconv/os2cp.c
vendored
30
externals/SDL/src/core/os2/geniconv/os2cp.c
vendored
@@ -22,11 +22,21 @@
|
||||
#define INCL_DOSNLS
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "os2cp.h"
|
||||
|
||||
#ifndef GENICONV_STANDALONE
|
||||
#include "../../../SDL_internal.h"
|
||||
#else
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#define SDL_isspace isspace
|
||||
#define SDL_strchr strchr
|
||||
#define SDL_memcpy memcpy
|
||||
#define SDL_strupr strupr
|
||||
#define SDL_strcmp strcmp
|
||||
#endif
|
||||
|
||||
typedef struct _CP2NAME {
|
||||
ULONG ulCode;
|
||||
PSZ pszName;
|
||||
@@ -354,28 +364,28 @@ unsigned long os2cpFromName(char *cp)
|
||||
return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0];
|
||||
}
|
||||
|
||||
while (isspace(*cp))
|
||||
while (SDL_isspace(*cp))
|
||||
cp++;
|
||||
|
||||
pcEnd = strchr(cp, ' ');
|
||||
pcEnd = SDL_strchr(cp, ' ');
|
||||
if (pcEnd == NULL)
|
||||
pcEnd = strchr(cp, '\0');
|
||||
pcEnd = SDL_strchr(cp, '\0');
|
||||
|
||||
ulNext = pcEnd - cp;
|
||||
if (ulNext >= sizeof(acBuf))
|
||||
return 0;
|
||||
|
||||
memcpy(acBuf, cp, ulNext);
|
||||
SDL_memcpy(acBuf, cp, ulNext);
|
||||
acBuf[ulNext] = '\0';
|
||||
strupr(acBuf);
|
||||
SDL_strupr(acBuf);
|
||||
|
||||
lCmp = strcmp(aName2CP[0].pszName, acBuf);
|
||||
lCmp = SDL_strcmp(aName2CP[0].pszName, acBuf);
|
||||
if (lCmp > 0)
|
||||
return 0;
|
||||
else if (lCmp == 0)
|
||||
return aName2CP[0].ulCode;
|
||||
|
||||
lCmp = strcmp(aName2CP[ulHi].pszName, acBuf);
|
||||
lCmp = SDL_strcmp(aName2CP[ulHi].pszName, acBuf);
|
||||
if (lCmp < 0)
|
||||
return 0;
|
||||
else if (lCmp == 0)
|
||||
@@ -384,7 +394,7 @@ unsigned long os2cpFromName(char *cp)
|
||||
while ((ulHi - ulLo) > 1) {
|
||||
ulNext = (ulLo + ulHi) / 2;
|
||||
|
||||
lCmp = strcmp(aName2CP[ulNext].pszName, acBuf);
|
||||
lCmp = SDL_strcmp(aName2CP[ulNext].pszName, acBuf);
|
||||
if (lCmp < 0)
|
||||
ulLo = ulNext;
|
||||
else if (lCmp > 0)
|
||||
|
37
externals/SDL/src/core/os2/geniconv/os2iconv.c
vendored
37
externals/SDL/src/core/os2/geniconv/os2iconv.c
vendored
@@ -31,19 +31,30 @@
|
||||
#define _ULS_CALLCONV_
|
||||
#define CALLCONV _System
|
||||
#include <uconv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef ICONV_THREAD_SAFE
|
||||
#define INCL_DOSSEMAPHORES
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
#include "os2cp.h"
|
||||
|
||||
#ifndef GENICONV_STANDALONE
|
||||
#include "../../../SDL_internal.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(min)
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#define SDL_min min
|
||||
#define SDL_strcasecmp stricmp
|
||||
#define SDL_snprintf _snprintf
|
||||
#define SDL_malloc malloc
|
||||
#define SDL_free free
|
||||
#define SDL_memcpy memcpy
|
||||
#endif
|
||||
|
||||
#define MAX_CP_NAME_LEN 64
|
||||
|
||||
@@ -82,7 +93,7 @@ static int uconv_open(const char *code, UconvObject *uobj)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!stricmp(code, "UTF-16")) {
|
||||
if (!SDL_strcasecmp(code, "UTF-16")) {
|
||||
*uobj = NULL;
|
||||
return ULS_SUCCESS;
|
||||
}
|
||||
@@ -92,7 +103,7 @@ static int uconv_open(const char *code, UconvObject *uobj)
|
||||
unsigned long cp = os2cpFromName((char *)code);
|
||||
char cp_name[16];
|
||||
|
||||
if (cp != 0 && _snprintf(cp_name, sizeof(cp_name), "IBM-%u", cp) > 0)
|
||||
if (cp != 0 && SDL_snprintf(cp_name, sizeof(cp_name), "IBM-%u", cp) > 0)
|
||||
rc = _createUconvObj(cp_name, uobj);
|
||||
}
|
||||
|
||||
@@ -113,7 +124,7 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
|
||||
if (fromcode == NULL)
|
||||
fromcode = "";
|
||||
|
||||
if (stricmp(tocode, fromcode) != 0) {
|
||||
if (SDL_strcasecmp(tocode, fromcode) != 0) {
|
||||
rc = uconv_open(fromcode, &uo_fromcode);
|
||||
if (rc != ULS_SUCCESS) {
|
||||
errno = EINVAL;
|
||||
@@ -131,7 +142,7 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
|
||||
uo_fromcode = NULL;
|
||||
}
|
||||
|
||||
iuobj = (iuconv_obj *) malloc(sizeof(iuconv_obj));
|
||||
iuobj = (iuconv_obj *) SDL_malloc(sizeof(iuconv_obj));
|
||||
iuobj->uo_tocode = uo_tocode;
|
||||
iuobj->uo_fromcode = uo_fromcode;
|
||||
iuobj->buf_len = 0;
|
||||
@@ -158,8 +169,8 @@ extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
|
||||
size_t ret = (size_t)(-1);
|
||||
|
||||
if (uo_tocode == NULL && uo_fromcode == NULL) {
|
||||
uc_buf_len = min(*inbytesleft, *outbytesleft);
|
||||
memcpy(*outbuf, *inbuf, uc_buf_len);
|
||||
uc_buf_len = SDL_min(*inbytesleft, *outbytesleft);
|
||||
SDL_memcpy(*outbuf, *inbuf, uc_buf_len);
|
||||
*inbytesleft -= uc_buf_len;
|
||||
*outbytesleft -= uc_buf_len;
|
||||
outbuf += uc_buf_len;
|
||||
@@ -174,9 +185,9 @@ extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
|
||||
if (uo_tocode && uo_fromcode &&
|
||||
(((iuconv_obj *)cd)->buf_len >> 1) < *inbytesleft) {
|
||||
if (((iuconv_obj *)cd)->buf != NULL)
|
||||
free(((iuconv_obj *)cd)->buf);
|
||||
SDL_free(((iuconv_obj *)cd)->buf);
|
||||
((iuconv_obj *)cd)->buf_len = *inbytesleft << 1;
|
||||
((iuconv_obj *)cd)->buf = (UniChar *)malloc(((iuconv_obj *)cd)->buf_len);
|
||||
((iuconv_obj *)cd)->buf = (UniChar *)SDL_malloc(((iuconv_obj *)cd)->buf_len);
|
||||
}
|
||||
|
||||
if (uo_fromcode) {
|
||||
@@ -260,9 +271,9 @@ int _System os2_iconv_close(iconv_t cd)
|
||||
UniFreeUconvObject(((iuconv_obj *)cd)->uo_fromcode);
|
||||
|
||||
if (((iuconv_obj *)cd)->buf != NULL)
|
||||
free(((iuconv_obj *)cd)->buf);
|
||||
SDL_free(((iuconv_obj *)cd)->buf);
|
||||
|
||||
free(cd);
|
||||
SDL_free(cd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
16
externals/SDL/src/core/os2/geniconv/sys2utf8.c
vendored
16
externals/SDL/src/core/os2/geniconv/sys2utf8.c
vendored
@@ -20,7 +20,15 @@
|
||||
*/
|
||||
|
||||
#include "geniconv.h"
|
||||
|
||||
#ifndef GENICONV_STANDALONE
|
||||
#include "../../../SDL_internal.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define SDL_malloc malloc
|
||||
#define SDL_realloc realloc
|
||||
#define SDL_free free
|
||||
#endif
|
||||
|
||||
int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
|
||||
{
|
||||
@@ -83,25 +91,25 @@ int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
|
||||
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr)
|
||||
{
|
||||
int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
|
||||
char *pszNewStr = (char *) malloc(cbNewStr);
|
||||
char *pszNewStr = (char *) SDL_malloc(cbNewStr);
|
||||
|
||||
if (pszNewStr == NULL)
|
||||
return NULL;
|
||||
|
||||
cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
|
||||
if (cbNewStr != -1) {
|
||||
pcStr = (char *) realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
|
||||
pcStr = (char *) SDL_realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
|
||||
if (pcStr)
|
||||
return pcStr;
|
||||
}
|
||||
|
||||
free(pszNewStr);
|
||||
SDL_free(pszNewStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void StrUTF8Free(char *pszStr)
|
||||
{
|
||||
free(pszStr);
|
||||
SDL_free(pszStr);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
27
externals/SDL/src/core/unix/SDL_poll.c
vendored
27
externals/SDL/src/core/unix/SDL_poll.c
vendored
@@ -34,10 +34,12 @@
|
||||
|
||||
|
||||
int
|
||||
SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
SDL_IOReady(int fd, int flags, int timeoutMS)
|
||||
{
|
||||
int result;
|
||||
|
||||
SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE));
|
||||
|
||||
/* Note: We don't bother to account for elapsed time if we get EINTR */
|
||||
do
|
||||
{
|
||||
@@ -45,10 +47,12 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
struct pollfd info;
|
||||
|
||||
info.fd = fd;
|
||||
if (forWrite) {
|
||||
info.events = POLLOUT;
|
||||
} else {
|
||||
info.events = POLLIN | POLLPRI;
|
||||
info.events = 0;
|
||||
if (flags & SDL_IOR_READ) {
|
||||
info.events |= POLLIN | POLLPRI;
|
||||
}
|
||||
if (flags & SDL_IOR_WRITE) {
|
||||
info.events |= POLLOUT;
|
||||
}
|
||||
result = poll(&info, 1, timeoutMS);
|
||||
#else
|
||||
@@ -59,15 +63,16 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
/* If this assert triggers we'll corrupt memory here */
|
||||
SDL_assert(fd >= 0 && fd < FD_SETSIZE);
|
||||
|
||||
if (forWrite) {
|
||||
FD_ZERO(&wfdset);
|
||||
FD_SET(fd, &wfdset);
|
||||
wfdp = &wfdset;
|
||||
} else {
|
||||
if (flags & SDL_IOR_READ) {
|
||||
FD_ZERO(&rfdset);
|
||||
FD_SET(fd, &rfdset);
|
||||
rfdp = &rfdset;
|
||||
}
|
||||
if (flags & SDL_IOR_WRITE) {
|
||||
FD_ZERO(&wfdset);
|
||||
FD_SET(fd, &wfdset);
|
||||
wfdp = &wfdset;
|
||||
}
|
||||
|
||||
if (timeoutMS >= 0) {
|
||||
tv.tv_sec = timeoutMS / 1000;
|
||||
@@ -78,7 +83,7 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
result = select(fd + 1, rfdp, wfdp, NULL, tvp);
|
||||
#endif /* HAVE_POLL */
|
||||
|
||||
} while ( result < 0 && errno == EINTR );
|
||||
} while ( result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
5
externals/SDL/src/core/unix/SDL_poll.h
vendored
5
externals/SDL/src/core/unix/SDL_poll.h
vendored
@@ -26,8 +26,11 @@
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#define SDL_IOR_READ 0x1
|
||||
#define SDL_IOR_WRITE 0x2
|
||||
#define SDL_IOR_NO_RETRY 0x4
|
||||
|
||||
extern int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS);
|
||||
extern int SDL_IOReady(int fd, int flags, int timeoutMS);
|
||||
|
||||
#endif /* SDL_poll_h_ */
|
||||
|
||||
|
21
externals/SDL/src/core/windows/SDL_windows.c
vendored
21
externals/SDL/src/core/windows/SDL_windows.c
vendored
@@ -45,8 +45,9 @@ WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
TCHAR buffer[1024];
|
||||
char *message;
|
||||
TCHAR *p = buffer;
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
|
||||
DWORD c = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
|
||||
buffer, SDL_arraysize(buffer), NULL);
|
||||
buffer[c] = 0;
|
||||
/* kill CR/LF that FormatMessage() sticks at the end */
|
||||
while (*p) {
|
||||
if (*p == '\r') {
|
||||
@@ -248,6 +249,24 @@ WIN_IsEqualIID(REFIID a, REFIID b)
|
||||
return (SDL_memcmp(a, b, sizeof (*a)) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect)
|
||||
{
|
||||
sdlrect->x = winrect->left;
|
||||
sdlrect->w = (winrect->right - winrect->left) + 1;
|
||||
sdlrect->y = winrect->top;
|
||||
sdlrect->h = (winrect->bottom - winrect->top) + 1;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
|
||||
{
|
||||
winrect->left = sdlrect->x;
|
||||
winrect->right = sdlrect->x + sdlrect->w - 1;
|
||||
winrect->top = sdlrect->y;
|
||||
winrect->bottom = sdlrect->y + sdlrect->h - 1;
|
||||
}
|
||||
|
||||
#endif /* __WIN32__ || __WINRT__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
14
externals/SDL/src/core/windows/SDL_windows.h
vendored
14
externals/SDL/src/core/windows/SDL_windows.h
vendored
@@ -37,12 +37,14 @@
|
||||
#include <windows.h>
|
||||
#include <basetyps.h> /* for REFIID with broken mingw.org headers */
|
||||
|
||||
#include "SDL_rect.h"
|
||||
|
||||
/* Routines to convert from UTF8 to native Windows text */
|
||||
#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
|
||||
#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
|
||||
/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
|
||||
#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
|
||||
#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
|
||||
#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S)+1))
|
||||
#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S)+1)
|
||||
#if UNICODE
|
||||
#define WIN_StringToUTF8 WIN_StringToUTF8W
|
||||
#define WIN_UTF8ToString WIN_UTF8ToStringW
|
||||
@@ -81,6 +83,10 @@ extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
|
||||
extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
|
||||
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
||||
|
||||
/* Convert between SDL_rect and RECT */
|
||||
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
||||
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
||||
|
||||
#endif /* _INCLUDED_WINDOWS_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -357,9 +357,16 @@ void SDL_WinRTApp::Run()
|
||||
{
|
||||
// TODO, WinRT: pass the C-style main() a reasonably realistic
|
||||
// representation of command line arguments.
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
int argc = 1;
|
||||
char **argv = (char **)SDL_malloc(2 * sizeof(*argv));
|
||||
if (!argv) {
|
||||
return;
|
||||
}
|
||||
argv[0] = SDL_strdup("WinRTApp");
|
||||
argv[1] = NULL;
|
||||
WINRT_SDLAppEntryPoint(argc, argv);
|
||||
SDL_free(argv[0]);
|
||||
SDL_free(argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user