mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 08:37:42 +00:00
[Common] Remove <windows.h> references and add typedefs, part 1
This commit is contained in:
parent
4a1ec013be
commit
a36c6b312e
10 changed files with 398 additions and 48 deletions
|
|
@ -89,11 +89,8 @@ public:
|
|||
class AppIntegration:public AppActionQueue
|
||||
{
|
||||
protected:
|
||||
HWND hwnd;
|
||||
int FShiftFlags;
|
||||
public:
|
||||
AppIntegration();
|
||||
|
||||
/* Context functions */
|
||||
|
||||
virtual void AddContext(WCHAR ch) = 0; //I2436
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ typedef struct tagKEYMAN64THREADDATA
|
|||
|
||||
} KEYMAN64THREADDATA, *PKEYMAN64THREADDATA;
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
/* Thread Local Data */
|
||||
|
||||
PKEYMAN64THREADDATA ThreadGlobals();
|
||||
|
|
@ -34,6 +32,6 @@ extern wchar_t g_baseLayout[260], g_baseLayoutAlt[34];
|
|||
extern INTKEYBOARDINFO g_keyboard;
|
||||
extern KMXTest_KeyboardOption g_keyboardOption[1024];
|
||||
extern int g_keyboardOptionCount;
|
||||
|
||||
extern BOOL g_capsLock;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
#ifndef _KEYMAN64_H
|
||||
#define _KEYMAN64_H
|
||||
|
||||
/*
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
|
@ -65,9 +66,318 @@
|
|||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
*/
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef int BOOL;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
|
||||
typedef _Null_terminated_ WCHAR *NWPSTR, *LPWSTR, *PWSTR;
|
||||
typedef WCHAR *PWCHAR, *LPWCH, *PWCH;
|
||||
|
||||
typedef char CHAR;
|
||||
typedef CHAR *PCHAR, *LPCH, *PCH;
|
||||
typedef _Null_terminated_ CHAR *NPSTR, *LPSTR, *PSTR;
|
||||
|
||||
#define far
|
||||
#define near
|
||||
|
||||
typedef unsigned int UINT;
|
||||
|
||||
typedef BYTE near *PBYTE;
|
||||
typedef BYTE far *LPBYTE;
|
||||
typedef WORD near *PWORD;
|
||||
typedef WORD far *LPWORD;
|
||||
typedef DWORD near *PDWORD;
|
||||
typedef DWORD far *LPDWORD;
|
||||
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VK_LBUTTON
|
||||
|
||||
/*
|
||||
* Virtual Keys, Standard Set
|
||||
*/
|
||||
#define VK_LBUTTON 0x01
|
||||
#define VK_RBUTTON 0x02
|
||||
#define VK_CANCEL 0x03
|
||||
#define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */
|
||||
#define VK_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */
|
||||
#endif /* _WIN32_WINNT >= 0x0500 */
|
||||
|
||||
/*
|
||||
* 0x07 : unassigned
|
||||
*/
|
||||
|
||||
#define VK_BACK 0x08
|
||||
#define VK_TAB 0x09
|
||||
|
||||
/*
|
||||
* 0x0A - 0x0B : reserved
|
||||
*/
|
||||
|
||||
#define VK_CLEAR 0x0C
|
||||
#define VK_RETURN 0x0D
|
||||
|
||||
#define VK_SHIFT 0x10
|
||||
#define VK_CONTROL 0x11
|
||||
#define VK_MENU 0x12
|
||||
#define VK_PAUSE 0x13
|
||||
#define VK_CAPITAL 0x14
|
||||
|
||||
#define VK_KANA 0x15
|
||||
#define VK_HANGEUL 0x15 /* old name - should be here for compatibility */
|
||||
#define VK_HANGUL 0x15
|
||||
#define VK_JUNJA 0x17
|
||||
#define VK_FINAL 0x18
|
||||
#define VK_HANJA 0x19
|
||||
#define VK_KANJI 0x19
|
||||
|
||||
#define VK_ESCAPE 0x1B
|
||||
|
||||
#define VK_CONVERT 0x1C
|
||||
#define VK_NONCONVERT 0x1D
|
||||
#define VK_ACCEPT 0x1E
|
||||
#define VK_MODECHANGE 0x1F
|
||||
|
||||
#define VK_SPACE 0x20
|
||||
#define VK_PRIOR 0x21
|
||||
#define VK_NEXT 0x22
|
||||
#define VK_END 0x23
|
||||
#define VK_HOME 0x24
|
||||
#define VK_LEFT 0x25
|
||||
#define VK_UP 0x26
|
||||
#define VK_RIGHT 0x27
|
||||
#define VK_DOWN 0x28
|
||||
#define VK_SELECT 0x29
|
||||
#define VK_PRINT 0x2A
|
||||
#define VK_EXECUTE 0x2B
|
||||
#define VK_SNAPSHOT 0x2C
|
||||
#define VK_INSERT 0x2D
|
||||
#define VK_DELETE 0x2E
|
||||
#define VK_HELP 0x2F
|
||||
|
||||
/*
|
||||
* VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
|
||||
* 0x40 : unassigned
|
||||
* VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
|
||||
*/
|
||||
|
||||
#define VK_LWIN 0x5B
|
||||
#define VK_RWIN 0x5C
|
||||
#define VK_APPS 0x5D
|
||||
|
||||
/*
|
||||
* 0x5E : reserved
|
||||
*/
|
||||
|
||||
#define VK_SLEEP 0x5F
|
||||
|
||||
#define VK_NUMPAD0 0x60
|
||||
#define VK_NUMPAD1 0x61
|
||||
#define VK_NUMPAD2 0x62
|
||||
#define VK_NUMPAD3 0x63
|
||||
#define VK_NUMPAD4 0x64
|
||||
#define VK_NUMPAD5 0x65
|
||||
#define VK_NUMPAD6 0x66
|
||||
#define VK_NUMPAD7 0x67
|
||||
#define VK_NUMPAD8 0x68
|
||||
#define VK_NUMPAD9 0x69
|
||||
#define VK_MULTIPLY 0x6A
|
||||
#define VK_ADD 0x6B
|
||||
#define VK_SEPARATOR 0x6C
|
||||
#define VK_SUBTRACT 0x6D
|
||||
#define VK_DECIMAL 0x6E
|
||||
#define VK_DIVIDE 0x6F
|
||||
#define VK_F1 0x70
|
||||
#define VK_F2 0x71
|
||||
#define VK_F3 0x72
|
||||
#define VK_F4 0x73
|
||||
#define VK_F5 0x74
|
||||
#define VK_F6 0x75
|
||||
#define VK_F7 0x76
|
||||
#define VK_F8 0x77
|
||||
#define VK_F9 0x78
|
||||
#define VK_F10 0x79
|
||||
#define VK_F11 0x7A
|
||||
#define VK_F12 0x7B
|
||||
#define VK_F13 0x7C
|
||||
#define VK_F14 0x7D
|
||||
#define VK_F15 0x7E
|
||||
#define VK_F16 0x7F
|
||||
#define VK_F17 0x80
|
||||
#define VK_F18 0x81
|
||||
#define VK_F19 0x82
|
||||
#define VK_F20 0x83
|
||||
#define VK_F21 0x84
|
||||
#define VK_F22 0x85
|
||||
#define VK_F23 0x86
|
||||
#define VK_F24 0x87
|
||||
|
||||
/*
|
||||
* 0x88 - 0x8F : unassigned
|
||||
*/
|
||||
|
||||
#define VK_NUMLOCK 0x90
|
||||
#define VK_SCROLL 0x91
|
||||
|
||||
/*
|
||||
* NEC PC-9800 kbd definitions
|
||||
*/
|
||||
#define VK_OEM_NEC_EQUAL 0x92 // '=' key on numpad
|
||||
|
||||
/*
|
||||
* Fujitsu/OASYS kbd definitions
|
||||
*/
|
||||
#define VK_OEM_FJ_JISHO 0x92 // 'Dictionary' key
|
||||
#define VK_OEM_FJ_MASSHOU 0x93 // 'Unregister word' key
|
||||
#define VK_OEM_FJ_TOUROKU 0x94 // 'Register word' key
|
||||
#define VK_OEM_FJ_LOYA 0x95 // 'Left OYAYUBI' key
|
||||
#define VK_OEM_FJ_ROYA 0x96 // 'Right OYAYUBI' key
|
||||
|
||||
/*
|
||||
* 0x97 - 0x9F : unassigned
|
||||
*/
|
||||
|
||||
/*
|
||||
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
|
||||
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
|
||||
* No other API or message will distinguish left and right keys in this way.
|
||||
*/
|
||||
#define VK_LSHIFT 0xA0
|
||||
#define VK_RSHIFT 0xA1
|
||||
#define VK_LCONTROL 0xA2
|
||||
#define VK_RCONTROL 0xA3
|
||||
#define VK_LMENU 0xA4
|
||||
#define VK_RMENU 0xA5
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_BROWSER_BACK 0xA6
|
||||
#define VK_BROWSER_FORWARD 0xA7
|
||||
#define VK_BROWSER_REFRESH 0xA8
|
||||
#define VK_BROWSER_STOP 0xA9
|
||||
#define VK_BROWSER_SEARCH 0xAA
|
||||
#define VK_BROWSER_FAVORITES 0xAB
|
||||
#define VK_BROWSER_HOME 0xAC
|
||||
|
||||
#define VK_VOLUME_MUTE 0xAD
|
||||
#define VK_VOLUME_DOWN 0xAE
|
||||
#define VK_VOLUME_UP 0xAF
|
||||
#define VK_MEDIA_NEXT_TRACK 0xB0
|
||||
#define VK_MEDIA_PREV_TRACK 0xB1
|
||||
#define VK_MEDIA_STOP 0xB2
|
||||
#define VK_MEDIA_PLAY_PAUSE 0xB3
|
||||
#define VK_LAUNCH_MAIL 0xB4
|
||||
#define VK_LAUNCH_MEDIA_SELECT 0xB5
|
||||
#define VK_LAUNCH_APP1 0xB6
|
||||
#define VK_LAUNCH_APP2 0xB7
|
||||
|
||||
#endif /* _WIN32_WINNT >= 0x0500 */
|
||||
|
||||
/*
|
||||
* 0xB8 - 0xB9 : reserved
|
||||
*/
|
||||
|
||||
#define VK_OEM_1 0xBA // ';:' for US
|
||||
#define VK_OEM_PLUS 0xBB // '+' any country
|
||||
#define VK_OEM_COMMA 0xBC // ',' any country
|
||||
#define VK_OEM_MINUS 0xBD // '-' any country
|
||||
#define VK_OEM_PERIOD 0xBE // '.' any country
|
||||
#define VK_OEM_2 0xBF // '/?' for US
|
||||
#define VK_OEM_3 0xC0 // '`~' for US
|
||||
|
||||
/*
|
||||
* 0xC1 - 0xD7 : reserved
|
||||
*/
|
||||
|
||||
/*
|
||||
* 0xD8 - 0xDA : unassigned
|
||||
*/
|
||||
|
||||
#define VK_OEM_4 0xDB // '[{' for US
|
||||
#define VK_OEM_5 0xDC // '\|' for US
|
||||
#define VK_OEM_6 0xDD // ']}' for US
|
||||
#define VK_OEM_7 0xDE // ''"' for US
|
||||
#define VK_OEM_8 0xDF
|
||||
|
||||
/*
|
||||
* 0xE0 : reserved
|
||||
*/
|
||||
|
||||
/*
|
||||
* Various extended or enhanced keyboards
|
||||
*/
|
||||
#define VK_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd
|
||||
#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd.
|
||||
#define VK_ICO_HELP 0xE3 // Help key on ICO
|
||||
#define VK_ICO_00 0xE4 // 00 key on ICO
|
||||
|
||||
#if(WINVER >= 0x0400)
|
||||
#define VK_PROCESSKEY 0xE5
|
||||
#endif /* WINVER >= 0x0400 */
|
||||
|
||||
#define VK_ICO_CLEAR 0xE6
|
||||
|
||||
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define VK_PACKET 0xE7
|
||||
#endif /* _WIN32_WINNT >= 0x0500 */
|
||||
|
||||
/*
|
||||
* 0xE8 : unassigned
|
||||
*/
|
||||
|
||||
/*
|
||||
* Nokia/Ericsson definitions
|
||||
*/
|
||||
#define VK_OEM_RESET 0xE9
|
||||
#define VK_OEM_JUMP 0xEA
|
||||
#define VK_OEM_PA1 0xEB
|
||||
#define VK_OEM_PA2 0xEC
|
||||
#define VK_OEM_PA3 0xED
|
||||
#define VK_OEM_WSCTRL 0xEE
|
||||
#define VK_OEM_CUSEL 0xEF
|
||||
#define VK_OEM_ATTN 0xF0
|
||||
#define VK_OEM_FINISH 0xF1
|
||||
#define VK_OEM_COPY 0xF2
|
||||
#define VK_OEM_AUTO 0xF3
|
||||
#define VK_OEM_ENLW 0xF4
|
||||
#define VK_OEM_BACKTAB 0xF5
|
||||
|
||||
#define VK_ATTN 0xF6
|
||||
#define VK_CRSEL 0xF7
|
||||
#define VK_EXSEL 0xF8
|
||||
#define VK_EREOF 0xF9
|
||||
#define VK_PLAY 0xFA
|
||||
#define VK_ZOOM 0xFB
|
||||
#define VK_NONAME 0xFC
|
||||
#define VK_PA1 0xFD
|
||||
#define VK_OEM_CLEAR 0xFE
|
||||
|
||||
/*
|
||||
* 0xFF : reserved
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include "compiler.h"
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct tagSTORE
|
||||
|
|
@ -122,13 +432,6 @@ typedef struct tagKEYBOARD
|
|||
DWORD dwFlags; // Flags for the keyboard file
|
||||
|
||||
DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey)
|
||||
|
||||
//PWSTR dpName; // offset of name
|
||||
//PWSTR dpLanguageName; // offset of language name;
|
||||
//PWSTR dpCopyright; // offset of copyright
|
||||
//PWSTR dpMessage; // offset of message in Keyboard About box
|
||||
|
||||
HBITMAP hBitmap; // handle to the bitmap in the file;
|
||||
} KEYBOARD, *LPKEYBOARD;
|
||||
|
||||
typedef struct tagINTKEYBOARDOPTIONS
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
#define PCH_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <corecrt_wstring.h>
|
||||
#include "keyman64.h"
|
||||
#include "kmxtest.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
|
|
@ -108,6 +108,7 @@
|
|||
<AdditionalIncludeDirectories>$(ProjectDir)inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PreprocessorDefinitions>;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
|
@ -115,6 +116,7 @@
|
|||
<AdditionalIncludeDirectories>$(ProjectDir)inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PreprocessorDefinitions>;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
Authors: mcdurdin
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
|
@ -13,19 +14,48 @@ inline BOOL ShouldDebug() {
|
|||
#define TAB "\t"
|
||||
#define NL "\n"
|
||||
|
||||
#include <chrono>
|
||||
#define _USE_WINDOWS
|
||||
|
||||
#ifdef _USE_WINDOWS
|
||||
#define DECLSPEC_IMPORT __declspec(dllimport)
|
||||
#define WINBASEAPI DECLSPEC_IMPORT
|
||||
#define VOID void
|
||||
#define WINAPI __stdcall
|
||||
|
||||
extern "C"
|
||||
__declspec(dllimport)
|
||||
void
|
||||
__stdcall
|
||||
OutputDebugStringA(
|
||||
char *lpOutputString
|
||||
);
|
||||
|
||||
#else
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
// simulation of Windows GetTickCount()
|
||||
unsigned long
|
||||
GetTickCount()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return (unsigned long) duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
int DebugLog_1(char *file, int line, char *function, char *fmt, ...)
|
||||
{
|
||||
char fmtbuf[256];
|
||||
|
||||
va_list vars;
|
||||
va_start(vars, fmt);
|
||||
vsnprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547
|
||||
vsnprintf_s(fmtbuf, sizeof(fmtbuf) / sizeof(fmtbuf[0]), _TRUNCATE, fmt, vars); // I2248 // I3547
|
||||
fmtbuf[255] = 0;
|
||||
|
||||
if(g_debug_KeymanLog) {
|
||||
if(g_debug_ToConsole) { // I3951
|
||||
char windowinfo[1024];
|
||||
wsprintf(windowinfo,
|
||||
sprintf(windowinfo,
|
||||
"%d" TAB //"TickCount" TAB
|
||||
"%s:%d" TAB //"SourceFile" TAB
|
||||
"%s" TAB //"Function"
|
||||
|
|
@ -35,7 +65,11 @@ int DebugLog_1(char *file, int line, char *function, char *fmt, ...)
|
|||
file, line, //"SourceFile" TAB
|
||||
function, //"Function" TAB
|
||||
fmtbuf); //"Message"
|
||||
OutputDebugString(windowinfo);
|
||||
#ifdef _USE_WINDOWS
|
||||
OutputDebugStringA(windowinfo);
|
||||
#else
|
||||
syslog(LOG_DEBUG, "%s", windowinfo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,10 +85,10 @@ char *Debug_VirtualKey(WORD vk) {
|
|||
}
|
||||
|
||||
if (vk < 256) {
|
||||
wsprintf(buf, "['%s' 0x%x]", VKeyNames[vk], vk);
|
||||
sprintf(buf, "['%s' 0x%x]", VKeyNames[vk], vk);
|
||||
}
|
||||
else {
|
||||
wsprintf(buf, "[0x%x]", vk);
|
||||
sprintf(buf, "[0x%x]", vk);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -68,7 +102,7 @@ char *Debug_UnicodeString(PWSTR s, int x) {
|
|||
char *q;
|
||||
for (p = s, q = bufout[x]; *p && (p - s < 128); p++)
|
||||
{
|
||||
wsprintf(q, "U+%4.4X ", *p); q = strchr(q, 0);
|
||||
sprintf(q, "U+%4.4X ", *p); q = strchr(q, 0);
|
||||
}
|
||||
//WideCharToMultiByte(CP_ACP, 0, buf, -1, bufout, 128, NULL, NULL);
|
||||
return bufout[x];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
Authors: mcdurdin
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include <share.h>
|
||||
|
||||
BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz);
|
||||
BOOL LoadKeyboard(LPSTR fileName, LPKEYBOARD *lpKeyboard);
|
||||
|
|
@ -84,7 +85,7 @@ BOOL LoadKeyboard(LPSTR fileName, LPKEYBOARD *lpKeyboard)
|
|||
{
|
||||
DWORD sz;
|
||||
LPBYTE buf;
|
||||
HANDLE hFile;
|
||||
FILE *fp;
|
||||
LPKEYBOARD kbp;
|
||||
PBYTE filebase;
|
||||
|
||||
|
|
@ -94,14 +95,28 @@ BOOL LoadKeyboard(LPSTR fileName, LPKEYBOARD *lpKeyboard)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
fp = _fsopen(fileName, "rb", _SH_DENYWR);
|
||||
if(fp == NULL)
|
||||
{
|
||||
DebugLog("Could not open file");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sz = GetFileSize(hFile, NULL);
|
||||
if (fseek(fp, 0, SEEK_END) != 0) {
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sz = ftell(fp);
|
||||
if (sz < 0) {
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (fseek(fp, 0, SEEK_SET) != 0) {
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
buf = new BYTE[sz*3];
|
||||
|
|
@ -111,7 +126,7 @@ BOOL LoadKeyboard(LPSTR fileName, LPKEYBOARD *lpKeyboard)
|
|||
|
||||
if(!buf)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
fclose(fp);
|
||||
DebugLog("Not allocmem");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -121,8 +136,12 @@ BOOL LoadKeyboard(LPSTR fileName, LPKEYBOARD *lpKeyboard)
|
|||
filebase = buf;
|
||||
#endif
|
||||
|
||||
ReadFile(hFile, filebase, sz, &sz, NULL);
|
||||
CloseHandle(hFile);
|
||||
if (fread(filebase, 1, sz, fp) < sz) {
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if(*LPDWORD(filebase) != FILEID_COMPILED)
|
||||
{
|
||||
|
|
@ -246,8 +265,6 @@ LPKEYBOARD CopyKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize)
|
|||
|
||||
LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFileSize);
|
||||
|
||||
DWORD i, j;
|
||||
PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base;
|
||||
PCOMP_GROUP cgp;
|
||||
|
|
@ -261,8 +278,6 @@ LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize)
|
|||
kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray);
|
||||
kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray);
|
||||
|
||||
kbp->hBitmap = NULL;
|
||||
|
||||
for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++)
|
||||
{
|
||||
sp->dpName = StringOffset(base, csp->dpName);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
Authors: mcdurdin
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include <stdlib.h>
|
||||
#include <corecrt_wstring.h>
|
||||
|
||||
const LPSTR ItemTypes[QIT_MAX+1] = {
|
||||
"QIT_VKEYDOWN", "QIT_VKEYUP", "QIT_VSHIFTDOWN", "QIT_VSHIFTUP",
|
||||
|
|
@ -138,7 +140,7 @@ BOOL AppActionQueue::QueueAction(int ItemType, DWORD dwData)
|
|||
{
|
||||
if(QueueSize > MAXACTIONQUEUE - 1)
|
||||
{
|
||||
MessageBeep(0xFFFFFFFF);
|
||||
DebugLog("App::QueueAction: queue size exceeded");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +154,3 @@ BOOL AppActionQueue::QueueAction(int ItemType, DWORD dwData)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* AppIntegration */
|
||||
|
||||
AppIntegration::AppIntegration()
|
||||
{
|
||||
hwnd = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void ResetCapsLock(void)
|
|||
if(g_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF)
|
||||
{
|
||||
DebugLog("ResetCapsLock: caps lock should be always off");
|
||||
if(GetKeyState(VK_CAPITAL) & 1)
|
||||
if(g_capsLock)
|
||||
{
|
||||
DebugLog("ResetCapsLock: caps lock is on, switching off caps lock");
|
||||
GetApp()->QueueAction(QIT_CAPSLOCK, 0);
|
||||
|
|
@ -25,14 +25,14 @@ void KeyCapsLockPress(BOOL FIsUp) // I3284 - void // I3529
|
|||
{
|
||||
if(g_keyboard.Keyboard->dwFlags & KF_CAPSONONLY)
|
||||
{
|
||||
if(FIsUp && !(GetKeyState(VK_CAPITAL) & 1)) // I267 - 24/11/2006 invert GetKeyState test
|
||||
if(FIsUp && !g_capsLock) // I267 - 24/11/2006 invert GetKeyState test
|
||||
{
|
||||
GetApp()->QueueAction(QIT_CAPSLOCK, 1);
|
||||
}
|
||||
}
|
||||
else if(g_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF)
|
||||
{
|
||||
if(!FIsUp && (GetKeyState(VK_CAPITAL) & 1))
|
||||
if(!FIsUp && g_capsLock)
|
||||
{ // I267 - 24/11/2006 invert GetKeyState test
|
||||
GetApp()->QueueAction(QIT_CAPSLOCK, 0);
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ void KeyCapsLockPress(BOOL FIsUp) // I3284 - void // I3529
|
|||
|
||||
void KeyShiftPress(BOOL FIsUp) // I3284 - void // I3529
|
||||
{
|
||||
if((GetKeyState(VK_CAPITAL) & 1) == 0) return;
|
||||
if(!g_capsLock) return;
|
||||
|
||||
if(g_keyboard.Keyboard->dwFlags & KF_SHIFTFREESCAPS)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <corecrt_wstring.h>
|
||||
#include <string.h>
|
||||
|
||||
struct KMXTest_KeyEvent {
|
||||
UINT vkey;
|
||||
|
|
@ -46,6 +48,7 @@ wchar_t g_baseLayout[260] = L"kbdus.dll",
|
|||
BOOL g_simulateAltGr = FALSE,
|
||||
g_baseLayoutGivesCtrlRAltForRAlt = FALSE;
|
||||
char g_platform[128] = "windows desktop hardware native"; // TODO
|
||||
BOOL g_capsLock = FALSE;
|
||||
|
||||
/* Constants - to refactor */
|
||||
extern const struct KMXTest_ModifierNames s_modifierNames[];
|
||||
|
|
@ -58,6 +61,7 @@ void print_default_environment() {
|
|||
wprintf(L" env.base_layout=%s\n", g_baseLayout);
|
||||
wprintf(L" env.base_layout_alt=%s\n", g_baseLayoutAlt);
|
||||
wprintf(L" env.platform=%hs\n", g_platform);
|
||||
wprintf(L" env.caps_lock=%d\n", g_capsLock);
|
||||
}
|
||||
|
||||
BOOL addKeyboardOption(char *storeName, char *value) {
|
||||
|
|
@ -95,6 +99,9 @@ BOOL addOption(char *val) {
|
|||
else if (!_strnicmp(val, "env.platform", len)) {
|
||||
strcpy_s(g_platform, p);
|
||||
}
|
||||
else if (!_strnicmp(val, "env.caps_lock", len)) {
|
||||
g_capsLock = !!atoi(p);
|
||||
}
|
||||
else if (!_strnicmp(val, "opt.", 4)) {
|
||||
*(p - 1) = 0;
|
||||
if (!addKeyboardOption(val + 4, p)) {
|
||||
|
|
@ -322,11 +329,6 @@ BOOL ReleaseKeyboardMemory(LPKEYBOARD kbd)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ConvertStringToGuid(WCHAR *buf, GUID *guid) // I3581
|
||||
{
|
||||
return IIDFromString(buf, guid) == S_OK;
|
||||
}
|
||||
|
||||
PWSTR GetSystemStore(LPKEYBOARD kb, DWORD SystemID)
|
||||
{
|
||||
for (DWORD i = 0; i < kb->cxStoreArray; i++)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue