src/power/psp/SDL_syspower.c
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 7191 75360622e65f
child 8093 b43765095a6f
permissions -rw-r--r--
WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app. This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
kimonline@7009
     1
/*
kimonline@7009
     2
  Simple DirectMedia Layer
kimonline@7009
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
kimonline@7009
     4
kimonline@7009
     5
  This software is provided 'as-is', without any express or implied
kimonline@7009
     6
  warranty.  In no event will the authors be held liable for any damages
kimonline@7009
     7
  arising from the use of this software.
kimonline@7009
     8
kimonline@7009
     9
  Permission is granted to anyone to use this software for any purpose,
kimonline@7009
    10
  including commercial applications, and to alter it and redistribute it
kimonline@7009
    11
  freely, subject to the following restrictions:
kimonline@7009
    12
kimonline@7009
    13
  1. The origin of this software must not be misrepresented; you must not
kimonline@7009
    14
     claim that you wrote the original software. If you use this software
kimonline@7009
    15
     in a product, an acknowledgment in the product documentation would be
kimonline@7009
    16
     appreciated but is not required.
kimonline@7009
    17
  2. Altered source versions must be plainly marked as such, and must not be
kimonline@7009
    18
     misrepresented as being the original software.
kimonline@7009
    19
  3. This notice may not be removed or altered from any source distribution.
kimonline@7009
    20
*/
kimonline@7009
    21
kimonline@7009
    22
#include "SDL_config.h"
kimonline@7009
    23
kimonline@7009
    24
#ifndef SDL_POWER_DISABLED
kimonline@7009
    25
#if SDL_POWER_PSP
kimonline@7009
    26
kimonline@7009
    27
#include "SDL_power.h"
slouken@7191
    28
#include <psppower.h>
kimonline@7009
    29
kimonline@7009
    30
kimonline@7009
    31
SDL_bool
kimonline@7009
    32
SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds,
kimonline@7009
    33
                            int *percent)
kimonline@7009
    34
{
kimonline@7009
    35
    int battery = scePowerIsBatteryExist();
kimonline@7009
    36
    int plugged = scePowerIsPowerOnline();
slouken@7191
    37
    int charging = scePowerIsBatteryCharging();
kimonline@7009
    38
kimonline@7009
    39
    *state = SDL_POWERSTATE_UNKNOWN;
slouken@7191
    40
    *seconds = -1;
slouken@7191
    41
    *percent = -1;
slouken@7191
    42
slouken@7191
    43
    if (!battery) {
slouken@7191
    44
        *state = SDL_POWERSTATE_NO_BATTERY;
slouken@7191
    45
        *seconds = -1;
slouken@7191
    46
        *percent = -1;
kimonline@7009
    47
    } else if (charging) {
kimonline@7009
    48
        *state = SDL_POWERSTATE_CHARGING;
slouken@7191
    49
        *percent = scePowerGetBatteryLifePercent();
slouken@7191
    50
        *seconds = scePowerGetBatteryLifeTime()*60;
kimonline@7009
    51
    } else if (plugged) {
kimonline@7009
    52
        *state = SDL_POWERSTATE_CHARGED;
slouken@7191
    53
        *percent = scePowerGetBatteryLifePercent();
slouken@7191
    54
        *seconds = scePowerGetBatteryLifeTime()*60;
kimonline@7009
    55
    } else {
kimonline@7009
    56
        *state = SDL_POWERSTATE_ON_BATTERY;
slouken@7191
    57
        *percent = scePowerGetBatteryLifePercent();
slouken@7191
    58
        *seconds = scePowerGetBatteryLifeTime()*60;
kimonline@7009
    59
    }
kimonline@7009
    60
slouken@7191
    61
kimonline@7009
    62
    return SDL_TRUE;            /* always the definitive answer on PSP. */
kimonline@7009
    63
}
kimonline@7009
    64
kimonline@7009
    65
#endif /* SDL_POWER_PSP */
kimonline@7009
    66
#endif /* SDL_POWER_DISABLED */
kimonline@7009
    67
kimonline@7009
    68
/* vi: set ts=4 sw=4 expandtab: */