From c80600ef2c0ded9c51ebd0f169972149956d939b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 17:34:27 +0000 Subject: Always grab input on Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1597 --- src/i_video.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/i_video.c b/src/i_video.c index e0db6145..aaefd922 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -182,7 +182,7 @@ static boolean MouseShouldBeGrabbed() if (screensaver_mode) return false; - // if the window doesnt have focus, never grab it + // if the window doesn't have focus, never grab it if (!window_focused) return false; @@ -193,6 +193,17 @@ static boolean MouseShouldBeGrabbed() if (fullscreen) return true; +#ifdef _WIN32_WCE + + // On Windows CE, always grab input. This is because hardware + // button events are only acquired by SDL when the input is grabbed. + // Almost all Windows CE devices should have touch screens anyway, + // so this shouldn't affect mouse grabbing behavior. + + return true; + +#else + // Don't grab the mouse if mouse input is disabled if (!usemouse || nomouse) @@ -204,18 +215,20 @@ static boolean MouseShouldBeGrabbed() return false; // if we specify not to grab the mouse, never grab - + if (!grabmouse) return false; // when menu is active or game is paused, release the mouse - + if (menuactive || paused) return false; // only grab mouse when playing levels (but not demos) return (gamestate == GS_LEVEL) && !demoplayback; + +#endif /* #ifndef _WIN32_WCE */ } // Update the value of window_focused when we get a focus event -- cgit v1.2.3 From 9fc871cdc51ddc335db803abae91eda42efdb2ed Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 17:35:39 +0000 Subject: Set the USER environment variable based on the owner information from the registry. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1598 --- wince/env.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/wince/env.c b/wince/env.c index 72af2212..b3400627 100644 --- a/wince/env.c +++ b/wince/env.c @@ -40,17 +40,48 @@ static void SetEnvironment(char *env_string, wchar_t *wvalue) putenv(value); } +static int ReadOwnerName(wchar_t *value, DWORD len) +{ + HKEY key; + DWORD valtype; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, + L"\\ControlPanel\\Owner", 0, + KEY_READ, &key) != ERROR_SUCCESS) + { + MessageBoxW(NULL, L"Can't open owner", L"Error", MB_OK); + return 0; + } + + valtype = REG_SZ; + + if (RegQueryValueExW(key, L"Name", NULL, &valtype, + (LPBYTE) value, &len) != ERROR_SUCCESS) + { + MessageBoxW(NULL, L"Can't read owner", L"Error", MB_OK); + return 0; + } + + MessageBoxW(NULL, value, L"Error", MB_OK); + + // Close the key + + RegCloseKey(key); + + return 1; +} + void PopulateEnvironment(void) { wchar_t temp[MAX_PATH]; - DWORD buf_len; // Username: - buf_len = UNLEN; - GetUserNameExW(NameDisplay, temp, &buf_len); - SetEnvironment("USER=", temp); - SetEnvironment("USERNAME=", temp); + if (ReadOwnerName(temp, MAX_PATH)) + { + SetEnvironment("USER=", temp); + SetEnvironment("USERNAME=", temp); + } // Temp dir: -- cgit v1.2.3 From a3b1c4e95cf3d8196858f5c98a92565eedbc1e48 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 17:58:42 +0000 Subject: Remove debug messages. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1599 --- wince/env.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wince/env.c b/wince/env.c index b3400627..c90b4c8d 100644 --- a/wince/env.c +++ b/wince/env.c @@ -49,7 +49,6 @@ static int ReadOwnerName(wchar_t *value, DWORD len) L"\\ControlPanel\\Owner", 0, KEY_READ, &key) != ERROR_SUCCESS) { - MessageBoxW(NULL, L"Can't open owner", L"Error", MB_OK); return 0; } @@ -58,12 +57,9 @@ static int ReadOwnerName(wchar_t *value, DWORD len) if (RegQueryValueExW(key, L"Name", NULL, &valtype, (LPBYTE) value, &len) != ERROR_SUCCESS) { - MessageBoxW(NULL, L"Can't read owner", L"Error", MB_OK); return 0; } - MessageBoxW(NULL, value, L"Error", MB_OK); - // Close the key RegCloseKey(key); -- cgit v1.2.3 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 ++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/configfile.h | 2 ++ setup/mainmenu.c | 2 ++ src/d_main.c | 1 + src/m_config.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/m_config.h | 1 + 6 files changed, 160 insertions(+) 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 +} + diff --git a/setup/configfile.h b/setup/configfile.h index f7c6156e..3ef2cf9b 100644 --- a/setup/configfile.h +++ b/setup/configfile.h @@ -38,5 +38,7 @@ void M_SetConfigDir(void); void M_SaveMainDefaults(char *filename); void M_SaveExtraDefaults(char *filename); +void M_ApplyPlatformDefaults(void); + #endif diff --git a/setup/mainmenu.c b/setup/mainmenu.c index 6a1f01c2..c7e4f48d 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -143,6 +143,8 @@ void MainMenu(void) static void InitConfig(void) { + M_ApplyPlatformDefaults(); + SetChatMacroDefaults(); SetPlayerNameDefault(); diff --git a/src/d_main.c b/src/d_main.c index 29a366a1..c59a8fb7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -974,6 +974,7 @@ void D_DoomMain (void) V_Init (); printf (DEH_String("M_LoadDefaults: Load system defaults.\n")); + M_ApplyPlatformDefaults(); M_LoadDefaults (); // load before initing other systems printf (DEH_String("W_Init: Init WADfiles.\n")); diff --git a/src/m_config.c b/src/m_config.c index 9e770e48..4f789845 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -31,6 +31,11 @@ #include #include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include "config.h" #include "deh_main.h" #include "doomdef.h" @@ -1380,3 +1385,76 @@ void M_SetConfigDir(void) } } +#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 +} + diff --git a/src/m_config.h b/src/m_config.h index 747569cd..ff11e6d6 100644 --- a/src/m_config.h +++ b/src/m_config.h @@ -31,6 +31,7 @@ void M_LoadDefaults(void); void M_SaveDefaults(void); void M_SetConfigDir(void); +void M_ApplyPlatformDefaults(void); extern char *configdir; -- cgit v1.2.3