ref: d91e3e86736f710265629e56dc77c1dec0b425e7
parent: 0f5de61b743fdf05335436c1c71b4b488870483f
parent: d4863b4c4ac47766b5fd3b8b0949be7af792e3d0
author: Simon Howard <[email protected]>
date: Sat Jun 13 11:36:20 EDT 2009
Merge from trunk. Subversion-branch: /branches/raven-branch Subversion-revision: 1601
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -348,6 +348,8 @@
{
int i;
+ M_ApplyPlatformDefaults();
+
I_BindVideoVariables();
I_BindJoystickVariables();
I_BindSoundVariables();
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -737,6 +737,8 @@
extern int snd_Channels;
int i;
+ M_ApplyPlatformDefaults();
+
I_BindVideoVariables();
I_BindJoystickVariables();
I_BindSoundVariables();
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -147,6 +147,8 @@
{
int i;
+ M_ApplyPlatformDefaults();
+
I_BindVideoVariables();
I_BindJoystickVariables();
I_BindSoundVariables();
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -266,7 +266,7 @@
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,6 +277,17 @@
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)
@@ -283,7 +294,7 @@
return false;
// if we specify not to grab the mouse, never grab
-
+
if (!grabmouse)
return false;
@@ -298,6 +309,8 @@
{
return true;
}
+
+#endif /* #ifndef _WIN32_WCE */
}
void I_SetGrabMouseCallback(grabmouse_callback_t func)
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -272,3 +272,79 @@
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
+}
+
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -144,5 +144,7 @@
void M_BindMapControls(void);
void M_BindMenuControls(void);
+void M_ApplyPlatformDefaults(void);
+
#endif /* #ifndef __M_CONTROLS_H__ */
--- a/src/setup/mode.c
+++ b/src/setup/mode.c
@@ -127,6 +127,8 @@
void InitBindings(void)
{
+ M_ApplyPlatformDefaults();
+
// Keyboard, mouse, joystick controls
M_BindBaseControls();
--- a/wince/env.c
+++ b/wince/env.c
@@ -40,17 +40,44 @@
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: