From e889fd8e7bed1a594528b96bf4536a7254dcff3a Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Aug 2024 14:09:58 +0200 Subject: [PATCH] refactor(mac): use km_types from common --- mac/mcompile/keymap.cpp | 8 +-- mac/mcompile/keymap.h | 37 ++++++++++- mac/mcompile/km_types.h | 111 ------------------------------- mac/mcompile/mc_import_rules.cpp | 50 +++++++------- mac/mcompile/mc_kmxfile.cpp | 6 +- mac/mcompile/mc_kmxfile.h | 2 +- mac/mcompile/mcompile.cpp | 33 ++++----- mac/mcompile/mcompile.h | 2 +- mac/mcompile/u16.h | 2 +- 9 files changed, 86 insertions(+), 165 deletions(-) delete mode 100644 mac/mcompile/km_types.h diff --git a/mac/mcompile/keymap.cpp b/mac/mcompile/keymap.cpp index c3ea47c979..0a9e520f63 100644 --- a/mac/mcompile/keymap.cpp +++ b/mac/mcompile/keymap.cpp @@ -154,7 +154,7 @@ vec_dword_2D mac_create_empty_2D_Vector(int dim_rows, int dim_ss) { * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard * @param keyboard_layout pointer to currently used (underlying) keybord layout * @return 0 on success; - * 1 if the initialization of the underlying vector failes; + * 1 if the initialization of the underlying vector fails; * 2 if data of less than 2 keyboards is contained in all_vector; */ int mac_append_underlying_ToVector(vec_dword_3D& all_vector, const UCKeyboardLayout* keyboard_layout) { @@ -190,8 +190,8 @@ int mac_append_underlying_ToVector(vec_dword_3D& all_vector, const UCKeyboardLay } /** - * @brief create a pointer to pointer of the current keyboard_layout for later use - * @param keyboard_layout pointer to pointer to currently used (underlying) keyboard layout + * @brief initializes GDK and return the current keyboard_layout for later use + * @param keyboard_layoutout[out] currently used (underlying) keyboard layout * @return 0 on success; * 1 if the display is not found; * 2 if the keymap is not found @@ -302,7 +302,7 @@ KMX_DWORD mac_KMX_get_KeyVal_From_KeyCode_dk(const UCKeyboardLayout* keyboard_la * @return 0xFFFF in case a deadkey was found, then the deadkey is stored in deadKey; * or else the keyval obtained from Keycode and shiftstate and caps; */ -KMX_DWORD mac_KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(const UCKeyboardLayout* keyboard_layout, UINT kc_underlying, UINT vk_ShiftState, PKMX_WCHAR deadKey) { +KMX_DWORD mac_KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(const UCKeyboardLayout* keyboard_layout, KMX_DWORD kc_underlying, KMX_DWORD vk_ShiftState, PKMX_WCHAR deadKey) { PKMX_WCHAR dky = NULL; UInt32 isdk = 0; KMX_DWORD keyV; diff --git a/mac/mcompile/keymap.h b/mac/mcompile/keymap.h index 847b1f482b..ff0bcf1f85 100644 --- a/mac/mcompile/keymap.h +++ b/mac/mcompile/keymap.h @@ -21,7 +21,38 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; +#define VK_SPACE 0x20 +#define VK_COLON 0xBA +#define VK_EQUAL 0xBB +#define VK_COMMA 0xBC +#define VK_HYPHEN 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_ACCENT 0xC0 +#define VK_LBRKT 0xDB +#define VK_BKSLASH 0xDC +#define VK_RBRKT 0xDD +#define VK_QUOTE 0xDE +#define VK_xDF 0xDF +#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. +#define VK_DIVIDE 0x6F +#define VK_CANCEL 3 +#define VK_DECIMAL 0x2E + +#define VK_OEM_CLEAR 0xFE +#define VK_LSHIFT 0xA0 +#define VK_RSHIFT 0xA1 +#define VK_LCONTROL 0xA2 +#define VK_RCONTROL 0xA3 +#define VK_LMENU 0xA4 +#define VK_RMENU 0xA5 + +#define VK_SHIFT 0x10 +#define VK_CONTROL 0x11 +#define VK_MENU 0x12 +#define VK_PAUSE 0x13 +#define VK_CAPITAL 0x14 // Map of all US English virtual key codes that we can translate const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', @@ -93,7 +124,7 @@ bool mac_InitializeUCHR(const UCKeyboardLayout** keyboard_layout); * @brief array of USVirtualKey-ScanCode-pairs * we use the same type of array as throughout Keyman even though we have lots of unused fields */ -const UINT mac_USVirtualKeyToScanCode[256] = { +const KMX_DWORD mac_USVirtualKeyToScanCode[256] = { 0xFFFF, // not used 0xFFFF, // not used 0xFFFF, // not used @@ -356,7 +387,7 @@ const UINT mac_USVirtualKeyToScanCode[256] = { * @brief array of ScanCode-USVirtualKey-pairs * we use the same type of array as throughout Keyman even though we have lots of unused fields */ -const UINT mac_ScanCodeToUSVirtualKey[128] = { +const KMX_DWORD mac_ScanCodeToUSVirtualKey[128] = { 0x41, // L"K_A", // &H41 0x53, // L"K_S", // &H53 0x44, // L"K_D", // &H44 @@ -494,7 +525,7 @@ KMX_DWORD mac_KMX_get_KeyVal_From_KeyCode(const UCKeyboardLayout* keyboard_layou KMX_DWORD mac_KMX_get_KeyVal_From_KeyCode_dk(const UCKeyboardLayout* keyboard_layout, int keycode, int shiftstate_mac, int caps, UInt32& deadkeystate); /** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ -KMX_DWORD mac_KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(const UCKeyboardLayout* keyboard_layout, UINT kc_underlying, UINT vk_ShiftState, PKMX_WCHAR deadKey); +KMX_DWORD mac_KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(const UCKeyboardLayout* keyboard_layout, KMX_DWORD kc_underlying, KMX_DWORD vk_ShiftState, PKMX_WCHAR deadKey); /** @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard */ KMX_DWORD mac_KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us); diff --git a/mac/mcompile/km_types.h b/mac/mcompile/km_types.h deleted file mode 100644 index 5381ff1e6a..0000000000 --- a/mac/mcompile/km_types.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once -#ifndef KM_TYPES -#define KM_TYPES -#include -/* -#if defined(_WIN32) || defined(_WIN64) -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#endif -*/ - -#if defined(__LP64__) || defined(_LP64) -/* 64-bit, g++ */ -#define KMX_64BIT -#endif - -#if defined(_WIN64) && !defined(USE_64) -/* 64-bit, Windows */ -#define KMX_64BIT -#endif - -typedef uint32_t KMX_DWORD; -typedef int32_t KMX_BOOL; -typedef uint8_t KMX_BYTE; -typedef uint16_t KMX_WORD; - -#if defined(__cplusplus) -typedef char16_t km_kbp_cp; -typedef char32_t km_kbp_usv; -#else -typedef uint16_t km_kbp_cp; // code point -typedef uint32_t km_kbp_usv; // Unicode Scalar Value -#endif - -typedef unsigned int UINT; -typedef unsigned long DWORD; - -typedef unsigned char BYTE; -typedef char KMX_CHAR; - -typedef char16_t KMX_WCHAR; -typedef KMX_WCHAR* PKMX_WCHAR; - -typedef wchar_t WCHAR; -typedef WCHAR KMX_WCHART; -typedef wchar_t* PWSTR; -typedef WCHAR* PWCHAR; - -typedef uint8_t* LPKMX_BYTE; -typedef uint8_t* PKMX_BYTE; - -typedef KMX_BYTE* PKMX_BYTE; -typedef KMX_DWORD* PKMX_DWORD; -typedef int BOOL; - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -// Macros and types to support char16_t vs wchar_t depending on project - -#ifdef USE_CHAR16_T -#define lpuch(x) u ## x -typedef km_kbp_cp KMX_UCHAR; -#else -#define lpuch(x) L ## x -typedef wchar_t KMX_UCHAR; -#endif - -typedef KMX_UCHAR* KMX_PUCHAR; - -#define VK_SPACE 0x20 -#define VK_COLON 0xBA -#define VK_EQUAL 0xBB -#define VK_COMMA 0xBC -#define VK_HYPHEN 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_ACCENT 0xC0 -#define VK_LBRKT 0xDB -#define VK_BKSLASH 0xDC -#define VK_RBRKT 0xDD -#define VK_QUOTE 0xDE -#define VK_xDF 0xDF -#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. - -#define VK_DIVIDE 0x6F -#define VK_CANCEL 3 -#define VK_DECIMAL 0x2E - -#define VK_OEM_CLEAR 0xFE -#define VK_LSHIFT 0xA0 -#define VK_RSHIFT 0xA1 -#define VK_LCONTROL 0xA2 -#define VK_RCONTROL 0xA3 -#define VK_LMENU 0xA4 -#define VK_RMENU 0xA5 - -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 - -#endif /*KM_TYPES*/ diff --git a/mac/mcompile/mc_import_rules.cpp b/mac/mcompile/mc_import_rules.cpp index 7515f01e8e..73e1f25dd9 100644 --- a/mac/mcompile/mc_import_rules.cpp +++ b/mac/mcompile/mc_import_rules.cpp @@ -128,35 +128,35 @@ KMX_WCHAR mac_KMX_DeadKeyMap(int index, std::vector*deadkeys, int dead */ class mac_KMX_VirtualKey { private: - UINT m_vk; - UINT m_sc; + KMX_DWORD m_vk; + KMX_DWORD m_sc; bool m_rgfDeadKey[10][2]; std::u16string m_rgss[10][2]; public: - mac_KMX_VirtualKey(UINT scanCode) { + mac_KMX_VirtualKey(KMX_DWORD scanCode) { this->m_vk = mac_KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); this->m_sc = scanCode; memset(this->m_rgfDeadKey, 0, sizeof(this->m_rgfDeadKey)); } /** @brief return member variable virtual key */ - UINT VK() { + KMX_DWORD VK() { return this->m_vk; } /** @brief return member variable scancode */ - UINT SC() { + KMX_DWORD SC() { return this->m_sc; } std::u16string mac_KMX_GetShiftState(ShiftState shiftState, bool capsLock) { - return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; + return this->m_rgss[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)]; } void mac_KMX_SetShiftState(ShiftState shiftState, std::u16string value, bool isDeadKey, bool capsLock) { - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + this->m_rgfDeadKey[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)] = value; } bool mac_KMX_IsSGCAPS() { @@ -222,7 +222,7 @@ public: return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { + KMX_DWORD KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } @@ -263,7 +263,7 @@ public: } /** @brief edit the row of kmx-file */ - bool mac_KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, BOOL bDeadkeyConversion, vec_dword_3D& all_vector, const UCKeyboardLayout* keyboard_layout) { // I4552 + bool mac_KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, bool bDeadkeyConversion, vec_dword_3D& all_vector, const UCKeyboardLayout* keyboard_layout) { // I4552 // Get the CAPSLOCK value /*int capslock = (this->mac_KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -353,7 +353,7 @@ public: class mac_KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; - UINT m_XxxxVk; + KMX_DWORD m_XxxxVk; public: mac_KMX_Loader() { @@ -361,11 +361,11 @@ public: memset(lpKeyStateNull, 0, sizeof(lpKeyStateNull)); } - UINT Get_XxxxVk() { + KMX_DWORD Get_XxxxVk() { return m_XxxxVk; } - void Set_XxxxVk(UINT value) { + void Set_XxxxVk(KMX_DWORD value) { m_XxxxVk = value; } @@ -378,7 +378,7 @@ public: } DeadKey* ProcessDeadKey( - UINT iKeyDead, // The index into the VirtualKey of the dead key + KMX_DWORD iKeyDead, // The index into the VirtualKey of the dead key ShiftState shiftStateDead, // The shiftstate that contains the dead key std::vector rgKey, // Our array of dead keys bool fCapsLock, // Was the caps lock key pressed? @@ -456,7 +456,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // flag that the VK is valid, and it can store the SC value. // Windows and Linux Keycodes start with 1; Mac keycodes start with 0 - for (UINT sc = 0x00; sc <= 0x7f; sc++) { + for (KMX_DWORD sc = 0x00; sc <= 0x7f; sc++) { /* HERE IS A BIG DIFFERENCE COMPARED TO MCOMPILE FOR WINDOWS: * mcompile on Windows fills rgkey.m_vk with the VK of the Underlying keyboard * mcompile for macOS fills rgkey.m_vk with the VK of the US keyboard @@ -476,7 +476,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe } // in this part we skip shiftstates 4, 5, 8, 9 - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if (rgKey[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for (ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -507,7 +507,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe sbBuffer[2] = 0; rgKey[iKey]->mac_KMX_SetShiftState(ss, sbBuffer, true, (caps == 0)); DeadKey* dk = NULL; - for (UINT iDead = 0; iDead < alDead.size(); iDead++) { + for (KMX_DWORD iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; if (dk->KMX_DeadCharacter() == rgKey[iKey]->mac_KMX_GetShiftState(ss, caps == 0)[0]) { break; @@ -537,10 +537,10 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // kp->dpGroupArray = gp; - for (UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + for (KMX_DWORD i = 0; i < kp->cxGroupArray; i++, gp++) { LPKMX_KEY kkp = gp->dpKeyArray; - for (UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + for (KMX_DWORD j = 0; j < gp->cxKeyArray; j++, kkp++) { nDeadkey = std::max(nDeadkey, mac_KMX_GetMaxDeadkeyIndex(kkp->dpContext)); nDeadkey = std::max(nDeadkey, mac_KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } @@ -551,8 +551,8 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // calculate the required size of `gp->dpKeyArray` - UINT nkeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + KMX_DWORD nkeys = 0; + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->mac_KMX_IsKeymanUsedKey() && (!rgKey[iKey]->mac_KMX_IsEmpty())) { nkeys += rgKey[iKey]->mac_KMX_GetKeyCount(loader.KMX_MaxShiftState()); } @@ -571,7 +571,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // Fill in the new rules // nkeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->mac_KMX_IsKeymanUsedKey() && (!rgKey[iKey]->mac_KMX_IsEmpty())) { if (rgKey[iKey]->mac_KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector, *keyboard_layout)) { // I4552 nkeys += rgKey[iKey]->mac_KMX_GetKeyCount(loader.KMX_MaxShiftState()); @@ -585,7 +585,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // Add nomatch control to each terminating 'using keys' group // I4550 // LPKMX_GROUP gp2 = kp->dpGroupArray; - for (UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + for (KMX_DWORD i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if (gp2->fUsingKeys && gp2->dpNoMatch == NULL) { KMX_WCHAR* p = gp2->dpNoMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; @@ -597,7 +597,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. // - UINT j; + KMX_DWORD j; LPKMX_KEY kkp; for (j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { if ((kkp->ShiftFlags & (K_CTRLFLAG | K_ALTFLAG | LCTRLFLAG | LALTFLAG | RCTRLFLAG | RALTFLAG)) != 0) { @@ -652,7 +652,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, const UCKe int nStoreBase = kp->cxStoreArray; kp->cxStoreArray += alDead.size() * 2; - for (UINT i = 0; i < alDead.size(); i++) { + for (KMX_DWORD i = 0; i < alDead.size(); i++) { DeadKey* dk = alDead[i]; sp->dpName = NULL; diff --git a/mac/mcompile/mc_kmxfile.cpp b/mac/mcompile/mc_kmxfile.cpp index 0f1b7ea272..86845f8165 100644 --- a/mac/mcompile/mc_kmxfile.cpp +++ b/mac/mcompile/mc_kmxfile.cpp @@ -41,7 +41,7 @@ const int CODE__SIZE[] = { }; /** @brief check if the file has correct version */ -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); +KMX_BOOL KMX_VerifyKeyboard(PKMX_BYTE filebase, KMX_DWORD file_size); /** @brief Fixup the keyboard by expanding pointers. */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); @@ -64,7 +64,7 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX PKMX_COMP_KEY kp; PKMX_BYTE buf; KMX_DWORD size, offset; - DWORD i, j; + KMX_DWORD i, j; // Calculate how much memory to allocate size = sizeof(KMX_COMP_KEYBOARD) + @@ -495,7 +495,7 @@ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { * @return true if successful; * false if not */ -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size) { +KMX_BOOL KMX_VerifyKeyboard(PKMX_BYTE filebase, KMX_DWORD file_size) { KMX_DWORD i; PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; PKMX_COMP_STORE csp; diff --git a/mac/mcompile/mc_kmxfile.h b/mac/mcompile/mc_kmxfile.h index e3aadf9c5a..12d9ba4a8c 100644 --- a/mac/mcompile/mc_kmxfile.h +++ b/mac/mcompile/mc_kmxfile.h @@ -2,7 +2,7 @@ #ifndef MC_KMXFILE_H #define MC_KMXFILE_H -#include "km_types.h" +#include "../../common/include/km_types.h" #include "kmx_file.h" #include "mcompile.h" diff --git a/mac/mcompile/mcompile.cpp b/mac/mcompile/mcompile.cpp index 8f1453f282..a13d04d7fa 100644 --- a/mac/mcompile/mcompile.cpp +++ b/mac/mcompile/mcompile.cpp @@ -10,6 +10,7 @@ */ #include +#include #include #include "mcompile.h" #include "u16.h" @@ -24,7 +25,7 @@ bool mac_KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D &all_vector, const UCKe int mac_run(int argc, char* argv[]); /** @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard */ -int mac_KMX_GetDeadkeys(const UCKeyboardLayout* keyboard_layout, vec_dword_3D& all_vector, KMX_WCHAR deadkey, UINT shift_dk, KMX_WORD* outputPairs); // returns array of [usvk, ch_out] pairs +int mac_KMX_GetDeadkeys(const UCKeyboardLayout* keyboard_layout, vec_dword_3D& all_vector, KMX_WCHAR deadkey, KMX_DWORD shift_dk, KMX_WORD* outputPairs); // returns array of [usvk, ch_out] pairs std::vector KMX_FDeadkeys; // I4353 @@ -142,7 +143,7 @@ int mac_run(int argc, char* argv[]) { } // Map of all shift states that we will work with -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; +const KMX_DWORD VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; // // TranslateKey @@ -158,7 +159,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void mac_KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void mac_KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -190,7 +191,7 @@ void mac_KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void mac_KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void mac_KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { mac_KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } @@ -203,7 +204,7 @@ void mac_KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHA * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void mac_KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void mac_KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { mac_KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); @@ -253,7 +254,7 @@ void mac_KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { * @param shift shiftstate * @param ch character of the underlying keyboard */ -void mac_KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void mac_KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { if ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -290,7 +291,7 @@ void mac_KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, * @param shift shiftstate * @param character of the underlying keyboard */ -void mac_KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void mac_KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { mac_KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } @@ -304,7 +305,7 @@ void mac_KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WOR * @param shift shiftstate * @param character of the underlying keyboard */ -void mac_KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void mac_KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { mac_KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); @@ -319,7 +320,7 @@ void mac_KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX * @param vk a keyvalue of the US keyboard * @param shift shiftstate */ -void mac_KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { +void mac_KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -381,7 +382,7 @@ KMX_WCHAR mac_KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { LPKMX_GROUP gp; LPKMX_KEY kp; LPKMX_STORE sp; - UINT i, j; + KMX_DWORD i, j; KMX_WCHAR dkid = 0; static KMX_WCHAR s_next_dkid = 0; static KMX_dkidmap* s_dkids = NULL; @@ -437,7 +438,7 @@ KMX_WCHAR mac_KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { * @param keymap pointer to the currently used (underlying) keyboard Layout * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards */ -void mac_KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, const UCKeyboardLayout* keyboard_layout) { +void mac_KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, KMX_DWORD shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, const UCKeyboardLayout* keyboard_layout) { KMX_WORD deadkeys[512] = {0}; KMX_WORD* pdk; @@ -454,7 +455,7 @@ void mac_KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_ while (*pdk) { // Look up the ch - UINT KeyValUnderlying = mac_KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); + KMX_DWORD KeyValUnderlying = mac_KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); mac_KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk + 1), *(pdk + 2)); pdk += 3; } @@ -468,7 +469,7 @@ void mac_KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_ */ KMX_BOOL mac_KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; - UINT i; + KMX_DWORD i; for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { if (sp->dwSystemID == TSS_MNEMONIC) { if (!sp->dpString) { @@ -529,7 +530,7 @@ KMX_BOOL mac_KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, int for (int i = 0; KMX_VKMap[i]; i++) { // I4651 // Windows uses VK as sorting order in rgkey[], Linux and macOS use SC/Keycode as sorting order - UINT scUnderlying = mac_KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); + KMX_DWORD scUnderlying = mac_KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = mac_KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keyboard_layout, scUnderlying, VKShiftState[j], &DeadKey); // wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); @@ -565,7 +566,7 @@ KMX_BOOL mac_KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, int * @param[out] outputPairs pointer to array of [usvk, ch_out] pairs * @return size of array of [usvk, ch_out] pairs */ -int mac_KMX_GetDeadkeys(const UCKeyboardLayout* keyboard_layout, vec_dword_3D& all_vector, KMX_WCHAR deadkey, UINT shift_dk, KMX_WORD* outputPairs) { +int mac_KMX_GetDeadkeys(const UCKeyboardLayout* keyboard_layout, vec_dword_3D& all_vector, KMX_WCHAR deadkey, KMX_DWORD shift_dk, KMX_WORD* outputPairs) { UInt32 deadkeystate; UniCharCount maxStringlength = 5; UniCharCount actualStringlength = 0; @@ -619,7 +620,7 @@ int mac_KMX_GetDeadkeys(const UCKeyboardLayout* keyboard_layout, vec_dword_3D& a * @param fmt text to print */ void mac_KMX_LogError(const wchar_t* fmt, ...) { - WCHAR fmtbuf[256]; + wchar_t fmtbuf[256]; const wchar_t* end = L"\0"; const wchar_t* nl = L"\n"; va_list vars; diff --git a/mac/mcompile/mcompile.h b/mac/mcompile/mcompile.h index 9ec05cdff8..3fa7f6d6ce 100644 --- a/mac/mcompile/mcompile.h +++ b/mac/mcompile/mcompile.h @@ -27,7 +27,7 @@ struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; - UINT shift; + KMX_DWORD shift; KMX_WORD vk; }; diff --git a/mac/mcompile/u16.h b/mac/mcompile/u16.h index 54bac4cd03..aeafde33c0 100644 --- a/mac/mcompile/u16.h +++ b/mac/mcompile/u16.h @@ -2,7 +2,7 @@ #define U16_H #pragma once -#include "km_types.h" +#include "../../common/include/km_types.h" #include #include #include