early-access version 2835

This commit is contained in:
pineappleEA
2022-07-15 04:00:50 +02:00
parent 5c0ee5eba6
commit 0e7aef7e36
1173 changed files with 55320 additions and 18881 deletions

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -303,6 +303,7 @@ static jmethodID midClipboardGetText;
static jmethodID midClipboardHasText;
static jmethodID midClipboardSetText;
static jmethodID midCreateCustomCursor;
static jmethodID midDestroyCustomCursor;
static jmethodID midGetContext;
static jmethodID midGetDisplayDPI;
static jmethodID midGetManifestEnvironmentVariables;
@@ -510,9 +511,10 @@ register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, i
/* Library init */
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
mJavaVM = vm;
JNIEnv *env = NULL;
mJavaVM = vm;
if ((*mJavaVM)->GetEnv(mJavaVM, (void **)&env, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to get JNI Env");
return JNI_VERSION_1_4;
@@ -582,6 +584,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
midClipboardHasText = (*env)->GetStaticMethodID(env, mActivityClass, "clipboardHasText", "()Z");
midClipboardSetText = (*env)->GetStaticMethodID(env, mActivityClass, "clipboardSetText", "(Ljava/lang/String;)V");
midCreateCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "createCustomCursor", "([IIIII)I");
midDestroyCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "destroyCustomCursor", "(I)V");
midGetContext = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;");
midGetDisplayDPI = (*env)->GetStaticMethodID(env, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
midGetManifestEnvironmentVariables = (*env)->GetStaticMethodID(env, mActivityClass, "getManifestEnvironmentVariables", "()Z");
@@ -612,6 +615,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
!midClipboardHasText ||
!midClipboardSetText ||
!midCreateCustomCursor ||
!midDestroyCustomCursor ||
!midGetContext ||
!midGetDisplayDPI ||
!midGetManifestEnvironmentVariables ||
@@ -1006,6 +1010,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j
{
SDL_LockMutex(Android_ActivityMutex);
#if SDL_VIDEO_OPENGL_EGL
if (Android_Window)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
@@ -1018,6 +1023,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j
/* GL Context handling is done in the event loop because this function is run from the Java thread */
}
#endif
SDL_UnlockMutex(Android_ActivityMutex);
}
@@ -1048,10 +1054,12 @@ retry:
}
}
#if SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
data->egl_surface = EGL_NO_SURFACE;
}
#endif
if (data->native_window) {
ANativeWindow_release(data->native_window);
@@ -2123,6 +2131,15 @@ void Android_JNI_HapticStop(int device_id)
/* See SDLActivity.java for constants. */
#define COMMAND_SET_KEEP_SCREEN_ON 5
int SDL_AndroidSendMessage(Uint32 command, int param)
{
if (command >= 0x8000) {
return Android_JNI_SendMessage(command, param);
}
return -1;
}
/* sends message to be handled on the UI event dispatch thread */
int Android_JNI_SendMessage(int command, int param)
{
@@ -2503,6 +2520,12 @@ int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
return custom_cursor;
}
void Android_JNI_DestroyCustomCursor(int cursorID)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
return;
}
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
{
@@ -2531,6 +2554,7 @@ SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
SDL_bool Android_JNI_RequestPermission(const char *permission)
{
JNIEnv *env = Android_JNI_GetEnv();
jstring jpermission;
const int requestCode = 1;
/* Wait for any pending request on another thread */
@@ -2539,7 +2563,7 @@ SDL_bool Android_JNI_RequestPermission(const char *permission)
}
SDL_AtomicSet(&bPermissionRequestPending, SDL_TRUE);
jstring jpermission = (*env)->NewStringUTF(env, permission);
jpermission = (*env)->NewStringUTF(env, permission);
(*env)->CallStaticVoidMethod(env, mActivityClass, midRequestPermission, jpermission, requestCode);
(*env)->DeleteLocalRef(env, jpermission);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -118,6 +118,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
/* Cursor support */
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
void Android_JNI_DestroyCustomCursor(int cursorID);
SDL_bool Android_JNI_SetCustomCursor(int cursorID);
SDL_bool Android_JNI_SetSystemCursor(int cursorID);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -22,6 +22,7 @@
#include "SDL_hints.h"
#include "SDL_dbus.h"
#include "SDL_atomic.h"
#include "../../stdlib/SDL_vacopy.h"
#if SDL_USE_LIBDBUS
/* we never link directly to libdbus. */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2020 Collabora Ltd.
This software is provided 'as-is', without any express or implied

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2020 Collabora Ltd.
This software is provided 'as-is', without any express or implied

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -85,14 +85,22 @@ GetAppName()
}
static size_t
Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
Fcitx_GetPreeditString(SDL_DBusContext *dbus,
DBusMessage *msg,
char **ret,
Sint32 *start_pos,
Sint32 *end_pos)
{
char *text = NULL, *subtext;
size_t text_bytes = 0;
DBusMessageIter iter, array, sub;
Sint32 p_start_pos = -1;
Sint32 p_end_pos = -1;
dbus->message_iter_init(msg, &iter);
/* Message type is a(si)i, we only need string part */
if (dbus->message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
size_t pos = 0;
/* First pass: calculate string length */
dbus->message_iter_recurse(&iter, &array);
while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
@@ -103,7 +111,29 @@ Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
text_bytes += SDL_strlen(subtext);
}
}
dbus->message_iter_next(&sub);
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_INT32 && p_end_pos == -1) {
/* Type is a bit field defined as follows: */
/* bit 3: Underline, bit 4: HighLight, bit 5: DontCommit, */
/* bit 6: Bold, bit 7: Strike, bit 8: Italic */
Sint32 type;
dbus->message_iter_get_basic(&sub, &type);
/* We only consider highlight */
if (type & (1 << 4)) {
if (p_start_pos == -1) {
p_start_pos = pos;
}
} else if (p_start_pos != -1 && p_end_pos == -1) {
p_end_pos = pos;
}
}
dbus->message_iter_next(&array);
if (subtext && *subtext) {
pos += SDL_utf8strlen(subtext);
}
}
if (p_start_pos != -1 && p_end_pos == -1) {
p_end_pos = pos;
}
if (text_bytes) {
text = SDL_malloc(text_bytes + 1);
@@ -129,10 +159,32 @@ Fcitx_GetPreeditString(SDL_DBusContext *dbus, DBusMessage *msg, char **ret) {
text_bytes = 0;
}
}
*ret= text;
*ret = text;
*start_pos = p_start_pos;
*end_pos = p_end_pos;
return text_bytes;
}
static Sint32
Fcitx_GetPreeditCursorByte(SDL_DBusContext *dbus, DBusMessage *msg)
{
Sint32 byte = -1;
DBusMessageIter iter;
dbus->message_iter_init(msg, &iter);
dbus->message_iter_next(&iter);
if (dbus->message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) {
return -1;
}
dbus->message_iter_get_basic(&iter, &byte);
return byte;
}
static DBusHandlerResult
DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data)
{
@@ -162,20 +214,28 @@ DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data)
if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "UpdateFormattedPreedit")) {
char *text = NULL;
size_t text_bytes = Fcitx_GetPreeditString(dbus, msg, &text);
Sint32 start_pos, end_pos;
size_t text_bytes = Fcitx_GetPreeditString(dbus, msg, &text, &start_pos, &end_pos);
if (text_bytes) {
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
size_t i = 0;
size_t cursor = 0;
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE)) {
if (start_pos == -1) {
Sint32 byte_pos = Fcitx_GetPreeditCursorByte(dbus, msg);
start_pos = byte_pos >= 0 ? SDL_utf8strnlen(text, byte_pos) : -1;
}
SDL_SendEditingText(text, start_pos, end_pos >= 0 ? end_pos - start_pos : -1);
} else {
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
size_t i = 0;
size_t cursor = 0;
while (i < text_bytes) {
const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
const size_t chars = SDL_utf8strlen(buf);
while (i < text_bytes) {
const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf));
const size_t chars = SDL_utf8strlen(buf);
SDL_SendEditingText(buf, cursor, chars);
SDL_SendEditingText(buf, cursor, chars);
i += sz;
cursor += chars;
i += sz;
cursor += chars;
}
}
SDL_free(text);
} else {
@@ -339,11 +399,11 @@ SDL_Fcitx_Reset(void)
}
SDL_bool
SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode)
SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
Uint32 state = Fcitx_ModState();
Uint32 mod_state = Fcitx_ModState();
Uint32 handled = SDL_FALSE;
Uint32 is_release = SDL_FALSE;
Uint32 is_release = (state == SDL_RELEASED);
Uint32 event_time = 0;
if (!fcitx_client.ic_path) {
@@ -351,7 +411,7 @@ SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode)
}
if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent",
DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &state, DBUS_TYPE_BOOLEAN, &is_release, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID,
DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &mod_state, DBUS_TYPE_BOOLEAN, &is_release, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID,
DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) {
if (handled) {
SDL_Fcitx_UpdateTextRect(NULL);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -31,7 +31,7 @@ extern SDL_bool SDL_Fcitx_Init(void);
extern void SDL_Fcitx_Quit(void);
extern void SDL_Fcitx_SetFocus(SDL_bool focused);
extern void SDL_Fcitx_Reset(void);
extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode);
extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern void SDL_Fcitx_UpdateTextRect(SDL_Rect *rect);
extern void SDL_Fcitx_PumpEvents(void);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -22,6 +22,7 @@
#ifdef HAVE_IBUS_IBUS_H
#include "SDL.h"
#include "SDL_hints.h"
#include "SDL_syswm.h"
#include "SDL_ibus.h"
#include "SDL_dbus.h"
@@ -66,107 +67,217 @@ IBus_ModState(void)
return ibus_mods;
}
static SDL_bool
IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
DBusMessageIter *inside, const char * struct_id, size_t id_size)
{
DBusMessageIter sub;
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) {
return SDL_FALSE;
}
dbus->message_iter_recurse(iter, &sub);
if (dbus->message_iter_get_arg_type(&sub) != DBUS_TYPE_STRUCT) {
return SDL_FALSE;
}
dbus->message_iter_recurse(&sub, inside);
if (dbus->message_iter_get_arg_type(inside) != DBUS_TYPE_STRING) {
return SDL_FALSE;
}
dbus->message_iter_get_basic(inside, &struct_id);
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
return SDL_FALSE;
}
return SDL_TRUE;
}
static SDL_bool
IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
Uint32 *start_pos, Uint32 *end_pos)
{
DBusMessageIter sub1, sub2, array;
if (!IBus_EnterVariant(conn, iter, dbus, &sub1, "IBusText", sizeof("IBusText"))) {
return SDL_FALSE;
}
dbus->message_iter_next(&sub1);
dbus->message_iter_next(&sub1);
dbus->message_iter_next(&sub1);
if (!IBus_EnterVariant(conn, &sub1, dbus, &sub2, "IBusAttrList", sizeof("IBusAttrList"))) {
return SDL_FALSE;
}
dbus->message_iter_next(&sub2);
dbus->message_iter_next(&sub2);
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_ARRAY) {
return SDL_FALSE;
}
dbus->message_iter_recurse(&sub2, &array);
while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_VARIANT) {
DBusMessageIter sub;
if (IBus_EnterVariant(conn, &array, dbus, &sub, "IBusAttribute", sizeof("IBusAttribute"))) {
Uint32 type;
dbus->message_iter_next(&sub);
dbus->message_iter_next(&sub);
/* From here on, the structure looks like this: */
/* Uint32 type: 1=underline, 2=foreground, 3=background */
/* Uint32 value: for underline it's 0=NONE, 1=SINGLE, 2=DOUBLE, */
/* 3=LOW, 4=ERROR */
/* for foreground and background it's a color */
/* Uint32 start_index: starting position for the style (utf8-char) */
/* Uint32 end_index: end position for the style (utf8-char) */
dbus->message_iter_get_basic(&sub, &type);
/* We only use the background type to determine the selection */
if (type == 3) {
Uint32 start = -1;
dbus->message_iter_next(&sub);
dbus->message_iter_next(&sub);
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32) {
dbus->message_iter_get_basic(&sub, &start);
dbus->message_iter_next(&sub);
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32) {
dbus->message_iter_get_basic(&sub, end_pos);
*start_pos = start;
return SDL_TRUE;
}
}
}
}
dbus->message_iter_next(&array);
}
return SDL_FALSE;
}
static const char *
IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus)
{
/* The text we need is nested weirdly, use dbus-monitor to see the structure better */
const char *text = NULL;
const char *struct_id = NULL;
DBusMessageIter sub1, sub2;
DBusMessageIter sub;
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) {
if (!IBus_EnterVariant(conn, iter, dbus, &sub, "IBusText", sizeof("IBusText"))) {
return NULL;
}
dbus->message_iter_recurse(iter, &sub1);
if (dbus->message_iter_get_arg_type(&sub1) != DBUS_TYPE_STRUCT) {
dbus->message_iter_next(&sub);
dbus->message_iter_next(&sub);
if (dbus->message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
return NULL;
}
dbus->message_iter_recurse(&sub1, &sub2);
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_STRING) {
return NULL;
}
dbus->message_iter_get_basic(&sub2, &struct_id);
if (!struct_id || SDL_strncmp(struct_id, "IBusText", sizeof("IBusText")) != 0) {
return NULL;
}
dbus->message_iter_next(&sub2);
dbus->message_iter_next(&sub2);
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_STRING) {
return NULL;
}
dbus->message_iter_get_basic(&sub2, &text);
dbus->message_iter_get_basic(&sub, &text);
return text;
}
static SDL_bool
IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
Uint32 *pos)
{
dbus->message_iter_next(iter);
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) {
return SDL_FALSE;
}
dbus->message_iter_get_basic(iter, pos);
return SDL_TRUE;
}
static DBusHandlerResult
IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
{
SDL_DBusContext *dbus = (SDL_DBusContext *)user_data;
if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "CommitText")) {
DBusMessageIter iter;
const char *text;
dbus->message_iter_init(msg, &iter);
text = IBus_GetVariantText(conn, &iter, dbus);
if (text && *text) {
char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
while (i < text_bytes) {
size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
SDL_SendKeyboardText(buf);
i += sz;
}
}
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "UpdatePreeditText")) {
DBusMessageIter iter;
const char *text;
dbus->message_iter_init(msg, &iter);
text = IBus_GetVariantText(conn, &iter, dbus);
if (text) {
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
size_t cursor = 0;
do {
const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
const size_t chars = SDL_utf8strlen(buf);
SDL_SendEditingText(buf, cursor, chars);
i += sz;
cursor += chars;
} while (i < text_bytes);
if (text) {
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE)) {
Uint32 pos, start_pos, end_pos;
SDL_bool has_pos = SDL_FALSE;
SDL_bool has_dec_pos = SDL_FALSE;
dbus->message_iter_init(msg, &iter);
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
if (!has_dec_pos)
{
dbus->message_iter_init(msg, &iter);
has_pos = IBus_GetVariantCursorPos(conn, &iter, dbus, &pos);
}
if(has_dec_pos) {
SDL_SendEditingText(text, start_pos, end_pos - start_pos);
} else if (has_pos) {
SDL_SendEditingText(text, pos, -1);
} else {
SDL_SendEditingText(text, -1, -1);
}
} else {
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
size_t text_bytes = SDL_strlen(text), i = 0;
size_t cursor = 0;
do {
const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
const size_t chars = SDL_utf8strlen(buf);
SDL_SendEditingText(buf, cursor, chars);
i += sz;
cursor += chars;
} while (i < text_bytes);
}
}
SDL_IBus_UpdateTextRect(NULL);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "HidePreeditText")) {
SDL_SendEditingText("", 0, 0);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -503,15 +614,20 @@ SDL_IBus_Reset(void)
}
SDL_bool
SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode)
SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
Uint32 result = 0;
SDL_DBusContext *dbus = SDL_DBus_GetContext();
if (IBus_CheckConnection(dbus)) {
Uint32 mods = IBus_ModState();
Uint32 ibus_keycode = keycode - 8;
if (state == SDL_RELEASED) {
mods |= (1 << 30); // IBUS_RELEASE_MASK
}
if (!SDL_DBus_CallMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, "ProcessKeyEvent",
DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &mods, DBUS_TYPE_INVALID,
DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &ibus_keycode, DBUS_TYPE_UINT32, &mods, DBUS_TYPE_INVALID,
DBUS_TYPE_BOOLEAN, &result, DBUS_TYPE_INVALID)) {
result = 0;
}

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -41,7 +41,7 @@ extern void SDL_IBus_Reset(void);
/* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to
update its candidate list or change input methods. PumpEvents should be
called some time after this, to recieve the TextInput / TextEditing event back. */
extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode);
extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
/* Update the position of IBus' candidate list. If rect is NULL then this will
just reposition it relative to the focused window's new position. */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -27,7 +27,7 @@ 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)(void);
typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32);
typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32, Uint8 state);
typedef void (*_SDL_IME_UpdateTextRect)(SDL_Rect *);
typedef void (*_SDL_IME_PumpEvents)(void);
@@ -127,10 +127,10 @@ SDL_IME_Reset(void)
}
SDL_bool
SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode)
SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
if (SDL_IME_ProcessKeyEvent_Real)
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode);
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, state);
return SDL_FALSE;
}

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -31,7 +31,7 @@ extern SDL_bool SDL_IME_Init(void);
extern void SDL_IME_Quit(void);
extern void SDL_IME_SetFocus(SDL_bool focused);
extern void SDL_IME_Reset(void);
extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode);
extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern void SDL_IME_UpdateTextRect(SDL_Rect *rect);
extern void SDL_IME_PumpEvents(void);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -394,6 +394,7 @@ typedef struct {
unsigned int text_len;
keysym_t composebuffer[2];
unsigned char composelen;
int type;
} SDL_WSCONS_input_data;
static SDL_WSCONS_input_data* inputs[4] = {NULL, NULL, NULL, NULL};
@@ -432,6 +433,7 @@ static SDL_WSCONS_input_data* SDL_WSCONS_Init_Keyboard(const char* dev)
RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GETLEDS, &input->ledstate));
input->origledstate = input->ledstate;
RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GETENCODING, &input->encoding));
RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GTYPE, &input->type));
#ifdef WSKBDIO_SETVERSION
RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_SETVERSION, &version));
#endif
@@ -725,7 +727,12 @@ static void updateKeyboard(SDL_WSCONS_input_data* input)
}
break;
}
Translate_to_keycode(input, type, events[i].value);
if (input->type == WSKBD_TYPE_USB && events[i].value <= 0xE7)
SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)events[i].value);
else
Translate_to_keycode(input, type, events[i].value);
if (type == WSCONS_EVENT_KEY_UP) continue;
if (IS_ALTGR_MODE && !IS_CONTROL_HELD)

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -25,78 +25,76 @@
Andrey Vasilkin, 2016.
*/
#define INCL_DOSMODULEMGR /* Module Manager values */
#define INCL_DOSERRORS /* Error values */
#define INCL_DOSMODULEMGR /* Module Manager */
#define INCL_DOSERRORS /* Error values */
#include <os2.h>
#include "geniconv.h"
/*#define DEBUG*/
#ifdef DEBUG
# include <stdio.h>
# define debug(s,...) printf(__func__"(): "##s"\n" ,##__VA_ARGS__)
# define iconv_debug(s,...) printf(__func__"(): "##s"\n" ,##__VA_ARGS__)
#else
# define debug(s,...) do {} while (0)
# define iconv_debug(s,...) do {} while (0)
#endif
/* Exports from os2iconv.c */
extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode);
extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
size_t *inbytesleft, char* * outbuf,
size_t *outbytesleft);
extern int _System os2_iconv_close(iconv_t cd);
extern iconv_t _System os2_iconv_open (const char* tocode, const char* fromcode);
extern size_t _System os2_iconv (iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
extern int _System os2_iconv_close (iconv_t cd);
/* Functions pointers types */
typedef iconv_t _System (*FNICONV_OPEN)(const char* tocode, const char* fromcode);
typedef size_t _System (*FNICONV)(iconv_t cd, char* * inbuf,
size_t *inbytesleft, char* * outbuf,
size_t *outbytesleft);
typedef int _System (*FNICONV_CLOSE)(iconv_t cd);
/* Used DLL module handle */
static HMODULE hmIconv = NULLHANDLE;
/* Functions pointers */
static FNICONV_OPEN fn_iconv_open = NULL;
static FNICONV fn_iconv = NULL;
static FNICONV_CLOSE fn_iconv_close = NULL;
typedef iconv_t (_System *FNICONV_OPEN)(const char*, const char*);
typedef size_t (_System *FNICONV) (iconv_t, char **, size_t *, char **, size_t *);
typedef int (_System *FNICONV_CLOSE)(iconv_t);
static HMODULE hmIconv = NULLHANDLE;
static FNICONV_OPEN fn_iconv_open = os2_iconv_open;
static FNICONV fn_iconv = os2_iconv;
static FNICONV_CLOSE fn_iconv_close = os2_iconv_close;
static int geniconv_init = 0;
static BOOL _loadDLL(PSZ pszName, PSZ pszIconvOpen, PSZ pszIconv,
PSZ pszIconvClose)
static BOOL _loadDLL(const char *dllname,
const char *sym_iconvopen,
const char *sym_iconv,
const char *sym_iconvclose)
{
ULONG ulRC;
CHAR acError[256];
ULONG rc;
char error[256];
ulRC = DosLoadModule(acError, sizeof(acError), pszName, &hmIconv);
if (ulRC != NO_ERROR) {
debug("DLL not loaded: %s", &acError);
rc = DosLoadModule(error, sizeof(error), dllname, &hmIconv);
if (rc != NO_ERROR) {
iconv_debug("DLL %s not loaded: %s", dllname, error);
return FALSE;
}
do {
ulRC = DosQueryProcAddr(hmIconv, 0, pszIconvOpen, (PFN *)&fn_iconv_open);
if (ulRC != NO_ERROR) {
debug("Error: cannot find entry %s in %s", pszIconvOpen, pszName);
break;
}
rc = DosQueryProcAddr(hmIconv, 0, sym_iconvopen, (PFN *)&fn_iconv_open);
if (rc != NO_ERROR) {
iconv_debug("Error: cannot find entry %s in %s", sym_iconvopen, dllname);
goto fail;
}
ulRC = DosQueryProcAddr(hmIconv, 0, pszIconv, (PFN *)&fn_iconv);
if (ulRC != NO_ERROR) {
debug("Error: cannot find entry %s in %s", pszIconv, pszName);
break;
}
rc = DosQueryProcAddr(hmIconv, 0, sym_iconv, (PFN *)&fn_iconv);
if (rc != NO_ERROR) {
iconv_debug("Error: cannot find entry %s in %s", sym_iconv, dllname);
goto fail;
}
ulRC = DosQueryProcAddr(hmIconv, 0, pszIconvClose, (PFN *)&fn_iconv_close);
if (ulRC != NO_ERROR) {
debug("Error: cannot find entry %s in %s", pszIconvClose, pszName);
break;
}
rc = DosQueryProcAddr(hmIconv, 0, sym_iconvclose, (PFN *)&fn_iconv_close);
if (rc != NO_ERROR) {
iconv_debug("Error: cannot find entry %s in %s", sym_iconvclose, dllname);
goto fail;
}
debug("DLL %s used", pszName);
return TRUE;
} while (FALSE);
iconv_debug("DLL %s used", dllname);
return TRUE;
fail:
DosFreeModule(hmIconv);
hmIconv = NULLHANDLE;
return FALSE;
@@ -104,15 +102,18 @@ static BOOL _loadDLL(PSZ pszName, PSZ pszIconvOpen, PSZ pszIconv,
static void _init(void)
{
if (fn_iconv_open != NULL) /* Already was initialized */
return;
if (geniconv_init) {
return; /* Already initialized */
}
geniconv_init = 1;
/* Try to load kiconv.dll, iconv2.dll or iconv.dll */
if (!_loadDLL("KICONV", "_libiconv_open", "_libiconv", "_libiconv_close") &&
!_loadDLL("ICONV2", "_libiconv_open", "_libiconv", "_libiconv_close") &&
!_loadDLL("ICONV", "_iconv_open", "_iconv", "_iconv_close") ) {
/* No DLL was loaded - use OS/2 conversion objects API */
debug("Uni*() API used");
iconv_debug("Uni*() API used");
fn_iconv_open = os2_iconv_open;
fn_iconv = os2_iconv;
fn_iconv_close = os2_iconv_close;
@@ -124,16 +125,19 @@ static void _init(void)
* ----------------
*/
/* Non-standard function for iconv to unload the used dynamic library */
/* function to unload the used iconv dynamic library */
void libiconv_clean(void)
{
geniconv_init = 0;
/* reset the function pointers. */
fn_iconv_open = os2_iconv_open;
fn_iconv = os2_iconv;
fn_iconv_close = os2_iconv_close;
if (hmIconv != NULLHANDLE) {
DosFreeModule(hmIconv);
hmIconv = NULLHANDLE;
fn_iconv_open = NULL;
fn_iconv = NULL;
fn_iconv_close = NULL;
}
}

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -58,27 +58,27 @@ size_t libiconv (iconv_t cd, char **inbuf, size_t *inbytesleft,
/* System codepage <-> UTF-8
*
* StrUTF8()
* Coverts string from system cp to UTF-8 (fToUTF8 is not 0) or from UTF-8 to
* the system cp (fToUTF8 is 0). Converted ASCIIZ string will be placed at the
* buffer pcDst, up to cbDst - 1 (for sys->utf8) or 2 (for utf8->sys) bytes.
* Returns the number of bytes written into pcDst, not counting the terminating
* Converts string from system cp to UTF-8 (to_utf8 is not 0) or from UTF-8 to
* the system cp (to_utf8 is 0). Converted ASCIIZ string will be placed at the
* buffer dst, up to c_dst - 1 (for sys->utf8) or 2 (for utf8->sys) bytes.
* Returns the number of bytes written into dst, not counting the terminating
* 0 byte(s) or -1 on error.
*/
int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc);
int StrUTF8(int to_utf8, char *dst, int c_dst, char *src, int c_src);
/* StrUTF8New()
* Coverts string from system cp to UTF-8 (fToUTF8 is not 0) or from UTF-8 to
* the system cp (fToUTF8 is 0). Memory for the new string is obtained by
* Converts string from system cp to UTF-8 (to_utf8 is not 0) or from UTF-8
* to the system cp (to_utf8 is 0). Memory for the new string is obtained by
* using libc malloc().
* Returns converted string, terminating two bytes 0 is appended to the result.
* Returns null on error.
*/
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr);
char *StrUTF8New(int to_utf8, char *str, int c_str);
/* StrUTF8Free()
* Deallocates the memory block located by StrUTF8New() (just libc free()).
* Deallocates the memory block allocated by StrUTF8New() (just libc free()).
*/
void StrUTF8Free(char *pszStr);
void StrUTF8Free(char *str);
#endif /* GENICONV_H */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -315,30 +315,30 @@ char *os2cpToName(unsigned long cp)
if (cp == SYSTEM_CP) {
ULONG aulCP[3];
ULONG cCP;
if (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)
if (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR) {
return NULL;
}
cp = aulCP[0];
}
if (aCP2Name[0].ulCode > cp || aCP2Name[ulHi].ulCode < cp)
if (aCP2Name[0].ulCode > cp || aCP2Name[ulHi].ulCode < cp) {
return NULL;
if (aCP2Name[0].ulCode == cp)
}
if (aCP2Name[0].ulCode == cp) {
return aCP2Name[0].pszName;
if (aCP2Name[ulHi].ulCode == cp)
}
if (aCP2Name[ulHi].ulCode == cp) {
return aCP2Name[ulHi].pszName;
}
while ((ulHi - ulLo) > 1) {
ulNext = (ulLo + ulHi) / 2;
if (aCP2Name[ulNext].ulCode < cp)
if (aCP2Name[ulNext].ulCode < cp) {
ulLo = ulNext;
else if (aCP2Name[ulNext].ulCode > cp)
} else if (aCP2Name[ulNext].ulCode > cp) {
ulHi = ulNext;
else {
} else {
lFound = ulNext;
break;
}
@@ -360,46 +360,51 @@ unsigned long os2cpFromName(char *cp)
if (cp == NULL) {
ULONG aulCP[3];
ULONG cCP;
return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0];
}
while (SDL_isspace(*cp))
while (SDL_isspace((unsigned char) *cp)) {
cp++;
}
pcEnd = SDL_strchr(cp, ' ');
if (pcEnd == NULL)
if (pcEnd == NULL) {
pcEnd = SDL_strchr(cp, '\0');
}
ulNext = pcEnd - cp;
if (ulNext >= sizeof(acBuf))
if (ulNext >= sizeof(acBuf)) {
return 0;
}
SDL_memcpy(acBuf, cp, ulNext);
acBuf[ulNext] = '\0';
SDL_strupr(acBuf);
lCmp = SDL_strcmp(aName2CP[0].pszName, acBuf);
if (lCmp > 0)
if (lCmp > 0) {
return 0;
else if (lCmp == 0)
}
if (lCmp == 0) {
return aName2CP[0].ulCode;
}
lCmp = SDL_strcmp(aName2CP[ulHi].pszName, acBuf);
if (lCmp < 0)
if (lCmp < 0) {
return 0;
else if (lCmp == 0)
}
if (lCmp == 0) {
return aName2CP[ulHi].ulCode;
}
while ((ulHi - ulLo) > 1) {
ulNext = (ulLo + ulHi) / 2;
lCmp = SDL_strcmp(aName2CP[ulNext].pszName, acBuf);
if (lCmp < 0)
if (lCmp < 0) {
ulLo = ulNext;
else if (lCmp > 0)
} else if (lCmp > 0) {
ulHi = ulNext;
else {
} else {
lFound = ulNext;
break;
}

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -73,7 +73,8 @@ static int _createUconvObj(const char *code, UconvObject *uobj)
{
UniChar uc_code[MAX_CP_NAME_LEN];
int i;
const char *ch = code;
const unsigned char *ch =
(const unsigned char *)code;
if (code == NULL)
uc_code[0] = 0;
@@ -102,27 +103,28 @@ static int uconv_open(const char *code, UconvObject *uobj)
if (rc != ULS_SUCCESS) {
unsigned long cp = os2cpFromName((char *)code);
char cp_name[16];
if (cp != 0 && SDL_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);
}
}
return rc;
}
extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
{
UconvObject uo_tocode;
UconvObject uo_fromcode;
int rc;
iuconv_obj *iuobj;
if (tocode == NULL)
if (tocode == NULL) {
tocode = "";
if (fromcode == NULL)
}
if (fromcode == NULL) {
fromcode = "";
}
if (SDL_strcasecmp(tocode, fromcode) != 0) {
rc = uconv_open(fromcode, &uo_fromcode);
@@ -130,7 +132,6 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
errno = EINVAL;
return (iconv_t)(-1);
}
rc = uconv_open(tocode, &uo_tocode);
if (rc != ULS_SUCCESS) {
UniFreeUconvObject(uo_fromcode);
@@ -154,9 +155,9 @@ extern iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
return iuobj;
}
extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
size_t *inbytesleft,
char* * outbuf, size_t *outbytesleft)
size_t _System os2_iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft ,
char **outbuf, size_t *outbytesleft)
{
UconvObject uo_tocode = ((iuconv_obj *)(cd))->uo_tocode;
UconvObject uo_fromcode = ((iuconv_obj *)(cd))->uo_fromcode;
@@ -182,12 +183,12 @@ extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
DosRequestMutexSem(((iuconv_obj *)(cd))->hMtx, SEM_INDEFINITE_WAIT);
#endif
if (uo_tocode && uo_fromcode &&
(((iuconv_obj *)cd)->buf_len >> 1) < *inbytesleft) {
if (((iuconv_obj *)cd)->buf != NULL)
if (uo_tocode && uo_fromcode && (((iuconv_obj *)cd)->buf_len >> 1) < *inbytesleft) {
if (((iuconv_obj *)cd)->buf != NULL) {
SDL_free(((iuconv_obj *)cd)->buf);
}
((iuconv_obj *)cd)->buf_len = *inbytesleft << 1;
((iuconv_obj *)cd)->buf = (UniChar *)SDL_malloc(((iuconv_obj *)cd)->buf_len);
((iuconv_obj *)cd)->buf = (UniChar *) SDL_malloc(((iuconv_obj *)cd)->buf_len);
}
if (uo_fromcode) {
@@ -204,8 +205,9 @@ extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
rc = UniUconvToUcs(uo_fromcode, (void **)inbuf, inbytesleft,
uc_str, uc_str_len, &nonIdenticalConv);
uc_buf_len = uc_buf_len << 1;
if (!uo_tocode)
if (!uo_tocode) {
*outbytesleft = uc_buf_len;
}
if (rc != ULS_SUCCESS) {
errno = EILSEQ;
@@ -215,8 +217,9 @@ extern size_t _System os2_iconv(iconv_t cd, char* * inbuf,
goto done;
}
if (!uo_tocode)
if (!uo_tocode) {
return nonIdenticalConv;
}
uc_buf = ((iuconv_obj *)cd)->buf;
uc_buf_len = ((iuconv_obj *)cd)->buf_len - uc_buf_len;
@@ -265,14 +268,16 @@ int _System os2_iconv_close(iconv_t cd)
#ifdef ICONV_THREAD_SAFE
DosCloseMutexSem(((iuconv_obj *)cd)->hMtx);
#endif
if (((iuconv_obj *)cd)->uo_tocode != NULL)
if (((iuconv_obj *)cd)->uo_tocode != NULL) {
UniFreeUconvObject(((iuconv_obj *)cd)->uo_tocode);
if (((iuconv_obj *)cd)->uo_fromcode != NULL)
}
if (((iuconv_obj *)cd)->uo_fromcode != NULL) {
UniFreeUconvObject(((iuconv_obj *)cd)->uo_fromcode);
}
if (((iuconv_obj *)cd)->buf != NULL)
if (((iuconv_obj *)cd)->buf != NULL) {
SDL_free(((iuconv_obj *)cd)->buf);
}
SDL_free(cd);
return 0;

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -30,40 +30,42 @@
#define SDL_free free
#endif
int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
int StrUTF8(int to_utf8, char *dst, int c_dst, char *src, int c_src)
{
size_t rc;
char *pcDstStart = pcDst;
char *dststart = dst;
iconv_t cd;
char *pszToCP, *pszFromCP;
int fError = 0;
char *tocp, *fromcp;
int err = 0;
if (cbDst < 4)
if (c_dst < 4) {
return -1;
if (fToUTF8) {
pszToCP = "UTF-8";
pszFromCP = "";
} else {
pszToCP = "";
pszFromCP = "UTF-8";
}
cd = iconv_open(pszToCP, pszFromCP);
if (cd == (iconv_t)-1)
return -1;
if (to_utf8) {
tocp = "UTF-8";
fromcp = "";
} else {
tocp = "";
fromcp = "UTF-8";
}
while (cbSrc > 0) {
rc = iconv(cd, &pcSrc, (size_t *)&cbSrc, &pcDst, (size_t *)&cbDst);
cd = iconv_open(tocp, fromcp);
if (cd == (iconv_t)-1) {
return -1;
}
while (c_src > 0) {
rc = iconv(cd, &src, (size_t *)&c_src, &dst, (size_t *)&c_dst);
if (rc == (size_t)-1) {
if (errno == EILSEQ) {
/* Try to skip invalid character */
pcSrc++;
cbSrc--;
src++;
c_src--;
continue;
}
fError = 1;
err = 1;
break;
}
}
@@ -71,45 +73,47 @@ int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
iconv_close(cd);
/* Write trailing ZERO (1 byte for UTF-8, 2 bytes for the system cp) */
if (fToUTF8) {
if (cbDst < 1) {
pcDst--;
fError = 1; /* The destination buffer overflow */
if (to_utf8) {
if (c_dst < 1) {
dst--;
err = 1; /* The destination buffer overflow */
}
*pcDst = '\0';
*dst = '\0';
} else {
if (cbDst < 2) {
pcDst -= (cbDst == 0)? 2 : 1;
fError = 1; /* The destination buffer overflow */
if (c_dst < 2) {
dst -= (c_dst == 0) ? 2 : 1;
err = 1; /* The destination buffer overflow */
}
*((short *)pcDst) = '\0';
*((short *)dst) = '\0';
}
return (fError) ? -1 : (pcDst - pcDstStart);
return (err) ? -1 : (dst - dststart);
}
char *StrUTF8New(int fToUTF8, char *pcStr, int cbStr)
char *StrUTF8New(int to_utf8, char *str, int c_str)
{
int cbNewStr = (((cbStr > 4)? cbStr : 4) + 1) * 2;
char *pszNewStr = (char *) SDL_malloc(cbNewStr);
int c_newstr = (((c_str > 4) ? c_str : 4) + 1) * 2;
char * newstr = (char *) SDL_malloc(c_newstr);
if (pszNewStr == NULL)
if (newstr == NULL) {
return NULL;
cbNewStr = StrUTF8(fToUTF8, pszNewStr, cbNewStr, pcStr, cbStr);
if (cbNewStr != -1) {
pcStr = (char *) SDL_realloc(pszNewStr, cbNewStr + ((fToUTF8)? 1 : sizeof(short)));
if (pcStr)
return pcStr;
}
SDL_free(pszNewStr);
c_newstr = StrUTF8(to_utf8, newstr, c_newstr, str, c_str);
if (c_newstr != -1) {
str = (char *) SDL_realloc(newstr, c_newstr + ((to_utf8) ? 1 : sizeof(short)));
if (str) {
return str;
}
}
SDL_free(newstr);
return NULL;
}
void StrUTF8Free(char *pszStr)
void StrUTF8Free(char *str)
{
SDL_free(pszStr);
SDL_free(str);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -27,8 +27,6 @@
HidD_GetString_t SDL_HidD_GetManufacturerString;
HidD_GetString_t SDL_HidD_GetProductString;
HidD_GetPreparsedData_t SDL_HidD_GetPreparsedData;
HidD_FreePreparsedData_t SDL_HidD_FreePreparsedData;
HidP_GetCaps_t SDL_HidP_GetCaps;
HidP_GetButtonCaps_t SDL_HidP_GetButtonCaps;
HidP_GetValueCaps_t SDL_HidP_GetValueCaps;
@@ -58,15 +56,13 @@ WIN_LoadHIDDLL(void)
SDL_HidD_GetManufacturerString = (HidD_GetString_t)GetProcAddress(s_pHIDDLL, "HidD_GetManufacturerString");
SDL_HidD_GetProductString = (HidD_GetString_t)GetProcAddress(s_pHIDDLL, "HidD_GetProductString");
SDL_HidD_GetPreparsedData = (HidD_GetPreparsedData_t)GetProcAddress(s_pHIDDLL, "HidD_GetPreparsedData");
SDL_HidD_FreePreparsedData = (HidD_FreePreparsedData_t)GetProcAddress(s_pHIDDLL, "HidD_FreePreparsedData");
SDL_HidP_GetCaps = (HidP_GetCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetCaps");
SDL_HidP_GetButtonCaps = (HidP_GetButtonCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetButtonCaps");
SDL_HidP_GetValueCaps = (HidP_GetValueCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetValueCaps");
SDL_HidP_MaxDataListLength = (HidP_MaxDataListLength_t)GetProcAddress(s_pHIDDLL, "HidP_MaxDataListLength");
SDL_HidP_GetData = (HidP_GetData_t)GetProcAddress(s_pHIDDLL, "HidP_GetData");
if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString || !SDL_HidD_GetPreparsedData ||
!SDL_HidD_FreePreparsedData || !SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString ||
!SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
!SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) {
WIN_UnloadHIDDLL();
return -1;

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -183,8 +183,6 @@ extern int WIN_LoadHIDDLL(void);
extern void WIN_UnloadHIDDLL(void);
typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);
typedef BOOLEAN (WINAPI *HidD_GetPreparsedData_t)(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData);
typedef BOOLEAN (WINAPI *HidD_FreePreparsedData_t)(PHIDP_PREPARSED_DATA PreparsedData);
typedef NTSTATUS (WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities);
typedef NTSTATUS (WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
typedef NTSTATUS (WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
@@ -193,8 +191,6 @@ typedef NTSTATUS (WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DAT
extern HidD_GetString_t SDL_HidD_GetManufacturerString;
extern HidD_GetString_t SDL_HidD_GetProductString;
extern HidD_GetPreparsedData_t SDL_HidD_GetPreparsedData;
extern HidD_FreePreparsedData_t SDL_HidD_FreePreparsedData;
extern HidP_GetCaps_t SDL_HidP_GetCaps;
extern HidP_GetButtonCaps_t SDL_HidP_GetButtonCaps;
extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps;

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -25,7 +25,15 @@
#include "SDL_windows.h"
#include "SDL_error.h"
#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */
#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */
#if defined(HAVE_ROAPI_H)
#include <roapi.h> /* For RoInitialize/RoUninitialize (Win32 only) */
#else
typedef enum RO_INIT_TYPE {
RO_INIT_SINGLETHREADED = 0,
RO_INIT_MULTITHREADED = 1
} RO_INIT_TYPE;
#endif
#ifndef _WIN32_WINNT_VISTA
#define _WIN32_WINNT_VISTA 0x0600
@@ -37,6 +45,10 @@
#define _WIN32_WINNT_WIN8 0x0602
#endif
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
/* Sets an error message based on an HRESULT */
int
@@ -108,6 +120,65 @@ WIN_CoUninitialize(void)
#endif
}
#ifndef __WINRT__
void *
WIN_LoadComBaseFunction(const char *name)
{
static SDL_bool s_bLoaded;
static HMODULE s_hComBase;
if (!s_bLoaded) {
s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
s_bLoaded = SDL_TRUE;
}
if (s_hComBase) {
return GetProcAddress(s_hComBase, name);
} else {
return NULL;
}
}
#endif
HRESULT
WIN_RoInitialize(void)
{
#ifdef __WINRT__
return S_OK;
#else
typedef HRESULT (WINAPI *RoInitialize_t)(RO_INIT_TYPE initType);
RoInitialize_t RoInitializeFunc = (RoInitialize_t)WIN_LoadComBaseFunction("RoInitialize");
if (RoInitializeFunc) {
/* RO_INIT_SINGLETHREADED is equivalent to COINIT_APARTMENTTHREADED */
HRESULT hr = RoInitializeFunc(RO_INIT_SINGLETHREADED);
if (hr == RPC_E_CHANGED_MODE) {
hr = RoInitializeFunc(RO_INIT_MULTITHREADED);
}
/* S_FALSE means success, but someone else already initialized. */
/* You still need to call RoUninitialize in this case! */
if (hr == S_FALSE) {
return S_OK;
}
return hr;
} else {
return E_NOINTERFACE;
}
#endif
}
void
WIN_RoUninitialize(void)
{
#ifndef __WINRT__
typedef void (WINAPI *RoUninitialize_t)(void);
RoUninitialize_t RoUninitializeFunc = (RoUninitialize_t)WIN_LoadComBaseFunction("RoUninitialize");
if (RoUninitializeFunc) {
RoUninitializeFunc();
}
#endif
}
#ifndef __WINRT__
static BOOL
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -30,8 +30,14 @@
#ifndef UNICODE
#define UNICODE 1
#endif
#undef WINVER
#define WINVER 0x0501
#undef _WIN32_WINNT
#if !defined(SDL_VIDEO_RENDER_D3D12)
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
#else
#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */
#endif
#endif
#include <windows.h>
@@ -63,10 +69,19 @@ extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
/* Sets an error message based on GetLastError(). Always return -1. */
extern int WIN_SetError(const char *prefix);
#if !defined(__WINRT__)
/* Load a function from combase.dll */
void *WIN_LoadComBaseFunction(const char *name);
#endif
/* Wrap up the oddities of CoInitialize() into a common function. */
extern HRESULT WIN_CoInitialize(void);
extern void WIN_CoUninitialize(void);
/* Wrap up the oddities of RoInitialize() into a common function. */
extern HRESULT WIN_RoInitialize(void);
extern void WIN_RoUninitialize(void);
/* Returns SDL_TRUE if we're running on Windows Vista and newer */
extern BOOL WIN_IsWindowsVistaOrGreater(void);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -23,8 +23,6 @@
#include "SDL_xinput.h"
#ifdef HAVE_XINPUT_H
XInputGetState_t SDL_XInputGetState = NULL;
XInputSetState_t SDL_XInputSetState = NULL;
XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL;
@@ -137,6 +135,5 @@ WIN_UnloadXInputDLL(void)
}
#endif /* __WINRT__ */
#endif /* HAVE_XINPUT_H */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -23,10 +23,11 @@
#ifndef SDL_xinput_h_
#define SDL_xinput_h_
#ifdef HAVE_XINPUT_H
#include "SDL_windows.h"
#ifdef HAVE_XINPUT_H
#include <xinput.h>
#endif /* HAVE_XINPUT_H */
#ifndef XUSER_MAX_COUNT
#define XUSER_MAX_COUNT 4
@@ -72,6 +73,53 @@
#define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
#endif
#ifndef XINPUT_FLAG_GAMEPAD
#define XINPUT_FLAG_GAMEPAD 0x01
#endif
#ifndef XINPUT_GAMEPAD_DPAD_UP
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
#endif
#ifndef XINPUT_GAMEPAD_DPAD_DOWN
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
#endif
#ifndef XINPUT_GAMEPAD_DPAD_LEFT
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
#endif
#ifndef XINPUT_GAMEPAD_DPAD_RIGHT
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
#endif
#ifndef XINPUT_GAMEPAD_START
#define XINPUT_GAMEPAD_START 0x0010
#endif
#ifndef XINPUT_GAMEPAD_BACK
#define XINPUT_GAMEPAD_BACK 0x0020
#endif
#ifndef XINPUT_GAMEPAD_LEFT_THUMB
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
#endif
#ifndef XINPUT_GAMEPAD_RIGHT_THUMB
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
#endif
#ifndef XINPUT_GAMEPAD_LEFT_SHOULDER
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
#endif
#ifndef XINPUT_GAMEPAD_RIGHT_SHOULDER
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
#endif
#ifndef XINPUT_GAMEPAD_A
#define XINPUT_GAMEPAD_A 0x1000
#endif
#ifndef XINPUT_GAMEPAD_B
#define XINPUT_GAMEPAD_B 0x2000
#endif
#ifndef XINPUT_GAMEPAD_X
#define XINPUT_GAMEPAD_X 0x4000
#endif
#ifndef XINPUT_GAMEPAD_Y
#define XINPUT_GAMEPAD_Y 0x8000
#endif
#ifndef XINPUT_GAMEPAD_GUIDE
#define XINPUT_GAMEPAD_GUIDE 0x0400
#endif
@@ -129,6 +177,36 @@ typedef struct
BYTE BatteryLevel;
} XINPUT_BATTERY_INFORMATION_EX;
#ifndef HAVE_XINPUT_H
typedef struct
{
WORD wButtons;
BYTE bLeftTrigger;
BYTE bRightTrigger;
SHORT sThumbLX;
SHORT sThumbLY;
SHORT sThumbRX;
SHORT sThumbRY;
} XINPUT_GAMEPAD;
typedef struct
{
WORD wLeftMotorSpeed;
WORD wRightMotorSpeed;
} XINPUT_VIBRATION;
typedef struct
{
BYTE Type;
BYTE SubType;
WORD Flags;
XINPUT_GAMEPAD Gamepad;
XINPUT_VIBRATION Vibration;
} XINPUT_CAPABILITIES;
#endif /* HAVE_XINPUT_H */
/* Forward decl's for XInput API's we load dynamically and use if available */
typedef DWORD (WINAPI *XInputGetState_t)
(
@@ -170,8 +248,6 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities
#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation
#endif /* HAVE_XINPUT_H */
#endif /* SDL_xinput_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -115,7 +115,7 @@ SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAs
// Make sure we have a valid XAML element (to draw onto):
if ( ! backgroundPanelAsIInspectable) {
return SDL_SetError("'backgroundPanelAsIInspectable' can't be NULL");
return SDL_InvalidParamError("backgroundPanelAsIInspectable");
}
Platform::Object ^ backgroundPanel = reinterpret_cast<Object ^>((IInspectable *) backgroundPanelAsIInspectable);

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages