mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-05 07:09:32 +00:00
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
88
src/SDL.c
88
src/SDL.c
@@ -24,17 +24,17 @@
|
||||
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
|
||||
#include "core/windows/SDL_windows.h"
|
||||
#elif !defined(SDL_PLATFORM_WINRT)
|
||||
#include <unistd.h> /* _exit(), etc. */
|
||||
#include <unistd.h> // _exit(), etc.
|
||||
#endif
|
||||
|
||||
/* this checks for HAVE_DBUS_DBUS_H internally. */
|
||||
// this checks for HAVE_DBUS_DBUS_H internally.
|
||||
#include "core/linux/SDL_dbus.h"
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
/* Initialization code for SDL */
|
||||
// Initialization code for SDL
|
||||
|
||||
#include "SDL_assert_c.h"
|
||||
#include "SDL_hints_c.h"
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
#define SDL_INIT_EVERYTHING ~0U
|
||||
|
||||
/* Initialization/Cleanup routines */
|
||||
// Initialization/Cleanup routines
|
||||
#include "timer/SDL_timer_c.h"
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
extern int SDL_HelperWindowCreate(void);
|
||||
@@ -72,7 +72,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
|
||||
SDL_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
|
||||
#endif
|
||||
|
||||
/* Limited by its encoding in SDL_VERSIONNUM */
|
||||
// Limited by its encoding in SDL_VERSIONNUM
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 10);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0);
|
||||
@@ -95,19 +95,19 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode)
|
||||
ExitProcess here that will never be reached but make MingW happy. */
|
||||
ExitProcess(exitcode);
|
||||
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
|
||||
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
||||
emscripten_force_exit(exitcode); /* this should "kill" the app. */
|
||||
emscripten_cancel_main_loop(); // this should "kill" the app.
|
||||
emscripten_force_exit(exitcode); // this should "kill" the app.
|
||||
exit(exitcode);
|
||||
#elif defined(SDL_PLATFORM_HAIKU) /* Haiku has _Exit, but it's not marked noreturn. */
|
||||
#elif defined(SDL_PLATFORM_HAIKU) // Haiku has _Exit, but it's not marked noreturn.
|
||||
_exit(exitcode);
|
||||
#elif defined(HAVE__EXIT) /* Upper case _Exit() */
|
||||
#elif defined(HAVE__EXIT) // Upper case _Exit()
|
||||
_Exit(exitcode);
|
||||
#else
|
||||
_exit(exitcode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* App metadata */
|
||||
// App metadata
|
||||
|
||||
int SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier)
|
||||
{
|
||||
@@ -171,7 +171,7 @@ const char *SDL_GetAppMetadataProperty(const char *name)
|
||||
}
|
||||
|
||||
|
||||
/* The initialized subsystems */
|
||||
// The initialized subsystems
|
||||
#ifdef SDL_MAIN_NEEDED
|
||||
static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
||||
#else
|
||||
@@ -180,7 +180,7 @@ static SDL_bool SDL_MainIsReady = SDL_TRUE;
|
||||
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
||||
static Uint8 SDL_SubsystemRefCount[32];
|
||||
|
||||
/* Private helper to increment a subsystem's ref counter. */
|
||||
// Private helper to increment a subsystem's ref counter.
|
||||
static void SDL_IncrementSubsystemRefCount(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
@@ -190,7 +190,7 @@ static void SDL_IncrementSubsystemRefCount(Uint32 subsystem)
|
||||
}
|
||||
}
|
||||
|
||||
/* Private helper to decrement a subsystem's ref counter. */
|
||||
// Private helper to decrement a subsystem's ref counter.
|
||||
static void SDL_DecrementSubsystemRefCount(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
@@ -203,7 +203,7 @@ static void SDL_DecrementSubsystemRefCount(Uint32 subsystem)
|
||||
}
|
||||
}
|
||||
|
||||
/* Private helper to check if a system needs init. */
|
||||
// Private helper to check if a system needs init.
|
||||
static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
@@ -211,7 +211,7 @@ static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
||||
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0));
|
||||
}
|
||||
|
||||
/* Private helper to check if a system needs to be quit. */
|
||||
// Private helper to check if a system needs to be quit.
|
||||
static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
||||
{
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
@@ -246,7 +246,7 @@ void SDL_SetMainReady(void)
|
||||
SDL_MainIsReady = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Initialize all the subsystems that require initialization before threads start */
|
||||
// Initialize all the subsystems that require initialization before threads start
|
||||
void SDL_InitMainThread(void)
|
||||
{
|
||||
SDL_InitTLSData();
|
||||
@@ -290,7 +290,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the event subsystem */
|
||||
// Initialize the event subsystem
|
||||
if (flags & SDL_INIT_EVENTS) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
@@ -304,7 +304,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
flags_initialized |= SDL_INIT_EVENTS;
|
||||
}
|
||||
|
||||
/* Initialize the timer subsystem */
|
||||
// Initialize the timer subsystem
|
||||
if (flags & SDL_INIT_TIMER) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_TIMER)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_TIMER);
|
||||
@@ -318,11 +318,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
flags_initialized |= SDL_INIT_TIMER;
|
||||
}
|
||||
|
||||
/* Initialize the video subsystem */
|
||||
// Initialize the video subsystem
|
||||
if (flags & SDL_INIT_VIDEO) {
|
||||
#ifndef SDL_VIDEO_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
||||
/* video implies events */
|
||||
// video implies events
|
||||
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
@@ -342,11 +342,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the audio subsystem */
|
||||
// Initialize the audio subsystem
|
||||
if (flags & SDL_INIT_AUDIO) {
|
||||
#ifndef SDL_AUDIO_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
||||
/* audio implies events */
|
||||
// audio implies events
|
||||
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
@@ -366,11 +366,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the joystick subsystem */
|
||||
// Initialize the joystick subsystem
|
||||
if (flags & SDL_INIT_JOYSTICK) {
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
/* joystick implies events */
|
||||
// joystick implies events
|
||||
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_GAMEPAD) {
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
/* game controller implies joystick */
|
||||
// game controller implies joystick
|
||||
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the haptic subsystem */
|
||||
// Initialize the haptic subsystem
|
||||
if (flags & SDL_INIT_HAPTIC) {
|
||||
#ifndef SDL_HAPTIC_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
||||
@@ -432,7 +432,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the sensor subsystem */
|
||||
// Initialize the sensor subsystem
|
||||
if (flags & SDL_INIT_SENSOR) {
|
||||
#ifndef SDL_SENSOR_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
||||
@@ -451,11 +451,11 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize the camera subsystem */
|
||||
// Initialize the camera subsystem
|
||||
if (flags & SDL_INIT_CAMERA) {
|
||||
#ifndef SDL_CAMERA_DISABLED
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_CAMERA)) {
|
||||
/* camera implies events */
|
||||
// camera implies events
|
||||
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
||||
goto quit_and_error;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
(void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
||||
(void)flags_initialized; // make static analysis happy, since this only gets used in error cases.
|
||||
|
||||
return SDL_ClearError();
|
||||
|
||||
@@ -491,13 +491,13 @@ int SDL_Init(SDL_InitFlags flags)
|
||||
|
||||
void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
{
|
||||
/* Shut down requested initialized subsystems */
|
||||
// Shut down requested initialized subsystems
|
||||
|
||||
#ifndef SDL_CAMERA_DISABLED
|
||||
if (flags & SDL_INIT_CAMERA) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_CAMERA)) {
|
||||
SDL_QuitCamera();
|
||||
/* camera implies events */
|
||||
// camera implies events
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_CAMERA);
|
||||
@@ -517,7 +517,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_GAMEPAD) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_GAMEPAD)) {
|
||||
SDL_QuitGamepads();
|
||||
/* game controller implies joystick */
|
||||
// game controller implies joystick
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
||||
@@ -526,7 +526,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_JOYSTICK) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||
SDL_QuitJoysticks();
|
||||
/* joystick implies events */
|
||||
// joystick implies events
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
||||
@@ -546,7 +546,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_AUDIO) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_AUDIO)) {
|
||||
SDL_QuitAudio();
|
||||
/* audio implies events */
|
||||
// audio implies events
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO);
|
||||
@@ -558,7 +558,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
||||
SDL_QuitRender();
|
||||
SDL_VideoQuit();
|
||||
/* video implies events */
|
||||
// video implies events
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
@@ -586,7 +586,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags)
|
||||
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
|
||||
Uint32 initialized = 0;
|
||||
|
||||
/* Fast path for checking one flag */
|
||||
// Fast path for checking one flag
|
||||
if (SDL_HasExactlyOneBitSet32(flags)) {
|
||||
int subsystem_index = SDL_MostSignificantBitIndex32(flags);
|
||||
return SDL_SubsystemRefCount[subsystem_index] ? flags : 0;
|
||||
@@ -598,7 +598,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags)
|
||||
|
||||
num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
|
||||
|
||||
/* Iterate over each bit in flags, and check the matching subsystem. */
|
||||
// Iterate over each bit in flags, and check the matching subsystem.
|
||||
for (i = 0; i < num_subsystems; ++i) {
|
||||
if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
|
||||
initialized |= (1 << i);
|
||||
@@ -614,7 +614,7 @@ void SDL_Quit(void)
|
||||
{
|
||||
SDL_bInMainQuit = SDL_TRUE;
|
||||
|
||||
/* Quit all subsystems */
|
||||
// Quit all subsystems
|
||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||
SDL_HelperWindowDestroy();
|
||||
#endif
|
||||
@@ -641,13 +641,13 @@ void SDL_Quit(void)
|
||||
SDL_bInMainQuit = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Get the library version number */
|
||||
// Get the library version number
|
||||
int SDL_GetVersion(void)
|
||||
{
|
||||
return SDL_VERSION;
|
||||
}
|
||||
|
||||
/* Get the library source revision */
|
||||
// Get the library source revision
|
||||
const char *SDL_GetRevision(void)
|
||||
{
|
||||
return SDL_REVISION;
|
||||
@@ -739,7 +739,7 @@ SDL_bool SDL_IsTablet(void)
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
|
||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||
/* FIXME: Still need to include DllMain() on Watcom C ? */
|
||||
// FIXME: Still need to include DllMain() on Watcom C ?
|
||||
|
||||
BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
@@ -752,6 +752,6 @@ BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_rea
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* Building DLL */
|
||||
#endif // Building DLL
|
||||
|
||||
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */
|
||||
#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
|
||||
// older Emscriptens don't have this, but we need to for wasm64 compatibility.
|
||||
#ifndef MAIN_THREAD_EM_ASM_PTR
|
||||
#ifdef __wasm64__
|
||||
#error You need to upgrade your Emscripten compiler to support wasm64
|
||||
@@ -45,7 +45,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The size of the stack buffer to use for rendering assert messages. */
|
||||
// The size of the stack buffer to use for rendering assert messages.
|
||||
#define SDL_MAX_ASSERT_MESSAGE_STACK 256
|
||||
|
||||
static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, void *userdata);
|
||||
@@ -80,7 +80,7 @@ static void SDL_AddAssertionToReport(SDL_AssertData *data)
|
||||
/* (data) is always a static struct defined with the assert macros, so
|
||||
we don't have to worry about copying or allocating them. */
|
||||
data->trigger_count++;
|
||||
if (data->trigger_count == 1) { /* not yet added? */
|
||||
if (data->trigger_count == 1) { // not yet added?
|
||||
data->next = triggered_assertions;
|
||||
triggered_assertions = data;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ static void SDL_GenerateAssertionReport(void)
|
||||
{
|
||||
const SDL_AssertData *item = triggered_assertions;
|
||||
|
||||
/* only do this if the app hasn't assigned an assertion handler. */
|
||||
// only do this if the app hasn't assigned an assertion handler.
|
||||
if ((item) && (assertion_handler != SDL_PromptAssertion)) {
|
||||
debug_print("\n\nSDL assertion report.\n");
|
||||
debug_print("All SDL assertions between last init/quit:\n\n");
|
||||
@@ -168,12 +168,12 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
size_t buf_len = sizeof(stack_buf);
|
||||
int len;
|
||||
|
||||
(void)userdata; /* unused in default handler. */
|
||||
(void)userdata; // unused in default handler.
|
||||
|
||||
/* Assume the output will fit... */
|
||||
// Assume the output will fit...
|
||||
len = SDL_RenderAssertMessage(message, buf_len, data);
|
||||
|
||||
/* .. and if it didn't, try to allocate as much room as we actually need. */
|
||||
// .. and if it didn't, try to allocate as much room as we actually need.
|
||||
if (len >= (int)buf_len) {
|
||||
if (SDL_size_add_overflow(len, 1, &buf_len) == 0) {
|
||||
message = (char *)SDL_malloc(buf_len);
|
||||
@@ -185,7 +185,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
}
|
||||
}
|
||||
|
||||
/* Something went very wrong */
|
||||
// Something went very wrong
|
||||
if (len < 0) {
|
||||
if (message != stack_buf) {
|
||||
SDL_free(message);
|
||||
@@ -195,7 +195,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
|
||||
debug_print("\n\n%s\n\n", message);
|
||||
|
||||
/* let env. variable override, so unit tests won't block in a GUI. */
|
||||
// let env. variable override, so unit tests won't block in a GUI.
|
||||
const char *hint = SDL_GetHint(SDL_HINT_ASSERT);
|
||||
if (hint) {
|
||||
if (message != stack_buf) {
|
||||
@@ -213,23 +213,23 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
} else if (SDL_strcmp(hint, "always_ignore") == 0) {
|
||||
return SDL_ASSERTION_ALWAYS_IGNORE;
|
||||
} else {
|
||||
return SDL_ASSERTION_ABORT; /* oh well. */
|
||||
return SDL_ASSERTION_ABORT; // oh well.
|
||||
}
|
||||
}
|
||||
|
||||
/* Leave fullscreen mode, if possible (scary!) */
|
||||
// Leave fullscreen mode, if possible (scary!)
|
||||
window = SDL_GetToplevelForKeyboardFocus();
|
||||
if (window) {
|
||||
if (window->fullscreen_exclusive) {
|
||||
SDL_MinimizeWindow(window);
|
||||
} else {
|
||||
/* !!! FIXME: ungrab the input if we're not fullscreen? */
|
||||
/* No need to mess with the window */
|
||||
// !!! FIXME: ungrab the input if we're not fullscreen?
|
||||
// No need to mess with the window
|
||||
window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Show a messagebox if we can, otherwise fall back to stdio */
|
||||
// Show a messagebox if we can, otherwise fall back to stdio
|
||||
SDL_zero(messagebox);
|
||||
messagebox.flags = SDL_MESSAGEBOX_WARNING;
|
||||
messagebox.window = window;
|
||||
@@ -246,10 +246,10 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
}
|
||||
} else {
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
/* This is nasty, but we can't block on a custom UI. */
|
||||
// This is nasty, but we can't block on a custom UI.
|
||||
for (;;) {
|
||||
SDL_bool okay = SDL_TRUE;
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
|
||||
var str =
|
||||
UTF8ToString($0) + '\n\n' +
|
||||
@@ -260,11 +260,11 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
}
|
||||
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
|
||||
}, message);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
if (SDL_strcmp(buf, "a") == 0) {
|
||||
state = SDL_ASSERTION_ABORT;
|
||||
#if 0 /* (currently) no break functionality on Emscripten */
|
||||
#if 0 // (currently) no break functionality on Emscripten
|
||||
} else if (SDL_strcmp(buf, "b") == 0) {
|
||||
state = SDL_ASSERTION_BREAK;
|
||||
#endif
|
||||
@@ -277,14 +277,14 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
} else {
|
||||
okay = SDL_FALSE;
|
||||
}
|
||||
free(buf); /* This should NOT be SDL_free() */
|
||||
free(buf); // This should NOT be SDL_free()
|
||||
|
||||
if (okay) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#elif defined(HAVE_STDIO_H)
|
||||
/* this is a little hacky. */
|
||||
// this is a little hacky.
|
||||
for (;;) {
|
||||
char buf[32];
|
||||
(void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||
@@ -310,10 +310,10 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_STDIO_H */
|
||||
#endif // HAVE_STDIO_H
|
||||
}
|
||||
|
||||
/* Re-enter fullscreen mode */
|
||||
// Re-enter fullscreen mode
|
||||
if (window) {
|
||||
SDL_RestoreWindow(window);
|
||||
}
|
||||
@@ -333,19 +333,19 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons
|
||||
#ifndef SDL_THREADS_DISABLED
|
||||
static SDL_SpinLock spinlock = 0;
|
||||
SDL_LockSpinlock(&spinlock);
|
||||
if (!assertion_mutex) { /* never called SDL_Init()? */
|
||||
if (!assertion_mutex) { // never called SDL_Init()?
|
||||
assertion_mutex = SDL_CreateMutex();
|
||||
if (!assertion_mutex) {
|
||||
SDL_UnlockSpinlock(&spinlock);
|
||||
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
|
||||
return SDL_ASSERTION_IGNORE; // oh well, I guess.
|
||||
}
|
||||
}
|
||||
SDL_UnlockSpinlock(&spinlock);
|
||||
|
||||
SDL_LockMutex(assertion_mutex);
|
||||
#endif /* !SDL_THREADS_DISABLED */
|
||||
#endif // !SDL_THREADS_DISABLED
|
||||
|
||||
/* doing this because Visual C is upset over assigning in the macro. */
|
||||
// doing this because Visual C is upset over assigning in the macro.
|
||||
if (data->trigger_count == 0) {
|
||||
data->function = func;
|
||||
data->filename = file;
|
||||
@@ -355,13 +355,13 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons
|
||||
SDL_AddAssertionToReport(data);
|
||||
|
||||
assertion_running++;
|
||||
if (assertion_running > 1) { /* assert during assert! Abort. */
|
||||
if (assertion_running > 1) { // assert during assert! Abort.
|
||||
if (assertion_running == 2) {
|
||||
SDL_AbortAssertion();
|
||||
} else if (assertion_running == 3) { /* Abort asserted! */
|
||||
} else if (assertion_running == 3) { // Abort asserted!
|
||||
SDL_ExitProcess(42);
|
||||
} else {
|
||||
while (1) { /* do nothing but spin; what else can you do?! */
|
||||
while (1) { // do nothing but spin; what else can you do?!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,11 +379,11 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons
|
||||
case SDL_ASSERTION_IGNORE:
|
||||
case SDL_ASSERTION_RETRY:
|
||||
case SDL_ASSERTION_BREAK:
|
||||
break; /* macro handles these. */
|
||||
break; // macro handles these.
|
||||
|
||||
case SDL_ASSERTION_ABORT:
|
||||
SDL_AbortAssertion();
|
||||
/*break; ...shouldn't return, but oh well. */
|
||||
// break; ...shouldn't return, but oh well.
|
||||
}
|
||||
|
||||
assertion_running--;
|
||||
@@ -405,7 +405,7 @@ void SDL_AssertionsQuit(void)
|
||||
assertion_mutex = NULL;
|
||||
}
|
||||
#endif
|
||||
#endif /* SDL_ASSERT_LEVEL > 0 */
|
||||
#endif // SDL_ASSERT_LEVEL > 0
|
||||
}
|
||||
|
||||
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
|
||||
extern void SDL_AssertionsQuit(void);
|
||||
|
||||
#endif /* SDL_assert_c_h_ */
|
||||
#endif // SDL_assert_c_h_
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Simple error handling in SDL */
|
||||
// Simple error handling in SDL
|
||||
|
||||
#include "SDL_error_c.h"
|
||||
|
||||
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
/* Ignore call if invalid format pointer was passed */
|
||||
// Ignore call if invalid format pointer was passed
|
||||
if (fmt) {
|
||||
va_list ap;
|
||||
int result;
|
||||
@@ -51,7 +51,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
}
|
||||
|
||||
if (SDL_GetLogPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
|
||||
/* If we are in debug mode, print out the error message */
|
||||
// If we are in debug mode, print out the error message
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef struct SDL_error
|
||||
SDL_free_func free_func;
|
||||
} SDL_error;
|
||||
|
||||
/* Defined in SDL_thread.c */
|
||||
// Defined in SDL_thread.c
|
||||
extern SDL_error *SDL_GetErrBuf(SDL_bool create);
|
||||
|
||||
#endif /* SDL_error_c_h_ */
|
||||
#endif // SDL_error_c_h_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* convert the guid to a printable string */
|
||||
// convert the guid to a printable string
|
||||
void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
|
||||
{
|
||||
static const char k_rgchHexToASCII[] = "0123456789abcdef";
|
||||
@@ -31,8 +31,8 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(guid.data) && i < (cbGUID - 1) / 2; i++) {
|
||||
/* each input byte writes 2 ascii chars, and might write a null byte. */
|
||||
/* If we don't have room for next input byte, stop */
|
||||
// each input byte writes 2 ascii chars, and might write a null byte.
|
||||
// If we don't have room for next input byte, stop
|
||||
unsigned char c = guid.data[i];
|
||||
|
||||
*pszGUID++ = k_rgchHexToASCII[c >> 4];
|
||||
@@ -60,12 +60,12 @@ static unsigned char nibble(unsigned char c)
|
||||
return c - 'a' + 0x0a;
|
||||
}
|
||||
|
||||
/* received an invalid character, and no real way to return an error */
|
||||
/* AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c); */
|
||||
// received an invalid character, and no real way to return an error
|
||||
// AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* convert the string version of a guid to the struct */
|
||||
// convert the string version of a guid to the struct
|
||||
SDL_GUID SDL_StringToGUID(const char *pchGUID)
|
||||
{
|
||||
SDL_GUID guid;
|
||||
@@ -74,7 +74,7 @@ SDL_GUID SDL_StringToGUID(const char *pchGUID)
|
||||
Uint8 *p;
|
||||
size_t i;
|
||||
|
||||
/* Make sure it's even */
|
||||
// Make sure it's even
|
||||
len = (len) & ~0x1;
|
||||
|
||||
SDL_memset(&guid, 0x00, sizeof(guid));
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef SDL_hashtable_h_
|
||||
#define SDL_hashtable_h_
|
||||
|
||||
/* this is not (currently) a public API. But maybe it should be! */
|
||||
// this is not (currently) a public API. But maybe it should be!
|
||||
|
||||
struct SDL_HashTable;
|
||||
typedef struct SDL_HashTable SDL_HashTable;
|
||||
@@ -57,4 +57,4 @@ extern SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused);
|
||||
|
||||
extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused);
|
||||
|
||||
#endif /* SDL_hashtable_h_ */
|
||||
#endif // SDL_hashtable_h_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file defines useful function for working with SDL hints */
|
||||
// This file defines useful function for working with SDL hints
|
||||
|
||||
#ifndef SDL_hints_c_h_
|
||||
#define SDL_hints_c_h_
|
||||
@@ -30,4 +30,4 @@ extern SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value);
|
||||
extern int SDL_GetStringInteger(const char *value, int default_value);
|
||||
extern void SDL_QuitHints(void);
|
||||
|
||||
#endif /* SDL_hints_c_h_ */
|
||||
#endif // SDL_hints_c_h_
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
#ifndef SDL_internal_h_
|
||||
#define SDL_internal_h_
|
||||
|
||||
/* Many of SDL's features require _GNU_SOURCE on various platforms */
|
||||
// Many of SDL's features require _GNU_SOURCE on various platforms
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
/* Need this so Linux systems define fseek64o, ftell64o and off64_t */
|
||||
// Need this so Linux systems define fseek64o, ftell64o and off64_t
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
@@ -44,11 +44,11 @@
|
||||
#define HAVE_GCC_DIAGNOSTIC_PRAGMA 1
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER /* We use constant comparison for generated code */
|
||||
#ifdef _MSC_VER // We use constant comparison for generated code
|
||||
#pragma warning(disable : 6326)
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER /* SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe */
|
||||
#ifdef _MSC_VER // SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe
|
||||
#pragma warning(disable : 6255)
|
||||
#endif
|
||||
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
#ifdef SDL_PLATFORM_APPLE
|
||||
#ifndef _DARWIN_C_SOURCE
|
||||
#define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */
|
||||
#define _DARWIN_C_SOURCE 1 // for memset_pattern4()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
#include <float.h>
|
||||
#endif
|
||||
|
||||
/* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */
|
||||
// If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC
|
||||
#ifndef HAVE_O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
@@ -192,7 +192,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef SDL_RENDER_DISABLED
|
||||
/* define the not defined ones as 0 */
|
||||
// define the not defined ones as 0
|
||||
#ifndef SDL_VIDEO_RENDER_D3D
|
||||
#define SDL_VIDEO_RENDER_D3D 0
|
||||
#endif
|
||||
@@ -223,7 +223,7 @@
|
||||
#ifndef SDL_VIDEO_RENDER_VULKAN
|
||||
#define SDL_VIDEO_RENDER_VULKAN 0
|
||||
#endif
|
||||
#else /* define all as 0 */
|
||||
#else // define all as 0
|
||||
#undef SDL_VIDEO_RENDER_SW
|
||||
#define SDL_VIDEO_RENDER_SW 0
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
@@ -246,7 +246,7 @@
|
||||
#define SDL_VIDEO_RENDER_VITA_GXM 0
|
||||
#undef SDL_VIDEO_RENDER_VULKAN
|
||||
#define SDL_VIDEO_RENDER_VULKAN 0
|
||||
#endif /* SDL_RENDER_DISABLED */
|
||||
#endif // SDL_RENDER_DISABLED
|
||||
|
||||
#define SDL_HAS_RENDER_DRIVER \
|
||||
(SDL_VIDEO_RENDER_SW | \
|
||||
@@ -276,17 +276,17 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_intrin.h>
|
||||
|
||||
#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */
|
||||
#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "SDL_utils_c.h"
|
||||
|
||||
/* Do any initialization that needs to happen before threads are started */
|
||||
// Do any initialization that needs to happen before threads are started
|
||||
extern void SDL_InitMainThread(void);
|
||||
|
||||
/* The internal implementations of these functions have up to nanosecond precision.
|
||||
@@ -296,9 +296,9 @@ extern int SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeout
|
||||
extern int SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS);
|
||||
extern SDL_bool SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_internal_h_ */
|
||||
#endif // SDL_internal_h_
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "./SDL_list.h"
|
||||
|
||||
/* Push */
|
||||
// Push
|
||||
int SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode *node = (SDL_ListNode *)SDL_malloc(sizeof(*node));
|
||||
@@ -37,12 +37,12 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Pop from end as a FIFO (if add with SDL_ListAdd) */
|
||||
// Pop from end as a FIFO (if add with SDL_ListAdd)
|
||||
void SDL_ListPop(SDL_ListNode **head, void **ent)
|
||||
{
|
||||
SDL_ListNode **ptr = head;
|
||||
|
||||
/* Invalid or empty */
|
||||
// Invalid or empty
|
||||
if (!head || !*head) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,4 +33,4 @@ void SDL_ListPop(SDL_ListNode **head, void **ent);
|
||||
void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
||||
void SDL_ListClear(SDL_ListNode **head);
|
||||
|
||||
#endif /* SDL_list_h_ */
|
||||
#endif // SDL_list_h_
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
/* Simple log messages in SDL */
|
||||
// Simple log messages in SDL
|
||||
|
||||
#include "SDL_log_c.h"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include "stdlib/SDL_vacopy.h"
|
||||
|
||||
/* The size of the stack buffer to use for rendering log messages. */
|
||||
// The size of the stack buffer to use for rendering log messages.
|
||||
#define SDL_MAX_LOG_MESSAGE_STACK 256
|
||||
|
||||
#define DEFAULT_CATEGORY -1
|
||||
@@ -51,7 +51,7 @@ typedef struct SDL_LogLevel
|
||||
} SDL_LogLevel;
|
||||
|
||||
|
||||
/* The default log output function */
|
||||
// The default log output function
|
||||
static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message);
|
||||
|
||||
static void SDL_ResetLogPrefixes(void);
|
||||
@@ -68,7 +68,7 @@ static SDL_Mutex *log_function_mutex = NULL;
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
/* If this list changes, update the documentation for SDL_HINT_LOGGING */
|
||||
// If this list changes, update the documentation for SDL_HINT_LOGGING
|
||||
static const char * const SDL_priority_names[] = {
|
||||
NULL,
|
||||
"VERBOSE",
|
||||
@@ -82,7 +82,7 @@ SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL
|
||||
|
||||
static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES];
|
||||
|
||||
/* If this list changes, update the documentation for SDL_HINT_LOGGING */
|
||||
// If this list changes, update the documentation for SDL_HINT_LOGGING
|
||||
static const char * const SDL_category_names[] = {
|
||||
"APP",
|
||||
"ERROR",
|
||||
@@ -110,12 +110,12 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_FATAL
|
||||
};
|
||||
#endif /* SDL_PLATFORM_ANDROID */
|
||||
#endif // SDL_PLATFORM_ANDROID
|
||||
|
||||
void SDL_InitLog(void)
|
||||
{
|
||||
if (!log_function_mutex) {
|
||||
/* if this fails we'll try to continue without it. */
|
||||
// if this fails we'll try to continue without it.
|
||||
log_function_mutex = SDL_CreateMutex();
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ void SDL_SetLogPriority(int category, SDL_LogPriority priority)
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new entry */
|
||||
// Create a new entry
|
||||
entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
|
||||
if (entry) {
|
||||
entry->category = category;
|
||||
@@ -194,7 +194,7 @@ static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogP
|
||||
if (SDL_isdigit(*string)) {
|
||||
i = SDL_atoi(string);
|
||||
if (i == 0) {
|
||||
/* 0 has a special meaning of "disable this category" */
|
||||
// 0 has a special meaning of "disable this category"
|
||||
*priority = SDL_NUM_LOG_PRIORITIES;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ static const char *GetCategoryPrefix(int category)
|
||||
}
|
||||
return "CUSTOM";
|
||||
}
|
||||
#endif /* SDL_PLATFORM_ANDROID */
|
||||
#endif // SDL_PLATFORM_ANDROID
|
||||
|
||||
void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
|
||||
{
|
||||
@@ -449,27 +449,27 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
int len;
|
||||
va_list aq;
|
||||
|
||||
/* Nothing to do if we don't have an output function */
|
||||
// Nothing to do if we don't have an output function
|
||||
if (!SDL_log_function) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure we don't exceed array bounds */
|
||||
// Make sure we don't exceed array bounds
|
||||
if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* See if we want to do anything with this message */
|
||||
// See if we want to do anything with this message
|
||||
if (priority < SDL_GetLogPriority(category)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!log_function_mutex) {
|
||||
/* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */
|
||||
// this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first!
|
||||
log_function_mutex = SDL_CreateMutex();
|
||||
}
|
||||
|
||||
/* Render into stack buffer */
|
||||
// Render into stack buffer
|
||||
va_copy(aq, ap);
|
||||
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
|
||||
va_end(aq);
|
||||
@@ -478,9 +478,9 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
return;
|
||||
}
|
||||
|
||||
/* If message truncated, allocate and re-render */
|
||||
// If message truncated, allocate and re-render
|
||||
if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) {
|
||||
/* Allocate exactly what we need, including the zero-terminator */
|
||||
// Allocate exactly what we need, including the zero-terminator
|
||||
message = (char *)SDL_malloc(len_plus_term);
|
||||
if (!message) {
|
||||
return;
|
||||
@@ -492,10 +492,10 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
message = stack_buf;
|
||||
}
|
||||
|
||||
/* Chop off final endline. */
|
||||
// Chop off final endline.
|
||||
if ((len > 0) && (message[len - 1] == '\n')) {
|
||||
message[--len] = '\0';
|
||||
if ((len > 0) && (message[len - 1] == '\r')) { /* catch "\r\n", too. */
|
||||
if ((len > 0) && (message[len - 1] == '\r')) { // catch "\r\n", too.
|
||||
message[--len] = '\0';
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
SDL_log_function(SDL_log_userdata, category, priority, message);
|
||||
SDL_UnlockMutex(log_function_mutex);
|
||||
|
||||
/* Free only if dynamically allocated */
|
||||
// Free only if dynamically allocated
|
||||
if (message != stack_buf) {
|
||||
SDL_free(message);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ enum {
|
||||
CONSOLE_ATTACHED_ERROR = -1,
|
||||
} consoleAttached = CONSOLE_UNATTACHED;
|
||||
|
||||
/* Handle to stderr output of console. */
|
||||
// Handle to stderr output of console.
|
||||
static HANDLE stderrHandle = NULL;
|
||||
#endif
|
||||
|
||||
@@ -527,8 +527,8 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
const char *message)
|
||||
{
|
||||
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)
|
||||
/* Way too many allocations here, urgh */
|
||||
/* Note: One can't call SDL_SetError here, since that function itself logs. */
|
||||
// Way too many allocations here, urgh
|
||||
// Note: One can't call SDL_SetError here, since that function itself logs.
|
||||
{
|
||||
char *output;
|
||||
size_t length;
|
||||
@@ -543,27 +543,27 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
DWORD charsWritten;
|
||||
#endif
|
||||
|
||||
/* Maybe attach console and get stderr handle */
|
||||
// Maybe attach console and get stderr handle
|
||||
if (consoleAttached == CONSOLE_UNATTACHED) {
|
||||
attachResult = AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
if (!attachResult) {
|
||||
attachError = GetLastError();
|
||||
if (attachError == ERROR_INVALID_HANDLE) {
|
||||
/* This is expected when running from Visual Studio */
|
||||
/*OutputDebugString(TEXT("Parent process has no console\r\n"));*/
|
||||
// This is expected when running from Visual Studio
|
||||
// OutputDebugString(TEXT("Parent process has no console\r\n"));
|
||||
consoleAttached = CONSOLE_ATTACHED_MSVC;
|
||||
} else if (attachError == ERROR_GEN_FAILURE) {
|
||||
OutputDebugString(TEXT("Could not attach to console of parent process\r\n"));
|
||||
consoleAttached = CONSOLE_ATTACHED_ERROR;
|
||||
} else if (attachError == ERROR_ACCESS_DENIED) {
|
||||
/* Already attached */
|
||||
// Already attached
|
||||
consoleAttached = CONSOLE_ATTACHED_CONSOLE;
|
||||
} else {
|
||||
OutputDebugString(TEXT("Error attaching console\r\n"));
|
||||
consoleAttached = CONSOLE_ATTACHED_ERROR;
|
||||
}
|
||||
} else {
|
||||
/* Newly attached */
|
||||
// Newly attached
|
||||
consoleAttached = CONSOLE_ATTACHED_CONSOLE;
|
||||
}
|
||||
|
||||
@@ -571,12 +571,12 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
|
||||
|
||||
if (GetConsoleMode(stderrHandle, &consoleMode) == 0) {
|
||||
/* WriteConsole fails if the output is redirected to a file. Must use WriteFile instead. */
|
||||
// WriteConsole fails if the output is redirected to a file. Must use WriteFile instead.
|
||||
consoleAttached = CONSOLE_ATTACHED_FILE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */
|
||||
#endif // !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
||||
length = SDL_strlen(SDL_GetLogPriorityPrefix(priority)) + SDL_strlen(message) + 1 + 1 + 1;
|
||||
output = SDL_small_alloc(char, length, &isstack);
|
||||
(void)SDL_snprintf(output, length, "%s%s\r\n", SDL_GetLogPriorityPrefix(priority), message);
|
||||
@@ -584,18 +584,18 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
|
||||
|
||||
#if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
||||
/* When running in MSVC and using stdio, rely on forwarding of stderr to the debug stream */
|
||||
// When running in MSVC and using stdio, rely on forwarding of stderr to the debug stream
|
||||
if (consoleAttached != CONSOLE_ATTACHED_MSVC) {
|
||||
/* Output to debugger */
|
||||
// Output to debugger
|
||||
OutputDebugString(tstr);
|
||||
}
|
||||
#else
|
||||
/* Output to debugger */
|
||||
// Output to debugger
|
||||
OutputDebugString(tstr);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
||||
/* Screen output to stderr, if console was attached. */
|
||||
// Screen output to stderr, if console was attached.
|
||||
if (consoleAttached == CONSOLE_ATTACHED_CONSOLE) {
|
||||
if (!WriteConsole(stderrHandle, tstr, (DWORD)SDL_tcslen(tstr), &charsWritten, NULL)) {
|
||||
OutputDebugString(TEXT("Error calling WriteConsole\r\n"));
|
||||
@@ -609,7 +609,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
OutputDebugString(TEXT("Error calling WriteFile\r\n"));
|
||||
}
|
||||
}
|
||||
#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */
|
||||
#endif // !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK)
|
||||
|
||||
SDL_free(tstr);
|
||||
SDL_small_free(output, isstack);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This file defines useful function for working with SDL logging */
|
||||
// This file defines useful function for working with SDL logging
|
||||
|
||||
#ifndef SDL_log_c_h_
|
||||
#define SDL_log_c_h_
|
||||
@@ -28,4 +28,4 @@
|
||||
extern void SDL_InitLog(void);
|
||||
extern void SDL_QuitLog(void);
|
||||
|
||||
#endif /* SDL_log_c_h_ */
|
||||
#endif // SDL_log_c_h_
|
||||
|
||||
@@ -177,7 +177,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
|
||||
SDL_UnlockMutex(SDL_properties_lock);
|
||||
|
||||
if (inserted) {
|
||||
/* All done! */
|
||||
// All done!
|
||||
return props;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
|
||||
SDL_Property *dst_property;
|
||||
|
||||
if (src_property->cleanup) {
|
||||
/* Can't copy properties with cleanup functions, we don't know how to duplicate the data */
|
||||
// Can't copy properties with cleanup functions, we don't know how to duplicate the data
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Common utility functions that aren't in the public API */
|
||||
// Common utility functions that aren't in the public API
|
||||
|
||||
int SDL_powerof2(int x)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (x <= 0) {
|
||||
/* Return some sane value - we shouldn't hit this in our use cases */
|
||||
// Return some sane value - we shouldn't hit this in our use cases
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This trick works for 32-bit values */
|
||||
// This trick works for 32-bit values
|
||||
{
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_powerof2, sizeof(x) == sizeof(Uint32));
|
||||
}
|
||||
@@ -105,7 +105,7 @@ SDL_bool SDL_endswith(const char *string, const char *suffix)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Assume we can wrap SDL_AtomicInt values and cast to Uint32 */
|
||||
// Assume we can wrap SDL_AtomicInt values and cast to Uint32
|
||||
SDL_COMPILE_TIME_ASSERT(sizeof_object_id, sizeof(int) == sizeof(Uint32));
|
||||
|
||||
Uint32 SDL_GetNextObjectID(void)
|
||||
@@ -165,7 +165,7 @@ SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
||||
void SDL_SetObjectsInvalid(void)
|
||||
{
|
||||
if (SDL_objects) {
|
||||
/* Log any leaked objects */
|
||||
// Log any leaked objects
|
||||
const void *object, *object_type;
|
||||
void *iter = NULL;
|
||||
while (SDL_IterateHashTable(SDL_objects, &object, &object_type, &iter)) {
|
||||
@@ -223,13 +223,13 @@ static int SDL_URIDecode(const char *src, char *dst, int len)
|
||||
}
|
||||
for (ri = 0, wi = 0, di = 0; ri < len && wi < len; ri += 1) {
|
||||
if (di == 0) {
|
||||
/* start decoding */
|
||||
// start decoding
|
||||
if (src[ri] == '%') {
|
||||
decode = '\0';
|
||||
di += 1;
|
||||
continue;
|
||||
}
|
||||
/* normal write */
|
||||
// normal write
|
||||
dst[wi] = src[ri];
|
||||
wi += 1;
|
||||
} else if (di == 1 || di == 2) {
|
||||
@@ -238,7 +238,7 @@ static int SDL_URIDecode(const char *src, char *dst, int len)
|
||||
char isA = src[ri] >= 'A' && src[ri] <= 'F';
|
||||
char isn = src[ri] >= '0' && src[ri] <= '9';
|
||||
if (!(isa || isA || isn)) {
|
||||
/* not a hexadecimal */
|
||||
// not a hexadecimal
|
||||
int sri;
|
||||
for (sri = ri - di; sri <= ri; sri += 1) {
|
||||
dst[wi] = src[sri];
|
||||
@@ -247,7 +247,7 @@ static int SDL_URIDecode(const char *src, char *dst, int len)
|
||||
di = 0;
|
||||
continue;
|
||||
}
|
||||
/* itsy bitsy magicsy */
|
||||
// itsy bitsy magicsy
|
||||
if (isn) {
|
||||
off = 0 - '0';
|
||||
} else if (isa) {
|
||||
@@ -272,14 +272,14 @@ static int SDL_URIDecode(const char *src, char *dst, int len)
|
||||
int SDL_URIToLocal(const char *src, char *dst)
|
||||
{
|
||||
if (SDL_memcmp(src, "file:/", 6) == 0) {
|
||||
src += 6; /* local file? */
|
||||
src += 6; // local file?
|
||||
} else if (SDL_strstr(src, ":/") != NULL) {
|
||||
return -1; /* wrong scheme */
|
||||
return -1; // wrong scheme
|
||||
}
|
||||
|
||||
SDL_bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/');
|
||||
|
||||
/* Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive. */
|
||||
// Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive.
|
||||
if (!local && src[0] == '/' && src[2] != '/') {
|
||||
char *hostname_end = SDL_strchr(src + 1, '/');
|
||||
if (hostname_end) {
|
||||
@@ -310,7 +310,7 @@ int SDL_URIToLocal(const char *src, char *dst)
|
||||
}
|
||||
|
||||
if (local) {
|
||||
/* Convert URI escape sequences to real characters */
|
||||
// Convert URI escape sequences to real characters
|
||||
if (src[0] == '/') {
|
||||
src++;
|
||||
} else {
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#ifndef SDL_utils_h_
|
||||
#define SDL_utils_h_
|
||||
|
||||
/* Common utility functions that aren't in the public API */
|
||||
// Common utility functions that aren't in the public API
|
||||
|
||||
/* Return the smallest power of 2 greater than or equal to 'x' */
|
||||
// Return the smallest power of 2 greater than or equal to 'x'
|
||||
extern int SDL_powerof2(int x);
|
||||
|
||||
extern void SDL_CalculateFraction(float x, int *numerator, int *denominator);
|
||||
@@ -67,4 +67,4 @@ extern void SDL_SetObjectsInvalid(void);
|
||||
|
||||
extern const char *SDL_GetPersistentString(const char *string);
|
||||
|
||||
#endif /* SDL_utils_h_ */
|
||||
#endif // SDL_utils_h_
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define HAVE_MSC_ATOMICS 1
|
||||
#endif
|
||||
|
||||
#ifdef SDL_PLATFORM_MACOS /* !!! FIXME: should we favor gcc atomics? */
|
||||
#ifdef SDL_PLATFORM_MACOS // !!! FIXME: should we favor gcc atomics?
|
||||
#include <libkern/OSAtomic.h>
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <atomic.h>
|
||||
#endif
|
||||
|
||||
/* The __atomic_load_n() intrinsic showed up in different times for different compilers. */
|
||||
// The __atomic_load_n() intrinsic showed up in different times for different compilers.
|
||||
#ifdef __clang__
|
||||
#if __has_builtin(__atomic_load_n) || defined(HAVE_GCC_ATOMICS)
|
||||
/* !!! FIXME: this advertises as available in the NDK but uses an external symbol we don't have.
|
||||
@@ -48,7 +48,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int));
|
||||
#define HAVE_WATCOM_ATOMICS
|
||||
@@ -74,8 +74,8 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
|
||||
value [eax] \
|
||||
modify exact [eax];
|
||||
|
||||
#endif /* __WATCOMC__ && __386__ */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#endif // __WATCOMC__ && __386__
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
/*
|
||||
If any of the operations are not provided then we must emulate some
|
||||
@@ -131,7 +131,7 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval)
|
||||
return _SDL_cmpxchg_watcom(&a->value, newval, oldval);
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
return __sync_bool_compare_and_swap(&a->value, oldval, newval);
|
||||
#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
|
||||
#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
||||
return OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value);
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
||||
@@ -159,9 +159,9 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval)
|
||||
return _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
return __sync_bool_compare_and_swap(a, oldval, newval);
|
||||
#elif defined(SDL_PLATFORM_MACOS) && defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
|
||||
#elif defined(SDL_PLATFORM_MACOS) && defined(__LP64__) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
||||
return OSAtomicCompareAndSwap64Barrier((int64_t)oldval, (int64_t)newval, (int64_t *)a);
|
||||
#elif defined(SDL_PLATFORM_MACOS) && !defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
|
||||
#elif defined(SDL_PLATFORM_MACOS) && !defined(__LP64__) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
||||
return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)a);
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
return (atomic_cas_ptr(a, oldval, newval) == oldval);
|
||||
@@ -254,7 +254,7 @@ int SDL_AtomicGet(SDL_AtomicInt *a)
|
||||
return _SDL_xadd_watcom(&a->value, 0);
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
return __sync_or_and_fetch(&a->value, 0);
|
||||
#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */
|
||||
#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
||||
return sizeof(a->value) == sizeof(uint32_t) ? OSAtomicOr32Barrier(0, (volatile uint32_t *)&a->value) : OSAtomicAdd64Barrier(0, (volatile int64_t *)&a->value);
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
return atomic_or_uint_nv((volatile uint_t *)&a->value, 0);
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <libkern/OSAtomic.h>
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
|
||||
extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
||||
@@ -53,10 +53,10 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
||||
parm [ecx] [eax] \
|
||||
value [eax] \
|
||||
modify exact [eax];
|
||||
#endif /* __WATCOMC__ && __386__ */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#endif // __WATCOMC__ && __386__
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
/* This function is where all the magic happens... */
|
||||
// This function is where all the magic happens...
|
||||
SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||
{
|
||||
#if defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
|
||||
@@ -116,15 +116,15 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||
return result == 0;
|
||||
|
||||
#elif defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
|
||||
/* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */
|
||||
// Maybe used for PowerPC, but the Intel asm or gcc atomics are favored.
|
||||
return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
|
||||
|
||||
#elif defined(SDL_PLATFORM_SOLARIS) && defined(_LP64)
|
||||
/* Used for Solaris with non-gcc compilers. */
|
||||
// Used for Solaris with non-gcc compilers.
|
||||
return ((int)atomic_cas_64((volatile uint64_t *)lock, 0, 1) == 0);
|
||||
|
||||
#elif defined(SDL_PLATFORM_SOLARIS) && !defined(_LP64)
|
||||
/* Used for Solaris with non-gcc compilers. */
|
||||
// Used for Solaris with non-gcc compilers.
|
||||
return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0);
|
||||
#elif defined(PS2)
|
||||
uint32_t oldintr;
|
||||
@@ -142,11 +142,11 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||
}
|
||||
return res;
|
||||
#else
|
||||
/* Terrible terrible damage */
|
||||
// Terrible terrible damage
|
||||
static SDL_Mutex *_spinlock_mutex;
|
||||
|
||||
if (!_spinlock_mutex) {
|
||||
/* Race condition on first lock... */
|
||||
// Race condition on first lock...
|
||||
_spinlock_mutex = SDL_CreateMutex();
|
||||
}
|
||||
SDL_LockMutex(_spinlock_mutex);
|
||||
@@ -164,13 +164,13 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
|
||||
void SDL_LockSpinlock(SDL_SpinLock *lock)
|
||||
{
|
||||
int iterations = 0;
|
||||
/* FIXME: Should we have an eventual timeout? */
|
||||
// FIXME: Should we have an eventual timeout?
|
||||
while (!SDL_TryLockSpinlock(lock)) {
|
||||
if (iterations < 32) {
|
||||
iterations++;
|
||||
SDL_CPUPauseInstruction();
|
||||
} else {
|
||||
/* !!! FIXME: this doesn't definitely give up the current timeslice, it does different things on various platforms. */
|
||||
// !!! FIXME: this doesn't definitely give up the current timeslice, it does different things on various platforms.
|
||||
SDL_Delay(0);
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ void SDL_UnlockSpinlock(SDL_SpinLock *lock)
|
||||
*lock = 0;
|
||||
|
||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||
/* Used for Solaris when not using gcc. */
|
||||
// Used for Solaris when not using gcc.
|
||||
*lock = 0;
|
||||
membar_producer();
|
||||
|
||||
|
||||
@@ -1722,7 +1722,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
||||
// uhoh, this device is undead, and just waiting to be cleaned up. Refuse explicit opens.
|
||||
SDL_SetError("Device was already lost and can't accept new opens");
|
||||
} else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
|
||||
/* SDL_calloc already called SDL_OutOfMemory */
|
||||
// SDL_calloc already called SDL_OutOfMemory
|
||||
} else if (OpenPhysicalAudioDevice(device, spec) < 0) { // if this is the first thing using this physical device, open at the OS level if necessary...
|
||||
SDL_free(logdev);
|
||||
} else {
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
|
||||
extern void SDL_UpdateAudio(void);
|
||||
|
||||
#endif /* SDL_audio_c_h_ */
|
||||
#endif // SDL_audio_c_h_
|
||||
|
||||
@@ -1055,7 +1055,7 @@ static void SDL_Convert71To61(float *dst, const float *src, int num_frames)
|
||||
|
||||
}
|
||||
|
||||
static const SDL_AudioChannelConverter channel_converters[8][8] = { /* [from][to] */
|
||||
static const SDL_AudioChannelConverter channel_converters[8][8] = { // [from][to]
|
||||
{ NULL, SDL_ConvertMonoToStereo, SDL_ConvertMonoTo21, SDL_ConvertMonoToQuad, SDL_ConvertMonoTo41, SDL_ConvertMonoTo51, SDL_ConvertMonoTo61, SDL_ConvertMonoTo71 },
|
||||
{ SDL_ConvertStereoToMono, NULL, SDL_ConvertStereoTo21, SDL_ConvertStereoToQuad, SDL_ConvertStereoTo41, SDL_ConvertStereoTo51, SDL_ConvertStereoTo61, SDL_ConvertStereoTo71 },
|
||||
{ SDL_Convert21ToMono, SDL_Convert21ToStereo, NULL, SDL_Convert21ToQuad, SDL_Convert21To41, SDL_Convert21To51, SDL_Convert21To61, SDL_Convert21To71 },
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
/* Make a lucky guess. */
|
||||
// Make a lucky guess.
|
||||
#define INT_MAX SDL_MAX_SINT32
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)-1)
|
||||
#endif
|
||||
|
||||
/* Microsoft WAVE file loading routines */
|
||||
// Microsoft WAVE file loading routines
|
||||
|
||||
#include "SDL_wave.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
@@ -52,17 +52,17 @@ static int SafeMult(size_t *f1, size_t f2)
|
||||
|
||||
typedef struct ADPCM_DecoderState
|
||||
{
|
||||
Uint32 channels; /* Number of channels. */
|
||||
size_t blocksize; /* Size of an ADPCM block in bytes. */
|
||||
size_t blockheadersize; /* Size of an ADPCM block header in bytes. */
|
||||
size_t samplesperblock; /* Number of samples per channel in an ADPCM block. */
|
||||
size_t framesize; /* Size of a sample frame (16-bit PCM) in bytes. */
|
||||
Sint64 framestotal; /* Total number of sample frames. */
|
||||
Sint64 framesleft; /* Number of sample frames still to be decoded. */
|
||||
void *ddata; /* Decoder data from initialization. */
|
||||
void *cstate; /* Decoding state for each channel. */
|
||||
Uint32 channels; // Number of channels.
|
||||
size_t blocksize; // Size of an ADPCM block in bytes.
|
||||
size_t blockheadersize; // Size of an ADPCM block header in bytes.
|
||||
size_t samplesperblock; // Number of samples per channel in an ADPCM block.
|
||||
size_t framesize; // Size of a sample frame (16-bit PCM) in bytes.
|
||||
Sint64 framestotal; // Total number of sample frames.
|
||||
Sint64 framesleft; // Number of sample frames still to be decoded.
|
||||
void *ddata; // Decoder data from initialization.
|
||||
void *cstate; // Decoding state for each channel.
|
||||
|
||||
/* ADPCM data. */
|
||||
// ADPCM data.
|
||||
struct
|
||||
{
|
||||
Uint8 *data;
|
||||
@@ -70,7 +70,7 @@ typedef struct ADPCM_DecoderState
|
||||
size_t pos;
|
||||
} input;
|
||||
|
||||
/* Current ADPCM block in the ADPCM data above. */
|
||||
// Current ADPCM block in the ADPCM data above.
|
||||
struct
|
||||
{
|
||||
Uint8 *data;
|
||||
@@ -78,7 +78,7 @@ typedef struct ADPCM_DecoderState
|
||||
size_t pos;
|
||||
} block;
|
||||
|
||||
/* Decoded 16-bit PCM data. */
|
||||
// Decoded 16-bit PCM data.
|
||||
struct
|
||||
{
|
||||
Sint16 *data;
|
||||
@@ -91,7 +91,7 @@ typedef struct MS_ADPCM_CoeffData
|
||||
{
|
||||
Uint16 coeffcount;
|
||||
Sint16 *coeff;
|
||||
Sint16 aligndummy; /* Has to be last member. */
|
||||
Sint16 aligndummy; // Has to be last member.
|
||||
} MS_ADPCM_CoeffData;
|
||||
|
||||
typedef struct MS_ADPCM_ChannelState
|
||||
@@ -342,18 +342,18 @@ static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
const size_t trailingdata = datalength % file->format.blockalign;
|
||||
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
/* The size of the data chunk must be a multiple of the block size. */
|
||||
// The size of the data chunk must be a multiple of the block size.
|
||||
if (datalength < blockheadersize || trailingdata > 0) {
|
||||
return SDL_SetError("Truncated MS ADPCM block");
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate number of sample frames that will be decoded. */
|
||||
// Calculate number of sample frames that will be decoded.
|
||||
file->sampleframes = (Sint64)availableblocks * format->samplesperblock;
|
||||
if (trailingdata > 0) {
|
||||
/* The last block is truncated. Check if we can get any samples out of it. */
|
||||
// The last block is truncated. Check if we can get any samples out of it.
|
||||
if (file->trunchint == TruncDropFrame) {
|
||||
/* Drop incomplete sample frame. */
|
||||
// Drop incomplete sample frame.
|
||||
if (trailingdata >= blockheadersize) {
|
||||
size_t trailingsamples = 2 + (trailingdata - blockheadersize) * 8 / blockframebitsize;
|
||||
if (trailingsamples > format->samplesperblock) {
|
||||
@@ -384,7 +384,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
size_t i, coeffcount;
|
||||
MS_ADPCM_CoeffData *coeffdata;
|
||||
|
||||
/* Sanity checks. */
|
||||
// Sanity checks.
|
||||
|
||||
/* While it's clear how IMA ADPCM handles more than two channels, the nibble
|
||||
* order of MS ADPCM makes it awkward. The Standards Update does not talk
|
||||
@@ -398,7 +398,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
return SDL_SetError("Invalid MS ADPCM bits per sample of %u", (unsigned int)format->bitspersample);
|
||||
}
|
||||
|
||||
/* The block size must be big enough to contain the block header. */
|
||||
// The block size must be big enough to contain the block header.
|
||||
if (format->blockalign < blockheadersize) {
|
||||
return SDL_SetError("Invalid MS ADPCM block size (nBlockAlign)");
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
}
|
||||
|
||||
format->samplesperblock = chunk->data[18] | ((Uint16)chunk->data[19] << 8);
|
||||
/* Number of coefficient pairs. A pair has two 16-bit integers. */
|
||||
// Number of coefficient pairs. A pair has two 16-bit integers.
|
||||
coeffcount = chunk->data[20] | ((size_t)chunk->data[21] << 8);
|
||||
/* bPredictor, the integer offset into the coefficients array, is only
|
||||
* 8 bits. It can only address the first 256 coefficients. Let's limit
|
||||
@@ -438,14 +438,14 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
}
|
||||
|
||||
coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
|
||||
file->decoderdata = coeffdata; /* Freed in cleanup. */
|
||||
file->decoderdata = coeffdata; // Freed in cleanup.
|
||||
if (!coeffdata) {
|
||||
return -1;
|
||||
}
|
||||
coeffdata->coeff = &coeffdata->aligndummy;
|
||||
coeffdata->coeffcount = (Uint16)coeffcount;
|
||||
|
||||
/* Copy the 16-bit pairs. */
|
||||
// Copy the 16-bit pairs.
|
||||
for (i = 0; i < coeffcount * 2; i++) {
|
||||
Sint32 c = chunk->data[22 + i * 2] | ((Sint32)chunk->data[23 + i * 2] << 8);
|
||||
if (c >= 0x8000) {
|
||||
@@ -504,7 +504,7 @@ static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sampl
|
||||
Uint32 delta = cstate->delta;
|
||||
|
||||
new_sample = (sample1 * cstate->coeff1 + sample2 * cstate->coeff2) / 256;
|
||||
/* The nibble is a signed 4-bit error delta. */
|
||||
// The nibble is a signed 4-bit error delta.
|
||||
errordelta = (Sint32)nybble - (nybble >= 0x08 ? 0x10 : 0);
|
||||
new_sample += (Sint32)delta * errordelta;
|
||||
if (new_sample < min_audioval) {
|
||||
@@ -538,7 +538,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
for (c = 0; c < channels; c++) {
|
||||
size_t o = c;
|
||||
|
||||
/* Load the coefficient pair into the channel state. */
|
||||
// Load the coefficient pair into the channel state.
|
||||
coeffindex = state->block.data[o];
|
||||
if (coeffindex > ddata->coeffcount) {
|
||||
return SDL_SetError("Invalid MS ADPCM coefficient index in block header");
|
||||
@@ -546,7 +546,7 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
cstate[c].coeff1 = ddata->coeff[coeffindex * 2];
|
||||
cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1];
|
||||
|
||||
/* Initial delta value. */
|
||||
// Initial delta value.
|
||||
o = (size_t)channels + c * 2;
|
||||
cstate[c].delta = state->block.data[o] | ((Uint16)state->block.data[o + 1] << 8);
|
||||
|
||||
@@ -572,10 +572,10 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
|
||||
state->block.pos += state->blockheadersize;
|
||||
|
||||
/* Skip second sample frame that came from the header. */
|
||||
// Skip second sample frame that came from the header.
|
||||
state->output.pos += state->channels;
|
||||
|
||||
/* Header provided two sample frames. */
|
||||
// Header provided two sample frames.
|
||||
state->framesleft -= 2;
|
||||
|
||||
return 0;
|
||||
@@ -611,12 +611,12 @@ static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
} else if (blockpos < blocksize) {
|
||||
nybble = state->block.data[blockpos++] | 0x4000;
|
||||
} else {
|
||||
/* Out of input data. Drop the incomplete frame and return. */
|
||||
// Out of input data. Drop the incomplete frame and return.
|
||||
state->output.pos = outpos - c;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load previous samples which may come from the block header. */
|
||||
// Load previous samples which may come from the block header.
|
||||
sample1 = state->output.data[outpos - channels];
|
||||
sample2 = state->output.data[outpos - channels * 2];
|
||||
|
||||
@@ -645,13 +645,13 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
SDL_zeroa(cstate);
|
||||
|
||||
if (chunk->size != chunk->length) {
|
||||
/* Could not read everything. Recalculate number of sample frames. */
|
||||
// Could not read everything. Recalculate number of sample frames.
|
||||
if (MS_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to decode, nothing to return. */
|
||||
// Nothing to decode, nothing to return.
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
@@ -671,7 +671,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
state.input.size = chunk->size;
|
||||
state.input.pos = 0;
|
||||
|
||||
/* The output size in bytes. May get modified if data is truncated. */
|
||||
// The output size in bytes. May get modified if data is truncated.
|
||||
outputsize = (size_t)state.framestotal;
|
||||
if (SafeMult(&outputsize, state.framesize)) {
|
||||
return SDL_SetError("WAVE file too big");
|
||||
@@ -688,7 +688,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
|
||||
state.cstate = cstate;
|
||||
|
||||
/* Decode block by block. A truncated block will stop the decoding. */
|
||||
// Decode block by block. A truncated block will stop the decoding.
|
||||
bytesleft = state.input.size - state.input.pos;
|
||||
while (state.framesleft > 0 && bytesleft >= state.blockheadersize) {
|
||||
state.block.data = state.input.data + state.input.pos;
|
||||
@@ -696,29 +696,29 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
state.block.pos = 0;
|
||||
|
||||
if (state.output.size - state.output.pos < (Uint64)state.framesleft * state.channels) {
|
||||
/* Somehow didn't allocate enough space for the output. */
|
||||
// Somehow didn't allocate enough space for the output.
|
||||
SDL_free(state.output.data);
|
||||
return SDL_SetError("Unexpected overflow in MS ADPCM decoder");
|
||||
}
|
||||
|
||||
/* Initialize decoder with the values from the block header. */
|
||||
// Initialize decoder with the values from the block header.
|
||||
result = MS_ADPCM_DecodeBlockHeader(&state);
|
||||
if (result < 0) {
|
||||
SDL_free(state.output.data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Decode the block data. It stores the samples directly in the output. */
|
||||
// Decode the block data. It stores the samples directly in the output.
|
||||
result = MS_ADPCM_DecodeBlockData(&state);
|
||||
if (result < 0) {
|
||||
/* Unexpected end. Stop decoding and return partial data if necessary. */
|
||||
// Unexpected end. Stop decoding and return partial data if necessary.
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
return SDL_SetError("Truncated data chunk");
|
||||
} else if (file->trunchint != TruncDropFrame) {
|
||||
state.output.pos -= state.output.pos % (state.samplesperblock * state.channels);
|
||||
}
|
||||
outputsize = state.output.pos * sizeof(Sint16); /* Can't overflow, is always smaller. */
|
||||
outputsize = state.output.pos * sizeof(Sint16); // Can't overflow, is always smaller.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -741,16 +741,16 @@ static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
const size_t trailingdata = datalength % format->blockalign;
|
||||
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
/* The size of the data chunk must be a multiple of the block size. */
|
||||
// The size of the data chunk must be a multiple of the block size.
|
||||
if (datalength < blockheadersize || trailingdata > 0) {
|
||||
return SDL_SetError("Truncated IMA ADPCM block");
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate number of sample frames that will be decoded. */
|
||||
// Calculate number of sample frames that will be decoded.
|
||||
file->sampleframes = (Uint64)availableblocks * format->samplesperblock;
|
||||
if (trailingdata > 0) {
|
||||
/* The last block is truncated. Check if we can get any samples out of it. */
|
||||
// The last block is truncated. Check if we can get any samples out of it.
|
||||
if (file->trunchint == TruncDropFrame && trailingdata > blockheadersize - 2) {
|
||||
/* The sample frame in the header of the truncated block is present.
|
||||
* Drop incomplete sample frames.
|
||||
@@ -758,7 +758,7 @@ static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
|
||||
size_t trailingsamples = 1;
|
||||
|
||||
if (trailingdata > blockheadersize) {
|
||||
/* More data following after the header. */
|
||||
// More data following after the header.
|
||||
const size_t trailingblockdata = trailingdata - blockheadersize;
|
||||
const size_t trailingsubblockdata = trailingblockdata % subblockframesize;
|
||||
trailingsamples += (trailingblockdata / subblockframesize) * 8;
|
||||
@@ -794,9 +794,9 @@ static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
const size_t blockframebitsize = (size_t)format->bitspersample * format->channels;
|
||||
const size_t blockdatasamples = (blockdatasize * 8) / blockframebitsize;
|
||||
|
||||
/* Sanity checks. */
|
||||
// Sanity checks.
|
||||
|
||||
/* IMA ADPCM can also have 3-bit samples, but it's not supported by SDL at this time. */
|
||||
// IMA ADPCM can also have 3-bit samples, but it's not supported by SDL at this time.
|
||||
if (format->bitspersample == 3) {
|
||||
return SDL_SetError("3-bit IMA ADPCM currently not supported");
|
||||
} else if (format->bitspersample != 4) {
|
||||
@@ -815,7 +815,7 @@ static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
* format because the extensible header has wSampePerBlocks too.
|
||||
*/
|
||||
} else {
|
||||
/* The Standards Update says there 'should' be 2 bytes for wSamplesPerBlock. */
|
||||
// The Standards Update says there 'should' be 2 bytes for wSamplesPerBlock.
|
||||
if (chunk->size >= 20 && format->extsize >= 2) {
|
||||
format->samplesperblock = chunk->data[18] | ((Uint16)chunk->data[19] << 8);
|
||||
}
|
||||
@@ -874,17 +874,17 @@ static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 ny
|
||||
Sint32 sample, delta;
|
||||
Sint8 index = *cindex;
|
||||
|
||||
/* Clamp index into valid range. */
|
||||
// Clamp index into valid range.
|
||||
if (index > 88) {
|
||||
index = 88;
|
||||
} else if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
/* explicit cast to avoid gcc warning about using 'char' as array index */
|
||||
// explicit cast to avoid gcc warning about using 'char' as array index
|
||||
step = step_table[(size_t)index];
|
||||
|
||||
/* Update index value */
|
||||
// Update index value
|
||||
*cindex = index + index_table_4b[nybble];
|
||||
|
||||
/* This calculation uses shifts and additions because multiplications were
|
||||
@@ -909,7 +909,7 @@ static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 ny
|
||||
|
||||
sample = lastsample + delta;
|
||||
|
||||
/* Clamp output sample */
|
||||
// Clamp output sample
|
||||
if (sample > max_audioval) {
|
||||
sample = max_audioval;
|
||||
} else if (sample < min_audioval) {
|
||||
@@ -928,18 +928,18 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
for (c = 0; c < state->channels; c++) {
|
||||
size_t o = state->block.pos + c * 4;
|
||||
|
||||
/* Extract the sample from the header. */
|
||||
// Extract the sample from the header.
|
||||
Sint32 sample = state->block.data[o] | ((Sint32)state->block.data[o + 1] << 8);
|
||||
if (sample >= 0x8000) {
|
||||
sample -= 0x10000;
|
||||
}
|
||||
state->output.data[state->output.pos++] = (Sint16)sample;
|
||||
|
||||
/* Channel step index. */
|
||||
// Channel step index.
|
||||
step = (Sint16)state->block.data[o + 2];
|
||||
cstate[c] = (Sint8)(step > 0x80 ? step - 0x100 : step);
|
||||
|
||||
/* Reserved byte in block header, should be 0. */
|
||||
// Reserved byte in block header, should be 0.
|
||||
if (state->block.data[o + 3] != 0) {
|
||||
/* Uh oh, corrupt data? Buggy code? */;
|
||||
}
|
||||
@@ -947,7 +947,7 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
|
||||
|
||||
state->block.pos += state->blockheadersize;
|
||||
|
||||
/* Header provided one sample frame. */
|
||||
// Header provided one sample frame.
|
||||
state->framesleft--;
|
||||
|
||||
return 0;
|
||||
@@ -980,14 +980,14 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
|
||||
bytesrequired = (blockframesleft + 7) / 8 * subblockframesize;
|
||||
if (blockleft < bytesrequired) {
|
||||
/* Data truncated. Calculate how many samples we can get out if it. */
|
||||
// Data truncated. Calculate how many samples we can get out if it.
|
||||
const size_t guaranteedframes = blockleft / subblockframesize;
|
||||
const size_t remainingbytes = blockleft % subblockframesize;
|
||||
blockframesleft = guaranteedframes;
|
||||
if (remainingbytes > subblockframesize - 4) {
|
||||
blockframesleft += (Sint64)(remainingbytes % 4) * 2;
|
||||
}
|
||||
/* Signal the truncation. */
|
||||
// Signal the truncation.
|
||||
retval = -1;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
|
||||
|
||||
for (c = 0; c < channels; c++) {
|
||||
Uint8 nybble = 0;
|
||||
/* Load previous sample which may come from the block header. */
|
||||
// Load previous sample which may come from the block header.
|
||||
Sint16 sample = state->output.data[outpos + c - channels];
|
||||
|
||||
for (i = 0; i < subblocksamples; i++) {
|
||||
@@ -1036,13 +1036,13 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
Sint8 *cstate;
|
||||
|
||||
if (chunk->size != chunk->length) {
|
||||
/* Could not read everything. Recalculate number of sample frames. */
|
||||
// Could not read everything. Recalculate number of sample frames.
|
||||
if (IMA_ADPCM_CalculateSampleFrames(file, chunk->size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to decode, nothing to return. */
|
||||
// Nothing to decode, nothing to return.
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
@@ -1062,7 +1062,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
state.input.size = chunk->size;
|
||||
state.input.pos = 0;
|
||||
|
||||
/* The output size in bytes. May get modified if data is truncated. */
|
||||
// The output size in bytes. May get modified if data is truncated.
|
||||
outputsize = (size_t)state.framestotal;
|
||||
if (SafeMult(&outputsize, state.framesize)) {
|
||||
return SDL_SetError("WAVE file too big");
|
||||
@@ -1084,7 +1084,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
}
|
||||
state.cstate = cstate;
|
||||
|
||||
/* Decode block by block. A truncated block will stop the decoding. */
|
||||
// Decode block by block. A truncated block will stop the decoding.
|
||||
bytesleft = state.input.size - state.input.pos;
|
||||
while (state.framesleft > 0 && bytesleft >= state.blockheadersize) {
|
||||
state.block.data = state.input.data + state.input.pos;
|
||||
@@ -1092,21 +1092,21 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
state.block.pos = 0;
|
||||
|
||||
if (state.output.size - state.output.pos < (Uint64)state.framesleft * state.channels) {
|
||||
/* Somehow didn't allocate enough space for the output. */
|
||||
// Somehow didn't allocate enough space for the output.
|
||||
SDL_free(state.output.data);
|
||||
SDL_free(cstate);
|
||||
return SDL_SetError("Unexpected overflow in IMA ADPCM decoder");
|
||||
}
|
||||
|
||||
/* Initialize decoder with the values from the block header. */
|
||||
// Initialize decoder with the values from the block header.
|
||||
result = IMA_ADPCM_DecodeBlockHeader(&state);
|
||||
if (result == 0) {
|
||||
/* Decode the block data. It stores the samples directly in the output. */
|
||||
// Decode the block data. It stores the samples directly in the output.
|
||||
result = IMA_ADPCM_DecodeBlockData(&state);
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
/* Unexpected end. Stop decoding and return partial data if necessary. */
|
||||
// Unexpected end. Stop decoding and return partial data if necessary.
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
SDL_free(cstate);
|
||||
@@ -1114,7 +1114,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
||||
} else if (file->trunchint != TruncDropFrame) {
|
||||
state.output.pos -= state.output.pos % (state.samplesperblock * state.channels);
|
||||
}
|
||||
outputsize = state.output.pos * sizeof(Sint16); /* Can't overflow, is always smaller. */
|
||||
outputsize = state.output.pos * sizeof(Sint16); // Can't overflow, is always smaller.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1134,12 +1134,12 @@ static int LAW_Init(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
|
||||
/* Standards Update requires this to be 8. */
|
||||
// Standards Update requires this to be 8.
|
||||
if (format->bitspersample != 8) {
|
||||
return SDL_SetError("Invalid companded bits per sample of %u", (unsigned int)format->bitspersample);
|
||||
}
|
||||
|
||||
/* Not going to bother with weird padding. */
|
||||
// Not going to bother with weird padding.
|
||||
if (format->blockalign != format->channels) {
|
||||
return SDL_SetError("Unsupported block alignment");
|
||||
}
|
||||
@@ -1212,7 +1212,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to decode, nothing to return. */
|
||||
// Nothing to decode, nothing to return.
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
@@ -1231,7 +1231,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
return SDL_SetError("WAVE file too big");
|
||||
}
|
||||
|
||||
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
|
||||
// 1 to avoid allocating zero bytes, to keep static analysis happy.
|
||||
src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
|
||||
if (!src) {
|
||||
return -1;
|
||||
@@ -1310,7 +1310,7 @@ static int PCM_Init(WaveFile *file, size_t datalength)
|
||||
case 16:
|
||||
case 24:
|
||||
case 32:
|
||||
/* These are supported. */
|
||||
// These are supported.
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("%u-bit PCM format not supported", (unsigned int)format->bitspersample);
|
||||
@@ -1324,7 +1324,7 @@ static int PCM_Init(WaveFile *file, size_t datalength)
|
||||
/* It wouldn't be that hard to support more exotic block sizes, but
|
||||
* the most common formats should do for now.
|
||||
*/
|
||||
/* Make sure we're a multiple of the blockalign, at least. */
|
||||
// Make sure we're a multiple of the blockalign, at least.
|
||||
if ((format->channels * format->bitspersample) % (format->blockalign * 8)) {
|
||||
return SDL_SetError("Unsupported block alignment");
|
||||
}
|
||||
@@ -1362,20 +1362,20 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
|
||||
return SDL_SetError("WAVE file too big");
|
||||
}
|
||||
|
||||
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
|
||||
// 1 to avoid allocating zero bytes, to keep static analysis happy.
|
||||
ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
|
||||
if (!ptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This pointer is now invalid. */
|
||||
// This pointer is now invalid.
|
||||
chunk->data = NULL;
|
||||
chunk->size = 0;
|
||||
|
||||
*audio_buf = ptr;
|
||||
*audio_len = (Uint32)expanded_len;
|
||||
|
||||
/* work from end to start, since we're expanding in-place. */
|
||||
// work from end to start, since we're expanding in-place.
|
||||
for (i = sample_count; i > 0; i--) {
|
||||
const size_t o = i - 1;
|
||||
uint8_t b[4];
|
||||
@@ -1407,14 +1407,14 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to decode, nothing to return. */
|
||||
// Nothing to decode, nothing to return.
|
||||
if (file->sampleframes == 0) {
|
||||
*audio_buf = NULL;
|
||||
*audio_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 24-bit samples get shifted to 32 bits. */
|
||||
// 24-bit samples get shifted to 32 bits.
|
||||
if (format->encoding == PCM_CODE && format->bitspersample == 24) {
|
||||
return PCM_ConvertSint24ToSint32(file, audio_buf, audio_len);
|
||||
}
|
||||
@@ -1429,7 +1429,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
*audio_buf = chunk->data;
|
||||
*audio_len = (Uint32)outputsize;
|
||||
|
||||
/* This pointer is going to be returned to the caller. Prevent free in cleanup. */
|
||||
// This pointer is going to be returned to the caller. Prevent free in cleanup.
|
||||
chunk->data = NULL;
|
||||
chunk->size = 0;
|
||||
|
||||
@@ -1507,21 +1507,21 @@ static int WaveNextChunk(SDL_IOStream *src, WaveChunk *chunk)
|
||||
Uint32 chunkheader[2];
|
||||
Sint64 nextposition = chunk->position + chunk->length;
|
||||
|
||||
/* Data is no longer valid after this function returns. */
|
||||
// Data is no longer valid after this function returns.
|
||||
WaveFreeChunkData(chunk);
|
||||
|
||||
/* Error on overflows. */
|
||||
// Error on overflows.
|
||||
if (SDL_MAX_SINT64 - chunk->length < chunk->position || SDL_MAX_SINT64 - 8 < nextposition) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* RIFF chunks have a 2-byte alignment. Skip padding byte. */
|
||||
// RIFF chunks have a 2-byte alignment. Skip padding byte.
|
||||
if (chunk->length & 1) {
|
||||
nextposition++;
|
||||
}
|
||||
|
||||
if (SDL_SeekIO(src, nextposition, SDL_IO_SEEK_SET) != nextposition) {
|
||||
/* Not sure how we ended up here. Just abort. */
|
||||
// Not sure how we ended up here. Just abort.
|
||||
return -2;
|
||||
} else if (SDL_ReadIO(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) {
|
||||
return -1;
|
||||
@@ -1549,13 +1549,13 @@ static int WaveReadPartialChunkData(SDL_IOStream *src, WaveChunk *chunk, size_t
|
||||
}
|
||||
|
||||
if (SDL_SeekIO(src, chunk->position, SDL_IO_SEEK_SET) != chunk->position) {
|
||||
/* Not sure how we ended up here. Just abort. */
|
||||
// Not sure how we ended up here. Just abort.
|
||||
return -2;
|
||||
}
|
||||
|
||||
chunk->size = SDL_ReadIO(src, chunk->data, length);
|
||||
if (chunk->size != length) {
|
||||
/* Expected to be handled by the caller. */
|
||||
// Expected to be handled by the caller.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1573,7 +1573,7 @@ typedef struct WaveExtensibleGUID
|
||||
Uint8 guid[16];
|
||||
} WaveExtensibleGUID;
|
||||
|
||||
/* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */
|
||||
// Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE.
|
||||
#define WAVE_FORMATTAG_GUID(tag) \
|
||||
{ \
|
||||
(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 \
|
||||
@@ -1606,7 +1606,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
size_t fmtlen = chunk->size;
|
||||
|
||||
if (fmtlen > SDL_MAX_SINT32) {
|
||||
/* Limit given by SDL_IOFromConstMem. */
|
||||
// Limit given by SDL_IOFromConstMem.
|
||||
return SDL_SetError("Data of WAVE fmt chunk too big");
|
||||
}
|
||||
fmtsrc = SDL_IOFromConstMem(chunk->data, (int)chunk->size);
|
||||
@@ -1623,7 +1623,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
}
|
||||
format->encoding = format->formattag;
|
||||
|
||||
/* This is PCM specific in the first version of the specification. */
|
||||
// This is PCM specific in the first version of the specification.
|
||||
if (fmtlen >= 16) {
|
||||
if (!SDL_ReadU16LE(fmtsrc, &format->bitspersample)) {
|
||||
return -1;
|
||||
@@ -1633,7 +1633,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk");
|
||||
}
|
||||
|
||||
/* The earlier versions also don't have this field. */
|
||||
// The earlier versions also don't have this field.
|
||||
if (fmtlen >= 18) {
|
||||
if (!SDL_ReadU16LE(fmtsrc, &format->extsize)) {
|
||||
return -1;
|
||||
@@ -1647,7 +1647,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
* to be useful working when they use this format flag.
|
||||
*/
|
||||
|
||||
/* Extensible header must be at least 22 bytes. */
|
||||
// Extensible header must be at least 22 bytes.
|
||||
if (fmtlen < 40 || format->extsize < 22) {
|
||||
SDL_CloseIO(fmtsrc);
|
||||
return SDL_SetError("Extensible WAVE header too small");
|
||||
@@ -1670,7 +1670,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
{
|
||||
WaveFormat *format = &file->format;
|
||||
|
||||
/* Check for some obvious issues. */
|
||||
// Check for some obvious issues.
|
||||
|
||||
if (format->channels == 0) {
|
||||
return SDL_SetError("Invalid number of channels");
|
||||
@@ -1682,7 +1682,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
return SDL_SetError("Sample rate exceeds limit of %d", INT_MAX);
|
||||
}
|
||||
|
||||
/* Reject invalid fact chunks in strict mode. */
|
||||
// Reject invalid fact chunks in strict mode.
|
||||
if (file->facthint == FactStrict && file->fact.status == -1) {
|
||||
return SDL_SetError("Invalid fact chunk in WAVE file");
|
||||
}
|
||||
@@ -1697,22 +1697,22 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
case MULAW_CODE:
|
||||
case MS_ADPCM_CODE:
|
||||
case IMA_ADPCM_CODE:
|
||||
/* These formats require a fact chunk. */
|
||||
// These formats require a fact chunk.
|
||||
if (file->facthint == FactStrict && file->fact.status <= 0) {
|
||||
return SDL_SetError("Missing fact chunk in WAVE file");
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case PCM_CODE:
|
||||
/* All supported formats require a non-zero bit depth. */
|
||||
// All supported formats require a non-zero bit depth.
|
||||
if (file->chunk.size < 16) {
|
||||
return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk");
|
||||
} else if (format->bitspersample == 0) {
|
||||
return SDL_SetError("Invalid bits per sample");
|
||||
}
|
||||
|
||||
/* All supported formats must have a proper block size. */
|
||||
// All supported formats must have a proper block size.
|
||||
if (format->blockalign == 0) {
|
||||
format->blockalign = 1; /* force it to 1 if it was unset. */
|
||||
format->blockalign = 1; // force it to 1 if it was unset.
|
||||
}
|
||||
|
||||
/* If the fact chunk is valid and the appropriate hint is set, the
|
||||
@@ -1727,7 +1727,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the format for encoding specific issues and initialize decoders. */
|
||||
// Check the format for encoding specific issues and initialize decoders.
|
||||
switch (format->encoding) {
|
||||
case PCM_CODE:
|
||||
case IEEE_FLOAT_CODE:
|
||||
@@ -1805,24 +1805,24 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
return SDL_SetError("Could not read RIFF header");
|
||||
}
|
||||
|
||||
/* Check main WAVE file identifiers. */
|
||||
// Check main WAVE file identifiers.
|
||||
if (RIFFchunk.fourcc == RIFF) {
|
||||
Uint32 formtype;
|
||||
/* Read the form type. "WAVE" expected. */
|
||||
// Read the form type. "WAVE" expected.
|
||||
if (!SDL_ReadU32LE(src, &formtype)) {
|
||||
return SDL_SetError("Could not read RIFF form type");
|
||||
} else if (formtype != WAVE) {
|
||||
return SDL_SetError("RIFF form type is not WAVE (not a Waveform file)");
|
||||
}
|
||||
} else if (RIFFchunk.fourcc == WAVE) {
|
||||
/* RIFF chunk missing or skipped. Length unknown. */
|
||||
// RIFF chunk missing or skipped. Length unknown.
|
||||
RIFFchunk.position = 0;
|
||||
RIFFchunk.length = 0;
|
||||
} else {
|
||||
return SDL_SetError("Could not find RIFF or WAVE identifiers (not a Waveform file)");
|
||||
}
|
||||
|
||||
/* The 4-byte form type is immediately followed by the first chunk.*/
|
||||
// The 4-byte form type is immediately followed by the first chunk.
|
||||
chunk->position = RIFFchunk.position + 4;
|
||||
|
||||
/* Use the RIFF chunk size to limit the search for the chunks. This is not
|
||||
@@ -1854,18 +1854,18 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
* currently also ignores cue, list, and slnt chunks.
|
||||
*/
|
||||
while ((Uint64)RIFFend > (Uint64)chunk->position + chunk->length + (chunk->length & 1)) {
|
||||
/* Abort after too many chunks or else corrupt files may waste time. */
|
||||
// Abort after too many chunks or else corrupt files may waste time.
|
||||
if (chunkcount++ >= chunkcountlimit) {
|
||||
return SDL_SetError("Chunk count in WAVE file exceeds limit of %" SDL_PRIu32, chunkcountlimit);
|
||||
}
|
||||
|
||||
result = WaveNextChunk(src, chunk);
|
||||
if (result < 0) {
|
||||
/* Unexpected EOF. Corrupt file or I/O issues. */
|
||||
// Unexpected EOF. Corrupt file or I/O issues.
|
||||
if (file->trunchint == TruncVeryStrict) {
|
||||
return SDL_SetError("Unexpected end of WAVE file");
|
||||
}
|
||||
/* Let the checks after this loop sort this issue out. */
|
||||
// Let the checks after this loop sort this issue out.
|
||||
break;
|
||||
} else if (result == -2) {
|
||||
return SDL_SetError("Could not seek to WAVE chunk header");
|
||||
@@ -1873,9 +1873,9 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
|
||||
if (chunk->fourcc == FMT) {
|
||||
if (fmtchunk.fourcc == FMT) {
|
||||
/* Multiple fmt chunks. Ignore or error? */
|
||||
// Multiple fmt chunks. Ignore or error?
|
||||
} else {
|
||||
/* The fmt chunk must occur before the data chunk. */
|
||||
// The fmt chunk must occur before the data chunk.
|
||||
if (datachunk.fourcc == DATA) {
|
||||
return SDL_SetError("fmt chunk after data chunk in WAVE file");
|
||||
}
|
||||
@@ -1896,7 +1896,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
if (chunk->length < 4) {
|
||||
file->fact.status = -1;
|
||||
} else {
|
||||
/* Let's use src directly, it's just too convenient. */
|
||||
// Let's use src directly, it's just too convenient.
|
||||
Sint64 position = SDL_SeekIO(src, chunk->position, SDL_IO_SEEK_SET);
|
||||
if (position == chunk->position && SDL_ReadU32LE(src, &file->fact.samplelength)) {
|
||||
file->fact.status = 1;
|
||||
@@ -1926,17 +1926,17 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
*/
|
||||
lastchunkpos = chunk->position + chunk->length;
|
||||
|
||||
/* The fmt chunk is mandatory. */
|
||||
// The fmt chunk is mandatory.
|
||||
if (fmtchunk.fourcc != FMT) {
|
||||
return SDL_SetError("Missing fmt chunk in WAVE file");
|
||||
}
|
||||
/* A data chunk must be present. */
|
||||
// A data chunk must be present.
|
||||
if (datachunk.fourcc != DATA) {
|
||||
return SDL_SetError("Missing data chunk in WAVE file");
|
||||
}
|
||||
/* Check if the last chunk has all of its data in verystrict mode. */
|
||||
// Check if the last chunk has all of its data in verystrict mode.
|
||||
if (file->trunchint == TruncVeryStrict) {
|
||||
/* data chunk is handled later. */
|
||||
// data chunk is handled later.
|
||||
if (chunk->fourcc != DATA && chunk->length > 0) {
|
||||
Uint8 tmp;
|
||||
Uint64 position = (Uint64)chunk->position + chunk->length - 1;
|
||||
@@ -1948,7 +1948,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
}
|
||||
}
|
||||
|
||||
/* Process fmt chunk. */
|
||||
// Process fmt chunk.
|
||||
*chunk = fmtchunk;
|
||||
|
||||
/* No need to read more than 1046 bytes of the fmt chunk data with the
|
||||
@@ -1980,7 +1980,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
|
||||
WaveFreeChunkData(chunk);
|
||||
|
||||
/* Process data chunk. */
|
||||
// Process data chunk.
|
||||
*chunk = datachunk;
|
||||
|
||||
if (chunk->length > 0) {
|
||||
@@ -1993,14 +1993,14 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
}
|
||||
|
||||
if (chunk->length != chunk->size) {
|
||||
/* I/O issues or corrupt file. */
|
||||
// I/O issues or corrupt file.
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
return SDL_SetError("Could not read data of WAVE data chunk");
|
||||
}
|
||||
/* The decoders handle this truncation. */
|
||||
// The decoders handle this truncation.
|
||||
}
|
||||
|
||||
/* Decode or convert the data if necessary. */
|
||||
// Decode or convert the data if necessary.
|
||||
switch (format->encoding) {
|
||||
case PCM_CODE:
|
||||
case IEEE_FLOAT_CODE:
|
||||
@@ -2038,7 +2038,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
case IMA_ADPCM_CODE:
|
||||
case ALAW_CODE:
|
||||
case MULAW_CODE:
|
||||
/* These can be easily stored in the byte order of the system. */
|
||||
// These can be easily stored in the byte order of the system.
|
||||
spec->format = SDL_AUDIO_S16;
|
||||
break;
|
||||
case IEEE_FLOAT_CODE:
|
||||
@@ -2052,12 +2052,12 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
case 16:
|
||||
spec->format = SDL_AUDIO_S16LE;
|
||||
break;
|
||||
case 24: /* Has been shifted to 32 bits. */
|
||||
case 24: // Has been shifted to 32 bits.
|
||||
case 32:
|
||||
spec->format = SDL_AUDIO_S32LE;
|
||||
break;
|
||||
default:
|
||||
/* Just in case something unexpected happened in the checks. */
|
||||
// Just in case something unexpected happened in the checks.
|
||||
return SDL_SetError("Unexpected %u-bit PCM data format", (unsigned int)format->bitspersample);
|
||||
}
|
||||
break;
|
||||
@@ -2065,7 +2065,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
||||
return SDL_SetError("Unexpected data format");
|
||||
}
|
||||
|
||||
/* Report the end position back to the cleanup code. */
|
||||
// Report the end position back to the cleanup code.
|
||||
if (RIFFlengthknown) {
|
||||
chunk->position = RIFFend;
|
||||
} else {
|
||||
@@ -2090,9 +2090,9 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin
|
||||
*audio_len = 0;
|
||||
}
|
||||
|
||||
/* Make sure we are passed a valid data source */
|
||||
// Make sure we are passed a valid data source
|
||||
if (!src) {
|
||||
goto done; /* Error may come from SDL_IOStream. */
|
||||
goto done; // Error may come from SDL_IOStream.
|
||||
} else if (!spec) {
|
||||
SDL_InvalidParamError("spec");
|
||||
goto done;
|
||||
@@ -2116,7 +2116,7 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin
|
||||
audio_len = 0;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
// Cleanup
|
||||
if (!closeio) {
|
||||
SDL_SeekIO(src, file.chunk.position, SDL_IO_SEEK_SET);
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* RIFF WAVE files are little-endian */
|
||||
// RIFF WAVE files are little-endian
|
||||
|
||||
/*******************************************/
|
||||
/* Define values for Microsoft WAVE format */
|
||||
// Define values for Microsoft WAVE format
|
||||
/*******************************************/
|
||||
/* FOURCC */
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define BEXT 0x74786562 /* "bext" */
|
||||
#define JUNK 0x4B4E554A /* "JUNK" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
/* Format tags */
|
||||
// FOURCC
|
||||
#define RIFF 0x46464952 // "RIFF"
|
||||
#define WAVE 0x45564157 // "WAVE"
|
||||
#define FACT 0x74636166 // "fact"
|
||||
#define LIST 0x5453494c // "LIST"
|
||||
#define BEXT 0x74786562 // "bext"
|
||||
#define JUNK 0x4B4E554A // "JUNK"
|
||||
#define FMT 0x20746D66 // "fmt "
|
||||
#define DATA 0x61746164 // "data"
|
||||
// Format tags
|
||||
#define UNKNOWN_CODE 0x0000
|
||||
#define PCM_CODE 0x0001
|
||||
#define MS_ADPCM_CODE 0x0002
|
||||
@@ -46,30 +46,30 @@
|
||||
#define MPEGLAYER3_CODE 0x0055
|
||||
#define EXTENSIBLE_CODE 0xFFFE
|
||||
|
||||
/* Stores the WAVE format information. */
|
||||
// Stores the WAVE format information.
|
||||
typedef struct WaveFormat
|
||||
{
|
||||
Uint16 formattag; /* Raw value of the first field in the fmt chunk data. */
|
||||
Uint16 encoding; /* Actual encoding, possibly from the extensible header. */
|
||||
Uint16 channels; /* Number of channels. */
|
||||
Uint32 frequency; /* Sampling rate in Hz. */
|
||||
Uint32 byterate; /* Average bytes per second. */
|
||||
Uint16 blockalign; /* Bytes per block. */
|
||||
Uint16 bitspersample; /* Currently supported are 8, 16, 24, 32, and 4 for ADPCM. */
|
||||
Uint16 formattag; // Raw value of the first field in the fmt chunk data.
|
||||
Uint16 encoding; // Actual encoding, possibly from the extensible header.
|
||||
Uint16 channels; // Number of channels.
|
||||
Uint32 frequency; // Sampling rate in Hz.
|
||||
Uint32 byterate; // Average bytes per second.
|
||||
Uint16 blockalign; // Bytes per block.
|
||||
Uint16 bitspersample; // Currently supported are 8, 16, 24, 32, and 4 for ADPCM.
|
||||
|
||||
/* Extra information size. Number of extra bytes starting at byte 18 in the
|
||||
* fmt chunk data. This is at least 22 for the extensible header.
|
||||
*/
|
||||
Uint16 extsize;
|
||||
|
||||
/* Extensible WAVE header fields */
|
||||
// Extensible WAVE header fields
|
||||
Uint16 validsamplebits;
|
||||
Uint32 samplesperblock; /* For compressed formats. Can be zero. Actually 16 bits in the header. */
|
||||
Uint32 samplesperblock; // For compressed formats. Can be zero. Actually 16 bits in the header.
|
||||
Uint32 channelmask;
|
||||
Uint8 subformat[16]; /* A format GUID. */
|
||||
Uint8 subformat[16]; // A format GUID.
|
||||
} WaveFormat;
|
||||
|
||||
/* Stores information on the fact chunk. */
|
||||
// Stores information on the fact chunk.
|
||||
typedef struct WaveFact
|
||||
{
|
||||
/* Represents the state of the fact chunk in the WAVE file.
|
||||
@@ -88,20 +88,20 @@ typedef struct WaveFact
|
||||
* because a compressed block is usually decoded to a fixed number of
|
||||
* sample frames.
|
||||
*/
|
||||
Uint32 samplelength; /* Raw sample length value from the fact chunk. */
|
||||
Uint32 samplelength; // Raw sample length value from the fact chunk.
|
||||
} WaveFact;
|
||||
|
||||
/* Generic struct for the chunks in the WAVE file. */
|
||||
// Generic struct for the chunks in the WAVE file.
|
||||
typedef struct WaveChunk
|
||||
{
|
||||
Uint32 fourcc; /* FOURCC of the chunk. */
|
||||
Uint32 length; /* Size of the chunk data. */
|
||||
Sint64 position; /* Position of the data in the stream. */
|
||||
Uint8 *data; /* When allocated, this points to the chunk data. length is used for the memory allocation size. */
|
||||
size_t size; /* Number of bytes in data that could be read from the stream. Can be smaller than length. */
|
||||
Uint32 fourcc; // FOURCC of the chunk.
|
||||
Uint32 length; // Size of the chunk data.
|
||||
Sint64 position; // Position of the data in the stream.
|
||||
Uint8 *data; // When allocated, this points to the chunk data. length is used for the memory allocation size.
|
||||
size_t size; // Number of bytes in data that could be read from the stream. Can be smaller than length.
|
||||
} WaveChunk;
|
||||
|
||||
/* Controls how the size of the RIFF chunk affects the loading of a WAVE file. */
|
||||
// Controls how the size of the RIFF chunk affects the loading of a WAVE file.
|
||||
typedef enum WaveRiffSizeHint
|
||||
{
|
||||
RiffSizeNoHint,
|
||||
@@ -111,7 +111,7 @@ typedef enum WaveRiffSizeHint
|
||||
RiffSizeMaximum
|
||||
} WaveRiffSizeHint;
|
||||
|
||||
/* Controls how a truncated WAVE file is handled. */
|
||||
// Controls how a truncated WAVE file is handled.
|
||||
typedef enum WaveTruncationHint
|
||||
{
|
||||
TruncNoHint,
|
||||
@@ -121,7 +121,7 @@ typedef enum WaveTruncationHint
|
||||
TruncDropBlock
|
||||
} WaveTruncationHint;
|
||||
|
||||
/* Controls how the fact chunk affects the loading of a WAVE file. */
|
||||
// Controls how the fact chunk affects the loading of a WAVE file.
|
||||
typedef enum WaveFactChunkHint
|
||||
{
|
||||
FactNoHint,
|
||||
@@ -143,7 +143,7 @@ typedef struct WaveFile
|
||||
*/
|
||||
Sint64 sampleframes;
|
||||
|
||||
void *decoderdata; /* Some decoders require extra data for a state. */
|
||||
void *decoderdata; // Some decoders require extra data for a state.
|
||||
|
||||
WaveRiffSizeHint riffhint;
|
||||
WaveTruncationHint trunchint;
|
||||
|
||||
@@ -883,7 +883,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
#else
|
||||
// Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS
|
||||
#endif /* SDL_PLATFORM_TVOS */
|
||||
#endif // SDL_PLATFORM_TVOS
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// just turn off clang-format for this whole file, this INDENT_OFF stuff on
|
||||
// each EM_ASM section is ugly.
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
|
||||
static Uint8 *EMSCRIPTENAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
||||
{
|
||||
@@ -346,6 +346,6 @@ AudioBootStrap EMSCRIPTENAUDIO_bootstrap = {
|
||||
"emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, SDL_FALSE
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
#endif // SDL_AUDIO_DRIVER_EMSCRIPTEN
|
||||
|
||||
@@ -47,7 +47,7 @@ static void NETBSDAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Au
|
||||
static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
||||
{
|
||||
#ifdef DEBUG_AUDIO
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
audio_info_t info;
|
||||
const struct audio_prinfo *prinfo;
|
||||
|
||||
@@ -109,7 +109,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
||||
"",
|
||||
device->spec.format,
|
||||
device->buffer_size);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
#endif // DEBUG_AUDIO
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ static const IID SDL_IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483, { 0x
|
||||
static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } };
|
||||
#ifdef __IAudioClient3_INTERFACE_DEFINED__
|
||||
static const IID SDL_IID_IAudioClient3 = { 0x7ed4ee07, 0x8e67, 0x4cd4, { 0x8c, 0x1a, 0x2b, 0x7a, 0x59, 0x87, 0xad, 0x42 } };
|
||||
#endif /**/
|
||||
#endif //
|
||||
|
||||
|
||||
// WASAPI is _really_ particular about various things happening on the same thread, for COM and such,
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
// just turn off clang-format for this whole file, this INDENT_OFF stuff on
|
||||
// each EM_ASM section is ugly.
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
|
||||
EM_JS_DEPS(sdlcamera, "$dynCall");
|
||||
|
||||
@@ -261,7 +261,7 @@ CameraBootStrap EMSCRIPTENCAMERA_bootstrap = {
|
||||
"emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, SDL_FALSE
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_EMSCRIPTEN
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
|
||||
*timestampNS = timestamp100NS * 100; // the timestamps are in 100-nanosecond increments; move to full nanoseconds.
|
||||
}
|
||||
|
||||
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); /*IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer);*/
|
||||
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(objs->sample, &objs->buffer); // IMFSample_GetBufferByIndex(objs->sample, 0, &objs->buffer);
|
||||
|
||||
if (FAILED(ret)) {
|
||||
SDL_free(objs);
|
||||
@@ -546,7 +546,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
|
||||
}
|
||||
|
||||
IMFMediaBuffer *buffer = NULL;
|
||||
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); /*IMFSample_GetBufferByIndex(sample, 0, &buffer);*/
|
||||
ret = (retval < 0) ? E_FAIL : IMFSample_ConvertToContiguousBuffer(sample, &buffer); // IMFSample_GetBufferByIndex(sample, 0, &buffer);
|
||||
|
||||
if (FAILED(ret)) {
|
||||
retval = -1;
|
||||
@@ -660,7 +660,7 @@ static HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride)
|
||||
|
||||
GUID subtype = GUID_NULL;
|
||||
UINT32 width = 0;
|
||||
/* UINT32 height = 0; */
|
||||
// UINT32 height = 0;
|
||||
UINT64 val = 0;
|
||||
|
||||
// Get the subtype and the image size.
|
||||
@@ -675,7 +675,7 @@ static HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride)
|
||||
}
|
||||
|
||||
width = (UINT32) (val >> 32);
|
||||
/* height = (UINT32) val; */
|
||||
// height = (UINT32) val;
|
||||
|
||||
ret = pMFGetStrideForBitmapInfoHeader(subtype.Data1, width, &lStride);
|
||||
if (FAILED(ret)) {
|
||||
|
||||
@@ -77,7 +77,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); /* SDL_WindowsMessageHook callback */
|
||||
SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); // SDL_WindowsMessageHook callback
|
||||
void SDL_SetWindowsMessageHook(void *callback, void *userdata)
|
||||
{
|
||||
(void)callback;
|
||||
@@ -95,15 +95,15 @@ void SDL_UnregisterApp(void)
|
||||
|
||||
#ifndef SDL_PLATFORM_WINRT
|
||||
|
||||
/* Returns SDL_WinRT_DeviceFamily enum */
|
||||
// Returns SDL_WinRT_DeviceFamily enum
|
||||
SDL_DECLSPEC int SDLCALL SDL_GetWinRTDeviceFamily(void);
|
||||
int SDL_GetWinRTDeviceFamily(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */
|
||||
return 0; // SDL_WINRT_DEVICEFAMILY_UNKNOWN
|
||||
}
|
||||
|
||||
SDL_DECLSPEC const char *SDLCALL SDL_GetWinRTFSPath(int pathType); /* SDL_WinRT_Path pathType */
|
||||
SDL_DECLSPEC const char *SDLCALL SDL_GetWinRTFSPath(int pathType); // SDL_WinRT_Path pathType
|
||||
const char *SDL_GetWinRTFSPath(int pathType)
|
||||
{
|
||||
(void)pathType;
|
||||
@@ -224,6 +224,6 @@ Sint32 JNI_OnLoad(void *vm, void *reserved)
|
||||
(void)vm;
|
||||
(void)reserved;
|
||||
SDL_Unsupported();
|
||||
return -1; /* JNI_ERR */
|
||||
return -1; // JNI_ERR
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
#define SDL_JAVA_CONTROLLER_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function)
|
||||
#define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function) CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function)
|
||||
|
||||
/* Audio encoding definitions */
|
||||
// Audio encoding definitions
|
||||
#define ENCODING_PCM_8BIT 3
|
||||
#define ENCODING_PCM_16BIT 2
|
||||
#define ENCODING_PCM_FLOAT 4
|
||||
|
||||
/* Java class SDLActivity */
|
||||
// Java class SDLActivity
|
||||
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(
|
||||
JNIEnv *env, jclass cls);
|
||||
|
||||
@@ -232,7 +232,7 @@ static JNINativeMethod SDLActivity_tab[] = {
|
||||
{ "onNativeFileDialog", "(I[Ljava/lang/String;I)V", SDL_JAVA_INTERFACE(onNativeFileDialog) }
|
||||
};
|
||||
|
||||
/* Java class SDLInputConnection */
|
||||
// Java class SDLInputConnection
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)(
|
||||
JNIEnv *env, jclass cls,
|
||||
jstring text, jint newCursorPosition);
|
||||
@@ -246,7 +246,7 @@ static JNINativeMethod SDLInputConnection_tab[] = {
|
||||
{ "nativeGenerateScancodeForUnichar", "(C)V", SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar) }
|
||||
};
|
||||
|
||||
/* Java class SDLAudioManager */
|
||||
// Java class SDLAudioManager
|
||||
JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(
|
||||
JNIEnv *env, jclass jcls);
|
||||
|
||||
@@ -264,7 +264,7 @@ static JNINativeMethod SDLAudioManager_tab[] = {
|
||||
{ "removeAudioDevice", "(ZI)V", SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice) }
|
||||
};
|
||||
|
||||
/* Java class SDLControllerManager */
|
||||
// Java class SDLControllerManager
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(
|
||||
JNIEnv *env, jclass jcls);
|
||||
|
||||
@@ -313,8 +313,8 @@ static JNINativeMethod SDLControllerManager_tab[] = {
|
||||
{ "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
|
||||
};
|
||||
|
||||
/* Uncomment this to log messages entering and exiting methods in this file */
|
||||
/* #define DEBUG_JNI */
|
||||
// Uncomment this to log messages entering and exiting methods in this file
|
||||
// #define DEBUG_JNI
|
||||
|
||||
static void checkJNIReady(void);
|
||||
|
||||
@@ -330,10 +330,10 @@ static pthread_key_t mThreadKey;
|
||||
static pthread_once_t key_once = PTHREAD_ONCE_INIT;
|
||||
static JavaVM *mJavaVM = NULL;
|
||||
|
||||
/* Main activity */
|
||||
// Main activity
|
||||
static jclass mActivityClass;
|
||||
|
||||
/* method signatures */
|
||||
// method signatures
|
||||
static jmethodID midClipboardGetText;
|
||||
static jmethodID midClipboardHasText;
|
||||
static jmethodID midClipboardSetText;
|
||||
@@ -366,25 +366,25 @@ static jmethodID midSupportsRelativeMouse;
|
||||
static jmethodID midOpenFileDescriptor;
|
||||
static jmethodID midShowFileDialog;
|
||||
|
||||
/* audio manager */
|
||||
// audio manager
|
||||
static jclass mAudioManagerClass;
|
||||
|
||||
/* method signatures */
|
||||
// method signatures
|
||||
static jmethodID midRegisterAudioDeviceCallback;
|
||||
static jmethodID midUnregisterAudioDeviceCallback;
|
||||
static jmethodID midAudioSetThreadPriority;
|
||||
|
||||
/* controller manager */
|
||||
// controller manager
|
||||
static jclass mControllerManagerClass;
|
||||
|
||||
/* method signatures */
|
||||
// method signatures
|
||||
static jmethodID midPollInputDevices;
|
||||
static jmethodID midPollHapticDevices;
|
||||
static jmethodID midHapticRun;
|
||||
static jmethodID midHapticRumble;
|
||||
static jmethodID midHapticStop;
|
||||
|
||||
/* Accelerometer data storage */
|
||||
// Accelerometer data storage
|
||||
static SDL_DisplayOrientation displayNaturalOrientation;
|
||||
static SDL_DisplayOrientation displayCurrentOrientation;
|
||||
static float fLastAccelerometer[3];
|
||||
@@ -392,13 +392,13 @@ static SDL_bool bHasNewData;
|
||||
|
||||
static SDL_bool bHasEnvironmentVariables;
|
||||
|
||||
/* Android AssetManager */
|
||||
// Android AssetManager
|
||||
static void Internal_Android_Create_AssetManager(void);
|
||||
static void Internal_Android_Destroy_AssetManager(void);
|
||||
static AAssetManager *asset_manager = NULL;
|
||||
static jobject javaAssetManagerRef = 0;
|
||||
|
||||
/* Re-create activity hint */
|
||||
// Re-create activity hint
|
||||
static SDL_AtomicInt bAllowRecreateActivity;
|
||||
|
||||
static SDL_Mutex *Android_ActivityMutex = NULL;
|
||||
@@ -433,7 +433,7 @@ static int Android_NumLifecycleEvents;
|
||||
* (except for some lost CPU cycles)
|
||||
*/
|
||||
|
||||
/* Set local storage value */
|
||||
// Set local storage value
|
||||
static int Android_JNI_SetEnv(JNIEnv *env)
|
||||
{
|
||||
int status = pthread_setspecific(mThreadKey, env);
|
||||
@@ -443,16 +443,16 @@ static int Android_JNI_SetEnv(JNIEnv *env)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Get local storage value */
|
||||
// Get local storage value
|
||||
JNIEnv *Android_JNI_GetEnv(void)
|
||||
{
|
||||
/* Get JNIEnv from the Thread local storage */
|
||||
// Get JNIEnv from the Thread local storage
|
||||
JNIEnv *env = pthread_getspecific(mThreadKey);
|
||||
if (!env) {
|
||||
/* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */
|
||||
// If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread()
|
||||
int status;
|
||||
|
||||
/* There should be a JVM */
|
||||
// There should be a JVM
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
|
||||
return NULL;
|
||||
@@ -466,7 +466,7 @@ JNIEnv *Android_JNI_GetEnv(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Save JNIEnv into the Thread local storage */
|
||||
// Save JNIEnv into the Thread local storage
|
||||
if (Android_JNI_SetEnv(env) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -475,13 +475,13 @@ JNIEnv *Android_JNI_GetEnv(void)
|
||||
return env;
|
||||
}
|
||||
|
||||
/* Set up an external thread for using JNI with Android_JNI_GetEnv() */
|
||||
// Set up an external thread for using JNI with Android_JNI_GetEnv()
|
||||
int Android_JNI_SetupThread(void)
|
||||
{
|
||||
JNIEnv *env;
|
||||
int status;
|
||||
|
||||
/* There should be a JVM */
|
||||
// There should be a JVM
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
|
||||
return 0;
|
||||
@@ -495,7 +495,7 @@ int Android_JNI_SetupThread(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save JNIEnv into the Thread local storage */
|
||||
// Save JNIEnv into the Thread local storage
|
||||
if (Android_JNI_SetEnv(env) < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -503,10 +503,10 @@ int Android_JNI_SetupThread(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Destructor called for each thread where mThreadKey is not NULL */
|
||||
// Destructor called for each thread where mThreadKey is not NULL
|
||||
static void Android_JNI_ThreadDestroyed(void *value)
|
||||
{
|
||||
/* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
|
||||
// The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required
|
||||
JNIEnv *env = (JNIEnv *)value;
|
||||
if (env) {
|
||||
(*mJavaVM)->DetachCurrentThread(mJavaVM);
|
||||
@@ -514,7 +514,7 @@ static void Android_JNI_ThreadDestroyed(void *value)
|
||||
}
|
||||
}
|
||||
|
||||
/* Creation of local storage mThreadKey */
|
||||
// Creation of local storage mThreadKey
|
||||
static void Android_JNI_CreateKey(void)
|
||||
{
|
||||
int status = pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed);
|
||||
@@ -540,7 +540,7 @@ static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod
|
||||
}
|
||||
}
|
||||
|
||||
/* Library init */
|
||||
// Library init
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
JNIEnv *env = NULL;
|
||||
@@ -565,14 +565,14 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
void checkJNIReady(void)
|
||||
{
|
||||
if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) {
|
||||
/* We aren't fully initialized, let's just return. */
|
||||
// We aren't fully initialized, let's just return.
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SetMainReady();
|
||||
}
|
||||
|
||||
/* Get SDL version -- called before SDL_main() to verify JNI bindings */
|
||||
// Get SDL version -- called before SDL_main() to verify JNI bindings
|
||||
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
char version[128];
|
||||
@@ -582,12 +582,12 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jcla
|
||||
return (*env)->NewStringUTF(env, version);
|
||||
}
|
||||
|
||||
/* Activity initialization -- called before SDL_main() to initialize JNI bindings */
|
||||
// Activity initialization -- called before SDL_main() to initialize JNI bindings
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
|
||||
|
||||
/* Start with a clean slate */
|
||||
// Start with a clean slate
|
||||
SDL_ClearError();
|
||||
|
||||
/*
|
||||
@@ -596,7 +596,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
*/
|
||||
Android_JNI_CreateKey_once();
|
||||
|
||||
/* Save JNIEnv of SDLActivity */
|
||||
// Save JNIEnv of SDLActivity
|
||||
Android_JNI_SetEnv(env);
|
||||
|
||||
if (!mJavaVM) {
|
||||
@@ -607,7 +607,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
* (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
|
||||
*/
|
||||
if (!Android_ActivityMutex) {
|
||||
Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */
|
||||
Android_ActivityMutex = SDL_CreateMutex(); // Could this be created twice if onCreate() is called a second time ?
|
||||
}
|
||||
|
||||
if (!Android_ActivityMutex) {
|
||||
@@ -695,7 +695,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
checkJNIReady();
|
||||
}
|
||||
|
||||
/* Audio initialization -- called before SDL_main() to initialize JNI bindings */
|
||||
// Audio initialization -- called before SDL_main() to initialize JNI bindings
|
||||
JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()");
|
||||
@@ -719,7 +719,7 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jcl
|
||||
checkJNIReady();
|
||||
}
|
||||
|
||||
/* Controller initialization -- called before SDL_main() to initialize JNI bindings */
|
||||
// Controller initialization -- called before SDL_main() to initialize JNI bindings
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()");
|
||||
@@ -744,7 +744,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env
|
||||
checkJNIReady();
|
||||
}
|
||||
|
||||
/* SDL main function prototype */
|
||||
// SDL main function prototype
|
||||
typedef int (*SDL_main_func)(int argc, char *argv[]);
|
||||
|
||||
static int run_count = 0;
|
||||
@@ -781,7 +781,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeInitMainThread)(
|
||||
}
|
||||
run_count += 1;
|
||||
|
||||
/* Save JNIEnv of SDLThread */
|
||||
// Save JNIEnv of SDLThread
|
||||
Android_JNI_SetEnv(env);
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeCleanupMainThread)(
|
||||
Android_JNI_SetEnv(NULL);
|
||||
}
|
||||
|
||||
/* Start up the SDL app */
|
||||
// Start up the SDL app
|
||||
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, jstring library, jstring function, jobject array)
|
||||
{
|
||||
int status = -1;
|
||||
@@ -826,9 +826,9 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
||||
char **argv;
|
||||
SDL_bool isstack;
|
||||
|
||||
/* Prepare the arguments. */
|
||||
// Prepare the arguments.
|
||||
len = (*env)->GetArrayLength(env, array);
|
||||
argv = SDL_small_alloc(char *, 1 + len + 1, &isstack); /* !!! FIXME: check for NULL */
|
||||
argv = SDL_small_alloc(char *, 1 + len + 1, &isstack); // !!! FIXME: check for NULL
|
||||
argc = 0;
|
||||
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
|
||||
https://github.com/love2d/love-android/issues/24
|
||||
@@ -852,10 +852,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
/* Run the application. */
|
||||
// Run the application.
|
||||
status = SDL_main(argc, argv);
|
||||
|
||||
/* Release the arguments. */
|
||||
// Release the arguments.
|
||||
for (i = 0; i < argc; ++i) {
|
||||
SDL_free(argv[i]);
|
||||
}
|
||||
@@ -873,8 +873,8 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, library, library_file);
|
||||
|
||||
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
||||
/* exit(status); */
|
||||
// Do not issue an exit or the whole application will terminate instead of just the SDL thread
|
||||
// exit(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -984,7 +984,7 @@ void Android_UnlockActivityMutex(void)
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Drop file */
|
||||
// Drop file
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jstring filename)
|
||||
@@ -995,7 +995,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
|
||||
SDL_SendDropComplete(NULL);
|
||||
}
|
||||
|
||||
/* Set screen resolution */
|
||||
// Set screen resolution
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint surfaceWidth, jint surfaceHeight,
|
||||
@@ -1008,7 +1008,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Resize */
|
||||
// Resize
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)(
|
||||
JNIEnv *env, jclass jcls)
|
||||
{
|
||||
@@ -1116,7 +1116,7 @@ SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean r
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Paddown */
|
||||
// Paddown
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode)
|
||||
@@ -1125,10 +1125,10 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
return Android_OnPadDown(device_id, keycode);
|
||||
#else
|
||||
return -1;
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
/* Padup */
|
||||
// Padup
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode)
|
||||
@@ -1137,27 +1137,27 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
return Android_OnPadUp(device_id, keycode);
|
||||
#else
|
||||
return -1;
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
/* Joy */
|
||||
// Joy
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint axis, jfloat value)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
Android_OnJoy(device_id, axis, value);
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
/* POV Hat */
|
||||
// POV Hat
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint hat_id, jint x, jint y)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
Android_OnHat(device_id, hat_id, x, y);
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
@@ -1177,7 +1177,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
(*env)->ReleaseStringUTFChars(env, device_desc, desc);
|
||||
#else
|
||||
retval = -1;
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1189,7 +1189,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
|
||||
return Android_RemoveJoystick(device_id);
|
||||
#else
|
||||
return -1;
|
||||
#endif /* SDL_JOYSTICK_ANDROID */
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
@@ -1204,7 +1204,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
(*env)->ReleaseStringUTFChars(env, device_name, name);
|
||||
#else
|
||||
retval = -1;
|
||||
#endif /* SDL_HAPTIC_ANDROID */
|
||||
#endif // SDL_HAPTIC_ANDROID
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1218,7 +1218,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Called from surfaceCreated() */
|
||||
// Called from surfaceCreated()
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, jclass jcls)
|
||||
{
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
@@ -1236,7 +1236,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, j
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Called from surfaceChanged() */
|
||||
// Called from surfaceChanged()
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, jclass jcls)
|
||||
{
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
@@ -1246,20 +1246,20 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_WindowData *data = Android_Window->internal;
|
||||
|
||||
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
|
||||
// If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here
|
||||
if (data->egl_surface == EGL_NO_SURFACE) {
|
||||
data->egl_surface = SDL_EGL_CreateSurface(_this, Android_Window, (NativeWindowType)data->native_window);
|
||||
SDL_SetPointerProperty(SDL_GetWindowProperties(Android_Window), SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER, data->egl_surface);
|
||||
}
|
||||
|
||||
/* GL Context handling is done in the event loop because this function is run from the Java thread */
|
||||
// GL Context handling is done in the event loop because this function is run from the Java thread
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Called from surfaceDestroyed() */
|
||||
// Called from surfaceDestroyed()
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env, jclass jcls)
|
||||
{
|
||||
int nb_attempt = 50;
|
||||
@@ -1271,7 +1271,7 @@ retry:
|
||||
if (Android_Window) {
|
||||
SDL_WindowData *data = Android_Window->internal;
|
||||
|
||||
/* Wait for Main thread being paused and context un-activated to release 'egl_surface' */
|
||||
// Wait for Main thread being paused and context un-activated to release 'egl_surface'
|
||||
if ((Android_Window->flags & SDL_WINDOW_OPENGL) && !data->backup_done) {
|
||||
nb_attempt -= 1;
|
||||
if (nb_attempt == 0) {
|
||||
@@ -1295,13 +1295,13 @@ retry:
|
||||
data->native_window = NULL;
|
||||
}
|
||||
|
||||
/* GL Context handling is done in the event loop because this function is run from the Java thread */
|
||||
// GL Context handling is done in the event loop because this function is run from the Java thread
|
||||
}
|
||||
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Keydown */
|
||||
// Keydown
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint keycode)
|
||||
@@ -1315,7 +1315,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Keyup */
|
||||
// Keyup
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint keycode)
|
||||
@@ -1329,7 +1329,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Virtual keyboard return key might stop text input */
|
||||
// Virtual keyboard return key might stop text input
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
||||
JNIEnv *env, jclass jcls)
|
||||
{
|
||||
@@ -1340,15 +1340,15 @@ JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/* Keyboard Focus Lost */
|
||||
// Keyboard Focus Lost
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
|
||||
JNIEnv *env, jclass jcls)
|
||||
{
|
||||
/* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */
|
||||
// Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget
|
||||
SDL_StopTextInput(Android_Window);
|
||||
}
|
||||
|
||||
/* Touch */
|
||||
// Touch
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint touch_device_id_in, jint pointer_finger_id_in,
|
||||
@@ -1361,7 +1361,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Mouse */
|
||||
// Mouse
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint button, jint action, jfloat x, jfloat y, jboolean relative)
|
||||
@@ -1373,7 +1373,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Accelerometer */
|
||||
// Accelerometer
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jfloat x, jfloat y, jfloat z)
|
||||
@@ -1384,14 +1384,14 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
|
||||
bHasNewData = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Clipboard */
|
||||
// Clipboard
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)(
|
||||
JNIEnv *env, jclass jcls)
|
||||
{
|
||||
SDL_SendClipboardUpdate();
|
||||
}
|
||||
|
||||
/* Low memory */
|
||||
// Low memory
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
|
||||
JNIEnv *env, jclass cls)
|
||||
{
|
||||
@@ -1406,21 +1406,21 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeLocaleChanged)(
|
||||
SDL_SendAppEvent(SDL_EVENT_LOCALE_CHANGED);
|
||||
}
|
||||
|
||||
/* Dark mode */
|
||||
// Dark mode
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDarkModeChanged)(
|
||||
JNIEnv *env, jclass cls, jboolean enabled)
|
||||
{
|
||||
Android_SetDarkMode(enabled);
|
||||
}
|
||||
|
||||
/* Send Quit event to "SDLThread" thread */
|
||||
// Send Quit event to "SDLThread" thread
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
|
||||
JNIEnv *env, jclass cls)
|
||||
{
|
||||
Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_DESTROY);
|
||||
}
|
||||
|
||||
/* Activity ends */
|
||||
// Activity ends
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
|
||||
JNIEnv *env, jclass cls)
|
||||
{
|
||||
@@ -1453,7 +1453,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
|
||||
}
|
||||
}
|
||||
|
||||
/* Pause */
|
||||
// Pause
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
|
||||
JNIEnv *env, jclass cls)
|
||||
{
|
||||
@@ -1462,7 +1462,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
|
||||
Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_PAUSE);
|
||||
}
|
||||
|
||||
/* Resume */
|
||||
// Resume
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
|
||||
JNIEnv *env, jclass cls)
|
||||
{
|
||||
@@ -1692,21 +1692,21 @@ void Android_AudioThreadInit(SDL_AudioDevice *device)
|
||||
Android_JNI_AudioSetThreadPriority((int) device->recording, (int)device->instance_id);
|
||||
}
|
||||
|
||||
/* Test for an exception and call SDL_SetError with its detail if one occurs */
|
||||
/* If the parameter silent is truthy then SDL_SetError() will not be called. */
|
||||
// Test for an exception and call SDL_SetError with its detail if one occurs
|
||||
// If the parameter silent is truthy then SDL_SetError() will not be called.
|
||||
static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jthrowable exception;
|
||||
|
||||
/* Detect mismatch LocalReferenceHolder_Init/Cleanup */
|
||||
// Detect mismatch LocalReferenceHolder_Init/Cleanup
|
||||
SDL_assert(SDL_AtomicGet(&s_active) > 0);
|
||||
|
||||
exception = (*env)->ExceptionOccurred(env);
|
||||
if (exception != NULL) {
|
||||
jmethodID mid;
|
||||
|
||||
/* Until this happens most JNI operations have undefined behaviour */
|
||||
// Until this happens most JNI operations have undefined behaviour
|
||||
(*env)->ExceptionClear(env);
|
||||
|
||||
if (!silent) {
|
||||
@@ -1754,10 +1754,10 @@ static void Internal_Android_Create_AssetManager(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
|
||||
/* javaAssetManager = context.getAssets(); */
|
||||
// javaAssetManager = context.getAssets();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
|
||||
"getAssets", "()Landroid/content/res/AssetManager;");
|
||||
javaAssetManager = (*env)->CallObjectMethod(env, context, mid);
|
||||
@@ -1901,7 +1901,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
|
||||
action = (*env)->NewStringUTF(env, "android.intent.action.BATTERY_CHANGED");
|
||||
@@ -1922,7 +1922,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
|
||||
|
||||
imid = (*env)->GetMethodID(env, cls, "getIntExtra", "(Ljava/lang/String;I)I");
|
||||
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
#define GET_INT_EXTRA(var, key) \
|
||||
int var; \
|
||||
iname = (*env)->NewStringUTF(env, key); \
|
||||
@@ -1931,7 +1931,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
|
||||
|
||||
bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z");
|
||||
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
#define GET_BOOL_EXTRA(var, key) \
|
||||
int var; \
|
||||
bname = (*env)->NewStringUTF(env, key); \
|
||||
@@ -1939,49 +1939,49 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
|
||||
(*env)->DeleteLocalRef(env, bname);
|
||||
|
||||
if (plugged) {
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
GET_INT_EXTRA(plug, "plugged") // == BatteryManager.EXTRA_PLUGGED (API 5)
|
||||
if (plug == -1) {
|
||||
LocalReferenceHolder_Cleanup(&refs);
|
||||
return -1;
|
||||
}
|
||||
/* 1 == BatteryManager.BATTERY_PLUGGED_AC */
|
||||
/* 2 == BatteryManager.BATTERY_PLUGGED_USB */
|
||||
// 1 == BatteryManager.BATTERY_PLUGGED_AC
|
||||
// 2 == BatteryManager.BATTERY_PLUGGED_USB
|
||||
*plugged = (0 < plug) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (charged) {
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
GET_INT_EXTRA(status, "status") // == BatteryManager.EXTRA_STATUS (API 5)
|
||||
if (status == -1) {
|
||||
LocalReferenceHolder_Cleanup(&refs);
|
||||
return -1;
|
||||
}
|
||||
/* 5 == BatteryManager.BATTERY_STATUS_FULL */
|
||||
// 5 == BatteryManager.BATTERY_STATUS_FULL
|
||||
*charged = (status == 5) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (battery) {
|
||||
GET_BOOL_EXTRA(present, "present") /* == BatteryManager.EXTRA_PRESENT (API 5) */
|
||||
GET_BOOL_EXTRA(present, "present") // == BatteryManager.EXTRA_PRESENT (API 5)
|
||||
*battery = present ? 1 : 0;
|
||||
}
|
||||
|
||||
if (seconds) {
|
||||
*seconds = -1; /* not possible */
|
||||
*seconds = -1; // not possible
|
||||
}
|
||||
|
||||
if (percent) {
|
||||
int level;
|
||||
int scale;
|
||||
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
{
|
||||
GET_INT_EXTRA(level_temp, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */
|
||||
GET_INT_EXTRA(level_temp, "level") // == BatteryManager.EXTRA_LEVEL (API 5)
|
||||
level = level_temp;
|
||||
}
|
||||
/* Watch out for C89 scoping rules because of the macro */
|
||||
// Watch out for C89 scoping rules because of the macro
|
||||
{
|
||||
GET_INT_EXTRA(scale_temp, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */
|
||||
GET_INT_EXTRA(scale_temp, "scale") // == BatteryManager.EXTRA_SCALE (API 5)
|
||||
scale = scale_temp;
|
||||
}
|
||||
|
||||
@@ -1998,7 +1998,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add all touch devices */
|
||||
// Add all touch devices
|
||||
void Android_JNI_InitTouch(void)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
@@ -2035,7 +2035,7 @@ void Android_JNI_HapticStop(int device_id)
|
||||
(*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticStop, device_id);
|
||||
}
|
||||
|
||||
/* See SDLActivity.java for constants. */
|
||||
// See SDLActivity.java for constants.
|
||||
#define COMMAND_SET_KEEP_SCREEN_ON 5
|
||||
|
||||
int SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
@@ -2046,7 +2046,7 @@ int SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* sends message to be handled on the UI event dispatch thread */
|
||||
// sends message to be handled on the UI event dispatch thread
|
||||
int Android_JNI_SendMessage(int command, int param)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
@@ -2073,7 +2073,7 @@ void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect)
|
||||
|
||||
void Android_JNI_HideScreenKeyboard(void)
|
||||
{
|
||||
/* has to match Activity constant */
|
||||
// has to match Activity constant
|
||||
const int COMMAND_TEXTEDIT_HIDE = 3;
|
||||
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
|
||||
}
|
||||
@@ -2104,7 +2104,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
|
||||
env = Android_JNI_GetEnv();
|
||||
|
||||
/* convert parameters */
|
||||
// convert parameters
|
||||
|
||||
clazz = (*env)->FindClass(env, "java/lang/String");
|
||||
|
||||
@@ -2148,7 +2148,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
|
||||
(*env)->DeleteLocalRef(env, clazz);
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, context);
|
||||
@@ -2167,7 +2167,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
(*env)->DeleteLocalRef(env, context);
|
||||
(*env)->DeleteLocalRef(env, clazz);
|
||||
|
||||
/* delete parameters */
|
||||
// delete parameters
|
||||
|
||||
(*env)->DeleteLocalRef(env, title);
|
||||
(*env)->DeleteLocalRef(env, message);
|
||||
@@ -2193,14 +2193,14 @@ void *SDL_GetAndroidJNIEnv(void)
|
||||
|
||||
void *SDL_GetAndroidActivity(void)
|
||||
{
|
||||
/* See SDL_system.h for caveats on using this function. */
|
||||
// See SDL_system.h for caveats on using this function.
|
||||
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (!env) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* return SDLActivity.getContext(); */
|
||||
// return SDLActivity.getContext();
|
||||
return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
}
|
||||
|
||||
@@ -2264,7 +2264,7 @@ const char *SDL_GetAndroidInternalStoragePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
if (!context) {
|
||||
SDL_SetError("Couldn't get Android context!");
|
||||
@@ -2272,7 +2272,7 @@ const char *SDL_GetAndroidInternalStoragePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fileObj = context.getFilesDir(); */
|
||||
// fileObj = context.getFilesDir();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
|
||||
"getFilesDir", "()Ljava/io/File;");
|
||||
fileObject = (*env)->CallObjectMethod(env, context, mid);
|
||||
@@ -2282,7 +2282,7 @@ const char *SDL_GetAndroidInternalStoragePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* path = fileObject.getCanonicalPath(); */
|
||||
// path = fileObject.getCanonicalPath();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
|
||||
"getCanonicalPath", "()Ljava/lang/String;");
|
||||
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
|
||||
@@ -2322,7 +2322,7 @@ Uint32 SDL_GetAndroidExternalStorageState(void)
|
||||
|
||||
state_string = (*env)->GetStringUTFChars(env, stateString, NULL);
|
||||
|
||||
/* Print an info message so people debugging know the storage state */
|
||||
// Print an info message so people debugging know the storage state
|
||||
__android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state_string);
|
||||
|
||||
if (SDL_strcmp(state_string, "mounted") == 0) {
|
||||
@@ -2358,10 +2358,10 @@ const char *SDL_GetAndroidExternalStoragePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
|
||||
/* fileObj = context.getExternalFilesDir(); */
|
||||
// fileObj = context.getExternalFilesDir();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
|
||||
"getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
|
||||
fileObject = (*env)->CallObjectMethod(env, context, mid, NULL);
|
||||
@@ -2371,7 +2371,7 @@ const char *SDL_GetAndroidExternalStoragePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* path = fileObject.getAbsolutePath(); */
|
||||
// path = fileObject.getAbsolutePath();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
|
||||
"getAbsolutePath", "()Ljava/lang/String;");
|
||||
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
|
||||
@@ -2404,10 +2404,10 @@ const char *SDL_GetAndroidCachePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* context = SDLActivity.getContext(); */
|
||||
// context = SDLActivity.getContext();
|
||||
context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||
|
||||
/* fileObj = context.getExternalFilesDir(); */
|
||||
// fileObj = context.getExternalFilesDir();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
|
||||
"getCacheDir", "(Ljava/lang/String;)Ljava/io/File;");
|
||||
fileObject = (*env)->CallObjectMethod(env, context, mid, NULL);
|
||||
@@ -2417,7 +2417,7 @@ const char *SDL_GetAndroidCachePath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* path = fileObject.getAbsolutePath(); */
|
||||
// path = fileObject.getAbsolutePath();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
|
||||
"getAbsolutePath", "()Ljava/lang/String;");
|
||||
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
|
||||
@@ -2568,7 +2568,7 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Show toast notification */
|
||||
// Show toast notification
|
||||
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -2585,7 +2585,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
|
||||
SDL_assert(buflen > 6);
|
||||
|
||||
/* Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED) */
|
||||
// Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED)
|
||||
Internal_Android_Destroy_AssetManager();
|
||||
|
||||
if (!asset_manager) {
|
||||
@@ -2610,7 +2610,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
AConfiguration_getLanguage(cfg, language);
|
||||
AConfiguration_getCountry(cfg, country);
|
||||
|
||||
/* copy language (not null terminated) */
|
||||
// copy language (not null terminated)
|
||||
if (language[0]) {
|
||||
buf[id++] = language[0];
|
||||
if (language[1]) {
|
||||
@@ -2620,7 +2620,7 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
|
||||
buf[id++] = '_';
|
||||
|
||||
/* copy country (not null terminated) */
|
||||
// copy country (not null terminated)
|
||||
if (country[0]) {
|
||||
buf[id++] = country[0];
|
||||
if (country[1]) {
|
||||
@@ -2648,7 +2648,7 @@ int Android_JNI_OpenURL(const char *url)
|
||||
|
||||
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode)
|
||||
{
|
||||
/* Get fopen-style modes */
|
||||
// Get fopen-style modes
|
||||
int moderead = 0, modewrite = 0, modeappend = 0, modeupdate = 0;
|
||||
|
||||
for (const char *cmode = mode; *cmode; cmode++) {
|
||||
@@ -2670,8 +2670,8 @@ int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode)
|
||||
}
|
||||
}
|
||||
|
||||
/* Translate fopen-style modes to ContentResolver modes. */
|
||||
/* Android only allows "r", "w", "wt", "wa", "rw" or "rwt". */
|
||||
// Translate fopen-style modes to ContentResolver modes.
|
||||
// Android only allows "r", "w", "wt", "wa", "rw" or "rwt".
|
||||
const char *contentResolverMode = "r";
|
||||
|
||||
if (moderead) {
|
||||
@@ -2719,7 +2719,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||
return;
|
||||
}
|
||||
|
||||
/* Convert fileList to string */
|
||||
// Convert fileList to string
|
||||
size_t count = (*env)->GetArrayLength(env, fileList);
|
||||
char **charFileList = SDL_calloc(sizeof(char*), count + 1);
|
||||
|
||||
@@ -2729,8 +2729,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||
return;
|
||||
}
|
||||
|
||||
/* Convert to UTF-8 */
|
||||
/* TODO: Fix modified UTF-8 to classic UTF-8 */
|
||||
// Convert to UTF-8
|
||||
// TODO: Fix modified UTF-8 to classic UTF-8
|
||||
for (int i = 0; i < count; i++) {
|
||||
jstring string = (*env)->GetObjectArrayElement(env, fileList, i);
|
||||
if (!string) {
|
||||
@@ -2750,7 +2750,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||
mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, NULL, -1);
|
||||
mAndroidFileDialogData.callback = NULL;
|
||||
|
||||
/* Cleanup memory */
|
||||
// Cleanup memory
|
||||
for (int j = 0; j < i; j++) {
|
||||
SDL_free(charFileList[j]);
|
||||
}
|
||||
@@ -2763,12 +2763,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||
(*env)->DeleteLocalRef(env, string);
|
||||
}
|
||||
|
||||
/* Call user-provided callback */
|
||||
// Call user-provided callback
|
||||
SDL_ClearError();
|
||||
mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, (const char *const *) charFileList, filter);
|
||||
mAndroidFileDialogData.callback = NULL;
|
||||
|
||||
/* Cleanup memory */
|
||||
// Cleanup memory
|
||||
for (int i = 0; i < count; i++) {
|
||||
SDL_free(charFileList[i]);
|
||||
}
|
||||
@@ -2792,13 +2792,13 @@ SDL_bool Android_JNI_OpenFileDialog(
|
||||
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
|
||||
/* Setup filters */
|
||||
// Setup filters
|
||||
jobjectArray filtersArray = NULL;
|
||||
if (filters) {
|
||||
jclass stringClass = (*env)->FindClass(env, "java/lang/String");
|
||||
filtersArray = (*env)->NewObjectArray(env, nfilters, stringClass, NULL);
|
||||
|
||||
/* Convert to string */
|
||||
// Convert to string
|
||||
for (int i = 0; i < nfilters; i++) {
|
||||
jstring str = (*env)->NewStringUTF(env, filters[i].pattern);
|
||||
(*env)->SetObjectArrayElement(env, filtersArray, i, str);
|
||||
@@ -2806,13 +2806,13 @@ SDL_bool Android_JNI_OpenFileDialog(
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup data */
|
||||
// Setup data
|
||||
static SDL_AtomicInt next_request_code;
|
||||
mAndroidFileDialogData.request_code = SDL_AtomicAdd(&next_request_code, 1);
|
||||
mAndroidFileDialogData.userdata = userdata;
|
||||
mAndroidFileDialogData.callback = callback;
|
||||
|
||||
/* Invoke JNI */
|
||||
// Invoke JNI
|
||||
jboolean success = (*env)->CallStaticBooleanMethod(env, mActivityClass,
|
||||
midShowFileDialog, filtersArray, (jboolean) multiple, (jboolean) forwrite, mAndroidFileDialogData.request_code);
|
||||
(*env)->DeleteLocalRef(env, filtersArray);
|
||||
@@ -2827,4 +2827,4 @@ SDL_bool Android_JNI_OpenFileDialog(
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#endif /* SDL_PLATFORM_ANDROID */
|
||||
#endif // SDL_PLATFORM_ANDROID
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef SDL_android_h
|
||||
#define SDL_android_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
@@ -38,7 +38,7 @@ extern "C" {
|
||||
// this appears to be broken right now (on Android, not SDL, I think...?).
|
||||
#define ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES 0
|
||||
|
||||
/* Life cycle */
|
||||
// Life cycle
|
||||
typedef enum
|
||||
{
|
||||
SDL_ANDROID_LIFECYCLE_WAKE,
|
||||
@@ -55,7 +55,7 @@ SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 tim
|
||||
void Android_LockActivityMutex(void);
|
||||
void Android_UnlockActivityMutex(void);
|
||||
|
||||
/* Interface from the SDL library into the Android Java activity */
|
||||
// Interface from the SDL library into the Android Java activity
|
||||
extern void Android_JNI_SetActivityTitle(const char *title);
|
||||
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
|
||||
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
|
||||
@@ -71,12 +71,12 @@ extern ANativeWindow *Android_JNI_GetNativeWindow(void);
|
||||
extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void);
|
||||
extern SDL_DisplayOrientation Android_JNI_GetDisplayCurrentOrientation(void);
|
||||
|
||||
/* Audio support */
|
||||
// Audio support
|
||||
void Android_StartAudioHotplug(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
|
||||
void Android_StopAudioHotplug(void);
|
||||
extern void Android_AudioThreadInit(SDL_AudioDevice *device);
|
||||
|
||||
/* Detecting device type */
|
||||
// Detecting device type
|
||||
extern SDL_bool Android_IsDeXMode(void);
|
||||
extern SDL_bool Android_IsChromebook(void);
|
||||
|
||||
@@ -87,58 +87,58 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta
|
||||
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status);
|
||||
int Android_JNI_FileClose(void *userdata);
|
||||
|
||||
/* Environment support */
|
||||
// Environment support
|
||||
void Android_JNI_GetManifestEnvironmentVariables(void);
|
||||
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
|
||||
|
||||
/* Clipboard support */
|
||||
// Clipboard support
|
||||
int Android_JNI_SetClipboardText(const char *text);
|
||||
char *Android_JNI_GetClipboardText(void);
|
||||
SDL_bool Android_JNI_HasClipboardText(void);
|
||||
|
||||
/* Power support */
|
||||
// Power support
|
||||
int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent);
|
||||
|
||||
/* Joystick support */
|
||||
// Joystick support
|
||||
void Android_JNI_PollInputDevices(void);
|
||||
|
||||
/* Haptic support */
|
||||
// Haptic support
|
||||
void Android_JNI_PollHapticDevices(void);
|
||||
void Android_JNI_HapticRun(int device_id, float intensity, int length);
|
||||
void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, float high_frequency_intensity, int length);
|
||||
void Android_JNI_HapticStop(int device_id);
|
||||
|
||||
/* Video */
|
||||
// Video
|
||||
int Android_JNI_SuspendScreenSaver(SDL_bool suspend);
|
||||
|
||||
/* Touch support */
|
||||
// Touch support
|
||||
void Android_JNI_InitTouch(void);
|
||||
|
||||
/* Threads */
|
||||
// Threads
|
||||
#include <jni.h>
|
||||
JNIEnv *Android_JNI_GetEnv(void);
|
||||
int Android_JNI_SetupThread(void);
|
||||
|
||||
/* Locale */
|
||||
// Locale
|
||||
int Android_JNI_GetLocale(char *buf, size_t buflen);
|
||||
|
||||
/* Generic messages */
|
||||
// Generic messages
|
||||
int Android_JNI_SendMessage(int command, int param);
|
||||
|
||||
/* MessageBox */
|
||||
// MessageBox
|
||||
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||
|
||||
/* Cursor support */
|
||||
// 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);
|
||||
|
||||
/* Relative mouse support */
|
||||
// Relative mouse support
|
||||
SDL_bool Android_JNI_SupportsRelativeMouse(void);
|
||||
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled);
|
||||
|
||||
/* Show toast notification */
|
||||
// Show toast notification
|
||||
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
|
||||
|
||||
int Android_JNI_OpenURL(const char *url);
|
||||
@@ -150,12 +150,12 @@ SDL_bool SDL_IsAndroidTV(void);
|
||||
SDL_bool SDL_IsChromebook(void);
|
||||
SDL_bool SDL_IsDeXMode(void);
|
||||
|
||||
/* File Dialogs */
|
||||
// File Dialogs
|
||||
SDL_bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
|
||||
const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite,
|
||||
SDL_bool multiple);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <sys/kbio.h>
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
/*
|
||||
* Automatically generated from /usr/share/vt/keymaps/us.acc.kbd.
|
||||
* DO NOT EDIT!
|
||||
@@ -123,45 +123,45 @@ static keymap_t keymap_default_us_acc = { 0x6d, {
|
||||
} };
|
||||
|
||||
static accentmap_t accentmap_default_us_acc = { 11, {
|
||||
/* dgra=0 */
|
||||
// dgra=0
|
||||
{ '`', { { 'a',0xe0 }, { 'A',0xc0 }, { 'e',0xe8 }, { 'E',0xc8 },
|
||||
{ 'i',0xec }, { 'I',0xcc }, { 'o',0xf2 }, { 'O',0xd2 },
|
||||
{ 'u',0xf9 }, { 'U',0xd9 }, }, },
|
||||
/* dacu=1 */
|
||||
// dacu=1
|
||||
{ 0xb4, { { 'a',0xe1 }, { 'A',0xc1 }, { 'e',0xe9 }, { 'E',0xc9 },
|
||||
{ 'i',0xed }, { 'I',0xcd }, { 'o',0xf3 }, { 'O',0xd3 },
|
||||
{ 'u',0xfa }, { 'U',0xda }, { 'y',0xfd }, { 'Y',0xdd }, }, },
|
||||
/* dcir=2 */
|
||||
// dcir=2
|
||||
{ '^', { { 'a',0xe2 }, { 'A',0xc2 }, { 'e',0xea }, { 'E',0xca },
|
||||
{ 'i',0xee }, { 'I',0xce }, { 'o',0xf4 }, { 'O',0xd4 },
|
||||
{ 'u',0xfb }, { 'U',0xdb }, }, },
|
||||
/* dtil=3 */
|
||||
// dtil=3
|
||||
{ '~', { { 'a',0xe3 }, { 'A',0xc3 }, { 'n',0xf1 }, { 'N',0xd1 },
|
||||
{ 'o',0xf5 }, { 'O',0xd5 }, }, },
|
||||
/* dmac=4 */
|
||||
{ 0x00 },
|
||||
/* dbre=5 */
|
||||
{ 0x00 },
|
||||
/* ddot=6 */
|
||||
{ 0x00 },
|
||||
/* duml=7 */
|
||||
// dmac=4
|
||||
{ 0x00 },
|
||||
// dbre=5
|
||||
{ 0x00 },
|
||||
// ddot=6
|
||||
{ 0x00 },
|
||||
// duml=7
|
||||
{ 0xa8, { { 'a',0xe4 }, { 'A',0xc4 }, { 'e',0xeb }, { 'E',0xcb },
|
||||
{ 'i',0xef }, { 'I',0xcf }, { 'o',0xf6 }, { 'O',0xd6 },
|
||||
{ 'u',0xfc }, { 'U',0xdc }, { 'y',0xff }, }, },
|
||||
/* dsla=8 */
|
||||
{ 0x00 },
|
||||
/* drin=9 */
|
||||
// dsla=8
|
||||
{ 0x00 },
|
||||
// drin=9
|
||||
{ 0xb0, { { 'a',0xe5 }, { 'A',0xc5 }, }, },
|
||||
/* dced=10 */
|
||||
// dced=10
|
||||
{ 0xb8, { { 'c',0xe7 }, { 'C',0xc7 }, }, },
|
||||
/* dapo=11 */
|
||||
{ 0x00 },
|
||||
/* ddac=12 */
|
||||
{ 0x00 },
|
||||
/* dogo=13 */
|
||||
{ 0x00 },
|
||||
/* dcar=14 */
|
||||
{ 0x00 },
|
||||
// dapo=11
|
||||
{ 0x00 },
|
||||
// ddac=12
|
||||
{ 0x00 },
|
||||
// dogo=13
|
||||
{ 0x00 },
|
||||
// dcar=14
|
||||
{ 0x00 },
|
||||
} };
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifdef SDL_INPUT_FBSDKBIO
|
||||
|
||||
/* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source, slightly modified to work with FreeBSD */
|
||||
// This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source, slightly modified to work with FreeBSD
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -52,12 +52,12 @@ struct SDL_EVDEV_keyboard_state
|
||||
unsigned short **key_maps;
|
||||
keymap_t *key_map;
|
||||
keyboard_info_t *kbInfo;
|
||||
unsigned char shift_down[4]; /* shift state counters.. */
|
||||
unsigned char shift_down[4]; // shift state counters..
|
||||
SDL_bool dead_key_next;
|
||||
int npadch; /* -1 or number assembled on pad */
|
||||
int npadch; // -1 or number assembled on pad
|
||||
accentmap_t *accents;
|
||||
unsigned int diacr;
|
||||
SDL_bool rep; /* flag telling character repeat */
|
||||
SDL_bool rep; // flag telling character repeat
|
||||
unsigned char lockstate;
|
||||
unsigned char ledflagstate;
|
||||
char shift_state;
|
||||
@@ -77,7 +77,7 @@ static int kbd_cleanup_atexit_installed = 0;
|
||||
static struct sigaction old_sigaction[NSIG];
|
||||
|
||||
static int fatal_signals[] = {
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */
|
||||
// Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit.
|
||||
SIGHUP, SIGQUIT, SIGILL, SIGABRT,
|
||||
SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
|
||||
SIGSYS
|
||||
@@ -114,22 +114,22 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
|
||||
struct sigaction *old_action_p = &(old_sigaction[signum]);
|
||||
sigset_t sigset;
|
||||
|
||||
/* Restore original signal handler before going any further. */
|
||||
// Restore original signal handler before going any further.
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
|
||||
/* Unmask current signal. */
|
||||
// Unmask current signal.
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, signum);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
|
||||
/* Save original signal info and context for archeologists. */
|
||||
// Save original signal info and context for archeologists.
|
||||
SDL_EVDEV_kdb_cleanup_siginfo = info;
|
||||
SDL_EVDEV_kdb_cleanup_ucontext = ucontext;
|
||||
|
||||
/* Restore keyboard. */
|
||||
// Restore keyboard.
|
||||
kbd_cleanup();
|
||||
|
||||
/* Reraise signal. */
|
||||
// Reraise signal.
|
||||
SDL_EVDEV_kbd_reraise_signal(signum);
|
||||
}
|
||||
|
||||
@@ -150,27 +150,27 @@ static void kbd_unregister_emerg_cleanup(void)
|
||||
int signum = fatal_signals[tabidx];
|
||||
old_action_p = &(old_sigaction[signum]);
|
||||
|
||||
/* Examine current signal action */
|
||||
// Examine current signal action
|
||||
if (sigaction(signum, NULL, &cur_action)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check if action installed and not modified */
|
||||
// Check if action installed and not modified
|
||||
if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Restore original action */
|
||||
// Restore original action
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void kbd_cleanup_atexit(void)
|
||||
{
|
||||
/* Restore keyboard. */
|
||||
// Restore keyboard.
|
||||
kbd_cleanup();
|
||||
|
||||
/* Try to restore signal handlers in case shared library is being unloaded */
|
||||
// Try to restore signal handlers in case shared library is being unloaded
|
||||
kbd_unregister_emerg_cleanup();
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ SDL_EVDEV_keyboard_state *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) */
|
||||
// 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 | O_CLOEXEC);
|
||||
|
||||
kbd->shift_state = 0;
|
||||
@@ -258,7 +258,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
}
|
||||
|
||||
if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) {
|
||||
/* Set the keyboard in XLATE mode and load the keymaps */
|
||||
// Set the keyboard in XLATE mode and load the keymaps
|
||||
ioctl(kbd->console_fd, KDSKBMODE, (unsigned long)(K_XLATE));
|
||||
if (!SDL_EVDEV_kbd_load_keymaps(kbd)) {
|
||||
SDL_free(kbd->key_map);
|
||||
@@ -306,7 +306,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
|
||||
kbd_unregister_emerg_cleanup();
|
||||
|
||||
if (kbd->keyboard_fd >= 0) {
|
||||
/* Restore the original keyboard mode */
|
||||
// Restore the original keyboard mode
|
||||
ioctl(kbd->keyboard_fd, KDSKBMODE, kbd->old_kbd_mode);
|
||||
|
||||
close(kbd->keyboard_fd);
|
||||
@@ -337,7 +337,7 @@ void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
|
||||
*/
|
||||
static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||
{
|
||||
/* c is already part of a UTF-8 sequence and safe to add as a character */
|
||||
// c is already part of a UTF-8 sequence and safe to add as a character
|
||||
if (kbd->text_len < (sizeof(kbd->text) - 1)) {
|
||||
kbd->text[kbd->text_len++] = (char)c;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
|
||||
for (i = 0; i < kbd->accents->n_accs; i++) {
|
||||
if (kbd->accents->acc[i].accchar == d) {
|
||||
for (j = 0; j < NUM_ACCENTCHARS; ++j) {
|
||||
if (kbd->accents->acc[i].map[j][0] == 0) { /* end of table */
|
||||
if (kbd->accents->acc[i].map[j][0] == 0) { // end of table
|
||||
break;
|
||||
}
|
||||
if (kbd->accents->acc[i].map[j][0] == ch) {
|
||||
@@ -426,7 +426,7 @@ static void chg_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
|
||||
static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag)
|
||||
{
|
||||
if (up_flag) {
|
||||
return; /* no action, if this is a key release */
|
||||
return; // no action, if this is a key release
|
||||
}
|
||||
|
||||
if (kbd->diacr) {
|
||||
@@ -472,7 +472,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
else
|
||||
kbd->shift_state &= ~(1 << value);
|
||||
|
||||
/* kludge */
|
||||
// kludge
|
||||
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
|
||||
put_utf8(kbd, kbd->npadch);
|
||||
kbd->npadch = -1;
|
||||
@@ -496,7 +496,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
|
||||
if (keycode < NUM_KEYS) {
|
||||
if (keycode >= 89 && keycode <= 95) {
|
||||
/* These constitute unprintable language-related keys, so ignore them. */
|
||||
// These constitute unprintable language-related keys, so ignore them.
|
||||
return;
|
||||
}
|
||||
if (keycode > 95) {
|
||||
@@ -520,69 +520,69 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
|
||||
map_from_key_sym = keysym.map[final_key_state];
|
||||
if ((keysym.spcl & (0x80 >> final_key_state)) || (map_from_key_sym & SPCLKEY)) {
|
||||
/* Special function.*/
|
||||
// Special function.
|
||||
if (map_from_key_sym == 0)
|
||||
return; /* Nothing to do. */
|
||||
return; // Nothing to do.
|
||||
if (map_from_key_sym & SPCLKEY) {
|
||||
map_from_key_sym &= ~SPCLKEY;
|
||||
}
|
||||
if (map_from_key_sym >= F_ACC && map_from_key_sym <= L_ACC) {
|
||||
/* Accent function.*/
|
||||
// Accent function.
|
||||
unsigned int accent_index = map_from_key_sym - F_ACC;
|
||||
if (kbd->accents->acc[accent_index].accchar != 0) {
|
||||
k_deadunicode(kbd, kbd->accents->acc[accent_index].accchar, !down);
|
||||
}
|
||||
} else {
|
||||
switch (map_from_key_sym) {
|
||||
case ASH: /* alt/meta shift */
|
||||
case ASH: // alt/meta shift
|
||||
k_shift(kbd, 3, down == 0);
|
||||
break;
|
||||
case LSHA: /* left shift + alt lock */
|
||||
case RSHA: /* right shift + alt lock */
|
||||
case LSHA: // left shift + alt lock
|
||||
case RSHA: // right shift + alt lock
|
||||
if (down == 0) {
|
||||
chg_vc_kbd_led(kbd, ALKED);
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case LSH: /* left shift */
|
||||
case RSH: /* right shift */
|
||||
case LSH: // left shift
|
||||
case RSH: // right shift
|
||||
k_shift(kbd, 0, down == 0);
|
||||
break;
|
||||
case LCTRA: /* left ctrl + alt lock */
|
||||
case RCTRA: /* right ctrl + alt lock */
|
||||
case LCTRA: // left ctrl + alt lock
|
||||
case RCTRA: // right ctrl + alt lock
|
||||
if (down == 0) {
|
||||
chg_vc_kbd_led(kbd, ALKED);
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case LCTR: /* left ctrl */
|
||||
case RCTR: /* right ctrl */
|
||||
case LCTR: // left ctrl
|
||||
case RCTR: // right ctrl
|
||||
k_shift(kbd, 1, down == 0);
|
||||
break;
|
||||
case LALTA: /* left alt + alt lock */
|
||||
case RALTA: /* right alt + alt lock */
|
||||
case LALTA: // left alt + alt lock
|
||||
case RALTA: // right alt + alt lock
|
||||
if (down == 0) {
|
||||
chg_vc_kbd_led(kbd, ALKED);
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case LALT: /* left alt */
|
||||
case RALT: /* right alt */
|
||||
case LALT: // left alt
|
||||
case RALT: // right alt
|
||||
k_shift(kbd, 2, down == 0);
|
||||
break;
|
||||
case ALK: /* alt lock */
|
||||
case ALK: // alt lock
|
||||
if (down == 1) {
|
||||
chg_vc_kbd_led(kbd, ALKED);
|
||||
}
|
||||
break;
|
||||
case CLK: /* caps lock*/
|
||||
case CLK: // caps lock
|
||||
if (down == 1) {
|
||||
chg_vc_kbd_led(kbd, CLKED);
|
||||
}
|
||||
break;
|
||||
case NLK: /* num lock */
|
||||
case NLK: // num lock
|
||||
if (down == 1) {
|
||||
chg_vc_kbd_led(kbd, NLKED);
|
||||
}
|
||||
break;
|
||||
case SLK: /* scroll lock */
|
||||
case SLK: // scroll lock
|
||||
if (down == 1) {
|
||||
chg_vc_kbd_led(kbd, SLKED);
|
||||
}
|
||||
@@ -610,4 +610,4 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_INPUT_FBSDKBIO */
|
||||
#endif // SDL_INPUT_FBSDKBIO
|
||||
|
||||
@@ -37,7 +37,7 @@ HANDLE plmSuspendComplete = nullptr;
|
||||
extern "C"
|
||||
int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
|
||||
{
|
||||
/* If this is the first call, first create the global task queue. */
|
||||
// If this is the first call, first create the global task queue.
|
||||
if (!GDK_GlobalTaskQueue) {
|
||||
HRESULT hr;
|
||||
|
||||
@@ -48,10 +48,10 @@ int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
|
||||
return SDL_SetError("[GDK] Could not create global task queue");
|
||||
}
|
||||
|
||||
/* The initial call gets the non-duplicated handle so they can clean it up */
|
||||
// The initial call gets the non-duplicated handle so they can clean it up
|
||||
*outTaskQueue = GDK_GlobalTaskQueue;
|
||||
} else {
|
||||
/* Duplicate the global task queue handle into outTaskQueue */
|
||||
// Duplicate the global task queue handle into outTaskQueue
|
||||
if (FAILED(XTaskQueueDuplicateHandle(GDK_GlobalTaskQueue, outTaskQueue))) {
|
||||
return SDL_SetError("[GDK] Unable to acquire global task queue");
|
||||
}
|
||||
@@ -67,7 +67,7 @@ void GDK_DispatchTaskQueue(void)
|
||||
* This gives the option to opt-out for those who want to handle everything themselves.
|
||||
*/
|
||||
if (GDK_GlobalTaskQueue) {
|
||||
/* Dispatch any callbacks which are ready. */
|
||||
// Dispatch any callbacks which are ready.
|
||||
while (XTaskQueueDispatch(GDK_GlobalTaskQueue, XTaskQueuePort::Completion, 0))
|
||||
;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ void GDK_DispatchTaskQueue(void)
|
||||
extern "C"
|
||||
int GDK_RegisterChangeNotifications(void)
|
||||
{
|
||||
/* Register suspend/resume handling */
|
||||
// Register suspend/resume handling
|
||||
plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
|
||||
if (!plmSuspendComplete) {
|
||||
SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
|
||||
@@ -102,7 +102,7 @@ int GDK_RegisterChangeNotifications(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Register constrain/unconstrain handling */
|
||||
// Register constrain/unconstrain handling
|
||||
auto raccn = [](BOOLEAN constrained, PVOID context) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler");
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
@@ -125,11 +125,11 @@ int GDK_RegisterChangeNotifications(void)
|
||||
extern "C"
|
||||
void GDK_UnregisterChangeNotifications(void)
|
||||
{
|
||||
/* Unregister suspend/resume handling */
|
||||
// Unregister suspend/resume handling
|
||||
UnregisterAppStateChangeNotification(hPLM);
|
||||
CloseHandle(plmSuspendComplete);
|
||||
|
||||
/* Unregister constrain/unconstrain handling */
|
||||
// Unregister constrain/unconstrain handling
|
||||
UnregisterAppConstrainedChangeNotification(hCPLM);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This is called from WIN_PumpEvents on GDK */
|
||||
// This is called from WIN_PumpEvents on GDK
|
||||
extern void GDK_DispatchTaskQueue(void);
|
||||
|
||||
extern int GDK_RegisterChangeNotifications(void);
|
||||
|
||||
@@ -36,7 +36,7 @@ extern "C" {
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Local includes */
|
||||
// Local includes
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../video/haiku/SDL_bframebuffer.h"
|
||||
|
||||
@@ -47,27 +47,27 @@ extern "C" {
|
||||
#include <vector>
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
// Forward declarations
|
||||
class SDL_BLooper;
|
||||
class SDL_BWin;
|
||||
|
||||
/* Message constants */
|
||||
// Message constants
|
||||
enum ToSDL
|
||||
{
|
||||
/* Intercepted by BWindow on its way to BView */
|
||||
// Intercepted by BWindow on its way to BView
|
||||
BAPP_MOUSE_MOVED,
|
||||
BAPP_MOUSE_BUTTON,
|
||||
BAPP_MOUSE_WHEEL,
|
||||
BAPP_KEY,
|
||||
BAPP_REPAINT, /* from _UPDATE_ */
|
||||
/* From BWindow */
|
||||
BAPP_MAXIMIZE, /* from B_ZOOM */
|
||||
BAPP_REPAINT, // from _UPDATE_
|
||||
// From BWindow
|
||||
BAPP_MAXIMIZE, // from B_ZOOM
|
||||
BAPP_MINIMIZE,
|
||||
BAPP_RESTORE, /* TODO: IMPLEMENT! */
|
||||
BAPP_RESTORE, // TODO: IMPLEMENT!
|
||||
BAPP_SHOW,
|
||||
BAPP_HIDE,
|
||||
BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */
|
||||
BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */
|
||||
BAPP_MOUSE_FOCUS, // caused by MOUSE_MOVE
|
||||
BAPP_KEYBOARD_FOCUS, // from WINDOW_ACTIVATED
|
||||
BAPP_WINDOW_CLOSE_REQUESTED,
|
||||
BAPP_WINDOW_MOVED,
|
||||
BAPP_WINDOW_RESIZED,
|
||||
@@ -78,7 +78,7 @@ enum ToSDL
|
||||
extern "C" SDL_BLooper *SDL_Looper;
|
||||
|
||||
|
||||
/* Create a descendant of BLooper */
|
||||
// Create a descendant of BLooper
|
||||
class SDL_BLooper : public BLooper
|
||||
{
|
||||
public:
|
||||
@@ -93,10 +93,10 @@ class SDL_BLooper : public BLooper
|
||||
{
|
||||
}
|
||||
|
||||
/* Event-handling functions */
|
||||
// Event-handling functions
|
||||
virtual void MessageReceived(BMessage *message)
|
||||
{
|
||||
/* Sort out SDL-related messages */
|
||||
// Sort out SDL-related messages
|
||||
switch (message->what) {
|
||||
case BAPP_MOUSE_MOVED:
|
||||
_HandleMouseMove(message);
|
||||
@@ -159,7 +159,7 @@ class SDL_BLooper : public BLooper
|
||||
break;
|
||||
|
||||
case BAPP_SCREEN_CHANGED:
|
||||
/* TODO: Handle screen resize or workspace change */
|
||||
// TODO: Handle screen resize or workspace change
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -168,7 +168,7 @@ class SDL_BLooper : public BLooper
|
||||
}
|
||||
}
|
||||
|
||||
/* Window creation/destruction methods */
|
||||
// Window creation/destruction methods
|
||||
int32 GetID(SDL_Window *win)
|
||||
{
|
||||
int32 i;
|
||||
@@ -179,19 +179,19 @@ class SDL_BLooper : public BLooper
|
||||
}
|
||||
}
|
||||
|
||||
/* Expand the vector if all slots are full */
|
||||
// Expand the vector if all slots are full
|
||||
if (i == _GetNumWindowSlots()) {
|
||||
_PushBackWindow(win);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* TODO: error handling */
|
||||
// TODO: error handling
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is
|
||||
there another way to do this? */
|
||||
void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
|
||||
void ClearID(SDL_BWin *bwin); // Defined in SDL_BeApp.cc
|
||||
|
||||
SDL_Window *GetSDLWindow(int32 winID)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ class SDL_BLooper : public BLooper
|
||||
#endif
|
||||
|
||||
private:
|
||||
/* Event management */
|
||||
// Event management
|
||||
void _HandleBasicWindowEvent(BMessage *msg, SDL_EventType sdlEventType)
|
||||
{
|
||||
SDL_Window *win;
|
||||
@@ -235,8 +235,8 @@ class SDL_BLooper : public BLooper
|
||||
int32 x = 0, y = 0;
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindInt32("x", &x) != B_OK || /* x movement */
|
||||
msg->FindInt32("y", &y) != B_OK /* y movement */
|
||||
msg->FindInt32("x", &x) != B_OK || // x movement
|
||||
msg->FindInt32("y", &y) != B_OK // y movement
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ class SDL_BLooper : public BLooper
|
||||
{
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
int32 button, state; /* left/middle/right, pressed/released */
|
||||
int32 button, state; // left/middle/right, pressed/released
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindInt32("button-id", &button) != B_OK ||
|
||||
@@ -294,7 +294,7 @@ class SDL_BLooper : public BLooper
|
||||
{
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
int32 scancode, state; /* scancode, pressed/released */
|
||||
int32 scancode, state; // scancode, pressed/released
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindInt32("key-state", &state) != B_OK ||
|
||||
@@ -321,7 +321,7 @@ class SDL_BLooper : public BLooper
|
||||
{
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
bool bSetFocus; /* If false, lose focus */
|
||||
bool bSetFocus; // If false, lose focus
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindBool("focusGained", &bSetFocus) != B_OK) {
|
||||
@@ -331,7 +331,7 @@ class SDL_BLooper : public BLooper
|
||||
if (bSetFocus) {
|
||||
SDL_SetMouseFocus(win);
|
||||
} else if (SDL_GetMouseFocus() == win) {
|
||||
/* Only lose all focus if this window was the current focus */
|
||||
// Only lose all focus if this window was the current focus
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,7 @@ class SDL_BLooper : public BLooper
|
||||
{
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
bool bSetFocus; /* If false, lose focus */
|
||||
bool bSetFocus; // If false, lose focus
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindBool("focusGained", &bSetFocus) != B_OK) {
|
||||
@@ -350,7 +350,7 @@ class SDL_BLooper : public BLooper
|
||||
if (bSetFocus) {
|
||||
SDL_SetKeyboardFocus(win);
|
||||
} else if (SDL_GetKeyboardFocus() == win) {
|
||||
/* Only lose all focus if this window was the current focus */
|
||||
// Only lose all focus if this window was the current focus
|
||||
SDL_SetKeyboardFocus(NULL);
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ class SDL_BLooper : public BLooper
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
int32 xPos, yPos;
|
||||
/* Get the window id and new x/y position of the window */
|
||||
// Get the window id and new x/y position of the window
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindInt32("window-x", &xPos) != B_OK ||
|
||||
@@ -376,7 +376,7 @@ class SDL_BLooper : public BLooper
|
||||
SDL_Window *win;
|
||||
int32 winID;
|
||||
int32 w, h;
|
||||
/* Get the window id ]and new x/y position of the window */
|
||||
// Get the window id ]and new x/y position of the window
|
||||
if (
|
||||
!_GetWinID(msg, &winID) ||
|
||||
msg->FindInt32("window-w", &w) != B_OK ||
|
||||
@@ -414,8 +414,8 @@ class SDL_BLooper : public BLooper
|
||||
_window_map.push_back(win);
|
||||
}
|
||||
|
||||
/* Members */
|
||||
std::vector<SDL_Window *> _window_map; /* Keeps track of SDL_Windows by index-id */
|
||||
// Members
|
||||
std::vector<SDL_Window *> _window_map; // Keeps track of SDL_Windows by index-id
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL
|
||||
BGLView *_current_context;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef SDL_PLATFORM_HAIKU
|
||||
|
||||
/* Handle the BeApp specific portions of the application */
|
||||
// Handle the BeApp specific portions of the application
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <storage/AppFileInfo.h>
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <unistd.h>
|
||||
#include <memory>
|
||||
|
||||
#include "SDL_BApp.h" /* SDL_BLooper class definition */
|
||||
#include "SDL_BApp.h" // SDL_BLooper class definition
|
||||
#include "SDL_BeApp.h"
|
||||
|
||||
#include "../../video/haiku/SDL_BWin.h"
|
||||
@@ -43,17 +43,17 @@ extern "C" {
|
||||
|
||||
#include "../../thread/SDL_systhread.h"
|
||||
|
||||
/* Flag to tell whether or not the Be application and looper are active or not */
|
||||
// Flag to tell whether or not the Be application and looper are active or not
|
||||
static int SDL_BeAppActive = 0;
|
||||
static SDL_Thread *SDL_AppThread = NULL;
|
||||
SDL_BLooper *SDL_Looper = NULL;
|
||||
|
||||
|
||||
/* Default application signature */
|
||||
// Default application signature
|
||||
const char *SDL_signature = "application/x-SDL-executable";
|
||||
|
||||
|
||||
/* Create a descendant of BApplication */
|
||||
// Create a descendant of BApplication
|
||||
class SDL_BApp : public BApplication {
|
||||
public:
|
||||
SDL_BApp(const char* signature) :
|
||||
@@ -123,43 +123,43 @@ static int StartBeLooper()
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the Be Application, if it's not already started */
|
||||
// Initialize the Be Application, if it's not already started
|
||||
int SDL_InitBeApp(void)
|
||||
{
|
||||
/* Create the BApplication that handles appserver interaction */
|
||||
// Create the BApplication that handles appserver interaction
|
||||
if (SDL_BeAppActive <= 0) {
|
||||
StartBeLooper();
|
||||
|
||||
/* Mark the application active */
|
||||
// Mark the application active
|
||||
SDL_BeAppActive = 0;
|
||||
}
|
||||
|
||||
/* Increment the application reference count */
|
||||
// Increment the application reference count
|
||||
++SDL_BeAppActive;
|
||||
|
||||
/* The app is running, and we're ready to go */
|
||||
// The app is running, and we're ready to go
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Quit the Be Application, if there's nothing left to do */
|
||||
// Quit the Be Application, if there's nothing left to do
|
||||
void SDL_QuitBeApp(void)
|
||||
{
|
||||
/* Decrement the application reference count */
|
||||
// Decrement the application reference count
|
||||
--SDL_BeAppActive;
|
||||
|
||||
/* If the reference count reached zero, clean up the app */
|
||||
// If the reference count reached zero, clean up the app
|
||||
if (SDL_BeAppActive == 0) {
|
||||
SDL_Looper->Lock();
|
||||
SDL_Looper->Quit();
|
||||
SDL_Looper = NULL;
|
||||
if (SDL_AppThread) {
|
||||
if (be_app != NULL) { /* Not tested */
|
||||
if (be_app != NULL) { // Not tested
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
SDL_WaitThread(SDL_AppThread, NULL);
|
||||
SDL_AppThread = NULL;
|
||||
}
|
||||
/* be_app should now be NULL since be_app has quit */
|
||||
// be_app should now be NULL since be_app has quit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ void SDL_QuitBeApp(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* SDL_BApp functions */
|
||||
// SDL_BApp functions
|
||||
void SDL_BLooper::ClearID(SDL_BWin *bwin) {
|
||||
_SetSDLWindow(NULL, bwin->GetID());
|
||||
int32 i = _GetNumWindowSlots() - 1;
|
||||
@@ -177,4 +177,4 @@ void SDL_BLooper::ClearID(SDL_BWin *bwin) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_PLATFORM_HAIKU */
|
||||
#endif // SDL_PLATFORM_HAIKU
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Handle the BeApp specific portions of the application */
|
||||
// Handle the BeApp specific portions of the application
|
||||
|
||||
/* Initialize the Be Application, if it's not already started */
|
||||
// Initialize the Be Application, if it's not already started
|
||||
extern int SDL_InitBeApp(void);
|
||||
|
||||
/* Quit the Be Application, if there's nothing left to do */
|
||||
// Quit the Be Application, if there's nothing left to do
|
||||
extern void SDL_QuitBeApp(void);
|
||||
|
||||
/* Be Application Signature*/
|
||||
// Be Application Signature
|
||||
extern const char *SDL_signature;
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../../stdlib/SDL_vacopy.h"
|
||||
|
||||
#ifdef SDL_USE_LIBDBUS
|
||||
/* we never link directly to libdbus. */
|
||||
// we never link directly to libdbus.
|
||||
static const char *dbus_library = "libdbus-1.so.3";
|
||||
static void *dbus_handle = NULL;
|
||||
static char *inhibit_handle = NULL;
|
||||
@@ -111,7 +111,7 @@ static int LoadDBUSLibrary(void)
|
||||
dbus_handle = SDL_LoadObject(dbus_library);
|
||||
if (!dbus_handle) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = LoadDBUSSyms();
|
||||
if (retval < 0) {
|
||||
@@ -125,19 +125,19 @@ static int LoadDBUSLibrary(void)
|
||||
|
||||
static SDL_SpinLock spinlock_dbus_init = 0;
|
||||
|
||||
/* you must hold spinlock_dbus_init before calling this! */
|
||||
// you must hold spinlock_dbus_init before calling this!
|
||||
static void SDL_DBus_Init_Spinlocked(void)
|
||||
{
|
||||
static SDL_bool is_dbus_available = SDL_TRUE;
|
||||
if (!is_dbus_available) {
|
||||
return; /* don't keep trying if this fails. */
|
||||
return; // don't keep trying if this fails.
|
||||
}
|
||||
|
||||
if (!dbus.session_conn) {
|
||||
DBusError err;
|
||||
|
||||
if (LoadDBUSLibrary() == -1) {
|
||||
is_dbus_available = SDL_FALSE; /* can't load at all? Don't keep trying. */
|
||||
is_dbus_available = SDL_FALSE; // can't load at all? Don't keep trying.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,18 +147,18 @@ static void SDL_DBus_Init_Spinlocked(void)
|
||||
}
|
||||
|
||||
dbus.error_init(&err);
|
||||
/* session bus is required */
|
||||
// session bus is required
|
||||
|
||||
dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err);
|
||||
if (dbus.error_is_set(&err)) {
|
||||
dbus.error_free(&err);
|
||||
SDL_DBus_Quit();
|
||||
is_dbus_available = SDL_FALSE;
|
||||
return; /* oh well */
|
||||
return; // oh well
|
||||
}
|
||||
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
|
||||
|
||||
/* system bus is optional */
|
||||
// system bus is optional
|
||||
dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err);
|
||||
if (!dbus.error_is_set(&err)) {
|
||||
dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0);
|
||||
@@ -170,7 +170,7 @@ static void SDL_DBus_Init_Spinlocked(void)
|
||||
|
||||
void SDL_DBus_Init(void)
|
||||
{
|
||||
SDL_LockSpinlock(&spinlock_dbus_init); /* make sure two threads can't init at same time, since this can happen before SDL_Init. */
|
||||
SDL_LockSpinlock(&spinlock_dbus_init); // make sure two threads can't init at same time, since this can happen before SDL_Init.
|
||||
SDL_DBus_Init_Spinlocked();
|
||||
SDL_UnlockSpinlock(&spinlock_dbus_init);
|
||||
}
|
||||
@@ -216,14 +216,14 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no
|
||||
if (msg) {
|
||||
int firstarg;
|
||||
va_list ap_reply;
|
||||
va_copy(ap_reply, ap); /* copy the arg list so we don't compete with D-Bus for it */
|
||||
va_copy(ap_reply, ap); // copy the arg list so we don't compete with D-Bus for it
|
||||
firstarg = va_arg(ap, int);
|
||||
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
|
||||
DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL);
|
||||
if (reply) {
|
||||
/* skip any input args, get to output args. */
|
||||
// skip any input args, get to output args.
|
||||
while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) {
|
||||
/* we assume D-Bus already validated all this. */
|
||||
// we assume D-Bus already validated all this.
|
||||
{
|
||||
void *dumpptr = va_arg(ap_reply, void *);
|
||||
(void)dumpptr;
|
||||
@@ -361,8 +361,8 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *
|
||||
|
||||
void SDL_DBus_ScreensaverTickle(void)
|
||||
{
|
||||
if (screensaver_cookie == 0 && !inhibit_handle) { /* no need to tickle if we're inhibiting. */
|
||||
/* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */
|
||||
if (screensaver_cookie == 0 && !inhibit_handle) { // no need to tickle if we're inhibiting.
|
||||
// org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now.
|
||||
SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
|
||||
SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
|
||||
}
|
||||
@@ -443,8 +443,8 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
const char *bus_name = "org.freedesktop.portal.Desktop";
|
||||
const char *path = "/org/freedesktop/portal/desktop";
|
||||
const char *interface = "org.freedesktop.portal.Inhibit";
|
||||
const char *window = ""; /* As a future improvement we could gather the X11 XID or Wayland surface identifier */
|
||||
static const unsigned int INHIBIT_IDLE = 8; /* Taken from the portal API reference */
|
||||
const char *window = ""; // As a future improvement we could gather the X11 XID or Wayland surface identifier
|
||||
static const unsigned int INHIBIT_IDLE = 8; // Taken from the portal API reference
|
||||
DBusMessageIter iterInit;
|
||||
|
||||
if (inhibit) {
|
||||
@@ -469,7 +469,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
|
||||
dbus.message_iter_init_append(msg, &iterInit);
|
||||
|
||||
/* a{sv} */
|
||||
// a{sv}
|
||||
if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) {
|
||||
dbus.message_unref(msg);
|
||||
return SDL_FALSE;
|
||||
@@ -524,7 +524,7 @@ void SDL_DBus_PumpEvents(void)
|
||||
dbus.connection_read_write(dbus.session_conn, 0);
|
||||
|
||||
while (dbus.connection_dispatch(dbus.session_conn) == DBUS_DISPATCH_DATA_REMAINS) {
|
||||
/* Do nothing, actual work happens in DBus_MessageFilter */
|
||||
// Do nothing, actual work happens in DBus_MessageFilter
|
||||
SDL_DelayNS(SDL_US_TO_NS(10));
|
||||
}
|
||||
}
|
||||
@@ -541,7 +541,7 @@ char *SDL_DBus_GetLocalMachineId(void)
|
||||
dbus.error_init(&err);
|
||||
|
||||
if (dbus.try_get_local_machine_id) {
|
||||
/* Available since dbus 1.12.0, has proper error-handling */
|
||||
// Available since dbus 1.12.0, has proper error-handling
|
||||
result = dbus.try_get_local_machine_id(&err);
|
||||
} else {
|
||||
/* Available since time immemorial, but has no error-handling:
|
||||
@@ -575,12 +575,12 @@ char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *path_count)
|
||||
DBusMessageIter iter, iterDict;
|
||||
char **paths = NULL;
|
||||
DBusMessage *reply = NULL;
|
||||
DBusMessage *msg = dbus.message_new_method_call("org.freedesktop.portal.Documents", /* Node */
|
||||
"/org/freedesktop/portal/documents", /* Path */
|
||||
"org.freedesktop.portal.FileTransfer", /* Interface */
|
||||
"RetrieveFiles"); /* Method */
|
||||
DBusMessage *msg = dbus.message_new_method_call("org.freedesktop.portal.Documents", // Node
|
||||
"/org/freedesktop/portal/documents", // Path
|
||||
"org.freedesktop.portal.FileTransfer", // Interface
|
||||
"RetrieveFiles"); // Method
|
||||
|
||||
/* Make sure we have a connection to the dbus session bus */
|
||||
// Make sure we have a connection to the dbus session bus
|
||||
if (!SDL_DBus_GetContext() || !dbus.session_conn) {
|
||||
/* We either cannot connect to the session bus or were unable to
|
||||
* load the D-Bus library at all. */
|
||||
@@ -589,7 +589,7 @@ char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *path_count)
|
||||
|
||||
dbus.error_init(&err);
|
||||
|
||||
/* First argument is a "application/vnd.portal.filetransfer" key from a DnD or clipboard event */
|
||||
// First argument is a "application/vnd.portal.filetransfer" key from a DnD or clipboard event
|
||||
if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) {
|
||||
SDL_OutOfMemory();
|
||||
dbus.message_unref(msg);
|
||||
|
||||
@@ -91,12 +91,12 @@ extern void SDL_DBus_Init(void);
|
||||
extern void SDL_DBus_Quit(void);
|
||||
extern SDL_DBusContext *SDL_DBus_GetContext(void);
|
||||
|
||||
/* These use the built-in Session connection. */
|
||||
// These use the built-in Session connection.
|
||||
extern SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
||||
extern SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
|
||||
extern SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
||||
|
||||
/* These use whatever connection you like. */
|
||||
// These use whatever connection you like.
|
||||
extern SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
||||
extern SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
|
||||
extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
|
||||
@@ -109,6 +109,6 @@ extern char *SDL_DBus_GetLocalMachineId(void);
|
||||
|
||||
extern char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *files_count);
|
||||
|
||||
#endif /* HAVE_DBUS_DBUS_H */
|
||||
#endif // HAVE_DBUS_DBUS_H
|
||||
|
||||
#endif /* SDL_dbus_h_ */
|
||||
#endif // SDL_dbus_h_
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef SDL_INPUT_LINUXEV
|
||||
|
||||
/* This is based on the linux joystick driver */
|
||||
// This is based on the linux joystick driver
|
||||
/* References: https://www.kernel.org/doc/Documentation/input/input.txt
|
||||
* https://www.kernel.org/doc/Documentation/input/event-codes.txt
|
||||
* /usr/include/linux/input.h
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "../../core/linux/SDL_evdev_capabilities.h"
|
||||
#include "../../core/linux/SDL_udev.h"
|
||||
|
||||
/* These are not defined in older Linux kernel headers */
|
||||
// These are not defined in older Linux kernel headers
|
||||
#ifndef SYN_DROPPED
|
||||
#define SYN_DROPPED 3
|
||||
#endif
|
||||
@@ -59,12 +59,12 @@
|
||||
#define REL_HWHEEL_HI_RES 0x0c
|
||||
#endif
|
||||
|
||||
/* The field to look up in struct input_event for integer seconds */
|
||||
// The field to look up in struct input_event for integer seconds
|
||||
#ifndef input_event_sec
|
||||
#define input_event_sec time.tv_sec
|
||||
#endif
|
||||
|
||||
/* The field to look up in struct input_event for fractional seconds */
|
||||
// The field to look up in struct input_event for fractional seconds
|
||||
#ifndef input_event_usec
|
||||
#define input_event_usec time.tv_usec
|
||||
#endif
|
||||
@@ -75,7 +75,7 @@ typedef struct SDL_evdevlist_item
|
||||
int fd;
|
||||
int udev_class;
|
||||
|
||||
/* TODO: use this for every device, not just touchscreen */
|
||||
// TODO: use this for every device, not just touchscreen
|
||||
SDL_bool out_of_sync;
|
||||
|
||||
/* TODO: expand on this to have data for every possible class (mouse,
|
||||
@@ -107,7 +107,7 @@ typedef struct SDL_evdevlist_item
|
||||
|
||||
} *touchscreen_data;
|
||||
|
||||
/* Mouse state */
|
||||
// Mouse state
|
||||
SDL_bool high_res_wheel;
|
||||
SDL_bool high_res_hwheel;
|
||||
SDL_bool relative_mouse;
|
||||
@@ -137,22 +137,22 @@ static int SDL_EVDEV_device_removed(const char *dev_path);
|
||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
|
||||
static Uint8 EVDEV_MouseButtons[] = {
|
||||
SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */
|
||||
SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */
|
||||
SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */
|
||||
SDL_BUTTON_X1, /* BTN_SIDE 0x113 */
|
||||
SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */
|
||||
SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */
|
||||
SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */
|
||||
SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */
|
||||
SDL_BUTTON_LEFT, // BTN_LEFT 0x110
|
||||
SDL_BUTTON_RIGHT, // BTN_RIGHT 0x111
|
||||
SDL_BUTTON_MIDDLE, // BTN_MIDDLE 0x112
|
||||
SDL_BUTTON_X1, // BTN_SIDE 0x113
|
||||
SDL_BUTTON_X2, // BTN_EXTRA 0x114
|
||||
SDL_BUTTON_X2 + 1, // BTN_FORWARD 0x115
|
||||
SDL_BUTTON_X2 + 2, // BTN_BACK 0x116
|
||||
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
|
||||
};
|
||||
|
||||
static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
/* Mice already send relative events through this interface */
|
||||
// Mice already send relative events through this interface
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ int SDL_EVDEV_Init(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set up the udev callback */
|
||||
// Set up the udev callback
|
||||
if (SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) {
|
||||
SDL_UDEV_Quit();
|
||||
SDL_free(_this);
|
||||
@@ -188,7 +188,7 @@ int SDL_EVDEV_Init(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Force a scan to build the initial device list */
|
||||
// Force a scan to build the initial device list
|
||||
SDL_UDEV_Scan();
|
||||
#else
|
||||
{
|
||||
@@ -212,10 +212,10 @@ int SDL_EVDEV_Init(void)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* TODO: Scan the devices manually, like a caveman */
|
||||
// TODO: Scan the devices manually, like a caveman
|
||||
}
|
||||
}
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
|
||||
_this->kbd = SDL_EVDEV_kbd_init();
|
||||
|
||||
@@ -241,9 +241,9 @@ void SDL_EVDEV_Quit(void)
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback);
|
||||
SDL_UDEV_Quit();
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
|
||||
/* Remove existing devices */
|
||||
// Remove existing devices
|
||||
while (_this->first) {
|
||||
SDL_EVDEV_device_removed(_this->first->path);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
|
||||
void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
||||
void (*acquire_callback)(void*), void *acquire_callback_data)
|
||||
@@ -371,7 +371,7 @@ void SDL_EVDEV_Poll(void)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Probably keyboard */
|
||||
// Probably keyboard
|
||||
scancode = SDL_EVDEV_translate_keycode(event->code);
|
||||
if (event->value == 0) {
|
||||
SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, SDL_RELEASED);
|
||||
@@ -383,13 +383,13 @@ void SDL_EVDEV_Poll(void)
|
||||
case EV_ABS:
|
||||
switch (event->code) {
|
||||
case ABS_MT_SLOT:
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
item->touchscreen_data->current_slot = event->value;
|
||||
break;
|
||||
case ABS_MT_TRACKING_ID:
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
if (event->value >= 0) {
|
||||
@@ -400,7 +400,7 @@ void SDL_EVDEV_Poll(void)
|
||||
}
|
||||
break;
|
||||
case ABS_MT_POSITION_X:
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
item->touchscreen_data->slots[item->touchscreen_data->current_slot].x = event->value;
|
||||
@@ -409,7 +409,7 @@ void SDL_EVDEV_Poll(void)
|
||||
}
|
||||
break;
|
||||
case ABS_MT_POSITION_Y:
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
item->touchscreen_data->slots[item->touchscreen_data->current_slot].y = event->value;
|
||||
@@ -418,7 +418,7 @@ void SDL_EVDEV_Poll(void)
|
||||
}
|
||||
break;
|
||||
case ABS_MT_PRESSURE:
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
item->touchscreen_data->slots[item->touchscreen_data->current_slot].pressure = event->value;
|
||||
@@ -487,7 +487,7 @@ void SDL_EVDEV_Poll(void)
|
||||
case EV_SYN:
|
||||
switch (event->code) {
|
||||
case SYN_REPORT:
|
||||
/* Send mouse axis changes together to ensure consistency and reduce event processing overhead */
|
||||
// Send mouse axis changes together to ensure consistency and reduce event processing overhead
|
||||
if (item->relative_mouse) {
|
||||
if (item->mouse_x != 0 || item->mouse_y != 0) {
|
||||
SDL_SendMouseMotion(SDL_EVDEV_GetEventTimestamp(event), mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, (float)item->mouse_x, (float)item->mouse_y);
|
||||
@@ -521,7 +521,7 @@ void SDL_EVDEV_Poll(void)
|
||||
item->mouse_wheel = item->mouse_hwheel = 0;
|
||||
}
|
||||
|
||||
if (!item->is_touchscreen) { /* FIXME: temp hack */
|
||||
if (!item->is_touchscreen) { // FIXME: temp hack
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ void SDL_EVDEV_Poll(void)
|
||||
norm_pressure = (float)(item->touchscreen_data->slots[j].pressure - item->touchscreen_data->min_pressure) /
|
||||
(float)item->touchscreen_data->range_pressure;
|
||||
} else {
|
||||
/* This touchscreen does not support pressure */
|
||||
// This touchscreen does not support pressure
|
||||
norm_pressure = 1.0f;
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode)
|
||||
keycode);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG_SCANCODES */
|
||||
#endif // DEBUG_SCANCODES
|
||||
|
||||
return scancode;
|
||||
}
|
||||
@@ -741,7 +741,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = SDL_AddTouch(item->fd, /* I guess our fd is unique enough */
|
||||
ret = SDL_AddTouch(item->fd, // I guess our fd is unique enough
|
||||
(udev_class & SDL_UDEV_DEVICE_TOUCHPAD) ? SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE : SDL_TOUCH_DEVICE_DIRECT,
|
||||
item->touchscreen_data->name);
|
||||
if (ret < 0) {
|
||||
@@ -783,7 +783,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
||||
Sint32 *mt_req_values;
|
||||
size_t mt_req_size;
|
||||
|
||||
/* TODO: sync devices other than touchscreen */
|
||||
// TODO: sync devices other than touchscreen
|
||||
if (!item->is_touchscreen) {
|
||||
return;
|
||||
}
|
||||
@@ -888,7 +888,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
||||
|
||||
SDL_free(mt_req_code);
|
||||
|
||||
#endif /* EVIOCGMTSLOTS */
|
||||
#endif // EVIOCGMTSLOTS
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
@@ -896,10 +896,10 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
SDL_evdevlist_item *item;
|
||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
||||
|
||||
/* Check to make sure it's not already in list. */
|
||||
// Check to make sure it's not already in list.
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
if (SDL_strcmp(dev_path, item->path) == 0) {
|
||||
return -1; /* already have this one */
|
||||
return -1; // already have this one
|
||||
}
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
item->high_res_hwheel = test_bit(REL_HWHEEL_HI_RES, relbit);
|
||||
}
|
||||
|
||||
/* For now, we just treat a touchpad like a touchscreen */
|
||||
// For now, we just treat a touchpad like a touchscreen
|
||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||
int ret;
|
||||
item->is_touchscreen = SDL_TRUE;
|
||||
@@ -978,7 +978,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
|
||||
SDL_evdevlist_item *prev = NULL;
|
||||
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
/* found it, remove it. */
|
||||
// found it, remove it.
|
||||
if (SDL_strcmp(dev_path, item->path) == 0) {
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
@@ -1033,4 +1033,4 @@ Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event)
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
#endif /* SDL_INPUT_LINUXEV */
|
||||
#endif // SDL_INPUT_LINUXEV
|
||||
|
||||
@@ -36,6 +36,6 @@ extern int SDL_EVDEV_GetDeviceCount(int device_class);
|
||||
extern void SDL_EVDEV_Poll(void);
|
||||
extern Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event);
|
||||
|
||||
#endif /* SDL_INPUT_LINUXEV */
|
||||
#endif // SDL_INPUT_LINUXEV
|
||||
|
||||
#endif /* SDL_evdev_h_ */
|
||||
#endif // SDL_evdev_h_
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifdef HAVE_LINUX_INPUT_H
|
||||
|
||||
/* missing defines in older Linux kernel headers */
|
||||
// missing defines in older Linux kernel headers
|
||||
#ifndef BTN_TRIGGER_HAPPY
|
||||
#define BTN_TRIGGER_HAPPY 0x2c0
|
||||
#endif
|
||||
@@ -49,7 +49,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
unsigned end;
|
||||
};
|
||||
|
||||
/* key code ranges above BTN_MISC (start is inclusive, stop is exclusive)*/
|
||||
// key code ranges above BTN_MISC (start is inclusive, stop is exclusive)
|
||||
static const struct range high_key_blocks[] = {
|
||||
{ KEY_OK, BTN_DPAD_UP },
|
||||
{ KEY_ALS_TOGGLE, BTN_TRIGGER_HAPPY }
|
||||
@@ -58,24 +58,24 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
int devclass = 0;
|
||||
unsigned long keyboard_mask;
|
||||
|
||||
/* If the kernel specifically says it's an accelerometer, believe it */
|
||||
// If the kernel specifically says it's an accelerometer, believe it
|
||||
if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_ACCELEROMETER;
|
||||
}
|
||||
|
||||
/* We treat pointing sticks as indistinguishable from mice */
|
||||
// We treat pointing sticks as indistinguishable from mice
|
||||
if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_MOUSE;
|
||||
}
|
||||
|
||||
/* We treat buttonpads as equivalent to touchpads */
|
||||
// We treat buttonpads as equivalent to touchpads
|
||||
if (test_bit(INPUT_PROP_TOPBUTTONPAD, bitmask_props) ||
|
||||
test_bit(INPUT_PROP_BUTTONPAD, bitmask_props) ||
|
||||
test_bit(INPUT_PROP_SEMI_MT, bitmask_props)) {
|
||||
return SDL_UDEV_DEVICE_TOUCHPAD;
|
||||
}
|
||||
|
||||
/* X, Y, Z axes but no buttons probably means an accelerometer */
|
||||
// X, Y, Z axes but no buttons probably means an accelerometer
|
||||
if (test_bit(EV_ABS, bitmask_ev) &&
|
||||
test_bit(ABS_X, bitmask_abs) &&
|
||||
test_bit(ABS_Y, bitmask_abs) &&
|
||||
@@ -97,15 +97,15 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
if (test_bit(EV_ABS, bitmask_ev) &&
|
||||
test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
|
||||
if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
|
||||
; /* ID_INPUT_TABLET */
|
||||
; // ID_INPUT_TABLET
|
||||
} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHPAD; /* 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 */
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE; // ID_INPUT_MOUSE
|
||||
} else if (test_bit(BTN_TOUCH, bitmask_key)) {
|
||||
/* TODO: better determining between touchscreen and multitouch touchpad,
|
||||
see https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-input_id.c */
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; /* ID_INPUT_TOUCHSCREEN */
|
||||
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; // ID_INPUT_TOUCHSCREEN
|
||||
}
|
||||
|
||||
if (test_bit(BTN_TRIGGER, bitmask_key) ||
|
||||
@@ -119,14 +119,14 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
test_bit(ABS_WHEEL, bitmask_abs) ||
|
||||
test_bit(ABS_GAS, bitmask_abs) ||
|
||||
test_bit(ABS_BRAKE, bitmask_abs)) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK; /* ID_INPUT_JOYSTICK */
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK; // ID_INPUT_JOYSTICK
|
||||
}
|
||||
}
|
||||
|
||||
if (test_bit(EV_REL, bitmask_ev) &&
|
||||
test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) &&
|
||||
test_bit(BTN_MOUSE, bitmask_key)) {
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
|
||||
devclass |= SDL_UDEV_DEVICE_MOUSE; // ID_INPUT_MOUSE
|
||||
}
|
||||
|
||||
if (test_bit(EV_KEY, bitmask_ev)) {
|
||||
@@ -136,7 +136,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
for (i = 0; i < BTN_MISC / BITS_PER_LONG; ++i) {
|
||||
found |= bitmask_key[i];
|
||||
}
|
||||
/* If there are no keys in the lower block, check the higher blocks */
|
||||
// If there are no keys in the lower block, check the higher blocks
|
||||
if (!found) {
|
||||
unsigned block;
|
||||
for (block = 0; block < (sizeof(high_key_blocks) / sizeof(struct range)); ++block) {
|
||||
@@ -150,7 +150,7 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
}
|
||||
|
||||
if (found > 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_HAS_KEYS; /* ID_INPUT_KEY */
|
||||
devclass |= SDL_UDEV_DEVICE_HAS_KEYS; // ID_INPUT_KEY
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,10 +159,10 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MA
|
||||
* do not test KEY_RESERVED, though */
|
||||
keyboard_mask = 0xFFFFFFFE;
|
||||
if ((bitmask_key[0] & keyboard_mask) == keyboard_mask) {
|
||||
devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */
|
||||
devclass |= SDL_UDEV_DEVICE_KEYBOARD; // ID_INPUT_KEYBOARD
|
||||
}
|
||||
|
||||
return devclass;
|
||||
}
|
||||
|
||||
#endif /* HAVE_LINUX_INPUT_H */
|
||||
#endif // HAVE_LINUX_INPUT_H
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#define INPUT_PROP_MAX 0x1f
|
||||
#endif
|
||||
|
||||
/* A device can be any combination of these classes */
|
||||
// A device can be any combination of these classes
|
||||
typedef enum
|
||||
{
|
||||
SDL_UDEV_DEVICE_UNKNOWN = 0x0000,
|
||||
@@ -71,6 +71,6 @@ extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(IN
|
||||
const unsigned long bitmask_key[NBITS(KEY_MAX)],
|
||||
const unsigned long bitmask_rel[NBITS(REL_MAX)]);
|
||||
|
||||
#endif /* HAVE_LINUX_INPUT_H */
|
||||
#endif // HAVE_LINUX_INPUT_H
|
||||
|
||||
#endif /* SDL_evdev_capabilities_h_ */
|
||||
#endif // SDL_evdev_capabilities_h_
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifdef SDL_INPUT_LINUXKD
|
||||
|
||||
/* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source */
|
||||
// This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
#include <linux/vt.h>
|
||||
#include <linux/tiocl.h> /* for TIOCL_GETSHIFTSTATE */
|
||||
#include <linux/tiocl.h> // for TIOCL_GETSHIFTSTATE
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "SDL_evdev_kbd_default_accents.h"
|
||||
#include "SDL_evdev_kbd_default_keymap.h"
|
||||
|
||||
/* These are not defined in older Linux kernel headers */
|
||||
// These are not defined in older Linux kernel headers
|
||||
#ifndef K_UNICODE
|
||||
#define K_UNICODE 0x03
|
||||
#endif
|
||||
@@ -87,12 +87,12 @@ struct SDL_EVDEV_keyboard_state
|
||||
SDL_bool muted;
|
||||
int old_kbd_mode;
|
||||
unsigned short **key_maps;
|
||||
unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
|
||||
unsigned char shift_down[NR_SHIFT]; // shift state counters..
|
||||
SDL_bool dead_key_next;
|
||||
int npadch; /* -1 or number assembled on pad */
|
||||
int npadch; // -1 or number assembled on pad
|
||||
struct kbdiacrs *accents;
|
||||
unsigned int diacr;
|
||||
SDL_bool rep; /* flag telling character repeat */
|
||||
SDL_bool rep; // flag telling character repeat
|
||||
unsigned char lockstate;
|
||||
unsigned char slockstate;
|
||||
unsigned char ledflagstate;
|
||||
@@ -125,7 +125,7 @@ static void SDL_EVDEV_dump_accents(SDL_EVDEV_keyboard_state *kbd)
|
||||
printf(" }\n");
|
||||
printf("};\n");
|
||||
}
|
||||
#endif /* DUMP_ACCENTS */
|
||||
#endif // DUMP_ACCENTS
|
||||
|
||||
#ifdef DUMP_KEYMAP
|
||||
static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd)
|
||||
@@ -155,7 +155,7 @@ static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd)
|
||||
}
|
||||
printf("};\n");
|
||||
}
|
||||
#endif /* DUMP_KEYMAP */
|
||||
#endif // DUMP_KEYMAP
|
||||
|
||||
static SDL_EVDEV_keyboard_state *kbd_cleanup_state = NULL;
|
||||
static int kbd_cleanup_sigactions_installed = 0;
|
||||
@@ -164,7 +164,7 @@ static int kbd_cleanup_atexit_installed = 0;
|
||||
static struct sigaction old_sigaction[NSIG];
|
||||
|
||||
static int fatal_signals[] = {
|
||||
/* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */
|
||||
// Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit.
|
||||
SIGHUP, SIGQUIT, SIGILL, SIGABRT,
|
||||
SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
|
||||
SIGSYS
|
||||
@@ -194,22 +194,22 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
|
||||
struct sigaction *old_action_p = &(old_sigaction[signum]);
|
||||
sigset_t sigset;
|
||||
|
||||
/* Restore original signal handler before going any further. */
|
||||
// Restore original signal handler before going any further.
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
|
||||
/* Unmask current signal. */
|
||||
// Unmask current signal.
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, signum);
|
||||
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
|
||||
/* Save original signal info and context for archeologists. */
|
||||
// Save original signal info and context for archeologists.
|
||||
SDL_EVDEV_kdb_cleanup_siginfo = info;
|
||||
SDL_EVDEV_kdb_cleanup_ucontext = ucontext;
|
||||
|
||||
/* Restore keyboard. */
|
||||
// Restore keyboard.
|
||||
kbd_cleanup();
|
||||
|
||||
/* Reraise signal. */
|
||||
// Reraise signal.
|
||||
SDL_EVDEV_kbd_reraise_signal(signum);
|
||||
}
|
||||
|
||||
@@ -230,27 +230,27 @@ static void kbd_unregister_emerg_cleanup(void)
|
||||
int signum = fatal_signals[tabidx];
|
||||
old_action_p = &(old_sigaction[signum]);
|
||||
|
||||
/* Examine current signal action */
|
||||
// Examine current signal action
|
||||
if (sigaction(signum, NULL, &cur_action)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check if action installed and not modified */
|
||||
// Check if action installed and not modified
|
||||
if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Restore original action */
|
||||
// Restore original action
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void kbd_cleanup_atexit(void)
|
||||
{
|
||||
/* Restore keyboard. */
|
||||
// Restore keyboard.
|
||||
kbd_cleanup();
|
||||
|
||||
/* Try to restore signal handlers in case shared library is being unloaded */
|
||||
// Try to restore signal handlers in case shared library is being unloaded
|
||||
kbd_unregister_emerg_cleanup();
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ static SDL_bool setup_vt_signal(int signum, signal_handler handler)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (old_action_p->sa_handler != SIG_DFL) {
|
||||
/* This signal is already in use */
|
||||
// This signal is already in use
|
||||
sigaction(signum, old_action_p, NULL);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -432,7 +432,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
|
||||
// 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 | O_CLOEXEC);
|
||||
if (!((ioctl(kbd->console_fd, KDGKBTYPE, &kbtype) == 0) && ((kbtype == KB_101) || (kbtype == KB_84)))) {
|
||||
close(kbd->console_fd);
|
||||
@@ -453,7 +453,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
kbd->key_maps = default_key_maps;
|
||||
|
||||
if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) {
|
||||
/* Set the keyboard in UNICODE mode and load the keymaps */
|
||||
// Set the keyboard in UNICODE mode and load the keymaps
|
||||
ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE);
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
|
||||
} else {
|
||||
kbd_unregister_emerg_cleanup();
|
||||
|
||||
/* Restore the original keyboard mode */
|
||||
// Restore the original keyboard mode
|
||||
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
|
||||
}
|
||||
state->muted = muted;
|
||||
@@ -549,7 +549,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
|
||||
*/
|
||||
static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
|
||||
{
|
||||
/* c is already part of a UTF-8 sequence and safe to add as a character */
|
||||
// c is already part of a UTF-8 sequence and safe to add as a character
|
||||
if (kbd->text_len < (sizeof(kbd->text) - 1)) {
|
||||
kbd->text[kbd->text_len++] = (char)c;
|
||||
}
|
||||
@@ -599,7 +599,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
|
||||
|
||||
if (kbd->console_fd >= 0)
|
||||
if (ioctl(kbd->console_fd, KDGKBDIACR, kbd->accents) < 0) {
|
||||
/* No worries, we'll use the default accent table */
|
||||
// No worries, we'll use the default accent table
|
||||
}
|
||||
|
||||
for (i = 0; i < kbd->accents->kb_cnt; i++) {
|
||||
@@ -721,7 +721,7 @@ static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char
|
||||
static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
|
||||
{
|
||||
if (up_flag) {
|
||||
return; /* no action, if this is a key release */
|
||||
return; // no action, if this is a key release
|
||||
}
|
||||
|
||||
if (kbd->diacr) {
|
||||
@@ -774,11 +774,11 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
|
||||
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
|
||||
|
||||
if (up_flag) {
|
||||
return; /* no action, if this is a key release */
|
||||
return; // no action, if this is a key release
|
||||
}
|
||||
|
||||
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
|
||||
/* unprintable action */
|
||||
// unprintable action
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
kbd->shift_state &= ~(1 << value);
|
||||
}
|
||||
|
||||
/* kludge */
|
||||
// kludge
|
||||
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
|
||||
put_utf8(kbd, kbd->npadch);
|
||||
kbd->npadch = -1;
|
||||
@@ -841,10 +841,10 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
}
|
||||
|
||||
if (value < 10) {
|
||||
/* decimal input of code, while Alt depressed */
|
||||
// decimal input of code, while Alt depressed
|
||||
base = 10;
|
||||
} else {
|
||||
/* hexadecimal input of code, while AltGr depressed */
|
||||
// hexadecimal input of code, while AltGr depressed
|
||||
value -= 10;
|
||||
base = 16;
|
||||
}
|
||||
@@ -873,7 +873,7 @@ static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
|
||||
}
|
||||
|
||||
chg_vc_kbd_slock(kbd, value);
|
||||
/* try to make Alt, oops, AltGr and such work */
|
||||
// try to make Alt, oops, AltGr and such work
|
||||
if (!kbd->key_maps[kbd->lockstate ^ kbd->slockstate]) {
|
||||
kbd->slockstate = 0;
|
||||
chg_vc_kbd_slock(kbd, value);
|
||||
@@ -900,7 +900,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
|
||||
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
|
||||
key_map = state->key_maps[shift_final];
|
||||
if (!key_map) {
|
||||
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
|
||||
// Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state
|
||||
state->shift_state = 0;
|
||||
state->slockstate = 0;
|
||||
state->lockstate = 0;
|
||||
@@ -932,7 +932,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
|
||||
} else {
|
||||
type -= 0xf0;
|
||||
|
||||
/* if type is KT_LETTER then it can be affected by Caps Lock */
|
||||
// if type is KT_LETTER then it can be affected by Caps Lock
|
||||
if (type == KT_LETTER) {
|
||||
type = KT_LATIN;
|
||||
|
||||
@@ -967,7 +967,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
|
||||
}
|
||||
}
|
||||
|
||||
#elif !defined(SDL_INPUT_FBSDKBIO) /* !SDL_INPUT_LINUXKD */
|
||||
#elif !defined(SDL_INPUT_FBSDKBIO) // !SDL_INPUT_LINUXKD
|
||||
|
||||
SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
|
||||
{
|
||||
@@ -994,4 +994,4 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* SDL_INPUT_LINUXKD */
|
||||
#endif // SDL_INPUT_LINUXKD
|
||||
|
||||
@@ -32,4 +32,4 @@ extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
||||
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
||||
extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
|
||||
|
||||
#endif /* SDL_evdev_kbd_h_ */
|
||||
#endif // SDL_evdev_kbd_h_
|
||||
|
||||
@@ -76,7 +76,7 @@ static char *GetAppName(void)
|
||||
return SDL_strdup(linkfile);
|
||||
}
|
||||
}
|
||||
#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD */
|
||||
#endif // SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD
|
||||
|
||||
return SDL_strdup("SDL_App");
|
||||
}
|
||||
@@ -94,10 +94,10 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus,
|
||||
Sint32 p_end_pos = -1;
|
||||
|
||||
dbus->message_iter_init(msg, &iter);
|
||||
/* Message type is a(si)i, we only need string part */
|
||||
// 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 */
|
||||
// First pass: calculate string length
|
||||
dbus->message_iter_recurse(&iter, &array);
|
||||
while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
|
||||
dbus->message_iter_recurse(&array, &sub);
|
||||
@@ -110,12 +110,12 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus,
|
||||
}
|
||||
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 */
|
||||
// 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 */
|
||||
// We only consider highlight
|
||||
if (type & (1 << 4)) {
|
||||
if (p_start_pos == -1) {
|
||||
p_start_pos = pos;
|
||||
@@ -138,7 +138,7 @@ static size_t Fcitx_GetPreeditString(SDL_DBusContext *dbus,
|
||||
|
||||
if (text) {
|
||||
char *pivot = text;
|
||||
/* Second pass: join all the sub string */
|
||||
// Second pass: join all the sub string
|
||||
dbus->message_iter_recurse(&iter, &array);
|
||||
while (dbus->message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
|
||||
dbus->message_iter_recurse(&array, &sub);
|
||||
@@ -239,8 +239,8 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
|
||||
}
|
||||
|
||||
if (hint && SDL_strstr(hint, "composition")) {
|
||||
caps |= (1 << 1); /* Preedit Flag */
|
||||
caps |= (1 << 4); /* Formatted Preedit Flag */
|
||||
caps |= (1 << 1); // Preedit Flag
|
||||
caps |= (1 << 4); // Formatted Preedit Flag
|
||||
}
|
||||
if (hint && SDL_strstr(hint, "candidates")) {
|
||||
// FIXME, turn off native candidate rendering
|
||||
@@ -285,9 +285,9 @@ static SDL_bool FcitxClientCreateIC(FcitxClient *client)
|
||||
char *ic_path = NULL;
|
||||
SDL_DBusContext *dbus = client->dbus;
|
||||
|
||||
/* SDL_DBus_CallMethod cannot handle a(ss) type, call dbus function directly */
|
||||
// SDL_DBus_CallMethod cannot handle a(ss) type, call dbus function directly
|
||||
if (!FcitxCreateInputContext(dbus, appname, &ic_path)) {
|
||||
ic_path = NULL; /* just in case. */
|
||||
ic_path = NULL; // just in case.
|
||||
}
|
||||
|
||||
SDL_free(appname);
|
||||
@@ -433,7 +433,7 @@ void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window)
|
||||
#endif
|
||||
|
||||
if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) {
|
||||
/* move to bottom left */
|
||||
// move to bottom left
|
||||
int w = 0, h = 0;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
cursor->x = 0;
|
||||
@@ -455,6 +455,6 @@ void SDL_Fcitx_PumpEvents(void)
|
||||
dbus->connection_read_write(conn, 0);
|
||||
|
||||
while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) {
|
||||
/* Do nothing, actual work happens in DBus_MessageFilter */
|
||||
// Do nothing, actual work happens in DBus_MessageFilter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 s
|
||||
extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window);
|
||||
extern void SDL_Fcitx_PumpEvents(void);
|
||||
|
||||
#endif /* SDL_fcitx_h_ */
|
||||
#endif // SDL_fcitx_h_
|
||||
|
||||
@@ -62,7 +62,7 @@ static Uint32 IBus_ModState(void)
|
||||
Uint32 ibus_mods = 0;
|
||||
SDL_Keymod sdl_mods = SDL_GetModState();
|
||||
|
||||
/* Not sure about MOD3, MOD4 and HYPER mappings */
|
||||
// Not sure about MOD3, MOD4 and HYPER mappings
|
||||
if (sdl_mods & SDL_KMOD_LSHIFT) {
|
||||
ibus_mods |= IBUS_SHIFT_MASK;
|
||||
}
|
||||
@@ -152,16 +152,16 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
|
||||
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) */
|
||||
// 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 */
|
||||
// We only use the background type to determine the selection
|
||||
if (type == 3) {
|
||||
Uint32 start = -1;
|
||||
dbus->message_iter_next(&sub);
|
||||
@@ -184,7 +184,7 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
|
||||
|
||||
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 */
|
||||
// The text we need is nested weirdly, use dbus-monitor to see the structure better
|
||||
const char *text = NULL;
|
||||
DBusMessageIter sub;
|
||||
|
||||
@@ -330,7 +330,7 @@ static char *IBus_GetDBusAddressFilename(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Use this environment variable if it exists. */
|
||||
// Use this environment variable if it exists.
|
||||
addr = SDL_getenv("IBUS_ADDRESS");
|
||||
if (addr && *addr) {
|
||||
return SDL_strdup(addr);
|
||||
@@ -453,7 +453,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||
ibus_conn = dbus->connection_open_private(addr, NULL);
|
||||
|
||||
if (!ibus_conn) {
|
||||
return SDL_FALSE; /* oh well. */
|
||||
return SDL_FALSE; // oh well.
|
||||
}
|
||||
|
||||
dbus->connection_flush(ibus_conn);
|
||||
@@ -469,7 +469,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
|
||||
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
|
||||
} else {
|
||||
/* re-using dbus->session_conn */
|
||||
// re-using dbus->session_conn
|
||||
dbus->connection_ref(ibus_conn);
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ SDL_bool SDL_IBus_Init(void)
|
||||
result = IBus_SetupConnection(dbus, addr);
|
||||
SDL_free(addr);
|
||||
|
||||
/* don't use the addr_file if using the portal interface. */
|
||||
// don't use the addr_file if using the portal interface.
|
||||
if (result && ibus_is_portal_interface) {
|
||||
if (inotify_fd > 0) {
|
||||
if (inotify_wd > 0) {
|
||||
@@ -616,7 +616,7 @@ void SDL_IBus_Quit(void)
|
||||
|
||||
dbus = SDL_DBus_GetContext();
|
||||
|
||||
/* if using portal, ibus_conn == session_conn; don't release it here. */
|
||||
// if using portal, ibus_conn == session_conn; don't release it here.
|
||||
if (dbus && ibus_conn && !ibus_is_portal_interface) {
|
||||
dbus->connection_close(ibus_conn);
|
||||
dbus->connection_unref(ibus_conn);
|
||||
@@ -633,7 +633,7 @@ void SDL_IBus_Quit(void)
|
||||
inotify_wd = -1;
|
||||
}
|
||||
|
||||
/* !!! FIXME: should we close(inotify_fd) here? */
|
||||
// !!! FIXME: should we close(inotify_fd) here?
|
||||
|
||||
SDL_DelHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, IBus_SetCapabilities, NULL);
|
||||
|
||||
@@ -733,7 +733,7 @@ void SDL_IBus_PumpEvents(void)
|
||||
dbus->connection_read_write(ibus_conn, 0);
|
||||
|
||||
while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) {
|
||||
/* Do nothing, actual work happens in IBus_MessageHandler */
|
||||
// Do nothing, actual work happens in IBus_MessageHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
extern SDL_bool SDL_IBus_Init(void);
|
||||
extern void SDL_IBus_Quit(void);
|
||||
|
||||
/* Lets the IBus server know about changes in window focus */
|
||||
// Lets the IBus server know about changes in window focus
|
||||
extern void SDL_IBus_SetFocus(SDL_bool focused);
|
||||
|
||||
/* Closes the candidate list and resets any text currently being edited */
|
||||
// Closes the candidate list and resets any text currently being edited
|
||||
extern void SDL_IBus_Reset(void);
|
||||
|
||||
/* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to
|
||||
@@ -50,6 +50,6 @@ extern void SDL_IBus_UpdateTextInputArea(SDL_Window *window);
|
||||
SDL_SendEditingText for each event it finds */
|
||||
extern void SDL_IBus_PumpEvents(void);
|
||||
|
||||
#endif /* HAVE_IBUS_IBUS_H */
|
||||
#endif // HAVE_IBUS_IBUS_H
|
||||
|
||||
#endif /* SDL_ibus_h_ */
|
||||
#endif // SDL_ibus_h_
|
||||
|
||||
@@ -54,7 +54,7 @@ static void InitIME(void)
|
||||
|
||||
inited = SDL_TRUE;
|
||||
|
||||
/* See if fcitx IME support is being requested */
|
||||
// See if fcitx IME support is being requested
|
||||
#ifdef HAVE_FCITX
|
||||
if (!SDL_IME_Init_Real &&
|
||||
((im_module && SDL_strcmp(im_module, "fcitx") == 0) ||
|
||||
@@ -67,9 +67,9 @@ static void InitIME(void)
|
||||
SDL_IME_UpdateTextInputArea_Real = SDL_Fcitx_UpdateTextInputArea;
|
||||
SDL_IME_PumpEvents_Real = SDL_Fcitx_PumpEvents;
|
||||
}
|
||||
#endif /* HAVE_FCITX */
|
||||
#endif // HAVE_FCITX
|
||||
|
||||
/* default to IBus */
|
||||
// default to IBus
|
||||
#ifdef HAVE_IBUS_IBUS_H
|
||||
if (!SDL_IME_Init_Real) {
|
||||
SDL_IME_Init_Real = SDL_IBus_Init;
|
||||
@@ -80,7 +80,7 @@ static void InitIME(void)
|
||||
SDL_IME_UpdateTextInputArea_Real = SDL_IBus_UpdateTextInputArea;
|
||||
SDL_IME_PumpEvents_Real = SDL_IBus_PumpEvents;
|
||||
}
|
||||
#endif /* HAVE_IBUS_IBUS_H */
|
||||
#endif // HAVE_IBUS_IBUS_H
|
||||
}
|
||||
|
||||
SDL_bool SDL_IME_Init(void)
|
||||
@@ -92,7 +92,7 @@ SDL_bool SDL_IME_Init(void)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* uhoh, the IME implementation's init failed! Disable IME support. */
|
||||
// uhoh, the IME implementation's init failed! Disable IME support.
|
||||
SDL_IME_Init_Real = NULL;
|
||||
SDL_IME_Quit_Real = NULL;
|
||||
SDL_IME_SetFocus_Real = NULL;
|
||||
|
||||
@@ -32,4 +32,4 @@ extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 sta
|
||||
extern void SDL_IME_UpdateTextInputArea(SDL_Window *window);
|
||||
extern void SDL_IME_PumpEvents(void);
|
||||
|
||||
#endif /* SDL_ime_h_ */
|
||||
#endif // SDL_ime_h_
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef enum
|
||||
SDL_SANDBOX_SNAP,
|
||||
} SDL_Sandbox;
|
||||
|
||||
/* Return the sandbox type currently in use, if any */
|
||||
// Return the sandbox type currently in use, if any
|
||||
SDL_Sandbox SDL_DetectSandbox(void);
|
||||
|
||||
#endif /* SDL_SANDBOX_H */
|
||||
#endif // SDL_SANDBOX_H
|
||||
|
||||
@@ -77,7 +77,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
const char *namespace, *key;
|
||||
|
||||
dbus->message_iter_init(msg, &signal_iter);
|
||||
/* Check if the parameters are what we expect */
|
||||
// Check if the parameters are what we expect
|
||||
if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING)
|
||||
goto not_our_signal;
|
||||
dbus->message_iter_get_basic(&signal_iter, &namespace);
|
||||
@@ -127,7 +127,7 @@ SDL_bool SDL_SystemTheme_Init(void)
|
||||
DBusMessageIter reply_iter, variant_outer_iter;
|
||||
|
||||
dbus->message_iter_init(reply, &reply_iter);
|
||||
/* The response has signature <<u>> */
|
||||
// The response has signature <<u>>
|
||||
if (dbus->message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT)
|
||||
goto incorrect_type;
|
||||
dbus->message_iter_recurse(&reply_iter, &variant_outer_iter);
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
extern SDL_bool SDL_SystemTheme_Init(void);
|
||||
extern SDL_SystemTheme SDL_SystemTheme_Get(void);
|
||||
|
||||
#endif /* SDL_system_theme_h_ */
|
||||
#endif // SDL_system_theme_h_
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* RLIMIT_RTTIME requires kernel >= 2.6.25 and is in glibc >= 2.14 */
|
||||
// RLIMIT_RTTIME requires kernel >= 2.6.25 and is in glibc >= 2.14
|
||||
#ifndef RLIMIT_RTTIME
|
||||
#define RLIMIT_RTTIME 15
|
||||
#endif
|
||||
/* SCHED_RESET_ON_FORK is in kernel >= 2.6.32. */
|
||||
// SCHED_RESET_ON_FORK is in kernel >= 2.6.32.
|
||||
#ifndef SCHED_RESET_ON_FORK
|
||||
#define SCHED_RESET_ON_FORK 0x40000000
|
||||
#endif
|
||||
@@ -42,12 +42,12 @@
|
||||
|
||||
#ifdef SDL_USE_LIBDBUS
|
||||
|
||||
/* d-bus queries to org.freedesktop.RealtimeKit1. */
|
||||
// d-bus queries to org.freedesktop.RealtimeKit1.
|
||||
#define RTKIT_DBUS_NODE "org.freedesktop.RealtimeKit1"
|
||||
#define RTKIT_DBUS_PATH "/org/freedesktop/RealtimeKit1"
|
||||
#define RTKIT_DBUS_INTERFACE "org.freedesktop.RealtimeKit1"
|
||||
|
||||
/* d-bus queries to the XDG portal interface to RealtimeKit1 */
|
||||
// d-bus queries to the XDG portal interface to RealtimeKit1
|
||||
#define XDG_PORTAL_DBUS_NODE "org.freedesktop.portal.Desktop"
|
||||
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
|
||||
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
|
||||
@@ -78,13 +78,13 @@ static void set_rtkit_interface(void)
|
||||
{
|
||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||
|
||||
/* xdg-desktop-portal works in all instances, so check for it first. */
|
||||
// xdg-desktop-portal works in all instances, so check for it first.
|
||||
if (dbus && realtime_portal_supported(dbus->session_conn)) {
|
||||
rtkit_use_session_conn = SDL_TRUE;
|
||||
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
|
||||
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
|
||||
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
|
||||
} else { /* Fall back to the standard rtkit interface in all other cases. */
|
||||
} else { // Fall back to the standard rtkit interface in all other cases.
|
||||
rtkit_use_session_conn = SDL_FALSE;
|
||||
rtkit_dbus_node = RTKIT_DBUS_NODE;
|
||||
rtkit_dbus_path = RTKIT_DBUS_PATH;
|
||||
@@ -110,19 +110,19 @@ static void rtkit_initialize(void)
|
||||
set_rtkit_interface();
|
||||
dbus_conn = get_rtkit_dbus_connection();
|
||||
|
||||
/* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
|
||||
// Try getting minimum nice level: this is often greater than PRIO_MIN (-20).
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
|
||||
DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
|
||||
rtkit_min_nice_level = -20;
|
||||
}
|
||||
|
||||
/* Try getting maximum realtime priority: this can be less than the POSIX default (99). */
|
||||
// Try getting maximum realtime priority: this can be less than the POSIX default (99).
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
|
||||
DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) {
|
||||
rtkit_max_realtime_priority = 99;
|
||||
}
|
||||
|
||||
/* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */
|
||||
// Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL
|
||||
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
|
||||
DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) {
|
||||
rtkit_max_rttime_usec = 200000;
|
||||
@@ -245,10 +245,10 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||
|
||||
#define rtkit_max_realtime_priority 99
|
||||
|
||||
#endif /* dbus */
|
||||
#endif /* threads */
|
||||
#endif // dbus
|
||||
#endif // threads
|
||||
|
||||
/* this is a public symbol, so it has to exist even if threads are disabled. */
|
||||
// this is a public symbol, so it has to exist even if threads are disabled.
|
||||
int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
{
|
||||
#ifdef SDL_THREADS_DISABLED
|
||||
@@ -280,7 +280,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* this is a public symbol, so it has to exist even if threads are disabled. */
|
||||
// this is a public symbol, so it has to exist even if threads are disabled.
|
||||
int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
{
|
||||
#ifdef SDL_THREADS_DISABLED
|
||||
@@ -342,4 +342,4 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SDL_PLATFORM_LINUX */
|
||||
#endif // SDL_PLATFORM_LINUX
|
||||
|
||||
@@ -52,7 +52,7 @@ static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr)
|
||||
{
|
||||
*addr = SDL_LoadFunction(_this->udev_handle, fn);
|
||||
if (!*addr) {
|
||||
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
|
||||
// Don't call SDL_SetError(): SDL_LoadFunction already did.
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ int SDL_UDEV_Init(void)
|
||||
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "video4linux", NULL);
|
||||
_this->syms.udev_monitor_enable_receiving(_this->udev_mon);
|
||||
|
||||
/* Do an initial scan of existing devices */
|
||||
// Do an initial scan of existing devices
|
||||
SDL_UDEV_Scan();
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void SDL_UDEV_Quit(void)
|
||||
_this->udev = NULL;
|
||||
}
|
||||
|
||||
/* Remove existing devices */
|
||||
// Remove existing devices
|
||||
while (_this->first) {
|
||||
SDL_UDEV_CallbackList *item = _this->first;
|
||||
_this->first = _this->first->next;
|
||||
@@ -299,13 +299,13 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
return SDL_SetError("UDEV not initialized");
|
||||
}
|
||||
|
||||
/* See if there is a udev library already loaded */
|
||||
// See if there is a udev library already loaded
|
||||
if (SDL_UDEV_load_syms() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SDL_UDEV_DYNAMIC
|
||||
/* Check for the build environment's libudev first */
|
||||
// Check for the build environment's libudev first
|
||||
if (!_this->udev_handle) {
|
||||
_this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
|
||||
if (_this->udev_handle) {
|
||||
@@ -332,7 +332,7 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
|
||||
if (!_this->udev_handle) {
|
||||
retval = -1;
|
||||
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ static int device_class(struct udev_device *dev)
|
||||
devclass = SDL_UDEV_DEVICE_VIDEO_CAPTURE;
|
||||
}
|
||||
} else if (SDL_strcmp(subsystem, "input") == 0) {
|
||||
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
|
||||
// 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 && SDL_strcmp(val, "1") == 0) {
|
||||
@@ -459,7 +459,7 @@ static int device_class(struct udev_device *dev)
|
||||
}
|
||||
|
||||
if (devclass == 0) {
|
||||
/* Fall back to old style input classes */
|
||||
// Fall back to old style input classes
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS");
|
||||
if (val) {
|
||||
if (SDL_strcmp(val, "joystick") == 0) {
|
||||
@@ -470,7 +470,7 @@ static int device_class(struct udev_device *dev)
|
||||
devclass = SDL_UDEV_DEVICE_HAS_KEYS | SDL_UDEV_DEVICE_KEYBOARD;
|
||||
}
|
||||
} else {
|
||||
/* We could be linked with libudev on a system that doesn't have udev running */
|
||||
// We could be linked with libudev on a system that doesn't have udev running
|
||||
devclass = guess_device_class(dev);
|
||||
}
|
||||
}
|
||||
@@ -495,7 +495,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Process callbacks */
|
||||
// Process callbacks
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
item->callback(type, devclass, path);
|
||||
}
|
||||
@@ -559,7 +559,7 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
}
|
||||
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
/* found it, remove it. */
|
||||
// found it, remove it.
|
||||
if (item->callback == cb) {
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
@@ -592,4 +592,4 @@ void SDL_UDEV_ReleaseUdevSyms(void)
|
||||
SDL_UDEV_Quit();
|
||||
}
|
||||
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
|
||||
@@ -92,7 +92,7 @@ typedef struct SDL_UDEV_PrivateData
|
||||
int ref_count;
|
||||
SDL_UDEV_CallbackList *first, *last;
|
||||
|
||||
/* Function pointers */
|
||||
// Function pointers
|
||||
SDL_UDEV_Symbols syms;
|
||||
} SDL_UDEV_PrivateData;
|
||||
|
||||
@@ -108,6 +108,6 @@ extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
||||
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
||||
extern void SDL_UDEV_ReleaseUdevSyms(void);
|
||||
|
||||
#endif /* HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H */
|
||||
#endif // HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H
|
||||
|
||||
#endif /* SDL_udev_h_ */
|
||||
#endif // SDL_udev_h_
|
||||
|
||||
@@ -53,44 +53,44 @@ extern SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse();
|
||||
extern void updateMouse(SDL_WSCONS_mouse_input_data *input);
|
||||
extern void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *input);
|
||||
|
||||
/* Conversion table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */
|
||||
// Conversion table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c
|
||||
static const unsigned char latin1_to_upper[256] = {
|
||||
/* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */
|
||||
0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 6 */
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 6 */
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 7 */
|
||||
'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* e */
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* e */
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* f */
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, /* f */
|
||||
// 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 5
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 5
|
||||
0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', // 6
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', // 6
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', // 7
|
||||
'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, // 7
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // a
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // a
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // b
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // b
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // c
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // c
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // d
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // d
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, // e
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, // e
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, // f
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, // f
|
||||
};
|
||||
|
||||
/* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */
|
||||
// Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c
|
||||
static struct SDL_wscons_compose_tab_s
|
||||
{
|
||||
keysym_t elem[2];
|
||||
@@ -487,7 +487,7 @@ void SDL_WSCONS_Quit(void)
|
||||
|
||||
static void put_queue(SDL_WSCONS_input_data *kbd, uint c)
|
||||
{
|
||||
/* c is already part of a UTF-8 sequence and safe to add as a character */
|
||||
// c is already part of a UTF-8 sequence and safe to add as a character
|
||||
if (kbd->text_len < (sizeof(kbd->text) - 1)) {
|
||||
kbd->text[kbd->text_len++] = (char)(c);
|
||||
}
|
||||
@@ -535,7 +535,7 @@ static void Translate_to_text(SDL_WSCONS_input_data *input, keysym_t ksym)
|
||||
case KS_BackSpace:
|
||||
case KS_Return:
|
||||
case KS_Linefeed:
|
||||
/* All of these are unprintable characters. Ignore them */
|
||||
// All of these are unprintable characters. Ignore them
|
||||
break;
|
||||
default:
|
||||
put_utf8(input, ksym);
|
||||
@@ -544,7 +544,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);
|
||||
/*SDL_memset(input->text, 0, sizeof(input->text));*/
|
||||
// SDL_memset(input->text, 0, sizeof(input->text));
|
||||
input->text_len = 0;
|
||||
input->text[0] = 0;
|
||||
}
|
||||
@@ -556,7 +556,7 @@ static void Translate_to_keycode(SDL_WSCONS_input_data *input, int type, keysym_
|
||||
keysym_t *group = &keyDesc.group1[KS_GROUP(keyDesc.group1[0]) == KS_GROUP_Keypad && IS_NUMLOCK_ON ? !IS_SHIFT_HELD : 0];
|
||||
int i = 0;
|
||||
|
||||
/* Check command first, then group[0]*/
|
||||
// Check command first, then group[0]
|
||||
switch (keyDesc.command) {
|
||||
case KS_Cmd_ScrollBack:
|
||||
{
|
||||
|
||||
@@ -78,13 +78,13 @@ void updateMouse(SDL_WSCONS_mouse_input_data *input)
|
||||
case WSCONS_EVENT_MOUSE_DOWN:
|
||||
{
|
||||
switch (events[i].value) {
|
||||
case 0: /* Left Mouse Button. */
|
||||
case 0: // Left Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
case 1: /* Middle Mouse Button. */
|
||||
case 1: // Middle Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_MIDDLE);
|
||||
break;
|
||||
case 2: /* Right Mouse Button. */
|
||||
case 2: // Right Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT);
|
||||
break;
|
||||
}
|
||||
@@ -92,13 +92,13 @@ void updateMouse(SDL_WSCONS_mouse_input_data *input)
|
||||
case WSCONS_EVENT_MOUSE_UP:
|
||||
{
|
||||
switch (events[i].value) {
|
||||
case 0: /* Left Mouse Button. */
|
||||
case 0: // Left Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
case 1: /* Middle Mouse Button. */
|
||||
case 1: // Middle Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||
break;
|
||||
case 2: /* Right Mouse Button. */
|
||||
case 2: // Right Mouse Button.
|
||||
SDL_SendMouseButton(0, mouse->focus, input->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ const char *SDL_GetExeName(void)
|
||||
{
|
||||
static const char *proc_name = NULL;
|
||||
|
||||
/* TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all) */
|
||||
// TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all)
|
||||
if (!proc_name) {
|
||||
#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD)
|
||||
static char linkfile[1024];
|
||||
@@ -62,12 +62,12 @@ const char *SDL_GetAppID(void)
|
||||
const char *id_str = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING);
|
||||
|
||||
if (!id_str) {
|
||||
/* If the hint isn't set, try to use the application's executable name */
|
||||
// If the hint isn't set, try to use the application's executable name
|
||||
id_str = SDL_GetExeName();
|
||||
}
|
||||
|
||||
if (!id_str) {
|
||||
/* Finally, use the default we've used forever */
|
||||
// Finally, use the default we've used forever
|
||||
id_str = "SDL_App";
|
||||
}
|
||||
|
||||
|
||||
@@ -27,4 +27,4 @@ freely, subject to the following restrictions:
|
||||
extern const char *SDL_GetExeName();
|
||||
extern const char *SDL_GetAppID();
|
||||
|
||||
#endif /* SDL_appid_h_ */
|
||||
#endif // SDL_appid_h_
|
||||
|
||||
@@ -38,7 +38,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS)
|
||||
|
||||
SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE));
|
||||
|
||||
/* Note: We don't bother to account for elapsed time if we get EINTR */
|
||||
// Note: We don't bother to account for elapsed time if we get EINTR
|
||||
do {
|
||||
#ifdef HAVE_POLL
|
||||
struct pollfd info;
|
||||
@@ -52,7 +52,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS)
|
||||
if (flags & SDL_IOR_WRITE) {
|
||||
info.events |= POLLOUT;
|
||||
}
|
||||
/* FIXME: Add support for ppoll() for nanosecond precision */
|
||||
// FIXME: Add support for ppoll() for nanosecond precision
|
||||
if (timeoutNS > 0) {
|
||||
timeoutMS = (int)SDL_NS_TO_MS(timeoutNS);
|
||||
} else if (timeoutNS == 0) {
|
||||
@@ -66,7 +66,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS)
|
||||
fd_set wfdset, *wfdp = NULL;
|
||||
struct timeval tv, *tvp = NULL;
|
||||
|
||||
/* If this assert triggers we'll corrupt memory here */
|
||||
// If this assert triggers we'll corrupt memory here
|
||||
SDL_assert(fd >= 0 && fd < FD_SETSIZE);
|
||||
|
||||
if (flags & SDL_IOR_READ) {
|
||||
@@ -87,7 +87,7 @@ int SDL_IOReady(int fd, int flags, Sint64 timeoutNS)
|
||||
}
|
||||
|
||||
result = select(fd + 1, rfdp, wfdp, NULL, tvp);
|
||||
#endif /* HAVE_POLL */
|
||||
#endif // HAVE_POLL
|
||||
|
||||
} while (result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY));
|
||||
|
||||
|
||||
@@ -30,4 +30,4 @@
|
||||
|
||||
extern int SDL_IOReady(int fd, int flags, Sint64 timeoutNS);
|
||||
|
||||
#endif /* SDL_poll_h_ */
|
||||
#endif // SDL_poll_h_
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef SDL_directx_h_
|
||||
#define SDL_directx_h_
|
||||
|
||||
/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */
|
||||
// Include all of the DirectX 8.0 headers and adds any necessary tweaks
|
||||
|
||||
#include "SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
@@ -32,12 +32,12 @@
|
||||
#endif
|
||||
#undef WINNT
|
||||
|
||||
/* Far pointers don't exist in 32-bit code */
|
||||
// Far pointers don't exist in 32-bit code
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
/* Error codes not yet included in Win32 API header files */
|
||||
// Error codes not yet included in Win32 API header files
|
||||
#ifndef MAKE_HRESULT
|
||||
#define MAKE_HRESULT(sev, fac, code) \
|
||||
((HRESULT)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) | ((unsigned long)(code))))
|
||||
@@ -73,12 +73,12 @@
|
||||
#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L
|
||||
#endif
|
||||
|
||||
/* Severity codes */
|
||||
// Severity codes
|
||||
#ifndef SEVERITY_ERROR
|
||||
#define SEVERITY_ERROR 1
|
||||
#endif
|
||||
|
||||
/* Error facility codes */
|
||||
// Error facility codes
|
||||
#ifndef FACILITY_WIN32
|
||||
#define FACILITY_WIN32 7
|
||||
#endif
|
||||
@@ -89,10 +89,10 @@
|
||||
|
||||
/* DirectX headers (if it isn't included, I haven't tested it yet)
|
||||
*/
|
||||
/* We need these defines to mark what version of DirectX API we use */
|
||||
// We need these defines to mark what version of DirectX API we use
|
||||
#define DIRECTDRAW_VERSION 0x0700
|
||||
#define DIRECTSOUND_VERSION 0x0800
|
||||
#define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */
|
||||
#define DIRECTINPUT_VERSION 0x0800 // Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve...
|
||||
|
||||
#ifdef HAVE_DDRAW_H
|
||||
#include <ddraw.h>
|
||||
@@ -109,4 +109,4 @@ typedef struct
|
||||
} DIDEVICEINSTANCE;
|
||||
#endif
|
||||
|
||||
#endif /* SDL_directx_h_ */
|
||||
#endif // SDL_directx_h_
|
||||
|
||||
@@ -41,7 +41,7 @@ int WIN_LoadHIDDLL(void)
|
||||
if (s_pHIDDLL) {
|
||||
SDL_assert(s_HIDDLLRefCount > 0);
|
||||
s_HIDDLLRefCount++;
|
||||
return 0; /* already loaded */
|
||||
return 0; // already loaded
|
||||
}
|
||||
|
||||
s_pHIDDLL = LoadLibrary(TEXT("hid.dll"));
|
||||
@@ -82,11 +82,11 @@ void WIN_UnloadHIDDLL(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !SDL_PLATFORM_WINRT */
|
||||
#endif // !SDL_PLATFORM_WINRT
|
||||
|
||||
#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
|
||||
/* CM_Register_Notification definitions */
|
||||
// CM_Register_Notification definitions
|
||||
|
||||
#define CR_SUCCESS 0
|
||||
|
||||
@@ -224,7 +224,7 @@ void WIN_QuitDeviceNotification(void)
|
||||
if (--s_DeviceNotificationsRequested > 0) {
|
||||
return;
|
||||
}
|
||||
/* Make sure we have balanced calls to init/quit */
|
||||
// Make sure we have balanced calls to init/quit
|
||||
SDL_assert(s_DeviceNotificationsRequested == 0);
|
||||
|
||||
if (cfgmgr32_lib_handle) {
|
||||
|
||||
@@ -208,11 +208,11 @@ extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps;
|
||||
extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength;
|
||||
extern HidP_GetData_t SDL_HidP_GetData;
|
||||
|
||||
#endif /* !SDL_PLATFORM_WINRT */
|
||||
#endif // !SDL_PLATFORM_WINRT
|
||||
|
||||
|
||||
void WIN_InitDeviceNotification(void);
|
||||
Uint64 WIN_GetLastDeviceNotification(void);
|
||||
void WIN_QuitDeviceNotification(void);
|
||||
|
||||
#endif /* SDL_hid_h_ */
|
||||
#endif // SDL_hid_h_
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "SDL_windows.h"
|
||||
#include "SDL_immdevice.h"
|
||||
#include "../../audio/SDL_sysaudio.h"
|
||||
#include <objbase.h> /* For CLSIDFromString */
|
||||
#include <objbase.h> // For CLSIDFromString
|
||||
|
||||
typedef struct SDL_IMMDevice_HandleData
|
||||
{
|
||||
@@ -33,20 +33,20 @@ typedef struct SDL_IMMDevice_HandleData
|
||||
GUID directsound_guid;
|
||||
} SDL_IMMDevice_HandleData;
|
||||
|
||||
static const ERole SDL_IMMDevice_role = eConsole; /* !!! FIXME: should this be eMultimedia? Should be a hint? */
|
||||
static const ERole SDL_IMMDevice_role = eConsole; // !!! FIXME: should this be eMultimedia? Should be a hint?
|
||||
|
||||
/* This is global to the WASAPI target, to handle hotplug and default device lookup. */
|
||||
// This is global to the WASAPI target, to handle hotplug and default device lookup.
|
||||
static IMMDeviceEnumerator *enumerator = NULL;
|
||||
static SDL_IMMDevice_callbacks immcallbacks;
|
||||
|
||||
/* PropVariantInit() is an inline function/macro in PropIdl.h that calls the C runtime's memset() directly. Use ours instead, to avoid dependency. */
|
||||
// PropVariantInit() is an inline function/macro in PropIdl.h that calls the C runtime's memset() directly. Use ours instead, to avoid dependency.
|
||||
#ifdef PropVariantInit
|
||||
#undef PropVariantInit
|
||||
#endif
|
||||
#define PropVariantInit(p) SDL_zerop(p)
|
||||
|
||||
/* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
static const CLSID SDL_CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,{ 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e } };
|
||||
static const IID SDL_IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,{ 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6 } };
|
||||
static const IID SDL_IID_IMMNotificationClient = { 0x7991eec9, 0x7e89, 0x4d85,{ 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0 } };
|
||||
@@ -54,7 +54,7 @@ static const IID SDL_IID_IMMEndpoint = { 0x1be09788, 0x6894, 0x4089,{ 0x85, 0x86
|
||||
static const PROPERTYKEY SDL_PKEY_Device_FriendlyName = { { 0xa45c254e, 0xdf1c, 0x4efd,{ 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, } }, 14 };
|
||||
static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x82c, 0x4e27,{ 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, } }, 0 };
|
||||
static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 };
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
static SDL_bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata)
|
||||
{
|
||||
@@ -205,11 +205,11 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_AddRef(IMMNotificationCli
|
||||
|
||||
static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationClient *iclient)
|
||||
{
|
||||
/* client is a static object; we don't ever free it. */
|
||||
// client is a static object; we don't ever free it.
|
||||
SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient;
|
||||
const ULONG retval = SDL_AtomicDecRef(&client->refcount);
|
||||
if (retval == 0) {
|
||||
SDL_AtomicSet(&client->refcount, 0); /* uhh... */
|
||||
SDL_AtomicSet(&client->refcount, 0); // uhh...
|
||||
return 0;
|
||||
}
|
||||
return retval - 1;
|
||||
@@ -292,7 +292,7 @@ int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
|
||||
{
|
||||
HRESULT ret;
|
||||
|
||||
/* just skip the discussion with COM here. */
|
||||
// just skip the discussion with COM here.
|
||||
if (!WIN_IsWindowsVistaOrGreater()) {
|
||||
return SDL_SetError("IMMDevice support requires Windows Vista or later");
|
||||
}
|
||||
@@ -338,7 +338,7 @@ void SDL_IMMDevice_Quit(void)
|
||||
|
||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording)
|
||||
{
|
||||
const Uint64 timeout = SDL_GetTicks() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */
|
||||
const Uint64 timeout = SDL_GetTicks() + 8000; // intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep.
|
||||
|
||||
SDL_assert(device != NULL);
|
||||
SDL_assert(immdevice != NULL);
|
||||
@@ -351,7 +351,7 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool r
|
||||
const Uint64 now = SDL_GetTicks();
|
||||
if (timeout > now) {
|
||||
const Uint64 ticksleft = timeout - now;
|
||||
SDL_Delay((Uint32)SDL_min(ticksleft, 300)); /* wait awhile and try again. */
|
||||
SDL_Delay((Uint32)SDL_min(ticksleft, 300)); // wait awhile and try again.
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -425,8 +425,8 @@ void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_Au
|
||||
EnumerateEndpointsForFlow(SDL_FALSE, default_playback);
|
||||
EnumerateEndpointsForFlow(SDL_TRUE, default_recording);
|
||||
|
||||
/* if this fails, we just won't get hotplug events. Carry on anyhow. */
|
||||
// if this fails, we just won't get hotplug events. Carry on anyhow.
|
||||
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client);
|
||||
}
|
||||
|
||||
#endif /* (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) */
|
||||
#endif // (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H)
|
||||
|
||||
@@ -42,4 +42,4 @@ LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
|
||||
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);
|
||||
void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device);
|
||||
|
||||
#endif /* SDL_IMMDEVICE_H */
|
||||
#endif // SDL_IMMDEVICE_H
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
#include "SDL_windows.h"
|
||||
|
||||
#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */
|
||||
#include <objbase.h> // for CoInitialize/CoUninitialize (Win32 only)
|
||||
#ifdef HAVE_ROAPI_H
|
||||
#include <roapi.h> /* For RoInitialize/RoUninitialize (Win32 only) */
|
||||
#include <roapi.h> // For RoInitialize/RoUninitialize (Win32 only)
|
||||
#else
|
||||
typedef enum RO_INIT_TYPE
|
||||
{
|
||||
@@ -53,7 +53,7 @@ typedef enum RO_INIT_TYPE
|
||||
#define WC_ERR_INVALID_CHARS 0x00000080
|
||||
#endif
|
||||
|
||||
/* Sets an error message based on an HRESULT */
|
||||
// Sets an error message based on an HRESULT
|
||||
int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
@@ -62,7 +62,7 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
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 */
|
||||
// kill CR/LF that FormatMessage() sticks at the end
|
||||
while (*p) {
|
||||
if (*p == '\r') {
|
||||
*p = 0;
|
||||
@@ -76,7 +76,7 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Sets an error message based on GetLastError() */
|
||||
// Sets an error message based on GetLastError()
|
||||
int WIN_SetError(const char *prefix)
|
||||
{
|
||||
return WIN_SetErrorFromHRESULT(prefix, GetLastError());
|
||||
@@ -98,7 +98,7 @@ WIN_CoInitialize(void)
|
||||
*/
|
||||
return S_OK;
|
||||
#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||
/* On Xbox, there's no need to call CoInitializeEx (and it's not implemented) */
|
||||
// On Xbox, there's no need to call CoInitializeEx (and it's not implemented)
|
||||
return S_OK;
|
||||
#else
|
||||
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
@@ -106,8 +106,8 @@ WIN_CoInitialize(void)
|
||||
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
}
|
||||
|
||||
/* S_FALSE means success, but someone else already initialized. */
|
||||
/* You still need to call CoUninitialize in this case! */
|
||||
// S_FALSE means success, but someone else already initialized.
|
||||
// You still need to call CoUninitialize in this case!
|
||||
if (hr == S_FALSE) {
|
||||
return S_OK;
|
||||
}
|
||||
@@ -150,14 +150,14 @@ WIN_RoInitialize(void)
|
||||
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 */
|
||||
// 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! */
|
||||
// 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;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM.
|
||||
char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
{
|
||||
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||
return WIN_StringToUTF8W(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */
|
||||
return WIN_StringToUTF8W(name); // No registry access on WinRT/UWP and Xbox, go with what we've got.
|
||||
#else
|
||||
static const GUID nullguid = { 0 };
|
||||
const unsigned char *ptr;
|
||||
@@ -278,7 +278,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
char *retval = NULL;
|
||||
|
||||
if (WIN_IsEqualGUID(guid, &nullguid)) {
|
||||
return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */
|
||||
return WIN_StringToUTF8(name); // No GUID, go with what we've got.
|
||||
}
|
||||
|
||||
ptr = (const unsigned char *)guid;
|
||||
@@ -291,34 +291,34 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);
|
||||
SDL_free(strw);
|
||||
if (!rc) {
|
||||
return WIN_StringToUTF8(name); /* oh well. */
|
||||
return WIN_StringToUTF8(name); // oh well.
|
||||
}
|
||||
|
||||
rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, NULL, &len) == ERROR_SUCCESS);
|
||||
if (!rc) {
|
||||
RegCloseKey(hkey);
|
||||
return WIN_StringToUTF8(name); /* oh well. */
|
||||
return WIN_StringToUTF8(name); // oh well.
|
||||
}
|
||||
|
||||
strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR));
|
||||
if (!strw) {
|
||||
RegCloseKey(hkey);
|
||||
return WIN_StringToUTF8(name); /* oh well. */
|
||||
return WIN_StringToUTF8(name); // oh well.
|
||||
}
|
||||
|
||||
rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE)strw, &len) == ERROR_SUCCESS);
|
||||
RegCloseKey(hkey);
|
||||
if (!rc) {
|
||||
SDL_free(strw);
|
||||
return WIN_StringToUTF8(name); /* oh well. */
|
||||
return WIN_StringToUTF8(name); // oh well.
|
||||
}
|
||||
|
||||
strw[len / 2] = 0; /* make sure it's null-terminated. */
|
||||
strw[len / 2] = 0; // make sure it's null-terminated.
|
||||
|
||||
retval = WIN_StringToUTF8(strw);
|
||||
SDL_free(strw);
|
||||
return retval ? retval : WIN_StringToUTF8(name);
|
||||
#endif /* if SDL_PLATFORM_WINRT / else */
|
||||
#endif // if SDL_PLATFORM_WINRT / else
|
||||
}
|
||||
|
||||
BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b)
|
||||
@@ -349,15 +349,15 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
|
||||
|
||||
BOOL WIN_IsRectEmpty(const RECT *rect)
|
||||
{
|
||||
/* Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty. */
|
||||
// Calculating this manually because UWP and Xbox do not support Win32 IsRectEmpty.
|
||||
return (rect->right <= rect->left) || (rect->bottom <= rect->top);
|
||||
}
|
||||
|
||||
/* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } };
|
||||
static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } };
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat)
|
||||
{
|
||||
@@ -389,4 +389,4 @@ int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr,
|
||||
return WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);
|
||||
}
|
||||
|
||||
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) */
|
||||
#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* This is an include file for windows.h with the SDL build settings */
|
||||
// This is an include file for windows.h with the SDL build settings
|
||||
|
||||
#ifndef _INCLUDED_WINDOWS_H
|
||||
#define _INCLUDED_WINDOWS_H
|
||||
@@ -37,11 +37,11 @@
|
||||
#undef WINVER
|
||||
#undef _WIN32_WINNT
|
||||
#if SDL_VIDEO_RENDER_D3D12 || defined(HAVE_DXGI1_6_H)
|
||||
#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */
|
||||
#define _WIN32_WINNT 0xA00 // For D3D12, 0xA00 is required
|
||||
#elif defined(HAVE_SHELLSCALINGAPI_H)
|
||||
#define _WIN32_WINNT 0x603 /* For DPI support */
|
||||
#define _WIN32_WINNT 0x603 // For DPI support
|
||||
#else
|
||||
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
|
||||
#define _WIN32_WINNT 0x501 // Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input
|
||||
#endif
|
||||
#define WINVER _WIN32_WINNT
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
#define WINVER _WIN32_WINNT
|
||||
#endif
|
||||
|
||||
/* See https://github.com/libsdl-org/SDL/pull/7607 */
|
||||
/* force_align_arg_pointer attribute requires gcc >= 4.2.x. */
|
||||
// See https://github.com/libsdl-org/SDL/pull/7607
|
||||
// force_align_arg_pointer attribute requires gcc >= 4.2.x.
|
||||
#if defined(__clang__)
|
||||
#define HAVE_FORCE_ALIGN_ARG_POINTER
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
|
||||
@@ -90,13 +90,13 @@
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <basetyps.h> /* for REFIID with broken mingw.org headers */
|
||||
#include <basetyps.h> // for REFIID with broken mingw.org headers
|
||||
#include <mmreg.h>
|
||||
|
||||
/* Routines to convert from UTF8 to native Windows text */
|
||||
// Routines to convert from UTF8 to native Windows text
|
||||
#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. */
|
||||
// !!! FIXME: UTF8ToString() can just be a SDL_strdup() here.
|
||||
#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
|
||||
@@ -111,64 +111,64 @@
|
||||
#define SDL_tcsstr SDL_strstr
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Sets an error message based on a given HRESULT */
|
||||
// Sets an error message based on a given HRESULT
|
||||
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
|
||||
|
||||
/* Sets an error message based on GetLastError(). Always return -1. */
|
||||
// Sets an error message based on GetLastError(). Always return -1.
|
||||
extern int WIN_SetError(const char *prefix);
|
||||
|
||||
#ifndef SDL_PLATFORM_WINRT
|
||||
/* Load a function from combase.dll */
|
||||
// Load a function from combase.dll
|
||||
FARPROC WIN_LoadComBaseFunction(const char *name);
|
||||
#endif
|
||||
|
||||
/* Wrap up the oddities of CoInitialize() into a common function. */
|
||||
// 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. */
|
||||
// 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 XP (any service pack). DOES NOT CHECK XP "OR GREATER"! */
|
||||
// Returns SDL_TRUE if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
|
||||
extern BOOL WIN_IsWindowsXP(void);
|
||||
|
||||
/* Returns SDL_TRUE if we're running on Windows Vista and newer */
|
||||
// Returns SDL_TRUE if we're running on Windows Vista and newer
|
||||
extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
||||
|
||||
/* Returns SDL_TRUE if we're running on Windows 7 and newer */
|
||||
// Returns SDL_TRUE if we're running on Windows 7 and newer
|
||||
extern BOOL WIN_IsWindows7OrGreater(void);
|
||||
|
||||
/* Returns SDL_TRUE if we're running on Windows 8 and newer */
|
||||
// Returns SDL_TRUE if we're running on Windows 8 and newer
|
||||
extern BOOL WIN_IsWindows8OrGreater(void);
|
||||
|
||||
/* You need to SDL_free() the result of this call. */
|
||||
// You need to SDL_free() the result of this call.
|
||||
extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
|
||||
|
||||
/* Checks to see if two GUID are the same. */
|
||||
// Checks to see if two GUID are the same.
|
||||
extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b);
|
||||
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
||||
|
||||
/* Convert between SDL_rect and RECT */
|
||||
// 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);
|
||||
|
||||
/* Returns SDL_TRUE if the rect is empty */
|
||||
// Returns SDL_TRUE if the rect is empty
|
||||
extern BOOL WIN_IsRectEmpty(const RECT *rect);
|
||||
|
||||
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
|
||||
|
||||
/* WideCharToMultiByte, but with some WinXP manangement. */
|
||||
// WideCharToMultiByte, but with some WinXP manangement.
|
||||
extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _INCLUDED_WINDOWS_H */
|
||||
#endif // _INCLUDED_WINDOWS_H
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "SDL_xinput.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -58,7 +58,7 @@ int WIN_LoadXInputDLL(void)
|
||||
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities;
|
||||
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation;
|
||||
|
||||
/* XInput 1.4 ships with Windows 8 and 8.1: */
|
||||
// XInput 1.4 ships with Windows 8 and 8.1:
|
||||
SDL_XInputVersion = (1 << 16) | 4;
|
||||
|
||||
return 0;
|
||||
@@ -68,7 +68,7 @@ void WIN_UnloadXInputDLL(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */
|
||||
#else // !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
|
||||
|
||||
int WIN_LoadXInputDLL(void)
|
||||
{
|
||||
@@ -77,7 +77,7 @@ int WIN_LoadXInputDLL(void)
|
||||
if (s_pXInputDLL) {
|
||||
SDL_assert(s_XInputDLLRefCount > 0);
|
||||
s_XInputDLLRefCount++;
|
||||
return 0; /* already loaded */
|
||||
return 0; // already loaded
|
||||
}
|
||||
|
||||
/* NOTE: Don't load XinputUap.dll
|
||||
@@ -85,16 +85,16 @@ int WIN_LoadXInputDLL(void)
|
||||
* limitations of that API (no devices at startup, no background input, etc.)
|
||||
*/
|
||||
version = (1 << 16) | 4;
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll")); /* 1.4 Ships with Windows 8. */
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll")); // 1.4 Ships with Windows 8.
|
||||
if (!s_pXInputDLL) {
|
||||
version = (1 << 16) | 3;
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll")); /* 1.3 can be installed as a redistributable component. */
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll")); // 1.3 can be installed as a redistributable component.
|
||||
}
|
||||
if (!s_pXInputDLL) {
|
||||
s_pXInputDLL = LoadLibrary(TEXT("bin\\XInput1_3.dll"));
|
||||
}
|
||||
if (!s_pXInputDLL) {
|
||||
/* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) */
|
||||
// "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.)
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll"));
|
||||
}
|
||||
if (!s_pXInputDLL) {
|
||||
@@ -105,14 +105,14 @@ int WIN_LoadXInputDLL(void)
|
||||
SDL_XInputVersion = version;
|
||||
s_XInputDLLRefCount = 1;
|
||||
|
||||
/* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
|
||||
// 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think...
|
||||
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100);
|
||||
if (!SDL_XInputGetState) {
|
||||
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState");
|
||||
}
|
||||
SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState");
|
||||
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities");
|
||||
/* 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller. */
|
||||
// 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller.
|
||||
SDL_XInputGetCapabilitiesEx = (XInputGetCapabilitiesEx_t)GetProcAddress(s_pXInputDLL, (LPCSTR)108);
|
||||
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation");
|
||||
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
|
||||
@@ -136,9 +136,9 @@ void WIN_UnloadXInputDLL(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_PLATFORM_WINRT */
|
||||
#endif // SDL_PLATFORM_WINRT
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,14 +27,14 @@
|
||||
|
||||
#ifdef HAVE_XINPUT_H
|
||||
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||
/* Xbox supports an XInput wrapper which is a C++-only header... */
|
||||
#include <math.h> /* Required to compile with recent MSVC... */
|
||||
// Xbox supports an XInput wrapper which is a C++-only header...
|
||||
#include <math.h> // Required to compile with recent MSVC...
|
||||
#include <XInputOnGameInput.h>
|
||||
using namespace XInputOnGameInput;
|
||||
#else
|
||||
#include <xinput.h>
|
||||
#endif
|
||||
#endif /* HAVE_XINPUT_H */
|
||||
#endif // HAVE_XINPUT_H
|
||||
|
||||
#ifndef XUSER_MAX_COUNT
|
||||
#define XUSER_MAX_COUNT 4
|
||||
@@ -160,15 +160,15 @@ using namespace XInputOnGameInput;
|
||||
#define BATTERY_LEVEL_FULL 0x03
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* typedef's for XInput structs we use */
|
||||
// typedef's for XInput structs we use
|
||||
|
||||
|
||||
/* This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 */
|
||||
// This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
typedef struct
|
||||
{
|
||||
BYTE BatteryType;
|
||||
@@ -209,9 +209,9 @@ typedef struct
|
||||
XINPUT_VIBRATION Vibration;
|
||||
} XINPUT_CAPABILITIES;
|
||||
|
||||
#endif /* HAVE_XINPUT_H */
|
||||
#endif // HAVE_XINPUT_H
|
||||
|
||||
/* This struct is not defined in XInput headers. */
|
||||
// This struct is not defined in XInput headers.
|
||||
typedef struct
|
||||
{
|
||||
XINPUT_CAPABILITIES Capabilities;
|
||||
@@ -222,29 +222,29 @@ typedef struct
|
||||
DWORD unk2;
|
||||
} SDL_XINPUT_CAPABILITIES_EX;
|
||||
|
||||
/* Forward decl's for XInput API's we load dynamically and use if available */
|
||||
// Forward decl's for XInput API's we load dynamically and use if available
|
||||
typedef DWORD(WINAPI *XInputGetState_t)(
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
XINPUT_STATE *pState /* [out] Receives the current state */
|
||||
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
|
||||
XINPUT_STATE *pState // [out] Receives the current state
|
||||
);
|
||||
|
||||
typedef DWORD(WINAPI *XInputSetState_t)(
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
XINPUT_VIBRATION *pVibration /* [in, out] The vibration information to send to the controller */
|
||||
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
|
||||
XINPUT_VIBRATION *pVibration // [in, out] The vibration information to send to the controller
|
||||
);
|
||||
|
||||
typedef DWORD(WINAPI *XInputGetCapabilities_t)(
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
DWORD dwFlags, /* [in] Input flags that identify the device type */
|
||||
XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */
|
||||
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
|
||||
DWORD dwFlags, // [in] Input flags that identify the device type
|
||||
XINPUT_CAPABILITIES *pCapabilities // [out] Receives the capabilities
|
||||
);
|
||||
|
||||
/* Only available in XInput 1.4 that is shipped with Windows 8 and newer. */
|
||||
// Only available in XInput 1.4 that is shipped with Windows 8 and newer.
|
||||
typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)(
|
||||
DWORD dwReserved, /* [in] Must be 1 */
|
||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||
DWORD dwFlags, /* [in] Input flags that identify the device type */
|
||||
SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
|
||||
DWORD dwReserved, // [in] Must be 1
|
||||
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
|
||||
DWORD dwFlags, // [in] Input flags that identify the device type
|
||||
SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx // [out] Receives the capabilities
|
||||
);
|
||||
|
||||
typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
|
||||
@@ -260,9 +260,9 @@ extern XInputSetState_t SDL_XInputSetState;
|
||||
extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
|
||||
extern XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx;
|
||||
extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation;
|
||||
extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
|
||||
extern DWORD SDL_XInputVersion; // ((major << 16) & 0xFF00) | (minor & 0xFF)
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -273,4 +273,4 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
|
||||
#define XINPUTGETCAPABILITIESEX SDL_XInputGetCapabilitiesEx
|
||||
#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation
|
||||
|
||||
#endif /* SDL_xinput_h_ */
|
||||
#endif // SDL_xinput_h_
|
||||
|
||||
@@ -27,7 +27,7 @@ int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
|
||||
extern "C"
|
||||
SDL_WinRT_DeviceFamily SDL_GetWinRTDeviceFamily()
|
||||
{
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10 /* !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan. */
|
||||
#if NTDDI_VERSION >= NTDDI_WIN10 // !!! FIXME: I have no idea if this is the right test. This is a UWP API, I think. Older windows should...just return "mobile"? I don't know. --ryan.
|
||||
Platform::String ^ deviceFamily = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily;
|
||||
|
||||
if (deviceFamily->Equals("Windows.Desktop")) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Windows includes */
|
||||
// Windows includes
|
||||
#include "ppltasks.h"
|
||||
using namespace concurrency;
|
||||
using namespace Windows::ApplicationModel;
|
||||
@@ -37,7 +37,7 @@ using namespace Windows::UI::Input;
|
||||
using namespace Windows::Phone::UI::Input;
|
||||
#endif
|
||||
|
||||
/* SDL includes */
|
||||
// SDL includes
|
||||
extern "C" {
|
||||
#include "../../video/SDL_sysvideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
@@ -354,7 +354,7 @@ static bool IsSDLWindowEventPending(SDL_EventType windowEventID)
|
||||
|
||||
bool SDL_WinRTApp::ShouldWaitForAppResumeEvents()
|
||||
{
|
||||
/* Don't wait if the app is visible: */
|
||||
// Don't wait if the app is visible:
|
||||
if (m_windowVisible) {
|
||||
return false;
|
||||
}
|
||||
@@ -541,10 +541,10 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr
|
||||
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, cursorPos.X, cursorPos.Y);
|
||||
#endif
|
||||
|
||||
/* TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation) */
|
||||
// TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation)
|
||||
// WIN_CheckAsyncMouseRelease(data);
|
||||
|
||||
/* TODO, WinRT: implement clipboard support, if possible */
|
||||
// TODO, WinRT: implement clipboard support, if possible
|
||||
///*
|
||||
// * FIXME: Update keyboard state
|
||||
// */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Windows includes */
|
||||
// Windows includes
|
||||
#include <agile.h>
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
#endif
|
||||
|
||||
/* SDL includes */
|
||||
// SDL includes
|
||||
#include "../../video/winrt/SDL_winrtevents_c.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
#include "SDL_winrtapp_common.h"
|
||||
#include "SDL_winrtapp_xaml.h"
|
||||
|
||||
/* SDL-internal globals: */
|
||||
// SDL-internal globals:
|
||||
SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
/* CPU feature detection for SDL */
|
||||
// CPU feature detection for SDL
|
||||
|
||||
#ifdef HAVE_SYSCONF
|
||||
#include <unistd.h>
|
||||
@@ -37,10 +37,10 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#if defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__))
|
||||
#include <sys/sysctl.h> /* For AltiVec check */
|
||||
#include <sys/sysctl.h> // For AltiVec check
|
||||
#elif defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h> /* For AltiVec check */
|
||||
#include <sys/sysctl.h> // For AltiVec check
|
||||
#include <machine/cpu.h>
|
||||
#elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__)
|
||||
#include <machine/cpu.h>
|
||||
@@ -57,7 +57,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <elf.h>
|
||||
|
||||
/*#include <asm/hwcap.h>*/
|
||||
// #include <asm/hwcap.h>
|
||||
#ifndef AT_HWCAP
|
||||
#define AT_HWCAP 16
|
||||
#endif
|
||||
@@ -122,13 +122,13 @@ static void illegal_instruction(int sig)
|
||||
{
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
#endif /* HAVE_SETJMP */
|
||||
#endif // HAVE_SETJMP
|
||||
|
||||
static int CPU_haveCPUID(void)
|
||||
{
|
||||
int has_CPUID = 0;
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
#ifndef SDL_PLATFORM_EMSCRIPTEN
|
||||
#if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__)
|
||||
__asm__ (
|
||||
@@ -216,8 +216,8 @@ done:
|
||||
"1: \n"
|
||||
);
|
||||
#endif
|
||||
#endif /* !SDL_PLATFORM_EMSCRIPTEN */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#endif // !SDL_PLATFORM_EMSCRIPTEN
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
return has_CPUID;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ done:
|
||||
__asm mov d, edx \
|
||||
}
|
||||
#elif (defined(_MSC_VER) && defined(_M_X64))
|
||||
/* Use __cpuidex instead of __cpuid because ICL does not clear ecx register */
|
||||
// Use __cpuidex instead of __cpuid because ICL does not clear ecx register
|
||||
#define cpuid(func, a, b, c, d) \
|
||||
{ \
|
||||
int CPUInfo[4]; \
|
||||
@@ -295,15 +295,15 @@ static void CPU_calcCPUIDFeatures(void)
|
||||
CPU_CPUIDFeatures[2] = c;
|
||||
CPU_CPUIDFeatures[3] = d;
|
||||
|
||||
/* Check to make sure we can call xgetbv */
|
||||
// Check to make sure we can call xgetbv
|
||||
if (c & 0x08000000) {
|
||||
/* Call xgetbv to see if YMM (etc) register state is saved */
|
||||
// Call xgetbv to see if YMM (etc) register state is saved
|
||||
#if (defined(__GNUC__) || defined(__llvm__)) && (defined(__i386__) || defined(__x86_64__))
|
||||
__asm__(".byte 0x0f, 0x01, 0xd0"
|
||||
: "=a"(a)
|
||||
: "c"(0)
|
||||
: "%edx");
|
||||
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */
|
||||
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) // VS2010 SP1
|
||||
a = (int)_xgetbv(0);
|
||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
||||
__asm
|
||||
@@ -447,28 +447,28 @@ static int CPU_haveNEON(void)
|
||||
/* The way you detect NEON is a privileged instruction on ARM, so you have
|
||||
query the OS kernel in a platform-specific way. :/ */
|
||||
#if defined(SDL_PLATFORM_WINDOWS) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||
/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */
|
||||
/* Seems to have been removed */
|
||||
// Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first.
|
||||
// Seems to have been removed
|
||||
#ifndef PF_ARM_NEON_INSTRUCTIONS_AVAILABLE
|
||||
#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
|
||||
#endif
|
||||
/* All WinRT ARM devices are required to support NEON, but just in case. */
|
||||
// All WinRT ARM devices are required to support NEON, but just in case.
|
||||
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
#elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__)
|
||||
return 1; /* ARMv8 always has non-optional NEON support. */
|
||||
return 1; // ARMv8 always has non-optional NEON support.
|
||||
#elif defined(SDL_PLATFORM_VITA)
|
||||
return 1;
|
||||
#elif defined(SDL_PLATFORM_3DS)
|
||||
return 0;
|
||||
#elif defined(SDL_PLATFORM_APPLE) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)
|
||||
/* (note that sysctlbyname("hw.optional.neon") doesn't work!) */
|
||||
return 1; /* all Apple ARMv7 chips and later have NEON. */
|
||||
// (note that sysctlbyname("hw.optional.neon") doesn't work!)
|
||||
return 1; // all Apple ARMv7 chips and later have NEON.
|
||||
#elif defined(SDL_PLATFORM_APPLE)
|
||||
return 0; /* assume anything else from Apple doesn't have NEON. */
|
||||
return 0; // assume anything else from Apple doesn't have NEON.
|
||||
#elif !defined(__arm__)
|
||||
return 0; /* not an ARM CPU at all. */
|
||||
return 0; // not an ARM CPU at all.
|
||||
#elif defined(SDL_PLATFORM_OPENBSD)
|
||||
return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */
|
||||
return 1; // OpenBSD only supports ARMv7 CPUs that have NEON.
|
||||
#elif defined(HAVE_ELF_AUX_INFO)
|
||||
unsigned long hasneon = 0;
|
||||
if (elf_aux_info(AT_HWCAP, (void *)&hasneon, (int)sizeof(hasneon)) != 0) {
|
||||
@@ -480,7 +480,7 @@ static int CPU_haveNEON(void)
|
||||
#elif defined(SDL_PLATFORM_LINUX)
|
||||
return readProcAuxvForNeon();
|
||||
#elif defined(SDL_PLATFORM_ANDROID)
|
||||
/* Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo */
|
||||
// Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo
|
||||
{
|
||||
AndroidCpuFamily cpu_family = android_getCpuFamily();
|
||||
if (cpu_family == ANDROID_CPU_FAMILY_ARM) {
|
||||
@@ -492,7 +492,7 @@ static int CPU_haveNEON(void)
|
||||
return 0;
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_RISCOS)
|
||||
/* Use the VFPSupport_Features SWI to access the MVFR registers */
|
||||
// Use the VFPSupport_Features SWI to access the MVFR registers
|
||||
{
|
||||
_kernel_swi_regs regs;
|
||||
regs.r[0] = 0;
|
||||
@@ -590,7 +590,7 @@ static int CPU_haveAVX2(void)
|
||||
(void)a;
|
||||
(void)b;
|
||||
(void)c;
|
||||
(void)d; /* compiler warnings... */
|
||||
(void)d; // compiler warnings...
|
||||
cpuid(7, a, b, c, d);
|
||||
return b & 0x00000020;
|
||||
}
|
||||
@@ -612,7 +612,7 @@ static int CPU_haveAVX512F(void)
|
||||
(void)a;
|
||||
(void)b;
|
||||
(void)c;
|
||||
(void)d; /* compiler warnings... */
|
||||
(void)d; // compiler warnings...
|
||||
cpuid(7, a, b, c, d);
|
||||
return b & 0x00010000;
|
||||
}
|
||||
@@ -643,7 +643,7 @@ int SDL_GetCPUCount(void)
|
||||
SDL_CPUCount = info.dwNumberOfProcessors;
|
||||
}
|
||||
#endif
|
||||
/* There has to be at least 1, right? :) */
|
||||
// There has to be at least 1, right? :)
|
||||
if (SDL_CPUCount <= 0) {
|
||||
SDL_CPUCount = 1;
|
||||
}
|
||||
@@ -662,7 +662,7 @@ SDL_GetCPUType(void)
|
||||
return SDL_CPUType;
|
||||
}
|
||||
#else
|
||||
/* Oh, such a sweet sweet trick, just not very useful. :) */
|
||||
// Oh, such a sweet sweet trick, just not very useful. :)
|
||||
static const char *SDL_GetCPUType(void)
|
||||
{
|
||||
static char SDL_CPUType[13];
|
||||
@@ -671,7 +671,7 @@ static const char *SDL_GetCPUType(void)
|
||||
int i = 0;
|
||||
|
||||
CPU_calcCPUIDFeatures();
|
||||
if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */
|
||||
if (CPU_CPUIDMaxFunction > 0) { // do we have CPUID at all?
|
||||
int a, b, c, d;
|
||||
cpuid(0x00000000, a, b, c, d);
|
||||
(void)a;
|
||||
@@ -729,7 +729,7 @@ static const char *SDL_GetCPUName(void)
|
||||
int a, b, c, d;
|
||||
|
||||
CPU_calcCPUIDFeatures();
|
||||
if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */
|
||||
if (CPU_CPUIDMaxFunction > 0) { // do we have CPUID at all?
|
||||
cpuid(0x80000000, a, b, c, d);
|
||||
if (a >= 0x80000004) {
|
||||
cpuid(0x80000002, a, b, c, d);
|
||||
@@ -845,7 +845,7 @@ static const char *SDL_GetCPUName(void)
|
||||
int SDL_GetCPUCacheLineSize(void)
|
||||
{
|
||||
const char *cpuType = SDL_GetCPUType();
|
||||
int cacheline_size = SDL_CACHELINE_SIZE; /* initial guess */
|
||||
int cacheline_size = SDL_CACHELINE_SIZE; // initial guess
|
||||
int a, b, c, d;
|
||||
(void)a;
|
||||
(void)b;
|
||||
@@ -949,7 +949,7 @@ static Uint32 SDLCALL SDL_CPUFeatureMaskFromHint(void)
|
||||
} else if (ref_string_equals("lasx", spot, end)) {
|
||||
spot_mask = CPU_HAS_LASX;
|
||||
} else {
|
||||
/* Ignore unknown/incorrect cpu feature(s) */
|
||||
// Ignore unknown/incorrect cpu feature(s)
|
||||
continue;
|
||||
}
|
||||
if (add_spot_mask) {
|
||||
@@ -967,7 +967,7 @@ static Uint32 SDL_GetCPUFeatures(void)
|
||||
if (SDL_CPUFeatures == SDL_CPUFEATURES_RESET_VALUE) {
|
||||
CPU_calcCPUIDFeatures();
|
||||
SDL_CPUFeatures = 0;
|
||||
SDL_SIMDAlignment = sizeof(void *); /* a good safe base value */
|
||||
SDL_SIMDAlignment = sizeof(void *); // a good safe base value
|
||||
if (CPU_haveAltiVec()) {
|
||||
SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
|
||||
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16);
|
||||
@@ -1118,18 +1118,18 @@ int SDL_GetSystemRAM(void)
|
||||
#ifdef HAVE_SYSCTLBYNAME
|
||||
if (SDL_SystemRAM <= 0) {
|
||||
#ifdef HW_PHYSMEM64
|
||||
/* (64-bit): NetBSD since 2003, OpenBSD */
|
||||
// (64-bit): NetBSD since 2003, OpenBSD
|
||||
int mib[2] = { CTL_HW, HW_PHYSMEM64 };
|
||||
#elif defined(HW_REALMEM)
|
||||
/* (64-bit): FreeBSD since 2005, DragonFly */
|
||||
// (64-bit): FreeBSD since 2005, DragonFly
|
||||
int mib[2] = { CTL_HW, HW_REALMEM };
|
||||
#elif defined(HW_MEMSIZE)
|
||||
/* (64-bit): Darwin */
|
||||
// (64-bit): Darwin
|
||||
int mib[2] = { CTL_HW, HW_MEMSIZE };
|
||||
#else
|
||||
/* (32-bit): very old BSD, might only report up to 2 GiB */
|
||||
// (32-bit): very old BSD, might only report up to 2 GiB
|
||||
int mib[2] = { CTL_HW, HW_PHYSMEM };
|
||||
#endif /* HW_PHYSMEM64 */
|
||||
#endif // HW_PHYSMEM64
|
||||
Uint64 memsize = 0;
|
||||
size_t len = sizeof(memsize);
|
||||
|
||||
@@ -1165,7 +1165,7 @@ int SDL_GetSystemRAM(void)
|
||||
#endif
|
||||
#ifdef SDL_PLATFORM_PS2
|
||||
if (SDL_SystemRAM <= 0) {
|
||||
/* PlayStation 2 has 32MiB however there are some special models with 64 and 128 */
|
||||
// PlayStation 2 has 32MiB however there are some special models with 64 and 128
|
||||
SDL_SystemRAM = GetMemorySize();
|
||||
}
|
||||
#endif
|
||||
@@ -1186,7 +1186,7 @@ int SDL_GetSystemRAM(void)
|
||||
size_t SDL_GetSIMDAlignment(void)
|
||||
{
|
||||
if (SDL_SIMDAlignment == 0xFFFFFFFF) {
|
||||
SDL_GetCPUFeatures(); /* make sure this has been calculated */
|
||||
SDL_GetCPUFeatures(); // make sure this has been calculated
|
||||
}
|
||||
SDL_assert(SDL_SIMDAlignment != 0);
|
||||
return SDL_SIMDAlignment;
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
|
||||
extern void SDL_QuitCPUInfo(void);
|
||||
|
||||
#endif /* SDL_cpuinfo_c_h_ */
|
||||
#endif // SDL_cpuinfo_c_h_
|
||||
|
||||
@@ -78,7 +78,7 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
|
||||
SDL_free(converted);
|
||||
}
|
||||
|
||||
/* If the filter list is empty, put the suffix */
|
||||
// If the filter list is empty, put the suffix
|
||||
if (!filters->name || !filters->pattern) {
|
||||
new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1;
|
||||
|
||||
@@ -117,7 +117,7 @@ char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf,
|
||||
if (ntf) {
|
||||
name_filtered = ntf(filter.name);
|
||||
} else {
|
||||
/* Useless strdup, but easier to read and maintain code this way */
|
||||
// Useless strdup, but easier to read and maintain code this way
|
||||
name_filtered = SDL_strdup(filter.name);
|
||||
}
|
||||
|
||||
@@ -161,10 +161,10 @@ char *convert_ext_list(const char *list, const char *prefix,
|
||||
}
|
||||
|
||||
total_length =
|
||||
SDL_strlen(list) - semicolons /* length of list contents */
|
||||
+ semicolons * SDL_strlen(separator) /* length of separators */
|
||||
+ SDL_strlen(prefix) + SDL_strlen(suffix) /* length of prefix/suffix */
|
||||
+ 1; /* terminating null byte */
|
||||
SDL_strlen(list) - semicolons // length of list contents
|
||||
+ semicolons * SDL_strlen(separator) // length of separators
|
||||
+ SDL_strlen(prefix) + SDL_strlen(suffix) // length of prefix/suffix
|
||||
+ 1; // terminating null byte
|
||||
|
||||
converted = (char *) SDL_malloc(total_length);
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
as "|" with Zenity). */
|
||||
typedef char *(NameTransform)(const char * name);
|
||||
|
||||
/* Converts all the filters into a single string. */
|
||||
/* <prefix>[filter]{<separator>[filter]...}<suffix> */
|
||||
// Converts all the filters into a single string.
|
||||
// <prefix>[filter]{<separator>[filter]...}<suffix>
|
||||
char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
|
||||
NameTransform ntf, const char *prefix,
|
||||
const char *separator, const char *suffix,
|
||||
@@ -39,20 +39,20 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
|
||||
const char *filt_suffix, const char *ext_prefix,
|
||||
const char *ext_separator, const char *ext_suffix);
|
||||
|
||||
/* Converts one filter into a single string. */
|
||||
/* <prefix>[filter name]<separator>[filter extension list]<suffix> */
|
||||
// Converts one filter into a single string.
|
||||
// <prefix>[filter name]<separator>[filter extension list]<suffix>
|
||||
char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf,
|
||||
const char *prefix, const char *separator,
|
||||
const char *suffix, const char *ext_prefix,
|
||||
const char *ext_separator, const char *ext_suffix);
|
||||
|
||||
/* Converts the extenstion list of a filter into a single string. */
|
||||
/* <prefix>[extension]{<separator>[extension]...}<suffix> */
|
||||
// Converts the extenstion list of a filter into a single string.
|
||||
// <prefix>[extension]{<separator>[extension]...}<suffix>
|
||||
char *convert_ext_list(const char *list, const char *prefix,
|
||||
const char *separator, const char *suffix);
|
||||
|
||||
/* Must be used if convert_* functions aren't used */
|
||||
/* Returns an error message if there's a problem, NULL otherwise */
|
||||
// Returns an error message if there's a problem, NULL otherwise
|
||||
const char *validate_filters(const SDL_DialogFileFilter *filters,
|
||||
int nfilters);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, SDL_bool allow_many)
|
||||
{
|
||||
if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_FALSE, allow_many)) {
|
||||
/* SDL_SetError is already called when it fails */
|
||||
// SDL_SetError is already called when it fails
|
||||
callback(userdata, NULL, -1);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userd
|
||||
void SDLCALL SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location)
|
||||
{
|
||||
if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_TRUE, SDL_FALSE)) {
|
||||
/* SDL_SetError is already called when it fails */
|
||||
// SDL_SetError is already called when it fails
|
||||
callback(userdata, NULL, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
return;
|
||||
}
|
||||
|
||||
/* NSOpenPanel inherits from NSSavePanel */
|
||||
// NSOpenPanel inherits from NSSavePanel
|
||||
NSSavePanel *dialog;
|
||||
NSOpenPanel *dialog_as_open;
|
||||
|
||||
@@ -120,7 +120,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep behavior consistent with other platforms */
|
||||
// Keep behavior consistent with other platforms
|
||||
[dialog setAllowsOtherFileTypes:YES];
|
||||
|
||||
if (default_location) {
|
||||
|
||||
@@ -165,19 +165,19 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
const char **path;
|
||||
|
||||
dbus->message_iter_init(msg, &signal_iter);
|
||||
/* Check if the parameters are what we expect */
|
||||
// Check if the parameters are what we expect
|
||||
if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_UINT32)
|
||||
goto not_our_signal;
|
||||
dbus->message_iter_get_basic(&signal_iter, &result);
|
||||
|
||||
if (result == 1 || result == 2) {
|
||||
/* cancelled */
|
||||
// cancelled
|
||||
const char *result_data[] = { NULL };
|
||||
signal_data->callback(signal_data->userdata, result_data, -1); /* TODO: Set this to the last selected filter */
|
||||
signal_data->callback(signal_data->userdata, result_data, -1); // TODO: Set this to the last selected filter
|
||||
goto handled;
|
||||
}
|
||||
else if (result) {
|
||||
/* some error occurred */
|
||||
// some error occurred
|
||||
signal_data->callback(signal_data->userdata, NULL, -1);
|
||||
goto handled;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
|
||||
dbus->message_iter_get_basic(&array_entry, &method);
|
||||
if (!SDL_strcmp(method, "uris")) {
|
||||
/* we only care about the selected file paths */
|
||||
// we only care about the selected file paths
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -239,8 +239,8 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
|
||||
dbus->message_iter_get_basic(&uri_entry, &uri);
|
||||
|
||||
/* https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html */
|
||||
/* Returned paths will always start with 'file://'; SDL_URIToLocal() truncates it. */
|
||||
// https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html
|
||||
// Returned paths will always start with 'file://'; SDL_URIToLocal() truncates it.
|
||||
char *decoded_uri = SDL_malloc(SDL_strlen(uri) + 1);
|
||||
if (SDL_URIToLocal(uri, decoded_uri)) {
|
||||
path[current] = decoded_uri;
|
||||
@@ -255,7 +255,7 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
|
||||
++current;
|
||||
}
|
||||
path[length - 1] = NULL;
|
||||
signal_data->callback(signal_data->userdata, path, -1); /* TODO: Fetch the index of the filter that was used */
|
||||
signal_data->callback(signal_data->userdata, path, -1); // TODO: Fetch the index of the filter that was used
|
||||
cleanup:
|
||||
dbus->connection_remove_filter(conn, &DBus_MessageFilter, signal_data);
|
||||
|
||||
@@ -326,14 +326,14 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di
|
||||
} else {
|
||||
const Uint64 xid = (Uint64)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
if (xid) {
|
||||
const size_t len = sizeof(X11_HANDLE_PREFIX) + 24; /* A 64-bit number can be 20 characters max. */
|
||||
const size_t len = sizeof(X11_HANDLE_PREFIX) + 24; // A 64-bit number can be 20 characters max.
|
||||
handle_str = SDL_malloc(len * sizeof(char));
|
||||
if (!handle_str) {
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* The portal wants X11 window ID numbers in hex. */
|
||||
// The portal wants X11 window ID numbers in hex.
|
||||
SDL_snprintf(handle_str, len, "%s%" SDL_PRIx64, X11_HANDLE_PREFIX, xid);
|
||||
}
|
||||
}
|
||||
@@ -448,7 +448,7 @@ int SDL_Portal_detect(void)
|
||||
DBusMessageIter reply_iter;
|
||||
static int portal_present = -1;
|
||||
|
||||
/* No need for this if the result is cached. */
|
||||
// No need for this if the result is cached.
|
||||
if (portal_present != -1) {
|
||||
return portal_present;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ int SDL_Portal_detect(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Use introspection to get the available services. */
|
||||
// Use introspection to get the available services.
|
||||
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, "org.freedesktop.DBus.Introspectable", "Introspect");
|
||||
if (!msg) {
|
||||
goto done;
|
||||
@@ -485,7 +485,7 @@ int SDL_Portal_detect(void)
|
||||
*/
|
||||
dbus->message_iter_get_basic(&reply_iter, &reply_str);
|
||||
if (SDL_strstr(reply_str, PORTAL_INTERFACE)) {
|
||||
portal_present = 1; /* Found it! */
|
||||
portal_present = 1; // Found it!
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -498,7 +498,7 @@ done:
|
||||
|
||||
#else
|
||||
|
||||
/* Dummy implementation to avoid compilation problems */
|
||||
// Dummy implementation to avoid compilation problems
|
||||
|
||||
void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many)
|
||||
{
|
||||
@@ -523,4 +523,4 @@ int SDL_Portal_detect(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_USE_LIBDBUS */
|
||||
#endif // SDL_USE_LIBDBUS
|
||||
|
||||
@@ -44,7 +44,7 @@ static void set_callback(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns non-zero on success, 0 on failure */
|
||||
// Returns non-zero on success, 0 on failure
|
||||
static int detect_available_methods(const char *value)
|
||||
{
|
||||
const char *driver = value ? value : SDL_GetHint(SDL_HINT_FILE_DIALOG_DRIVER);
|
||||
@@ -75,9 +75,9 @@ static int detect_available_methods(const char *value)
|
||||
|
||||
void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many)
|
||||
{
|
||||
/* Call detect_available_methods() again each time in case the situation changed */
|
||||
// Call detect_available_methods() again each time in case the situation changed
|
||||
if (!detected_open && !detect_available_methods(NULL)) {
|
||||
/* SetError() done by detect_available_methods() */
|
||||
// SetError() done by detect_available_methods()
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
@@ -87,9 +87,9 @@ void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL
|
||||
|
||||
void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location)
|
||||
{
|
||||
/* Call detect_available_methods() again each time in case the situation changed */
|
||||
// Call detect_available_methods() again each time in case the situation changed
|
||||
if (!detected_save && !detect_available_methods(NULL)) {
|
||||
/* SetError() done by detect_available_methods() */
|
||||
// SetError() done by detect_available_methods()
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
@@ -99,9 +99,9 @@ void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL
|
||||
|
||||
void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many)
|
||||
{
|
||||
/* Call detect_available_methods() again each time in case the situation changed */
|
||||
// Call detect_available_methods() again each time in case the situation changed
|
||||
if (!detected_folder && !detect_available_methods(NULL)) {
|
||||
/* SetError() done by detect_available_methods() */
|
||||
// SetError() done by detect_available_methods()
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ char *zenity_clean_name(const char *name)
|
||||
there aren't others. TODO: find something better. */
|
||||
for (char *c = newname; *c; c++) {
|
||||
if (*c == '|') {
|
||||
/* Zenity doesn't support escaping with \ */
|
||||
// Zenity doesn't support escaping with '\'
|
||||
*c = '/';
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ static char** generate_args(const zenityArgs* info)
|
||||
int nextarg = 0;
|
||||
char **argv = NULL;
|
||||
|
||||
/* ARGC PASS */
|
||||
// ARGC PASS
|
||||
if (info->flags & ZENITY_MULTIPLE) {
|
||||
argc++;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ static char** generate_args(const zenityArgs* info)
|
||||
argv[nextarg++] = SDL_strdup("--separator=\n");
|
||||
CHECK_OOM()
|
||||
|
||||
/* ARGV PASS */
|
||||
// ARGV PASS
|
||||
if (info->flags & ZENITY_MULTIPLE) {
|
||||
argv[nextarg++] = SDL_strdup("--multiple");
|
||||
CHECK_OOM()
|
||||
@@ -185,7 +185,7 @@ void free_args(char **argv)
|
||||
SDL_free(argv);
|
||||
}
|
||||
|
||||
/* TODO: Zenity survives termination of the parent */
|
||||
// TODO: Zenity survives termination of the parent
|
||||
|
||||
static void run_zenity(zenityArgs* arg_struct)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ static void run_zenity(zenityArgs* arg_struct)
|
||||
char **args = generate_args(arg_struct);
|
||||
|
||||
if (!args) {
|
||||
/* SDL_SetError will have been called already */
|
||||
// SDL_SetError will have been called already
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ static void run_zenity(zenityArgs* arg_struct)
|
||||
return;
|
||||
} else if (process == 0){
|
||||
dup2(out[1], STDOUT_FILENO);
|
||||
close(STDERR_FILENO); /* Hide errors from Zenity to stderr */
|
||||
close(STDERR_FILENO); // Hide errors from Zenity to stderr
|
||||
close(out[0]);
|
||||
close(out[1]);
|
||||
|
||||
@@ -286,7 +286,7 @@ static void run_zenity(zenityArgs* arg_struct)
|
||||
for (int i = 0; i < bytes_read; i++) {
|
||||
if (container[i] == '\n') {
|
||||
container[i] = '\0';
|
||||
/* Reading from a process often leaves a trailing \n, so ignore the last one */
|
||||
// Reading from a process often leaves a trailing \n, so ignore the last one
|
||||
if (i < bytes_read - 1) {
|
||||
array[narray] = container + i + 1;
|
||||
narray++;
|
||||
@@ -303,7 +303,7 @@ static void run_zenity(zenityArgs* arg_struct)
|
||||
}
|
||||
}
|
||||
|
||||
/* 0 = the user chose one or more files, 1 = the user canceled the dialog */
|
||||
// 0 = the user chose one or more files, 1 = the user canceled the dialog
|
||||
if (status == 0 || status == 1) {
|
||||
callback(userdata, (const char * const*) array, -1);
|
||||
} else {
|
||||
@@ -418,7 +418,7 @@ int SDL_Zenity_detect(void)
|
||||
SDL_SetError("Could not fork process: %s", strerror(errno));
|
||||
return 0;
|
||||
} else if (process == 0){
|
||||
/* Disable output */
|
||||
// Disable output
|
||||
close(STDERR_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
execl("/usr/bin/env", "/usr/bin/env", "zenity", "--version", NULL);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include "../../thread/SDL_systhread.h"
|
||||
|
||||
/* If this number is too small, selecting too many files will give an error */
|
||||
// If this number is too small, selecting too many files will give an error
|
||||
#define SELECTLIST_SIZE 65536
|
||||
|
||||
typedef struct
|
||||
@@ -56,7 +56,7 @@ int getFilterIndex(int as_reported_by_windows)
|
||||
return as_reported_by_windows - 1;
|
||||
}
|
||||
|
||||
/* TODO: The new version of file dialogs */
|
||||
// TODO: The new version of file dialogs
|
||||
void windows_ShowFileDialog(void *ptr)
|
||||
{
|
||||
winArgs *args = (winArgs *) ptr;
|
||||
@@ -104,14 +104,14 @@ void windows_ShowFileDialog(void *ptr)
|
||||
window = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(parent), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
}
|
||||
|
||||
wchar_t *filebuffer; /* lpstrFile */
|
||||
wchar_t initfolder[MAX_PATH] = L""; /* lpstrInitialDir */
|
||||
wchar_t *filebuffer; // lpstrFile
|
||||
wchar_t initfolder[MAX_PATH] = L""; // lpstrInitialDir
|
||||
|
||||
/* If SELECTLIST_SIZE is too large, putting filebuffer on the stack might
|
||||
cause an overflow */
|
||||
filebuffer = (wchar_t *) SDL_malloc(SELECTLIST_SIZE * sizeof(wchar_t));
|
||||
|
||||
/* Necessary for the return code below */
|
||||
// Necessary for the return code below
|
||||
SDL_memset(filebuffer, 0, SELECTLIST_SIZE * sizeof(wchar_t));
|
||||
|
||||
if (default_file) {
|
||||
@@ -151,8 +151,8 @@ void windows_ShowFileDialog(void *ptr)
|
||||
wchar_t *filter_wchar = NULL;
|
||||
|
||||
if (filters) {
|
||||
/* '\x01' is used in place of a null byte */
|
||||
/* suffix needs two null bytes in case the filter list is empty */
|
||||
// '\x01' is used in place of a null byte
|
||||
// suffix needs two null bytes in case the filter list is empty
|
||||
char *filterlist = convert_filters(filters, nfilters, NULL, "", "",
|
||||
"\x01\x01", "", "\x01", "\x01",
|
||||
"*.", ";*.", "");
|
||||
@@ -206,7 +206,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||
dialog.lCustData = 0;
|
||||
dialog.lpfnHook = NULL;
|
||||
dialog.lpTemplateName = NULL;
|
||||
/* Skipped many mac-exclusive and reserved members */
|
||||
// Skipped many mac-exclusive and reserved members
|
||||
dialog.FlagsEx = 0;
|
||||
|
||||
BOOL result = pGetAnyFileName(&dialog);
|
||||
@@ -215,7 +215,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||
|
||||
if (result) {
|
||||
if (!(flags & OFN_ALLOWMULTISELECT)) {
|
||||
/* File is a C string stored in dialog.lpstrFile */
|
||||
// File is a C string stored in dialog.lpstrFile
|
||||
char *chosen_file = WIN_StringToUTF8W(dialog.lpstrFile);
|
||||
const char* opts[2] = { chosen_file, NULL };
|
||||
callback(userdata, opts, getFilterIndex(dialog.nFilterIndex));
|
||||
@@ -306,7 +306,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* If the user chose only one file, it's all just one string */
|
||||
// If the user chose only one file, it's all just one string
|
||||
if (nfiles == 0) {
|
||||
nfiles++;
|
||||
char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char*) * (nfiles + 1));
|
||||
@@ -340,7 +340,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||
}
|
||||
} else {
|
||||
DWORD error = pCommDlgExtendedError();
|
||||
/* Error code 0 means the user clicked the cancel button. */
|
||||
// Error code 0 means the user clicked the cancel button.
|
||||
if (error == 0) {
|
||||
/* Unlike SDL's handling of errors, Windows does reset the error
|
||||
code to 0 after calling GetOpenFileName if another Windows
|
||||
@@ -399,7 +399,7 @@ void windows_ShowFolderDialog(void* ptr)
|
||||
BROWSEINFOW dialog;
|
||||
dialog.hwndOwner = parent;
|
||||
dialog.pidlRoot = NULL;
|
||||
/* Windows docs say this is `LPTSTR` - apparently it's actually `LPWSTR`*/
|
||||
// Windows docs say this is `LPTSTR` - apparently it's actually `LPWSTR`
|
||||
dialog.pszDisplayName = buffer;
|
||||
dialog.lpszTitle = NULL;
|
||||
dialog.ulFlags = BIF_USENEWUI;
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
#endif
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */
|
||||
#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
|
||||
/* These headers have system specific definitions, so aren't included above */
|
||||
// These headers have system specific definitions, so aren't included above
|
||||
#include <SDL3/SDL_vulkan.h>
|
||||
|
||||
/* This is the version of the dynamic API. This doesn't match the SDL version
|
||||
@@ -62,9 +62,9 @@ static void SDL_InitDynamicAPI(void);
|
||||
/* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP.
|
||||
Even self-contained stuff might call SDL_SetError() and break everything. */
|
||||
|
||||
/* behold, the macro salsa! */
|
||||
// behold, the macro salsa!
|
||||
|
||||
/* Can't use the macro for varargs nonsense. This is atrocious. */
|
||||
// Can't use the macro for varargs nonsense. This is atrocious.
|
||||
#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \
|
||||
_static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
|
||||
{ \
|
||||
@@ -175,9 +175,9 @@ static void SDL_InitDynamicAPI(void);
|
||||
SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \
|
||||
SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL)
|
||||
|
||||
/* Typedefs for function pointers for jump table, and predeclare funcs */
|
||||
/* The DEFAULT funcs will init jump table and then call real function. */
|
||||
/* The REAL funcs are the actual functions, name-mangled to not clash. */
|
||||
// Typedefs for function pointers for jump table, and predeclare funcs
|
||||
// The DEFAULT funcs will init jump table and then call real function.
|
||||
// The REAL funcs are the actual functions, name-mangled to not clash.
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \
|
||||
typedef rc (SDLCALL *SDL_DYNAPIFN_##fn) params;\
|
||||
static rc SDLCALL fn##_DEFAULT params; \
|
||||
@@ -185,7 +185,7 @@ static void SDL_InitDynamicAPI(void);
|
||||
#include "SDL_dynapi_procs.h"
|
||||
#undef SDL_DYNAPI_PROC
|
||||
|
||||
/* The jump table! */
|
||||
// The jump table!
|
||||
typedef struct
|
||||
{
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) SDL_DYNAPIFN_##fn fn;
|
||||
@@ -193,19 +193,19 @@ typedef struct
|
||||
#undef SDL_DYNAPI_PROC
|
||||
} SDL_DYNAPI_jump_table;
|
||||
|
||||
/* Predeclare the default functions for initializing the jump table. */
|
||||
// Predeclare the default functions for initializing the jump table.
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) static rc SDLCALL fn##_DEFAULT params;
|
||||
#include "SDL_dynapi_procs.h"
|
||||
#undef SDL_DYNAPI_PROC
|
||||
|
||||
/* The actual jump table. */
|
||||
// The actual jump table.
|
||||
static SDL_DYNAPI_jump_table jump_table = {
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) fn##_DEFAULT,
|
||||
#include "SDL_dynapi_procs.h"
|
||||
#undef SDL_DYNAPI_PROC
|
||||
};
|
||||
|
||||
/* Default functions init the function table then call right thing. */
|
||||
// Default functions init the function table then call right thing.
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \
|
||||
static rc SDLCALL fn##_DEFAULT params \
|
||||
{ \
|
||||
@@ -218,7 +218,7 @@ static SDL_DYNAPI_jump_table jump_table = {
|
||||
#undef SDL_DYNAPI_PROC_NO_VARARGS
|
||||
SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI())
|
||||
|
||||
/* Public API functions to jump into the jump table. */
|
||||
// Public API functions to jump into the jump table.
|
||||
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \
|
||||
rc SDLCALL fn params \
|
||||
{ \
|
||||
@@ -234,7 +234,7 @@ SDL_DYNAPI_VARARGS(, , )
|
||||
#if ENABLE_SDL_CALL_LOGGING
|
||||
static int SDLCALL SDL_SetError_LOGSDLCALLS(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
char buf[512]; /* !!! FIXME: dynamic allocation */
|
||||
char buf[512]; // !!! FIXME: dynamic allocation
|
||||
va_list ap;
|
||||
SDL_Log_REAL("SDL3CALL SDL_SetError");
|
||||
va_start(ap, fmt);
|
||||
@@ -342,13 +342,13 @@ static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize)
|
||||
SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *)table;
|
||||
|
||||
if (apiver != SDL_DYNAPI_VERSION) {
|
||||
/* !!! FIXME: can maybe handle older versions? */
|
||||
return -1; /* not compatible. */
|
||||
// !!! FIXME: can maybe handle older versions?
|
||||
return -1; // not compatible.
|
||||
} else if (tablesize > sizeof(jump_table)) {
|
||||
return -1; /* newer version of SDL with functions we can't provide. */
|
||||
return -1; // newer version of SDL with functions we can't provide.
|
||||
}
|
||||
|
||||
/* Init our jump table first. */
|
||||
// Init our jump table first.
|
||||
#if ENABLE_SDL_CALL_LOGGING
|
||||
{
|
||||
const char *env = SDL_getenv_REAL("SDL_DYNAPI_LOG_CALLS");
|
||||
@@ -369,18 +369,18 @@ static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize)
|
||||
#undef SDL_DYNAPI_PROC
|
||||
#endif
|
||||
|
||||
/* Then the external table... */
|
||||
// Then the external table...
|
||||
if (output_jump_table != &jump_table) {
|
||||
jump_table.SDL_memcpy(output_jump_table, &jump_table, tablesize);
|
||||
}
|
||||
|
||||
/* Safe to call SDL functions now; jump table is initialized! */
|
||||
// Safe to call SDL functions now; jump table is initialized!
|
||||
|
||||
return 0; /* success! */
|
||||
return 0; // success!
|
||||
}
|
||||
|
||||
/* Here's the exported entry point that fills in the jump table. */
|
||||
/* Use specific types when an "int" might suffice to keep this sane. */
|
||||
// Here's the exported entry point that fills in the jump table.
|
||||
// Use specific types when an "int" might suffice to keep this sane.
|
||||
typedef Sint32 (SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize);
|
||||
extern SDL_DECLSPEC Sint32 SDLCALL SDL_DYNAPI_entry(Uint32, void *, Uint32);
|
||||
|
||||
@@ -393,8 +393,8 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Obviously we can't use SDL_LoadObject() to load SDL. :) */
|
||||
/* Also obviously, we never close the loaded library. */
|
||||
// Obviously we can't use SDL_LoadObject() to load SDL. :)
|
||||
// Also obviously, we never close the loaded library.
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
@@ -436,7 +436,7 @@ static void dynapi_warn(const char *msg)
|
||||
{
|
||||
const char *caption = "SDL Dynamic API Failure!";
|
||||
(void)caption;
|
||||
/* SDL_ShowSimpleMessageBox() is a too heavy for here. */
|
||||
// SDL_ShowSimpleMessageBox() is a too heavy for here.
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR);
|
||||
#elif defined(HAVE_STDIO_H)
|
||||
@@ -462,7 +462,7 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
||||
static void SDL_InitDynamicAPILocked(void)
|
||||
{
|
||||
const char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR);
|
||||
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
||||
SDL_DYNAPI_ENTRYFN entry = NULL; // funcs from here by default.
|
||||
SDL_bool use_internal = SDL_TRUE;
|
||||
|
||||
if (libname) {
|
||||
@@ -484,29 +484,29 @@ static void SDL_InitDynamicAPILocked(void)
|
||||
}
|
||||
if (!entry) {
|
||||
dynapi_warn("Couldn't load an overriding SDL library. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL.");
|
||||
/* Just fill in the function pointers from this library, later. */
|
||||
// Just fill in the function pointers from this library, later.
|
||||
}
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof(jump_table)) < 0) {
|
||||
dynapi_warn("Couldn't override SDL library. Using a newer SDL build might help. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL.");
|
||||
/* Just fill in the function pointers from this library, later. */
|
||||
// Just fill in the function pointers from this library, later.
|
||||
} else {
|
||||
use_internal = SDL_FALSE; /* We overrode SDL! Don't use the internal version! */
|
||||
use_internal = SDL_FALSE; // We overrode SDL! Don't use the internal version!
|
||||
}
|
||||
}
|
||||
|
||||
/* Just fill in the function pointers from this library. */
|
||||
// Just fill in the function pointers from this library.
|
||||
if (use_internal) {
|
||||
if (initialize_jumptable(SDL_DYNAPI_VERSION, &jump_table, sizeof(jump_table)) < 0) {
|
||||
/* Now we're screwed. Should definitely abort now. */
|
||||
// Now we're screwed. Should definitely abort now.
|
||||
dynapi_warn("Failed to initialize internal SDL dynapi. As this would otherwise crash, we have to abort now.");
|
||||
SDL_ExitProcess(86);
|
||||
}
|
||||
}
|
||||
|
||||
/* we intentionally never close the newly-loaded lib, of course. */
|
||||
// we intentionally never close the newly-loaded lib, of course.
|
||||
}
|
||||
|
||||
static void SDL_InitDynamicAPI(void)
|
||||
@@ -535,7 +535,7 @@ static void SDL_InitDynamicAPI(void)
|
||||
SDL_UnlockSpinlock_REAL(&lock);
|
||||
}
|
||||
|
||||
#else /* SDL_DYNAMIC_API */
|
||||
#else // SDL_DYNAMIC_API
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@@ -545,7 +545,7 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize)
|
||||
(void)apiver;
|
||||
(void)table;
|
||||
(void)tablesize;
|
||||
return -1; /* not compatible. */
|
||||
return -1; // not compatible.
|
||||
}
|
||||
|
||||
#endif /* SDL_DYNAMIC_API */
|
||||
#endif // SDL_DYNAMIC_API
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
updated SDL can transparently take advantage of them, but your program will
|
||||
not without this feature. Think hard before turning it off.
|
||||
*/
|
||||
#ifdef SDL_DYNAMIC_API /* Tried to force it on the command line? */
|
||||
#ifdef SDL_DYNAMIC_API // Tried to force it on the command line?
|
||||
#error Nope, you have to edit this file to force this off.
|
||||
#endif
|
||||
|
||||
@@ -43,33 +43,33 @@
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE // probably not useful on iOS.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_ANDROID) /* probably not useful on Android. */
|
||||
#elif defined(SDL_PLATFORM_ANDROID) // probably not useful on Android.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_EMSCRIPTEN) /* probably not useful on Emscripten. */
|
||||
#elif defined(SDL_PLATFORM_EMSCRIPTEN) // probably not useful on Emscripten.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */
|
||||
#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT // probably not useful on WinRT, given current .dll loading restrictions
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_PSP) && SDL_PLATFORM_PSP
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_RISCOS) /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */
|
||||
#elif defined(SDL_PLATFORM_RISCOS) // probably not useful on RISC OS, since dlopen() can't be used when using static linking.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(__clang_analyzer__) || defined(__INTELLISENSE__) || defined(SDL_THREAD_SAFETY_ANALYSIS)
|
||||
#define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */
|
||||
#define SDL_DYNAMIC_API 0 // Turn off for static analysis, so reports are more clear.
|
||||
#elif defined(SDL_PLATFORM_VITA)
|
||||
#define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */
|
||||
#define SDL_DYNAMIC_API 0 // vitasdk doesn't support dynamic linking
|
||||
#elif defined(SDL_PLATFORM_NGAGE)
|
||||
#define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */
|
||||
#define SDL_DYNAMIC_API 0 // The N-Gage doesn't support dynamic linking either
|
||||
#elif defined(SDL_PLATFORM_3DS)
|
||||
#define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */
|
||||
#define SDL_DYNAMIC_API 0 // devkitARM doesn't support dynamic linking
|
||||
#elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN)
|
||||
#define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */
|
||||
#define SDL_DYNAMIC_API 0 // we need dlopen(), but don't have it....
|
||||
#endif
|
||||
|
||||
/* everyone else. This is where we turn on the API if nothing forced it off. */
|
||||
// everyone else. This is where we turn on the API if nothing forced it off.
|
||||
#ifndef SDL_DYNAMIC_API
|
||||
#define SDL_DYNAMIC_API 1
|
||||
#endif
|
||||
|
||||
@@ -987,7 +987,7 @@ SDL3_0.0.0 {
|
||||
SDL_powf;
|
||||
SDL_qsort;
|
||||
SDL_qsort_r;
|
||||
SDL_rand;
|
||||
SDL_rand;
|
||||
SDL_rand_bits;
|
||||
SDL_rand_bits_r;
|
||||
SDL_rand_r;
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
*/
|
||||
|
||||
|
||||
/* DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl. */
|
||||
// DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl.
|
||||
|
||||
#if !SDL_DYNAMIC_API
|
||||
#error You should not be here.
|
||||
#endif
|
||||
|
||||
/* New API symbols are added at the end */
|
||||
// New API symbols are added at the end
|
||||
#define SDL_AcquireCameraFrame SDL_AcquireCameraFrame_REAL
|
||||
#define SDL_AddEventWatch SDL_AddEventWatch_REAL
|
||||
#define SDL_AddGamepadMapping SDL_AddGamepadMapping_REAL
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
Also, this file gets included multiple times, don't add #pragma once, etc.
|
||||
*/
|
||||
|
||||
/* direct jump magic can use these, the rest needs special code. */
|
||||
// direct jump magic can use these, the rest needs special code.
|
||||
#ifndef SDL_DYNAPI_PROC_NO_VARARGS
|
||||
SDL_DYNAPI_PROC(size_t,SDL_IOprintf,(SDL_IOStream *a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),)
|
||||
@@ -46,7 +46,7 @@ SDL_DYNAPI_PROC(int,SDL_sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const cha
|
||||
SDL_DYNAPI_PROC(int,SDL_swprintf,(SDL_OUT_Z_CAP(b) wchar_t *a, size_t b, SDL_PRINTF_FORMAT_STRING const wchar_t *c, ...),(a,b,c),return)
|
||||
#endif
|
||||
|
||||
/* New API symbols are added at the end */
|
||||
// New API symbols are added at the end
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_AcquireCameraFrame,(SDL_Camera *a, Uint64 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return)
|
||||
|
||||
@@ -99,7 +99,7 @@ def main():
|
||||
if match:
|
||||
continue
|
||||
|
||||
# Remove one line comment /* ... */
|
||||
# Remove one line comment // ...
|
||||
# eg: extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */);
|
||||
line = reg_comment_remove_content.sub('', line)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* SDL event categories */
|
||||
// SDL event categories
|
||||
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_categories_c.h"
|
||||
@@ -233,8 +233,8 @@ SDL_Window *SDL_GetWindowFromEvent(const SDL_Event *event)
|
||||
windowID = event->drop.windowID;
|
||||
break;
|
||||
default:
|
||||
/* < 0 -> invalid event type (error is set by SDL_GetEventCategory) */
|
||||
/* else -> event has no associated window (not an error) */
|
||||
// < 0 -> invalid event type (error is set by SDL_GetEventCategory)
|
||||
// else -> event has no associated window (not an error)
|
||||
return NULL;
|
||||
}
|
||||
return SDL_GetWindowFromID(windowID);
|
||||
|
||||
@@ -65,4 +65,4 @@ typedef enum SDL_EventCategory
|
||||
|
||||
extern SDL_EventCategory SDL_GetEventCategory(Uint32 type);
|
||||
|
||||
#endif /* SDL_categories_c_h_ */
|
||||
#endif // SDL_categories_c_h_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Clipboard event handling code for SDL */
|
||||
// Clipboard event handling code for SDL
|
||||
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_clipboardevents_c.h"
|
||||
@@ -29,7 +29,7 @@ int SDL_SendClipboardUpdate(void)
|
||||
{
|
||||
int posted;
|
||||
|
||||
/* Post the event, if desired */
|
||||
// Post the event, if desired
|
||||
posted = 0;
|
||||
if (SDL_EventEnabled(SDL_EVENT_CLIPBOARD_UPDATE)) {
|
||||
SDL_Event event;
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
|
||||
extern int SDL_SendClipboardUpdate(void);
|
||||
|
||||
#endif /* SDL_clipboardevents_c_h_ */
|
||||
#endif // SDL_clipboardevents_c_h_
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Display event handling code for SDL */
|
||||
// Display event handling code for SDL
|
||||
|
||||
#include "SDL_events_c.h"
|
||||
|
||||
@@ -42,7 +42,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
// Post the event, if desired
|
||||
posted = 0;
|
||||
if (SDL_EventEnabled(displayevent)) {
|
||||
SDL_Event event;
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
|
||||
extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2);
|
||||
|
||||
#endif /* SDL_displayevents_c_h_ */
|
||||
#endif // SDL_displayevents_c_h_
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Drag and drop event handling code for SDL */
|
||||
// Drag and drop event handling code for SDL
|
||||
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_dropevents_c.h"
|
||||
|
||||
#include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */
|
||||
#include "../video/SDL_sysvideo.h" // for SDL_Window internals.
|
||||
|
||||
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *source, const char *data, float x, float y)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch
|
||||
static float last_drop_y = 0;
|
||||
int posted = 0;
|
||||
|
||||
/* Post the event, if desired */
|
||||
// Post the event, if desired
|
||||
if (SDL_EventEnabled(evtype)) {
|
||||
const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping;
|
||||
SDL_Event event;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user