2015-04-07 19:51:57 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2016-01-10 03:06:50 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2015-04-07 19:51:57 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
* * You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-06-15 20:45:02 +00:00
|
|
|
#include <windows.h>
|
2015-09-15 02:49:10 +00:00
|
|
|
#include <boolean.h>
|
2015-06-15 20:45:02 +00:00
|
|
|
#include <retro_miscellaneous.h>
|
|
|
|
#include <dynamic/dylib.h>
|
2016-03-20 13:53:54 +00:00
|
|
|
#include <lists/file_list.h>
|
2016-04-30 15:04:04 +00:00
|
|
|
#include <file/file_path.h>
|
2015-06-15 20:45:02 +00:00
|
|
|
|
|
|
|
#include "../frontend_driver.h"
|
|
|
|
#include "../../general.h"
|
2015-11-23 11:14:53 +00:00
|
|
|
#include "../../verbosity.h"
|
2015-12-06 17:12:40 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
|
|
|
#endif
|
2015-06-15 20:45:02 +00:00
|
|
|
|
2016-04-28 14:00:43 +00:00
|
|
|
#include <defaults.h>
|
|
|
|
|
|
|
|
|
2015-04-09 20:58:57 +00:00
|
|
|
/* We only load this library once, so we let it be
|
|
|
|
* unloaded at application shutdown, since unloading
|
|
|
|
* it early seems to cause issues on some systems.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static dylib_t dwmlib;
|
|
|
|
|
|
|
|
static bool dwm_composition_disabled;
|
|
|
|
|
|
|
|
static void gfx_dwm_shutdown(void)
|
|
|
|
{
|
|
|
|
if (dwmlib)
|
|
|
|
dylib_close(dwmlib);
|
|
|
|
dwmlib = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gfx_init_dwm(void)
|
|
|
|
{
|
|
|
|
static bool inited = false;
|
|
|
|
|
|
|
|
if (inited)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
dwmlib = dylib_load("dwmapi.dll");
|
|
|
|
if (!dwmlib)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Did not find dwmapi.dll.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
atexit(gfx_dwm_shutdown);
|
|
|
|
|
|
|
|
HRESULT (WINAPI *mmcss)(BOOL) =
|
|
|
|
(HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS");
|
|
|
|
if (mmcss)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Setting multimedia scheduling for DWM.\n");
|
|
|
|
mmcss(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
inited = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_set_dwm(void)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!gfx_init_dwm())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (settings->video.disable_composition == dwm_composition_disabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
HRESULT (WINAPI *composition_enable)(UINT) =
|
|
|
|
(HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition");
|
|
|
|
if (!composition_enable)
|
|
|
|
{
|
|
|
|
RARCH_ERR("Did not find DwmEnableComposition ...\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = composition_enable(!settings->video.disable_composition);
|
|
|
|
if (FAILED(ret))
|
|
|
|
RARCH_ERR("Failed to set composition state ...\n");
|
|
|
|
dwm_composition_disabled = settings->video.disable_composition;
|
|
|
|
}
|
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
2015-04-07 21:28:45 +00:00
|
|
|
{
|
2015-04-08 00:11:23 +00:00
|
|
|
uint32_t version = GetVersion();
|
2015-04-07 21:28:45 +00:00
|
|
|
|
|
|
|
*major = (DWORD)(LOBYTE(LOWORD(version)));
|
|
|
|
*minor = (DWORD)(HIBYTE(LOWORD(version)));
|
2015-04-18 18:41:17 +00:00
|
|
|
|
|
|
|
switch (*major)
|
|
|
|
{
|
|
|
|
case 6:
|
|
|
|
switch (*minor)
|
|
|
|
{
|
|
|
|
case 3:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 8.1", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 8", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 7/2008 R2", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows Vista/2008", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
switch (*minor)
|
|
|
|
{
|
|
|
|
case 2:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 2003", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows XP", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 2000", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
switch (*minor)
|
|
|
|
{
|
|
|
|
case 0:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows NT 4.0", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 90:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows ME", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "Windows 98", len);
|
2015-04-18 18:41:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-04-07 21:28:45 +00:00
|
|
|
}
|
|
|
|
|
2015-04-08 00:11:23 +00:00
|
|
|
static void frontend_win32_init(void *data)
|
2015-04-07 21:28:45 +00:00
|
|
|
{
|
2015-04-08 05:20:28 +00:00
|
|
|
typedef BOOL (WINAPI *isProcessDPIAwareProc)();
|
|
|
|
typedef BOOL (WINAPI *setProcessDPIAwareProc)();
|
2015-04-08 05:44:18 +00:00
|
|
|
HMODULE handle = GetModuleHandle(TEXT("User32.dll"));
|
|
|
|
isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware");
|
|
|
|
setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware");
|
2015-04-08 05:20:28 +00:00
|
|
|
|
|
|
|
if (isDPIAwareProc)
|
|
|
|
{
|
|
|
|
if (!isDPIAwareProc())
|
|
|
|
{
|
|
|
|
if (setDPIAwareProc)
|
|
|
|
setDPIAwareProc();
|
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:58:57 +00:00
|
|
|
|
2015-04-07 21:28:45 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 15:16:55 +00:00
|
|
|
enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent)
|
|
|
|
{
|
2016-01-13 06:05:57 +00:00
|
|
|
SYSTEM_POWER_STATUS status;
|
2015-04-18 15:16:55 +00:00
|
|
|
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
|
|
|
|
|
|
|
|
if (!GetSystemPowerStatus(&status))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (status.BatteryFlag == 0xFF)
|
|
|
|
ret = FRONTEND_POWERSTATE_NONE;
|
|
|
|
if (status.BatteryFlag & (1 << 7))
|
|
|
|
ret = FRONTEND_POWERSTATE_NO_SOURCE;
|
|
|
|
else if (status.BatteryFlag & (1 << 3))
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGING;
|
|
|
|
else if (status.ACLineStatus == 1)
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGED;
|
|
|
|
else
|
|
|
|
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
|
|
|
|
|
|
|
*percent = (int)status.BatteryLifePercent;
|
|
|
|
*seconds = (int)status.BatteryLifeTime;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-18 18:03:59 +00:00
|
|
|
enum frontend_architecture frontend_win32_get_architecture(void)
|
|
|
|
{
|
|
|
|
/* stub */
|
|
|
|
return FRONTEND_ARCH_NONE;
|
|
|
|
}
|
|
|
|
|
2015-06-15 20:45:02 +00:00
|
|
|
static int frontend_win32_parse_drive_list(void *data)
|
|
|
|
{
|
2015-12-06 17:12:40 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-06-15 20:45:02 +00:00
|
|
|
size_t i = 0;
|
|
|
|
unsigned drives = GetLogicalDrives();
|
|
|
|
char drive[] = " :\\";
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
drive[0] = 'A' + i;
|
|
|
|
if (drives & (1 << i))
|
2016-04-11 03:49:39 +00:00
|
|
|
menu_entries_add(list,
|
2015-06-15 20:45:02 +00:00
|
|
|
drive, "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
}
|
2015-12-06 17:12:40 +00:00
|
|
|
#endif
|
2015-06-15 20:45:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-29 01:19:48 +00:00
|
|
|
static void frontend_win32_environment_get(int *argc, char *argv[],
|
|
|
|
void *args, void *params_data)
|
|
|
|
{
|
|
|
|
gfx_set_dwm();
|
2016-04-28 13:13:52 +00:00
|
|
|
|
2016-04-30 15:04:04 +00:00
|
|
|
fill_pathname_expand_special(g_defaults.dir.assets,
|
|
|
|
":/assets", sizeof(g_defaults.dir.assets));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.audio_filter,
|
|
|
|
":/filters/audio", sizeof(g_defaults.dir.audio_filter));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.video_filter,
|
|
|
|
":/filters/video", sizeof(g_defaults.dir.video_filter));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.cheats,
|
|
|
|
":/cheats", sizeof(g_defaults.dir.cheats));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.database,
|
|
|
|
":/database/rdb", sizeof(g_defaults.dir.database));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.cursor,
|
|
|
|
":/database/cursors", sizeof(g_defaults.dir.cursor));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.playlist,
|
|
|
|
":/playlists", sizeof(g_defaults.dir.assets));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.remap,
|
|
|
|
":/config/remap", sizeof(g_defaults.dir.remap));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.wallpapers,
|
2016-04-30 15:10:22 +00:00
|
|
|
":/assets/wallpapers", sizeof(g_defaults.dir.wallpapers));
|
2016-04-30 15:04:04 +00:00
|
|
|
fill_pathname_expand_special(g_defaults.dir.thumbnails,
|
2016-04-30 19:03:17 +00:00
|
|
|
":/thumbnails", sizeof(g_defaults.dir.thumbnails));
|
2016-04-30 15:04:04 +00:00
|
|
|
fill_pathname_expand_special(g_defaults.dir.overlay,
|
|
|
|
":/overlays", sizeof(g_defaults.dir.overlay));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.osk_overlay,
|
|
|
|
":/overlays", sizeof(g_defaults.dir.osk_overlay));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.osk_overlay,
|
|
|
|
":/overlays", sizeof(g_defaults.dir.osk_overlay));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.core,
|
|
|
|
":/cores", sizeof(g_defaults.dir.core));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.core_info,
|
|
|
|
":/info", sizeof(g_defaults.dir.core_info));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.autoconfig,
|
|
|
|
":/autoconfig", sizeof(g_defaults.dir.autoconfig));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.menu_config,
|
|
|
|
":/config", sizeof(g_defaults.dir.menu_config));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.shader,
|
|
|
|
":/shaders", sizeof(g_defaults.dir.shader));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.core_assets,
|
|
|
|
":/downloads", sizeof(g_defaults.dir.core_assets));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.screenshot,
|
|
|
|
":/screenshots", sizeof(g_defaults.dir.screenshot));
|
2016-04-30 14:10:52 +00:00
|
|
|
|
2016-04-30 19:33:02 +00:00
|
|
|
/* don't force this in the driver anymore, these will be handled by
|
|
|
|
a dummy config file so they can be reset to content dir
|
|
|
|
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.sram,
|
|
|
|
":/saves", sizeof(g_defaults.dir.sram));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.savestate,
|
|
|
|
":/states", sizeof(g_defaults.dir.savestate));
|
|
|
|
fill_pathname_expand_special(g_defaults.dir.system,
|
|
|
|
":/system", sizeof(g_defaults.dir.system));
|
|
|
|
*/
|
2016-04-30 14:11:28 +00:00
|
|
|
#ifdef HAVE_MENU
|
2016-04-30 14:10:52 +00:00
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb");
|
|
|
|
#endif
|
2016-04-30 14:11:28 +00:00
|
|
|
#endif
|
2016-04-30 15:04:04 +00:00
|
|
|
|
2015-09-29 01:19:48 +00:00
|
|
|
}
|
|
|
|
|
2015-07-27 01:44:28 +00:00
|
|
|
frontend_ctx_driver_t frontend_ctx_win32 = {
|
2015-09-30 02:44:38 +00:00
|
|
|
frontend_win32_environment_get,
|
2015-04-18 15:16:55 +00:00
|
|
|
frontend_win32_init,
|
2015-04-07 21:28:45 +00:00
|
|
|
NULL, /* deinit */
|
|
|
|
NULL, /* exitspawn */
|
|
|
|
NULL, /* process_args */
|
|
|
|
NULL, /* exec */
|
|
|
|
NULL, /* set_fork */
|
|
|
|
NULL, /* shutdown */
|
|
|
|
NULL, /* get_name */
|
2015-04-18 15:16:55 +00:00
|
|
|
frontend_win32_get_os,
|
2015-04-07 21:28:45 +00:00
|
|
|
NULL, /* get_rating */
|
|
|
|
NULL, /* load_content */
|
2015-04-18 18:03:59 +00:00
|
|
|
frontend_win32_get_architecture,
|
2015-04-18 15:16:55 +00:00
|
|
|
frontend_win32_get_powerstate,
|
2015-06-15 20:45:02 +00:00
|
|
|
frontend_win32_parse_drive_list,
|
2015-04-07 19:51:57 +00:00
|
|
|
"win32",
|
|
|
|
};
|