diff options
author | Simon Howard | 2009-06-13 15:36:20 +0000 |
---|---|---|
committer | Simon Howard | 2009-06-13 15:36:20 +0000 |
commit | d91e3e86736f710265629e56dc77c1dec0b425e7 (patch) | |
tree | 96a63dc34618bbdc6700b2bba4bb5d35cb4aa898 | |
parent | 0f5de61b743fdf05335436c1c71b4b488870483f (diff) | |
parent | d4863b4c4ac47766b5fd3b8b0949be7af792e3d0 (diff) | |
download | chocolate-doom-d91e3e86736f710265629e56dc77c1dec0b425e7.tar.gz chocolate-doom-d91e3e86736f710265629e56dc77c1dec0b425e7.tar.bz2 chocolate-doom-d91e3e86736f710265629e56dc77c1dec0b425e7.zip |
Merge from trunk.
Subversion-branch: /branches/raven-branch
Subversion-revision: 1601
-rw-r--r-- | src/doom/d_main.c | 2 | ||||
-rw-r--r-- | src/heretic/d_main.c | 2 | ||||
-rw-r--r-- | src/hexen/h2_main.c | 2 | ||||
-rw-r--r-- | src/i_video.c | 17 | ||||
-rw-r--r-- | src/m_controls.c | 76 | ||||
-rw-r--r-- | src/m_controls.h | 2 | ||||
-rw-r--r-- | src/setup/mode.c | 2 | ||||
-rw-r--r-- | wince/env.c | 37 |
8 files changed, 133 insertions, 7 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c index ce9b667d..9fa9ae3b 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -348,6 +348,8 @@ void D_BindVariables(void) { int i; + M_ApplyPlatformDefaults(); + I_BindVideoVariables(); I_BindJoystickVariables(); I_BindSoundVariables(); diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c index d501c496..10f5fd3e 100644 --- a/src/heretic/d_main.c +++ b/src/heretic/d_main.c @@ -737,6 +737,8 @@ void D_BindVariables(void) extern int snd_Channels; int i; + M_ApplyPlatformDefaults(); + I_BindVideoVariables(); I_BindJoystickVariables(); I_BindSoundVariables(); diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 656ab80c..ef223c0e 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -147,6 +147,8 @@ void D_BindVariables(void) { int i; + M_ApplyPlatformDefaults(); + I_BindVideoVariables(); I_BindJoystickVariables(); I_BindSoundVariables(); diff --git a/src/i_video.c b/src/i_video.c index a41f523b..a938b1f8 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -266,7 +266,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; @@ -277,13 +277,24 @@ 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) return false; // if we specify not to grab the mouse, never grab - + if (!grabmouse) return false; @@ -298,6 +309,8 @@ static boolean MouseShouldBeGrabbed() { return true; } + +#endif /* #ifndef _WIN32_WCE */ } void I_SetGrabMouseCallback(grabmouse_callback_t func) diff --git a/src/m_controls.c b/src/m_controls.c index 1cca6263..98b1e51b 100644 --- a/src/m_controls.c +++ b/src/m_controls.c @@ -272,3 +272,79 @@ void M_BindMenuControls(void) M_BindVariable("key_menu_decscreen", &key_menu_decscreen); } +#ifdef _WIN32_WCE + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +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_controls.h b/src/m_controls.h index 5054212e..2a4aa3df 100644 --- a/src/m_controls.h +++ b/src/m_controls.h @@ -144,5 +144,7 @@ void M_BindWeaponControls(void); void M_BindMapControls(void); void M_BindMenuControls(void); +void M_ApplyPlatformDefaults(void); + #endif /* #ifndef __M_CONTROLS_H__ */ diff --git a/src/setup/mode.c b/src/setup/mode.c index 9d900319..e300dc9f 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -127,6 +127,8 @@ static void BindMiscVariables(void) void InitBindings(void) { + M_ApplyPlatformDefaults(); + // Keyboard, mouse, joystick controls M_BindBaseControls(); diff --git a/wince/env.c b/wince/env.c index 72af2212..c90b4c8d 100644 --- a/wince/env.c +++ b/wince/env.c @@ -40,17 +40,44 @@ 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) + { + return 0; + } + + valtype = REG_SZ; + + if (RegQueryValueExW(key, L"Name", NULL, &valtype, + (LPBYTE) value, &len) != ERROR_SUCCESS) + { + return 0; + } + + // 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: |