From d4863b4c4ac47766b5fd3b8b0949be7af792e3d0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 19:07:55 +0000 Subject: On Windows CE systems without a keyboard, patch the default settings to use hardware keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1600 --- setup/configfile.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'setup/configfile.c') diff --git a/setup/configfile.c b/setup/configfile.c index 3b6007f5..fe3c13de 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -35,6 +35,8 @@ #ifdef _WIN32 #include +#define WIN32_LEAN_AND_MEAN +#include #else #include #include @@ -647,3 +649,77 @@ void M_SaveExtraDefaults(char *filename) extra_defaults.filename = main_filename; } +#ifdef _WIN32_WCE + +static int SystemHasKeyboard(void) +{ + HKEY key; + DWORD valtype; + DWORD valsize; + DWORD result; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, + L"\\Software\\Microsoft\\Shell", 0, + KEY_READ, &key) != ERROR_SUCCESS) + { + return 0; + } + + valtype = REG_SZ; + valsize = sizeof(DWORD); + + if (RegQueryValueExW(key, L"HasKeyboard", NULL, &valtype, + (LPBYTE) &result, &valsize) != ERROR_SUCCESS) + { + result = 0; + } + + // Close the key + + RegCloseKey(key); + + return result; +} + +// +// Apply custom defaults for Windows CE. +// + +static void M_ApplyWindowsCEDefaults(void) +{ + // If the system doesn't have a keyboard, patch the default + // configuration to use the hardware keys. + + if (!SystemHasKeyboard()) + { + key_use = KEY_F1; + key_fire = KEY_F2; + key_menu_activate = KEY_F3; + key_map_toggle = KEY_F4; + + key_menu_help = 0; + key_menu_save = 0; + key_menu_load = 0; + key_menu_volume = 0; + + key_menu_confirm = KEY_ENTER; + key_menu_back = KEY_F2; + key_menu_abort = KEY_F2; + } +} + + +#endif + +// +// Apply custom patches to the default values depending on the +// platform we are running on. +// + +void M_ApplyPlatformDefaults(void) +{ +#ifdef _WIN32_WCE + M_ApplyWindowsCEDefaults(); +#endif +} + -- cgit v1.2.3