\r
#include "profile.h"\r
#include "xkeymacs.h"\r
-#include "dotxkeymacs.h"\r
+#include "FuncDefs.h"\r
#include "mainfrm.h"\r
#include "../xkeymacsdll/xkeymacsdll.h"\r
#include "../xkeymacsdll/Utils.h"\r
+#include "../xkeymacsdll/PipeName.h"\r
\r
#ifdef _DEBUG\r
#undef THIS_FILE\r
\r
void CProfile::LoadData()\r
{\r
- CDotXkeymacs::Load();\r
+ FuncDefs::Load();\r
LevelUp();\r
LoadRegistry();\r
}\r
SetDllData();\r
}\r
\r
-void CProfile::InitDllData()\r
-{\r
- LoadData();\r
- SetDllData();\r
-}\r
-\r
void CProfile::DeleteAllRegistryData()\r
{\r
HKEY hkey = NULL;\r
// fall through\r
case 3:\r
// rename original function to remove IDS_REG_ORIGINAL_PREFIX\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
+ for (int nFuncID = 0; nFuncID < FuncDefs::GetNumOfDefs(); ++nFuncID) {\r
HKEY hKey = NULL;\r
- const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
+ const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + FuncDefs::GetName(nFuncID);\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
- // Use registry data\r
TCHAR szKeyBind[128];\r
DWORD dwKeyBind = sizeof(szKeyBind);\r
for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {\r
int nType, nKey;\r
StringToKey(szKeyBind, nType, nKey);\r
- SaveKeyBind(appName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
+ SaveKeyBind(appName, FuncDefs::GetName(nFuncID), nType, nKey);\r
dwKeyBind = sizeof(szKeyBind);\r
}\r
RegCloseKey(hKey);\r
}\r
}\r
}\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
+ memset(appConfig.FuncID, -1, sizeof(appConfig.FuncID));\r
+ for (int nFuncID = 0; nFuncID < FuncDefs::GetNumOfDefs(); ++nFuncID) {\r
HKEY hKey;\r
- const CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
+ CString regKey = regApp + _T("\\") + FuncDefs::GetName(nFuncID);\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
- CDotXkeymacs::ClearKey(nFuncID, nAppID);\r
TCHAR szKeyBind[128];\r
DWORD dwKeyBind = _countof(szKeyBind);\r
for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {\r
int nType, nKey;\r
StringToKey(szKeyBind, nType, nKey);\r
- CDotXkeymacs::SetKey(nFuncID, nAppID, nType, nKey);\r
+ appConfig.FuncID[nType][nKey] = static_cast<char>(nFuncID);\r
dwKeyBind = _countof(szKeyBind);\r
}\r
RegCloseKey(hKey);\r
for (int nComID = 1; nComID < MAX_COMMAND; ++nComID)\r
SaveKeyBind(appName, nComID, 0, 0);\r
for (int nType = 0; nType < MAX_COMMAND_TYPE; ++nType)\r
- for (int nKey = 0; nKey < MAX_KEY; ++nKey)\r
+ for (int nKey = 0; nKey < MAX_KEY; ++nKey) {\r
SaveKeyBind(appName, appConfig.CmdID[nType][nKey], nType, nKey);\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
- for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFuncID, nAppID); ++nKeyID) {\r
- int nType, nKey;\r
- CDotXkeymacs::GetKey(nFuncID, nAppID, nKeyID, &nType, &nKey);\r
- SaveKeyBind(appName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
+ int id = appConfig.FuncID[nType][nKey];\r
+ if (id >= 0)\r
+ SaveKeyBind(appName, FuncDefs::GetName(id), nType, nKey);\r
}\r
\r
entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
\r
void CProfile::SetDllData()\r
{\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
- _tcscpy_s(m_Config.FuncDefs[nFuncID], CDotXkeymacs::GetFunctionDefinition(nFuncID));\r
+ memcpy(m_Config.FuncDefs, FuncDefs::GetDefs(), sizeof(m_Config.FuncDefs));\r
for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
AppConfig& appConfig = m_Config.AppConfig[nAppID];\r
appConfig.CmdID[CONTROL]['X'] = 0; // C-x is unassigned.\r
for (int nType = 0; nType < MAX_COMMAND_TYPE; ++nType)\r
for (int nKey = 0; nKey < MAX_KEY; ++nKey)\r
- if ((nType & CONTROLX) && appConfig.CmdID[nType][nKey])\r
- appConfig.CmdID[CONTROL]['X'] = 1; // C-x is available.\r
- memset(appConfig.FuncID, -1, sizeof(appConfig.FuncID));\r
- for (BYTE nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
- for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFuncID, nAppID); ++nKeyID) {\r
- int nType, nKey;\r
- CDotXkeymacs::GetKey(nFuncID, nAppID, nKeyID, &nType, &nKey);\r
- appConfig.FuncID[nType][nKey] = nFuncID;\r
- if (nType & CONTROLX)\r
+ if ((nType & CONTROLX) && (appConfig.CmdID[nType][nKey] || appConfig.FuncID[nType][nKey] >= 0))\r
appConfig.CmdID[CONTROL]['X'] = 1; // C-x is available.\r
- }\r
}\r
m_Config.Is106Keyboard = Is106Keyboard();\r
+ _tcscpy_s(m_Config.PipeNameForIPC32, PipeName(PIPENAME_IPC32).GetName());\r
CXkeymacsDll::SetConfig(m_Config);\r
- CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp());\r
- if (!pApp->IsWow64())\r
+ if (!CXkeymacsApp::IsWow64())\r
return;\r
if (!CXkeymacsDll::SaveConfig())\r
return;\r
- pApp->SendIPCMessage(XKEYMACS_RELOAD);\r
+ CXkeymacsApp::SendIPC64Message(IPC64_RELOAD);\r
}\r
\r
void CProfile::SaveKeyBind(LPCTSTR appName, int comID, int type, int key)\r
{\r
int nAppID = 0;\r
for (nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
- if (!_tcscmp(appName, m_Config.AppConfig[nAppID].AppName))\r
+ if (!_tcsicmp(appName, m_Config.AppConfig[nAppID].AppName))\r
break;\r
return nAppID;\r
}\r
m_Config.AppConfig[nAppID].CmdID[nType][nKey] = static_cast<BYTE>(nComID);\r
}\r
\r
+int CProfile::GetFuncID(int nAppID, int nType, int nKey)\r
+{\r
+ return m_Config.AppConfig[nAppID].FuncID[nType][nKey];\r
+}\r
+\r
+void CProfile::SetFuncID(int nAppID, int nType, int nKey, int nFuncID)\r
+{\r
+ m_Config.AppConfig[nAppID].FuncID[nType][nKey] = static_cast<BYTE>(nFuncID);\r
+}\r
+\r
bool CProfile::GetUseDialogSetting(int nAppID)\r
{\r
return m_Config.AppConfig[nAppID].UseDialogSetting;\r
CFileDialog oFileOpenDialog(TRUE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER)));\r
if (oFileOpenDialog.DoModal() == IDOK) {\r
CString szCommandLine;\r
- szCommandLine.Format(_T("regedit \"%s\""), oFileOpenDialog.GetPathName());\r
- CUtils::Run(szCommandLine, TRUE); // regedit "x:\xkeymacs.reg"\r
+ szCommandLine.Format(_T("reg import \"%s\""), oFileOpenDialog.GetPathName());\r
+ CUtils::Run(szCommandLine, TRUE, TRUE); // reg import "x:\xkeymacs.reg"\r
}\r
\r
DiableTokenPrivileges();\r
CFileDialog oFileOpenDialog(FALSE, _T("reg"), _T("xkeymacs"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_REGISTRATION_FILTER)));\r
if (oFileOpenDialog.DoModal() == IDOK) {\r
CString szCommandLine;\r
- szCommandLine.Format(_T("regedit /e \"%s\" HKEY_CURRENT_USER\\%s"), oFileOpenDialog.GetPathName(), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)));\r
- CUtils::Run(szCommandLine, TRUE); // regedit /e "x:\xkeymacs.reg" HKEY_CURRENT_USER\Software\Oishi\XKeymacs2\r
+ szCommandLine.Format(_T("reg export HKEY_CURRENT_USER\\%s \"%s\" /y"), CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)), oFileOpenDialog.GetPathName());\r
+ CUtils::Run(szCommandLine, TRUE, TRUE); // reg export HKEY_CURRENT_USER\Software\Oishi\XKeymacs2 "x:\xkeymacs.reg" /y\r
}\r
\r
DiableTokenPrivileges();\r