mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,6 +29,7 @@ typedef SDL_bool
|
|||
(*SDL_GetPowerInfo_Impl) (SDL_PowerState * state, int *seconds,
|
||||
int *percent);
|
||||
|
||||
SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *);
|
||||
|
|
@ -38,6 +39,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *);
|
|||
SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *);
|
||||
SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *);
|
||||
|
||||
#ifndef SDL_POWER_DISABLED
|
||||
#ifdef SDL_POWER_HARDWIRED
|
||||
|
|
@ -57,6 +59,7 @@ SDL_GetPowerInfo_Hardwired(SDL_PowerState * state, int *seconds, int *percent)
|
|||
static SDL_GetPowerInfo_Impl implementations[] = {
|
||||
#ifndef SDL_POWER_DISABLED
|
||||
#ifdef SDL_POWER_LINUX /* in order of preference. More than could work. */
|
||||
SDL_GetPowerInfo_Linux_sys_class_power_supply,
|
||||
SDL_GetPowerInfo_Linux_proc_acpi,
|
||||
SDL_GetPowerInfo_Linux_proc_apm,
|
||||
#endif
|
||||
|
|
@ -81,6 +84,9 @@ static SDL_GetPowerInfo_Impl implementations[] = {
|
|||
#ifdef SDL_POWER_WINRT /* handles WinRT */
|
||||
SDL_GetPowerInfo_WinRT,
|
||||
#endif
|
||||
#ifdef SDL_POWER_EMSCRIPTEN /* handles Emscripten */
|
||||
SDL_GetPowerInfo_Emscripten,
|
||||
#endif
|
||||
|
||||
#ifdef SDL_POWER_HARDWIRED
|
||||
SDL_GetPowerInfo_Hardwired,
|
||||
|
|
@ -93,7 +99,7 @@ SDL_GetPowerInfo(int *seconds, int *percent)
|
|||
{
|
||||
const int total = sizeof(implementations) / sizeof(implementations[0]);
|
||||
int _seconds, _percent;
|
||||
SDL_PowerState retval;
|
||||
SDL_PowerState retval = SDL_POWERSTATE_UNKNOWN;
|
||||
int i;
|
||||
|
||||
/* Make these never NULL for platform-specific implementations. */
|
||||
|
|
@ -106,7 +112,7 @@ SDL_GetPowerInfo(int *seconds, int *percent)
|
|||
}
|
||||
|
||||
for (i = 0; i < total; i++) {
|
||||
if (implementations[i] (&retval, seconds, percent)) {
|
||||
if (implementations[i](&retval, seconds, percent)) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
62
Engine/lib/sdl/src/power/emscripten/SDL_syspower.c
Normal file
62
Engine/lib/sdl/src/power/emscripten/SDL_syspower.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_POWER_DISABLED
|
||||
#if SDL_POWER_EMSCRIPTEN
|
||||
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#include "SDL_power.h"
|
||||
|
||||
SDL_bool
|
||||
SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *percent)
|
||||
{
|
||||
EmscriptenBatteryEvent batteryState;
|
||||
int haveBattery = 0;
|
||||
|
||||
if (emscripten_get_battery_status(&batteryState) == EMSCRIPTEN_RESULT_NOT_SUPPORTED)
|
||||
return SDL_FALSE;
|
||||
|
||||
haveBattery = batteryState.level != 1.0 || !batteryState.charging || batteryState.chargingTime != 0.0;
|
||||
|
||||
if (!haveBattery) {
|
||||
*state = SDL_POWERSTATE_NO_BATTERY;
|
||||
*seconds = -1;
|
||||
*percent = -1;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (batteryState.charging)
|
||||
*state = batteryState.chargingTime == 0.0 ? SDL_POWERSTATE_CHARGED : SDL_POWERSTATE_CHARGING;
|
||||
else
|
||||
*state = SDL_POWERSTATE_ON_BATTERY;
|
||||
|
||||
*seconds = batteryState.dischargingTime;
|
||||
*percent = batteryState.level * 100;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#endif /* SDL_POWER_EMSCRIPTEN */
|
||||
#endif /* SDL_POWER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -36,8 +36,10 @@
|
|||
static const char *proc_apm_path = "/proc/apm";
|
||||
static const char *proc_acpi_battery_path = "/proc/acpi/battery";
|
||||
static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter";
|
||||
static const char *sys_class_power_supply_path = "/sys/class/power_supply";
|
||||
|
||||
static int open_acpi_file(const char *base, const char *node, const char *key)
|
||||
static int
|
||||
open_power_file(const char *base, const char *node, const char *key)
|
||||
{
|
||||
const size_t pathlen = strlen(base) + strlen(node) + strlen(key) + 3;
|
||||
char *path = (char *) alloca(pathlen);
|
||||
|
|
@ -51,11 +53,11 @@ static int open_acpi_file(const char *base, const char *node, const char *key)
|
|||
|
||||
|
||||
static SDL_bool
|
||||
load_acpi_file(const char *base, const char *node, const char *key,
|
||||
char *buf, size_t buflen)
|
||||
read_power_file(const char *base, const char *node, const char *key,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
ssize_t br = 0;
|
||||
const int fd = open_acpi_file(base, node, key);
|
||||
const int fd = open_power_file(base, node, key);
|
||||
if (fd == -1) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
|
@ -133,9 +135,9 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery,
|
|||
int secs = -1;
|
||||
int pct = -1;
|
||||
|
||||
if (!load_acpi_file(base, node, "state", state, sizeof (state))) {
|
||||
if (!read_power_file(base, node, "state", state, sizeof (state))) {
|
||||
return;
|
||||
} else if (!load_acpi_file(base, node, "info", info, sizeof (info))) {
|
||||
} else if (!read_power_file(base, node, "info", info, sizeof (info))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +216,7 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac)
|
|||
char *key = NULL;
|
||||
char *val = NULL;
|
||||
|
||||
if (!load_acpi_file(base, node, "state", state, sizeof (state))) {
|
||||
if (!read_power_file(base, node, "state", state, sizeof (state))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -423,6 +425,94 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state,
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* !!! FIXME: implement d-bus queries to org.freedesktop.UPower. */
|
||||
|
||||
SDL_bool
|
||||
SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *seconds, int *percent)
|
||||
{
|
||||
const char *base = sys_class_power_supply_path;
|
||||
struct dirent *dent;
|
||||
DIR *dirp;
|
||||
|
||||
dirp = opendir(base);
|
||||
if (!dirp) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
*state = SDL_POWERSTATE_NO_BATTERY; /* assume we're just plugged in. */
|
||||
*seconds = -1;
|
||||
*percent = -1;
|
||||
|
||||
while ((dent = readdir(dirp)) != NULL) {
|
||||
const char *name = dent->d_name;
|
||||
SDL_bool choose = SDL_FALSE;
|
||||
char str[64];
|
||||
SDL_PowerState st;
|
||||
int secs;
|
||||
int pct;
|
||||
|
||||
if ((SDL_strcmp(name, ".") == 0) || (SDL_strcmp(name, "..") == 0)) {
|
||||
continue; /* skip these, of course. */
|
||||
} else if (!read_power_file(base, name, "type", str, sizeof (str))) {
|
||||
continue; /* Don't know _what_ we're looking at. Give up on it. */
|
||||
} else if (SDL_strcmp(str, "Battery\n") != 0) {
|
||||
continue; /* we don't care about UPS and such. */
|
||||
}
|
||||
|
||||
/* some drivers don't offer this, so if it's not explicitly reported assume it's present. */
|
||||
if (read_power_file(base, name, "present", str, sizeof (str)) && (SDL_strcmp(str, "0\n") == 0)) {
|
||||
st = SDL_POWERSTATE_NO_BATTERY;
|
||||
} else if (!read_power_file(base, name, "status", str, sizeof (str))) {
|
||||
st = SDL_POWERSTATE_UNKNOWN; /* uh oh */
|
||||
} else if (SDL_strcmp(str, "Charging\n") == 0) {
|
||||
st = SDL_POWERSTATE_CHARGING;
|
||||
} else if (SDL_strcmp(str, "Discharging\n") == 0) {
|
||||
st = SDL_POWERSTATE_ON_BATTERY;
|
||||
} else if ((SDL_strcmp(str, "Full\n") == 0) || (SDL_strcmp(str, "Not charging\n") == 0)) {
|
||||
st = SDL_POWERSTATE_CHARGED;
|
||||
} else {
|
||||
st = SDL_POWERSTATE_UNKNOWN; /* uh oh */
|
||||
}
|
||||
|
||||
if (!read_power_file(base, name, "capacity", str, sizeof (str))) {
|
||||
pct = -1;
|
||||
} else {
|
||||
pct = SDL_atoi(str);
|
||||
pct = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
|
||||
}
|
||||
|
||||
if (!read_power_file(base, name, "time_to_empty_now", str, sizeof (str))) {
|
||||
secs = -1;
|
||||
} else {
|
||||
secs = SDL_atoi(str);
|
||||
secs = (secs <= 0) ? -1 : secs; /* 0 == unknown */
|
||||
}
|
||||
|
||||
/*
|
||||
* We pick the battery that claims to have the most minutes left.
|
||||
* (failing a report of minutes, we'll take the highest percent.)
|
||||
*/
|
||||
if ((secs < 0) && (*seconds < 0)) {
|
||||
if ((pct < 0) && (*percent < 0)) {
|
||||
choose = SDL_TRUE; /* at least we know there's a battery. */
|
||||
} else if (pct > *percent) {
|
||||
choose = SDL_TRUE;
|
||||
}
|
||||
} else if (secs > *seconds) {
|
||||
choose = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (choose) {
|
||||
*seconds = secs;
|
||||
*percent = pct;
|
||||
*state = st;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
return SDL_TRUE; /* don't look any further. */
|
||||
}
|
||||
|
||||
#endif /* SDL_POWER_LINUX */
|
||||
#endif /* SDL_POWER_DISABLED */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -23,13 +23,13 @@
|
|||
#ifndef SDL_POWER_DISABLED
|
||||
#if SDL_POWER_MACOSX
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/ps/IOPowerSources.h>
|
||||
#include <IOKit/ps/IOPSKeys.h>
|
||||
|
||||
#include "SDL_power.h"
|
||||
|
||||
/* Carbon is so verbose... */
|
||||
/* CoreFoundation is so verbose... */
|
||||
#define STRMATCH(a,b) (CFStringCompare(a, b, 0) == kCFCompareEqualTo)
|
||||
#define GETVAL(k,v) \
|
||||
CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **) v)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -50,24 +50,24 @@ SDL_UIKit_UpdateBatteryMonitoring(void)
|
|||
SDL_bool
|
||||
SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent)
|
||||
{
|
||||
UIDevice *uidev = [UIDevice currentDevice];
|
||||
@autoreleasepool {
|
||||
UIDevice *uidev = [UIDevice currentDevice];
|
||||
|
||||
if (!SDL_UIKitLastPowerInfoQuery) {
|
||||
SDL_assert([uidev isBatteryMonitoringEnabled] == NO);
|
||||
[uidev setBatteryMonitoringEnabled:YES];
|
||||
}
|
||||
if (!SDL_UIKitLastPowerInfoQuery) {
|
||||
SDL_assert(uidev.isBatteryMonitoringEnabled == NO);
|
||||
uidev.batteryMonitoringEnabled = YES;
|
||||
}
|
||||
|
||||
/* UIKit_GL_SwapWindow() (etc) will check this and disable the battery
|
||||
* monitoring if the app hasn't queried it in the last X seconds.
|
||||
* Apparently monitoring the battery burns battery life. :)
|
||||
* Apple's docs say not to monitor the battery unless you need it.
|
||||
*/
|
||||
SDL_UIKitLastPowerInfoQuery = SDL_GetTicks();
|
||||
/* UIKit_GL_SwapWindow() (etc) will check this and disable the battery
|
||||
* monitoring if the app hasn't queried it in the last X seconds.
|
||||
* Apparently monitoring the battery burns battery life. :)
|
||||
* Apple's docs say not to monitor the battery unless you need it.
|
||||
*/
|
||||
SDL_UIKitLastPowerInfoQuery = SDL_GetTicks();
|
||||
|
||||
*seconds = -1; /* no API to estimate this in UIKit. */
|
||||
*seconds = -1; /* no API to estimate this in UIKit. */
|
||||
|
||||
switch ([uidev batteryState])
|
||||
{
|
||||
switch (uidev.batteryState) {
|
||||
case UIDeviceBatteryStateCharging:
|
||||
*state = SDL_POWERSTATE_CHARGING;
|
||||
break;
|
||||
|
|
@ -84,11 +84,12 @@ SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent)
|
|||
default:
|
||||
*state = SDL_POWERSTATE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const float level = [uidev batteryLevel];
|
||||
*percent = ( (level < 0.0f) ? -1 : ((int) ((level * 100) + 0.5f)) );
|
||||
return SDL_TRUE; /* always the definitive answer on iOS. */
|
||||
const float level = uidev.batteryLevel;
|
||||
*percent = ( (level < 0.0f) ? -1 : ((int) ((level * 100) + 0.5f)) );
|
||||
return SDL_TRUE; /* always the definitive answer on iOS. */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_POWER_UIKIT */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue