ReactOS 0.4.15-dev-5672-gf73ac17
KbdLayout.c File Reference
#include "precomp.h"
#include <ndk/kbd.h>
#include <strsafe.h>
Include dependency graph for KbdLayout.c:

Go to the source code of this file.

Typedefs

typedef PVOID(* PFN_KBDLAYERDESCRIPTOR) (VOID)
 

Functions

static void testLayout (_In_ LPWSTR szFileName, _In_ LPWSTR szFilePath)
 
static void testKeyboardLayouts (void)
 
 START_TEST (KbdLayout)
 

Typedef Documentation

◆ PFN_KBDLAYERDESCRIPTOR

typedef PVOID(* PFN_KBDLAYERDESCRIPTOR) (VOID)

Definition at line 12 of file KbdLayout.c.

Function Documentation

◆ START_TEST()

START_TEST ( KbdLayout  )

Definition at line 110 of file KbdLayout.c.

111{
113}
static void testKeyboardLayouts(void)
Definition: KbdLayout.c:72

◆ testKeyboardLayouts()

static void testKeyboardLayouts ( void  )
static

Definition at line 72 of file KbdLayout.c.

73{
74 DWORD dwRet;
75 WCHAR szSysPath[MAX_PATH],
76 szPattern[MAX_PATH],
78 HANDLE hFindFile = INVALID_HANDLE_VALUE;
80 BOOL bFound = TRUE;
81
82 dwRet = GetSystemDirectoryW(szSysPath, ARRAYSIZE(szSysPath));
83 if (!dwRet)
84 {
85 skip("GetSystemDirectoryW failed with code %ld\n", GetLastError());
86 return;
87 }
88
89 StringCchCopyW(szPattern, ARRAYSIZE(szPattern), szSysPath);
90 StringCchCatW(szPattern, ARRAYSIZE(szPattern), L"\\kbd*.dll");
91
92 for (hFindFile = FindFirstFileW(szPattern, &wfd);
93 bFound && (hFindFile != INVALID_HANDLE_VALUE);
94 bFound = FindNextFileW(hFindFile, &wfd))
95 {
96 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
97 continue;
98
102
103 testLayout(wfd.cFileName, szFilePath);
104 }
105
106 if (hFindFile != INVALID_HANDLE_VALUE)
107 FindClose(hFindFile);
108}
static void testLayout(_In_ LPWSTR szFileName, _In_ LPWSTR szFilePath)
Definition: KbdLayout.c:14
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
static WCHAR szFilePath[]
Definition: qotd.c:14
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ testLayout()

static void testLayout ( _In_ LPWSTR  szFileName,
_In_ LPWSTR  szFilePath 
)
static

Definition at line 14 of file KbdLayout.c.

17{
19 PFN_KBDLAYERDESCRIPTOR pfnKbdLayerDescriptor;
20 PKBDTABLES pKbdTbl;
21 USHORT i, uTableSize;
22
23 trace("Testing '%ls'...\n", szFileName);
24
26 if (!hModule)
27 {
28 ok(FALSE, "LoadLibraryW failed with code %ld\n", GetLastError());
29 return;
30 }
31
32 pfnKbdLayerDescriptor = (PFN_KBDLAYERDESCRIPTOR)GetProcAddress(hModule, "KbdLayerDescriptor");
33 if (!pfnKbdLayerDescriptor)
34 {
35 ok(FALSE, "KbdLayerDescriptor not found!\n");
36 goto Cleanup;
37 }
38
39 pKbdTbl = pfnKbdLayerDescriptor();
40 if (!pKbdTbl)
41 {
42 ok(FALSE, "PKBDTABLES is NULL!\n");
43 goto Cleanup;
44 }
45
46 if (!pKbdTbl->pusVSCtoVK)
47 {
48 ok(FALSE, "pusVSCtoVK table is NULL!\n");
49 goto Cleanup;
50 }
51
52 if (wcscmp(szFileName, L"kbdnec.dll") == 0)
53 uTableSize = 128; /* Only NEC PC-9800 Japanese keyboard layout has 128 entries. */
54 else
55 uTableSize = 127;
56
57 /* Validate number of entries in pusVSCtoVK array. */
58 ok(pKbdTbl->bMaxVSCtoVK == uTableSize, "pKbdTbl->bMaxVSCtoVK = %u\n", pKbdTbl->bMaxVSCtoVK);
59
60 for (i = 0; i < pKbdTbl->bMaxVSCtoVK; ++i)
61 {
62 /* Make sure there are no Virtual Keys with zero value. */
63 if (pKbdTbl->pusVSCtoVK[i] == 0)
64 ok(FALSE, "Scan Code %u => Virtual Key %u\n", i, pKbdTbl->pusVSCtoVK[i]);
65 }
66
68 if (hModule)
70}
PVOID(* PFN_KBDLAYERDESCRIPTOR)(VOID)
Definition: KbdLayout.c:12
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define FALSE
Definition: types.h:117
HMODULE hModule
Definition: animate.c:44
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
static const WCHAR Cleanup[]
Definition: register.c:80
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: kbd.h:95
BYTE bMaxVSCtoVK
Definition: kbd.h:103
USHORT * pusVSCtoVK
Definition: kbd.h:102

Referenced by testKeyboardLayouts().