implemented GetKeyboardLayoutNameW
[reactos.git] / reactos / lib / user32 / windows / input.c
index cc1b0c4..5f30b21 100644 (file)
@@ -29,6 +29,8 @@
 /* INCLUDES ******************************************************************/
 
 #include <user32.h>
+#define NDEBUG
+#include <debug.h>
 
 /* GLOBALS *******************************************************************/
 
@@ -162,24 +164,22 @@ GetDoubleClickTime(VOID)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 HKL STDCALL
 GetKeyboardLayout(DWORD idThread)
 {
-  UNIMPLEMENTED;
-  return (HKL)0;
+  return (HKL)NtUserCallOneParam((DWORD) idThread,  ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT);
 }
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 UINT STDCALL
 GetKBCodePage(VOID)
 {
-  UNIMPLEMENTED;
-  return 0;
+  return GetOEMCP();
 }
 
 
@@ -246,29 +246,31 @@ GetKeyboardLayoutList(int nBuff,
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL STDCALL
 GetKeyboardLayoutNameA(LPSTR pwszKLID)
 {
-  UNIMPLEMENTED;
+  WCHAR buf[KL_NAMELENGTH];
+    
+  if (GetKeyboardLayoutNameW(buf))
+    return WideCharToMultiByte( CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL ) != 0;
   return FALSE;
 }
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL STDCALL
 GetKeyboardLayoutNameW(LPWSTR pwszKLID)
 {
-  UNIMPLEMENTED;
-  return FALSE;
+  return NtUserGetKeyboardLayoutName( pwszKLID );
 }
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL STDCALL
 GetKeyboardState(PBYTE lpKeyState)
@@ -279,13 +281,12 @@ GetKeyboardState(PBYTE lpKeyState)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 int STDCALL
 GetKeyboardType(int nTypeFlag)
 {
-  UNIMPLEMENTED;
-  return 0;
+return (int)NtUserCallOneParam((DWORD) nTypeFlag,  ONEPARAM_ROUTINE_GETKEYBOARDTYPE);
 }
 
 
@@ -301,14 +302,22 @@ GetLastInputInfo(PLASTINPUTINFO plii)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 HKL STDCALL
 LoadKeyboardLayoutA(LPCSTR pwszKLID,
                    UINT Flags)
 {
-  UNIMPLEMENTED;
-  return (HKL)0;
+  HKL ret;
+  UNICODE_STRING pwszKLIDW;
+        
+  if (pwszKLID) RtlCreateUnicodeStringFromAsciiz(&pwszKLIDW, pwszKLID);
+  else pwszKLIDW.Buffer = NULL;
+                
+  ret = LoadKeyboardLayoutW(pwszKLIDW.Buffer, Flags);
+  RtlFreeUnicodeString(&pwszKLIDW);
+  return ret;
+
 }
 
 
@@ -371,13 +380,24 @@ MapVirtualKeyW(UINT uCode,
 
 
 /*
- * @unimplemented
- */
+ * @implemented
+ */ 
 DWORD STDCALL
 OemKeyScan(WORD wOemChar)
 {
-  UNIMPLEMENTED;
-  return 0;
+  WCHAR p;
+  SHORT Vk;
+  UINT Scan;
+
+  MultiByteToWideChar(CP_OEMCP, 0, (PCSTR)&wOemChar, 1, &p, 1);
+  Vk = VkKeyScanW(p);
+  Scan = MapVirtualKeyW((Vk & 0x00ff), 0);
+  if(!Scan) return -1;
+  /* 
+     Page 450-1, MS W2k SuperBible by SAMS. Return, low word has the
+     scan code and high word has the shift state.
+   */
+  return ((Vk & 0xff00) << 8) | Scan;
 }
 
 
@@ -411,7 +431,7 @@ SetDoubleClickTime(UINT uInterval)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 HWND STDCALL
 SetFocus(HWND hWnd)
@@ -421,7 +441,7 @@ SetFocus(HWND hWnd)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL STDCALL
 SetKeyboardState(LPBYTE lpKeyState)
@@ -495,7 +515,7 @@ ToUnicode(UINT wVirtKey,
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 int STDCALL
 ToUnicodeEx(UINT wVirtKey,
@@ -565,14 +585,13 @@ VkKeyScanExA(CHAR ch,
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 SHORT STDCALL
 VkKeyScanExW(WCHAR ch,
             HKL dwhkl)
 {
-  UNIMPLEMENTED;
-  return -1;
+  return (SHORT) NtUserVkKeyScanEx((DWORD) ch,(DWORD) dwhkl,(DWORD)NULL);
 }