XKeymacs for 64bit Windows
Revision | e3e40c9641fe308f8854218b548d9e4c2cc517ae (tree) |
---|---|
Time | 2011-05-27 08:44:02 |
Author | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Give main roles to 32bit version and simplify 64bit version.
Add 64bit versions of CXkeymacsApp and CMainFrame. xkeymacs64.exe
consists of these classes. xkeymacs.exe launches xkeymacs64.exe on
WOW64 and controls it through a named pipe.
xkeymacs.dll and xkeymacs64.dll share the properties through a
temporary file. xkeymacs64.exe enables the keyboard hook after it
reads the properties.
@@ -206,6 +206,7 @@ int CMainFrame::OnCreate(const LPCREATESTRUCT lpCreateStruct) | ||
206 | 206 | AfxGetApp()->GetProfileInt(CString(), CString(MAKEINTRESOURCE(IDS_REG_ENTRY_CHANGE_CURSOR)), 0)); |
207 | 207 | |
208 | 208 | CXkeymacsDll::SetHooks(); |
209 | + CXkeymacsDll::EnableKeyboardHook(); | |
209 | 210 | StartPollThread(); |
210 | 211 | |
211 | 212 | return 0; |
@@ -527,6 +528,7 @@ void CMainFrame::OnQuit() | ||
527 | 528 | |
528 | 529 | CXkeymacsDll::ReleaseHooks(); |
529 | 530 | TerminatePollThread(); |
531 | + static_cast<CXkeymacsApp *>(AfxGetApp())->SendIPCMessage(XKEYMACS_EXIT); | |
530 | 532 | DeleteAllShell_NotifyIcon(); |
531 | 533 | |
532 | 534 | PostQuitMessage(0); |
@@ -578,6 +580,9 @@ void CMainFrame::OnReset() | ||
578 | 580 | CXkeymacsDll::SetHooks(); |
579 | 581 | TerminatePollThread(); |
580 | 582 | StartPollThread(); |
583 | + CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp()); | |
584 | + if (!pApp->SendIPCMessage(XKEYMACS_RESET)) | |
585 | + pApp->Create64bitProcess(); // try to restart 64bit app | |
581 | 586 | } |
582 | 587 | |
583 | 588 | void CMainFrame::OnHelpFinder() |
@@ -0,0 +1,30 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include "mainfrm64.h" | |
3 | + | |
4 | +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) | |
5 | + | |
6 | +CMainFrame::CMainFrame() | |
7 | +{ | |
8 | + // register window class | |
9 | + WNDCLASS stWndClass; | |
10 | + CString szClassName(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)); | |
11 | + | |
12 | + stWndClass.style = CS_BYTEALIGNWINDOW; | |
13 | + stWndClass.lpfnWndProc = &AfxWndProc; | |
14 | + stWndClass.cbClsExtra = 0; | |
15 | + stWndClass.cbWndExtra = 0; | |
16 | + stWndClass.hInstance = AfxGetInstanceHandle(); | |
17 | + stWndClass.hIcon = NULL; | |
18 | + stWndClass.hCursor = NULL; | |
19 | + stWndClass.hbrBackground = (HBRUSH)COLOR_BACKGROUND; | |
20 | + stWndClass.lpszMenuName = NULL; | |
21 | + stWndClass.lpszClassName = szClassName; | |
22 | + | |
23 | + AfxRegisterClass(&stWndClass); | |
24 | + | |
25 | + // make window | |
26 | + CRect rect(0, 0, 100, 100); | |
27 | + | |
28 | + Create(szClassName, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)), WS_OVERLAPPEDWINDOW | WS_MINIMIZE, rect); | |
29 | +} | |
30 | + |
@@ -0,0 +1,16 @@ | ||
1 | +#ifndef AFX_MAINFRM64_H_INCLUDED | |
2 | +#define AFX_MAINFRM64_H_INCLUDED | |
3 | + | |
4 | +#if _MSC_VER > 1000 | |
5 | +#pragma once | |
6 | +#endif // _MSC_VER > 1000 | |
7 | + | |
8 | +class CMainFrame: public CFrameWnd | |
9 | +{ | |
10 | +public: | |
11 | + CMainFrame(); | |
12 | +protected: | |
13 | + DECLARE_DYNCREATE(CMainFrame) | |
14 | +}; | |
15 | + | |
16 | +#endif // AFX_MAINFRM64_H_INCLUDED |
@@ -822,6 +822,12 @@ void CProfile::SetDllData() | ||
822 | 822 | CXkeymacsDll::SetEnableCUA(nApplicationID, m_XkeymacsData[nApplicationID].GetEnableCUA()); |
823 | 823 | CXkeymacsDll::Set326Compatible(nApplicationID, m_XkeymacsData[nApplicationID].Get326Compatible()); |
824 | 824 | } |
825 | + CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp()); | |
826 | + if (!pApp->IsWow64()) | |
827 | + return; | |
828 | + if (!CXkeymacsDll::SaveConfig()) | |
829 | + return; | |
830 | + pApp->SendIPCMessage(XKEYMACS_RELOAD); | |
825 | 831 | } |
826 | 832 | |
827 | 833 | void CProfile::ReadKeyBind(int *const pnCommandType, int *const pnKey, LPCTSTR szKeyBind) |
@@ -31,7 +31,7 @@ | ||
31 | 31 | #define IDC_REG_ENTRY_IGNORE_META_CTRL 29 |
32 | 32 | #define IDC_REG_ENTRY_IGNORE_C_X 30 |
33 | 33 | #define IDS_ERR_SAVE_DATA 31 |
34 | -#define IDS_ERR_WINDOWS_VERSION 32 | |
34 | +#define IDS_ERR_32BIT 32 | |
35 | 35 | #define IDS_ERR_IMPORT 33 |
36 | 36 | #define IDS_ERR_EXPORT 34 |
37 | 37 | #define IDC_REG_ENTRY_ENABLE_CUA 35 |
@@ -173,22 +173,78 @@ | ||
173 | 173 | </ResourceCompile> |
174 | 174 | </ItemDefinitionGroup> |
175 | 175 | <ItemGroup> |
176 | - <ClCompile Include="104keyboard.cpp" /> | |
177 | - <ClCompile Include="109keyboard.cpp" /> | |
178 | - <ClCompile Include="about.cpp" /> | |
179 | - <ClCompile Include="data.cpp" /> | |
180 | - <ClCompile Include="dotxkeymacs.cpp" /> | |
181 | - <ClCompile Include="key.cpp" /> | |
182 | - <ClCompile Include="keyboardlayout.cpp" /> | |
183 | - <ClCompile Include="mainfrm.cpp" /> | |
184 | - <ClCompile Include="optionsdlg.cpp" /> | |
185 | - <ClCompile Include="profile.cpp" /> | |
186 | - <ClCompile Include="properties.cpp" /> | |
187 | - <ClCompile Include="propertiesadvanced.cpp" /> | |
188 | - <ClCompile Include="propertiesbasic.cpp" /> | |
189 | - <ClCompile Include="propertieslist.cpp" /> | |
190 | - <ClCompile Include="stdafx.cpp" /> | |
191 | - <ClCompile Include="xkeymacs.cpp" /> | |
176 | + <ClCompile Include="104keyboard.cpp"> | |
177 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
178 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
179 | + </ClCompile> | |
180 | + <ClCompile Include="109keyboard.cpp"> | |
181 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
182 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
183 | + </ClCompile> | |
184 | + <ClCompile Include="about.cpp"> | |
185 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
186 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
187 | + </ClCompile> | |
188 | + <ClCompile Include="data.cpp"> | |
189 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
190 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
191 | + </ClCompile> | |
192 | + <ClCompile Include="dotxkeymacs.cpp"> | |
193 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
194 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
195 | + </ClCompile> | |
196 | + <ClCompile Include="key.cpp"> | |
197 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
198 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
199 | + </ClCompile> | |
200 | + <ClCompile Include="keyboardlayout.cpp"> | |
201 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
202 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
203 | + </ClCompile> | |
204 | + <ClCompile Include="mainfrm.cpp"> | |
205 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
206 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
207 | + </ClCompile> | |
208 | + <ClCompile Include="mainfrm64.cpp"> | |
209 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | |
210 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | |
211 | + </ClCompile> | |
212 | + <ClCompile Include="optionsdlg.cpp"> | |
213 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
214 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
215 | + </ClCompile> | |
216 | + <ClCompile Include="profile.cpp"> | |
217 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
218 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
219 | + </ClCompile> | |
220 | + <ClCompile Include="properties.cpp"> | |
221 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
222 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
223 | + </ClCompile> | |
224 | + <ClCompile Include="propertiesadvanced.cpp"> | |
225 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
226 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
227 | + </ClCompile> | |
228 | + <ClCompile Include="propertiesbasic.cpp"> | |
229 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
230 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
231 | + </ClCompile> | |
232 | + <ClCompile Include="propertieslist.cpp"> | |
233 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
234 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
235 | + </ClCompile> | |
236 | + <ClCompile Include="stdafx.cpp"> | |
237 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
238 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
239 | + </ClCompile> | |
240 | + <ClCompile Include="xkeymacs.cpp"> | |
241 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
242 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
243 | + </ClCompile> | |
244 | + <ClCompile Include="xkeymacs64.cpp"> | |
245 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | |
246 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | |
247 | + </ClCompile> | |
192 | 248 | </ItemGroup> |
193 | 249 | <ItemGroup> |
194 | 250 | <ClInclude Include="104keyboard.h" /> |
@@ -199,6 +255,7 @@ | ||
199 | 255 | <ClInclude Include="key.h" /> |
200 | 256 | <ClInclude Include="keyboardlayout.h" /> |
201 | 257 | <ClInclude Include="mainfrm.h" /> |
258 | + <ClInclude Include="mainfrm64.h" /> | |
202 | 259 | <ClInclude Include="optionsdlg.h" /> |
203 | 260 | <ClInclude Include="profile.h" /> |
204 | 261 | <ClInclude Include="properties.h" /> |
@@ -208,6 +265,7 @@ | ||
208 | 265 | <ClInclude Include="resource.h" /> |
209 | 266 | <ClInclude Include="stdafx.h" /> |
210 | 267 | <ClInclude Include="xkeymacs.h" /> |
268 | + <ClInclude Include="xkeymacs64.h" /> | |
211 | 269 | </ItemGroup> |
212 | 270 | <ItemGroup> |
213 | 271 | <ResourceCompile Include="xkeymacs.rc" /> |
@@ -60,9 +60,15 @@ | ||
60 | 60 | <ClCompile Include="data.cpp"> |
61 | 61 | <Filter>Source Files</Filter> |
62 | 62 | </ClCompile> |
63 | + <ClCompile Include="mainfrm64.cpp"> | |
64 | + <Filter>Source Files</Filter> | |
65 | + </ClCompile> | |
63 | 66 | <ClCompile Include="about.cpp"> |
64 | 67 | <Filter>Source Files</Filter> |
65 | 68 | </ClCompile> |
69 | + <ClCompile Include="xkeymacs64.cpp"> | |
70 | + <Filter>Source Files</Filter> | |
71 | + </ClCompile> | |
66 | 72 | </ItemGroup> |
67 | 73 | <ItemGroup> |
68 | 74 | <ClInclude Include="104keyboard.h"> |
@@ -113,9 +119,15 @@ | ||
113 | 119 | <ClInclude Include="data.h"> |
114 | 120 | <Filter>Header Files</Filter> |
115 | 121 | </ClInclude> |
122 | + <ClInclude Include="mainfrm64.h"> | |
123 | + <Filter>Header Files</Filter> | |
124 | + </ClInclude> | |
116 | 125 | <ClInclude Include="about.h"> |
117 | 126 | <Filter>Header Files</Filter> |
118 | 127 | </ClInclude> |
128 | + <ClInclude Include="xkeymacs64.h"> | |
129 | + <Filter>Header Files</Filter> | |
130 | + </ClInclude> | |
119 | 131 | </ItemGroup> |
120 | 132 | <ItemGroup> |
121 | 133 | <ResourceCompile Include="xkeymacs.rc"> |
@@ -173,22 +173,78 @@ | ||
173 | 173 | </ResourceCompile> |
174 | 174 | </ItemDefinitionGroup> |
175 | 175 | <ItemGroup> |
176 | - <ClCompile Include="104keyboard.cpp" /> | |
177 | - <ClCompile Include="109keyboard.cpp" /> | |
178 | - <ClCompile Include="about.cpp" /> | |
179 | - <ClCompile Include="data.cpp" /> | |
180 | - <ClCompile Include="dotxkeymacs.cpp" /> | |
181 | - <ClCompile Include="key.cpp" /> | |
182 | - <ClCompile Include="keyboardlayout.cpp" /> | |
183 | - <ClCompile Include="mainfrm.cpp" /> | |
184 | - <ClCompile Include="optionsdlg.cpp" /> | |
185 | - <ClCompile Include="profile.cpp" /> | |
186 | - <ClCompile Include="properties.cpp" /> | |
187 | - <ClCompile Include="propertiesadvanced.cpp" /> | |
188 | - <ClCompile Include="propertiesbasic.cpp" /> | |
189 | - <ClCompile Include="propertieslist.cpp" /> | |
190 | - <ClCompile Include="stdafx.cpp" /> | |
191 | - <ClCompile Include="xkeymacs.cpp" /> | |
176 | + <ClCompile Include="104keyboard.cpp"> | |
177 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
178 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
179 | + </ClCompile> | |
180 | + <ClCompile Include="109keyboard.cpp"> | |
181 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
182 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
183 | + </ClCompile> | |
184 | + <ClCompile Include="about.cpp"> | |
185 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
186 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
187 | + </ClCompile> | |
188 | + <ClCompile Include="data.cpp"> | |
189 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
190 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
191 | + </ClCompile> | |
192 | + <ClCompile Include="dotxkeymacs.cpp"> | |
193 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
194 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
195 | + </ClCompile> | |
196 | + <ClCompile Include="key.cpp"> | |
197 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
198 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
199 | + </ClCompile> | |
200 | + <ClCompile Include="keyboardlayout.cpp"> | |
201 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
202 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
203 | + </ClCompile> | |
204 | + <ClCompile Include="mainfrm.cpp"> | |
205 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
206 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
207 | + </ClCompile> | |
208 | + <ClCompile Include="mainfrm64.cpp"> | |
209 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | |
210 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | |
211 | + </ClCompile> | |
212 | + <ClCompile Include="optionsdlg.cpp"> | |
213 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
214 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
215 | + </ClCompile> | |
216 | + <ClCompile Include="profile.cpp"> | |
217 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
218 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
219 | + </ClCompile> | |
220 | + <ClCompile Include="properties.cpp"> | |
221 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
222 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
223 | + </ClCompile> | |
224 | + <ClCompile Include="propertiesadvanced.cpp"> | |
225 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
226 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
227 | + </ClCompile> | |
228 | + <ClCompile Include="propertiesbasic.cpp"> | |
229 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
230 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
231 | + </ClCompile> | |
232 | + <ClCompile Include="propertieslist.cpp"> | |
233 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
234 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
235 | + </ClCompile> | |
236 | + <ClCompile Include="stdafx.cpp"> | |
237 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
238 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
239 | + </ClCompile> | |
240 | + <ClCompile Include="xkeymacs.cpp"> | |
241 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | |
242 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |
243 | + </ClCompile> | |
244 | + <ClCompile Include="xkeymacs64.cpp"> | |
245 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | |
246 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | |
247 | + </ClCompile> | |
192 | 248 | </ItemGroup> |
193 | 249 | <ItemGroup> |
194 | 250 | <ClInclude Include="104keyboard.h" /> |
@@ -199,6 +255,7 @@ | ||
199 | 255 | <ClInclude Include="key.h" /> |
200 | 256 | <ClInclude Include="keyboardlayout.h" /> |
201 | 257 | <ClInclude Include="mainfrm.h" /> |
258 | + <ClInclude Include="mainfrm64.h" /> | |
202 | 259 | <ClInclude Include="optionsdlg.h" /> |
203 | 260 | <ClInclude Include="profile.h" /> |
204 | 261 | <ClInclude Include="properties.h" /> |
@@ -208,6 +265,7 @@ | ||
208 | 265 | <ClInclude Include="resource.h" /> |
209 | 266 | <ClInclude Include="stdafx.h" /> |
210 | 267 | <ClInclude Include="xkeymacs.h" /> |
268 | + <ClInclude Include="xkeymacs64.h" /> | |
211 | 269 | </ItemGroup> |
212 | 270 | <ItemGroup> |
213 | 271 | <ResourceCompile Include="xkeymacs.rc" /> |
@@ -60,9 +60,15 @@ | ||
60 | 60 | <ClCompile Include="data.cpp"> |
61 | 61 | <Filter>Source Files</Filter> |
62 | 62 | </ClCompile> |
63 | + <ClCompile Include="mainfrm64.cpp"> | |
64 | + <Filter>Source Files</Filter> | |
65 | + </ClCompile> | |
63 | 66 | <ClCompile Include="about.cpp"> |
64 | 67 | <Filter>Source Files</Filter> |
65 | 68 | </ClCompile> |
69 | + <ClCompile Include="xkeymacs64.cpp"> | |
70 | + <Filter>Source Files</Filter> | |
71 | + </ClCompile> | |
66 | 72 | </ItemGroup> |
67 | 73 | <ItemGroup> |
68 | 74 | <ClInclude Include="104keyboard.h"> |
@@ -113,9 +119,15 @@ | ||
113 | 119 | <ClInclude Include="data.h"> |
114 | 120 | <Filter>Header Files</Filter> |
115 | 121 | </ClInclude> |
122 | + <ClInclude Include="mainfrm64.h"> | |
123 | + <Filter>Header Files</Filter> | |
124 | + </ClInclude> | |
116 | 125 | <ClInclude Include="about.h"> |
117 | 126 | <Filter>Header Files</Filter> |
118 | 127 | </ClInclude> |
128 | + <ClInclude Include="xkeymacs64.h"> | |
129 | + <Filter>Header Files</Filter> | |
130 | + </ClInclude> | |
119 | 131 | </ItemGroup> |
120 | 132 | <ItemGroup> |
121 | 133 | <ResourceCompile Include="xkeymacs.rc"> |
@@ -28,6 +28,7 @@ END_MESSAGE_MAP() | ||
28 | 28 | CXkeymacsApp::CXkeymacsApp() |
29 | 29 | { |
30 | 30 | m_hMutex = NULL; |
31 | + m_bIsWow64 = FALSE; | |
31 | 32 | } |
32 | 33 | |
33 | 34 | ///////////////////////////////////////////////////////////////////////////// |
@@ -46,16 +47,12 @@ BOOL CXkeymacsApp::InitInstance() | ||
46 | 47 | // If you are not using these features and wish to reduce the size |
47 | 48 | // of your final executable, you should remove from the following |
48 | 49 | // the specific initialization routines you do not need. |
49 | -#ifdef _WIN64 | |
50 | - m_hMutex = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)) + _T("64")); | |
51 | -#else | |
52 | 50 | m_hMutex = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE))); |
53 | -#endif | |
54 | - if (GetLastError() == ERROR_ALREADY_EXISTS) { | |
55 | - CloseHandle(m_hMutex); | |
51 | + if (GetLastError() == ERROR_ALREADY_EXISTS) { | |
52 | + CloseHandle(m_hMutex); | |
56 | 53 | m_hMutex = NULL; |
57 | - return FALSE; | |
58 | - } | |
54 | + return FALSE; | |
55 | + } | |
59 | 56 | |
60 | 57 | #ifdef _AFXDLL |
61 | 58 | Enable3dControls(); // Call this when using MFC in a shared DLL |
@@ -83,12 +80,60 @@ BOOL CXkeymacsApp::InitInstance() | ||
83 | 80 | SetClassLongPtr(m_pMainWnd->m_hWnd, GCLP_HICON, (LONG_PTR)LoadIcon(IDR_MAINFRAME)); |
84 | 81 | |
85 | 82 | // set registry key |
86 | - CProfile::InitDllData(); | |
87 | 83 | CUtils::InitCUtils(); |
84 | + if (!Create64bitProcess()) | |
85 | + return FALSE; | |
86 | + CProfile::InitDllData(); | |
87 | + | |
88 | + return TRUE; | |
89 | +} | |
90 | + | |
91 | +BOOL CXkeymacsApp::IsWow64() | |
92 | +{ | |
93 | + return m_bIsWow64; | |
94 | +} | |
88 | 95 | |
96 | +BOOL CXkeymacsApp::Create64bitProcess() | |
97 | +{ | |
98 | + typedef BOOL (WINAPI *PFIsWow64Process)(HANDLE, PBOOL); | |
99 | + PFIsWow64Process func = (PFIsWow64Process)GetProcAddress(GetModuleHandle(_T("kernel32")), _T("IsWow64Process")); | |
100 | + if (!func) | |
101 | + return TRUE; // IsWow64Process not exists | |
102 | + if (!func(GetCurrentProcess(), &m_bIsWow64)) | |
103 | + return FALSE; // error | |
104 | + if (!m_bIsWow64) | |
105 | + return TRUE; // do nothing | |
106 | + | |
107 | + TCHAR szFileName[MAX_PATH]; | |
108 | + if (!GetModuleFileName(NULL, szFileName, sizeof(szFileName))) | |
109 | + return FALSE; | |
110 | + TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFile[_MAX_FNAME], szExt[_MAX_EXT]; | |
111 | + if (_tsplitpath_s(szFileName, szDrive, szDir, szFile, szExt) || | |
112 | + _tcscat_s(szFile, _T("64")) || | |
113 | + _tmakepath_s(szFileName, szDrive, szDir, szFile, szExt)) | |
114 | + return FALSE; | |
115 | + | |
116 | + STARTUPINFO si; | |
117 | + ZeroMemory(&si, sizeof(si)); | |
118 | + si.cb = sizeof(si); | |
119 | + PROCESS_INFORMATION pi; | |
120 | + ZeroMemory(&pi, sizeof(pi)); | |
121 | + if (!CreateProcess(szFileName, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) | |
122 | + return FALSE; | |
123 | + // close unused handles | |
124 | + CloseHandle(pi.hProcess); | |
125 | + CloseHandle(pi.hThread); | |
89 | 126 | return TRUE; |
90 | 127 | } |
91 | 128 | |
129 | +BOOL CXkeymacsApp::SendIPCMessage(DWORD msg) | |
130 | +{ | |
131 | + if (!m_bIsWow64) | |
132 | + return TRUE; | |
133 | + DWORD ack, read; | |
134 | + return CallNamedPipe(IPC_PIPE, &msg, sizeof(msg), &ack, sizeof(DWORD), &read, 10000); | |
135 | +} | |
136 | + | |
92 | 137 | int CXkeymacsApp::ExitInstance() |
93 | 138 | { |
94 | 139 | if (m_hMutex) { |
@@ -37,9 +37,13 @@ public: | ||
37 | 37 | // NOTE - the ClassWizard will add and remove member functions here. |
38 | 38 | // DO NOT EDIT what you see in these blocks of generated code ! |
39 | 39 | //}}AFX_MSG |
40 | + BOOL IsWow64(); | |
41 | + BOOL SendIPCMessage(DWORD msg); | |
42 | + BOOL Create64bitProcess(); | |
40 | 43 | DECLARE_MESSAGE_MAP() |
41 | 44 | private: |
42 | 45 | HANDLE m_hMutex; |
46 | + BOOL m_bIsWow64; | |
43 | 47 | }; |
44 | 48 | |
45 | 49 | //{{AFX_INSERT_LOCATION}} |
@@ -1056,7 +1056,7 @@ END | ||
1056 | 1056 | |
1057 | 1057 | STRINGTABLE DISCARDABLE |
1058 | 1058 | BEGIN |
1059 | - IDS_ERR_WINDOWS_VERSION "XKeymacs はこのバージョンの Windows をサポートしておりません。" | |
1059 | + IDS_ERR_32BIT "32ビット版の xkeymacs.exe を実行してください。" | |
1060 | 1060 | IDS_ERR_IMPORT "%s\nファイルが見つかりません。\n指定したファイル名が正しいかどうか確認してください。" |
1061 | 1061 | IDS_ERR_EXPORT "設定の書き出しに失敗しました。" |
1062 | 1062 | IDC_REG_ENTRY_ENABLE_CUA "Enable CUA" |
@@ -2874,7 +2874,7 @@ END | ||
2874 | 2874 | |
2875 | 2875 | STRINGTABLE DISCARDABLE |
2876 | 2876 | BEGIN |
2877 | - IDS_ERR_WINDOWS_VERSION "XKeymacs does not support the Windows of this version." | |
2877 | + IDS_ERR_32BIT "Please start 32bit version of xkeymacs.exe." | |
2878 | 2878 | IDS_ERR_IMPORT "%s\nFile not found.\nPlease verify the correct file name was given." |
2879 | 2879 | IDS_ERR_EXPORT "Failed to export properties." |
2880 | 2880 | IDC_REG_ENTRY_ENABLE_CUA "Enable CUA" |
@@ -0,0 +1,90 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include "xkeymacs64.h" | |
3 | +#include "mainfrm64.h" | |
4 | + | |
5 | +CXkeymacsApp::CXkeymacsApp() | |
6 | +{ | |
7 | + m_hMutex = NULL; | |
8 | +} | |
9 | + | |
10 | +CXkeymacsApp theApp; | |
11 | + | |
12 | +static UINT PollIPCMessage(LPVOID lpParam); | |
13 | + | |
14 | +BOOL CXkeymacsApp::InitInstance() | |
15 | +{ | |
16 | + HANDLE h32 = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE))); | |
17 | + if (GetLastError() != ERROR_ALREADY_EXISTS) { | |
18 | + AfxMessageBox(CString(MAKEINTRESOURCE(IDS_ERR_32BIT))); | |
19 | + CloseHandle(h32); | |
20 | + return FALSE; | |
21 | + } | |
22 | + CloseHandle(h32); | |
23 | + m_hMutex = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)) + _T("64")); | |
24 | + if (GetLastError() == ERROR_ALREADY_EXISTS) { | |
25 | + CloseHandle(m_hMutex); | |
26 | + m_hMutex = NULL; | |
27 | + return FALSE; | |
28 | + } | |
29 | + | |
30 | + m_pMainWnd = new CMainFrame; | |
31 | + m_pMainWnd->ShowWindow(SW_HIDE); | |
32 | + m_pMainWnd->UpdateWindow(); | |
33 | + SetClassLongPtr(m_pMainWnd->m_hWnd, GCLP_HICON, (LONG_PTR)LoadIcon(IDR_MAINFRAME)); | |
34 | + | |
35 | + CUtils::InitCUtils(); | |
36 | + AfxBeginThread(PollIPCMessage, NULL); | |
37 | + CXkeymacsDll::SetHooks(); | |
38 | + return TRUE; | |
39 | +} | |
40 | + | |
41 | +UINT PollIPCMessage(LPVOID lpParam) | |
42 | +{ | |
43 | + HANDLE hPipe = CreateNamedPipe(IPC_PIPE, PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1, 512, 512, 0, NULL); | |
44 | + if (hPipe == INVALID_HANDLE_VALUE) | |
45 | + return 1; | |
46 | + for (; ;) { | |
47 | + if (ConnectNamedPipe(hPipe, NULL) ? FALSE : (GetLastError() != ERROR_PIPE_CONNECTED)) | |
48 | + break; | |
49 | + DWORD msg; | |
50 | + DWORD read; | |
51 | + if (!ReadFile(hPipe, &msg, sizeof(msg), &read, NULL) || read != sizeof(msg)) | |
52 | + break; | |
53 | + DWORD written, nul = 0; | |
54 | + if (!WriteFile(hPipe, &nul, sizeof(DWORD), &written, NULL) || written != sizeof(DWORD) | |
55 | + || !FlushFileBuffers(hPipe) || !DisconnectNamedPipe(hPipe)) | |
56 | + break; | |
57 | + switch (msg) | |
58 | + { | |
59 | + case XKEYMACS_EXIT: | |
60 | + goto exit; | |
61 | + break; | |
62 | + case XKEYMACS_RELOAD: | |
63 | + if (CXkeymacsDll::LoadConfig()) | |
64 | + CXkeymacsDll::EnableKeyboardHook(); | |
65 | + break; | |
66 | + case XKEYMACS_RESET: | |
67 | + CXkeymacsDll::ReleaseHooks(); | |
68 | + CXkeymacsDll::SetHooks(); | |
69 | + break; | |
70 | + } | |
71 | + } | |
72 | +exit: | |
73 | + CloseHandle(hPipe); | |
74 | + CXkeymacsDll::ReleaseHooks(); | |
75 | + ExitProcess(0); | |
76 | + return 0; | |
77 | +} | |
78 | + | |
79 | +int CXkeymacsApp::ExitInstance() | |
80 | +{ | |
81 | + if (m_hMutex) { | |
82 | + CloseHandle(m_hMutex); | |
83 | + | |
84 | + m_pMainWnd->DestroyWindow(); | |
85 | + delete m_pMainWnd; | |
86 | + m_pMainWnd = NULL; | |
87 | + } | |
88 | + | |
89 | + return CWinApp::ExitInstance(); | |
90 | +} |
@@ -0,0 +1,25 @@ | ||
1 | +#ifndef AFX_XKEYMACS64_H_INCLUDED | |
2 | +#define AFX_XKEYMACS64_H_INCLUDED | |
3 | + | |
4 | +#if _MSC_VER > 1000 | |
5 | +#pragma once | |
6 | +#endif // _MSC_VER > 1000 | |
7 | + | |
8 | +#include "resource.h" | |
9 | + | |
10 | +class CXkeymacsApp : public CWinApp | |
11 | +{ | |
12 | +public: | |
13 | + CXkeymacsApp(); | |
14 | +// Overrides | |
15 | + // ClassWizard generated virtual function overrides | |
16 | + //{{AFX_VIRTUAL(CXkeymacsApp) | |
17 | + public: | |
18 | + virtual BOOL InitInstance(); | |
19 | + virtual int ExitInstance(); | |
20 | + //}}AFX_VIRTUAL | |
21 | +private: | |
22 | + HANDLE m_hMutex; | |
23 | +}; | |
24 | + | |
25 | +#endif // AFX_XKEYMACS64_H_INCLUDED |
@@ -11,5 +11,26 @@ struct ICONMSG { | ||
11 | 11 | TCHAR szTip[128]; |
12 | 12 | }; |
13 | 13 | |
14 | +struct CONFIG { | |
15 | + int nMessage; | |
16 | + BOOL b326Compatible[MAX_APP]; | |
17 | + TCHAR szWindowText[MAX_APP][WINDOW_TEXT_LENGTH]; | |
18 | + TCHAR szFunctionDefinition[MAX_FUNCTION][MAX_DEFINITION]; | |
19 | + int nFunctionID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
20 | + BOOL bEnableCUA[MAX_APP]; | |
21 | + BOOL bUseDialogSetting[MAX_APP]; | |
22 | + BOOL bIgnoreUndefinedC_x[MAX_APP]; | |
23 | + BOOL bIgnoreUndefinedMetaCtrl[MAX_APP]; | |
24 | + int nSettingStyle[MAX_APP]; | |
25 | + int nKillRingMax[MAX_APP]; | |
26 | + TCHAR szSpecialApp[MAX_APP][CLASS_NAME_LENGTH]; | |
27 | + int nCommandID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
28 | + BOOL bAtIbeamCursorOnly[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
29 | + BOOL b106Keyboard; | |
30 | +}; | |
31 | + | |
32 | +enum XKEYMACS_IPC { XKEYMACS_EXIT, XKEYMACS_RELOAD, XKEYMACS_RESET }; | |
33 | + | |
14 | 34 | #define ICON_PIPE _T("\\\\.\\pipe\\XKEYMACS_ICON") |
35 | +#define IPC_PIPE _T("\\\\.\\pipe\\XKEYMACS_IPC") | |
15 | 36 | #endif |
@@ -201,39 +201,23 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) | ||
201 | 201 | HHOOK CXkeymacsDll::m_hHookCallWndRet = NULL; |
202 | 202 | HHOOK CXkeymacsDll::m_hHookGetMessage = NULL; |
203 | 203 | HHOOK CXkeymacsDll::m_hHookShell = NULL; |
204 | - int CXkeymacsDll::m_nCommandID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY] = {'\0'}; | |
205 | - BOOL CXkeymacsDll::m_bAtIbeamCursorOnly[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY] = {'\0'}; | |
206 | - int CXkeymacsDll::m_nFunctionID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY] = {'\0'}; | |
207 | - TCHAR CXkeymacsDll::m_szSpecialApp[MAX_APP][CLASS_NAME_LENGTH] = {'\0'}; | |
208 | - TCHAR CXkeymacsDll::m_szWindowText[MAX_APP][WINDOW_TEXT_LENGTH] = {'\0'}; | |
209 | 204 | BOOL CXkeymacsDll::m_bRightControl = FALSE; |
210 | 205 | BOOL CXkeymacsDll::m_bRightAlt = FALSE; |
211 | 206 | BOOL CXkeymacsDll::m_bRightShift = FALSE; |
212 | 207 | BOOL CXkeymacsDll::m_bHook = TRUE; |
213 | 208 | BOOL CXkeymacsDll::m_bDefiningMacro = FALSE; |
214 | - int CXkeymacsDll::m_nKillRingMax[MAX_APP] = {'\0'}; | |
215 | - BOOL CXkeymacsDll::m_bUseDialogSetting[MAX_APP] = {'\0'}; | |
216 | 209 | CList<CClipboardSnap *, CClipboardSnap *> CXkeymacsDll::m_oKillRing; |
217 | 210 | CObList CXkeymacsDll::m_Macro; |
218 | 211 | int CXkeymacsDll::m_nKillRing = 0; |
219 | 212 | int CXkeymacsDll::m_nOriginal[MAX_COMMAND_TYPE][MAX_KEY] = {'\0'}; |
220 | 213 | int CXkeymacsDll::m_nApplicationID = 0; |
221 | - int CXkeymacsDll::m_nSettingStyle[MAX_APP] = {'\0'}; | |
222 | - BOOL CXkeymacsDll::m_bIgnoreUndefinedMetaCtrl[MAX_APP] = {'\0'}; | |
223 | - BOOL CXkeymacsDll::m_bIgnoreUndefinedC_x[MAX_APP] = {'\0'}; | |
224 | -// int CXkeymacsDll::m_nPassThrough = 0; | |
225 | - TCHAR CXkeymacsDll::m_szApplicationName[MAX_PATH] = {'\0'}; | |
226 | - TCHAR CXkeymacsDll::m_szOldApplicationName[MAX_PATH] = {'\0'}; | |
227 | - BOOL CXkeymacsDll::m_bEnableCUA[MAX_APP] = {'\0'}; | |
228 | - TCHAR CXkeymacsDll::m_szFunctionDefinition[MAX_FUNCTION][MAX_DEFINITION] = {'\0'}; | |
229 | 214 | int CXkeymacsDll::m_nAccelerate = 0; |
230 | 215 | int CXkeymacsDll::m_nKeyboardSpeed = 31; |
231 | 216 | HCURSOR CXkeymacsDll::m_hCursor[MAX_STATUS] = {'\0'}; |
232 | 217 | HCURSOR CXkeymacsDll::m_hCurrentCursor = NULL; |
233 | 218 | BOOL CXkeymacsDll::m_bCursor = FALSE; |
234 | - BOOL CXkeymacsDll::m_b326Compatible[MAX_APP] = {'\0'}; | |
235 | - BOOL CXkeymacsDll::m_b106Keyboard = FALSE; | |
236 | 219 | TCHAR CXkeymacsDll::m_M_xTip[128] = ""; |
220 | + CONFIG CXkeymacsDll::m_Config = {0}; | |
237 | 221 | #pragma data_seg() |
238 | 222 | |
239 | 223 | ////////////////////////////////////////////////////////////////////// |
@@ -250,16 +234,52 @@ CXkeymacsDll::~CXkeymacsDll() | ||
250 | 234 | |
251 | 235 | } |
252 | 236 | |
237 | +BOOL CXkeymacsDll::SaveConfig() | |
238 | +{ | |
239 | + TCHAR szTmp[MAX_PATH]; | |
240 | + if (!GetTempPath(MAX_PATH, szTmp)) | |
241 | + return FALSE; | |
242 | + if (_tmakepath_s(szTmp, NULL, szTmp, _T("xkeymacs"), _T("tmp"))) | |
243 | + return FALSE; | |
244 | + HANDLE hFile = CreateFile(szTmp, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); | |
245 | + if (hFile == INVALID_HANDLE_VALUE) | |
246 | + return FALSE; | |
247 | + DWORD written; | |
248 | + BOOL res = WriteFile(hFile, &m_Config, sizeof(m_Config), &written, NULL) || written != sizeof(m_Config); | |
249 | + CloseHandle(hFile); | |
250 | + return res; | |
251 | +} | |
252 | + | |
253 | +BOOL CXkeymacsDll::LoadConfig() | |
254 | +{ | |
255 | + TCHAR szTmp[MAX_PATH]; | |
256 | + if (!GetTempPath(MAX_PATH, szTmp)) | |
257 | + return FALSE; | |
258 | + if (_tmakepath_s(szTmp, NULL, szTmp, _T("xkeymacs"), _T("tmp"))) | |
259 | + return FALSE; | |
260 | + HANDLE hFile = CreateFile(szTmp, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); | |
261 | + if (hFile == INVALID_HANDLE_VALUE) | |
262 | + return FALSE; | |
263 | + DWORD read; | |
264 | + BOOL res = ReadFile(hFile, &m_Config, sizeof(m_Config), &read, NULL) && read == sizeof(m_Config); | |
265 | + CloseHandle(hFile); | |
266 | + return res; | |
267 | +} | |
268 | + | |
253 | 269 | // set hooks |
254 | 270 | void CXkeymacsDll::SetHooks() |
255 | 271 | { |
256 | - m_bEnableKeyboardHook = TRUE; | |
257 | 272 | m_hHookCallWnd = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProc, g_hDllInst, 0); |
258 | 273 | m_hHookCallWndRet = SetWindowsHookEx(WH_CALLWNDPROCRET, (HOOKPROC)CallWndRetProc, g_hDllInst, 0); |
259 | 274 | m_hHookGetMessage = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetMsgProc, g_hDllInst, 0); |
260 | 275 | m_hHookShell = SetWindowsHookEx(WH_SHELL, (HOOKPROC)ShellProc, g_hDllInst, 0); |
261 | 276 | } |
262 | 277 | |
278 | +void CXkeymacsDll::EnableKeyboardHook() | |
279 | +{ | |
280 | + m_bEnableKeyboardHook = TRUE; | |
281 | +} | |
282 | + | |
263 | 283 | void CXkeymacsDll::SetKeyboardHook() |
264 | 284 | { |
265 | 285 | if (!g_hHookKeyboard) |
@@ -306,8 +326,8 @@ void CXkeymacsDll::SetKeyboardHookFlag(BOOL bFlag) | ||
306 | 326 | } else { |
307 | 327 | msg.nState = STATUS_DISABLE_WOCQ; |
308 | 328 | } |
309 | - if (m_nSettingStyle[m_nApplicationID] == SETTING_DISABLE | |
310 | - || (!_tcsicmp(m_szSpecialApp[m_nApplicationID], _T("Default")) | |
329 | + if (m_Config.nSettingStyle[m_nApplicationID] == SETTING_DISABLE | |
330 | + || (!_tcsicmp(m_Config.szSpecialApp[m_nApplicationID], _T("Default")) | |
311 | 331 | && CUtils::IsDefaultIgnoreApplication())) { |
312 | 332 | msg.nState = STATUS_DISABLE; |
313 | 333 | m_hCurrentCursor = m_hCursor[STATUS_DISABLE]; |
@@ -665,16 +685,16 @@ void CXkeymacsDll::InitKeyboardProc(BOOL bImeComposition) | ||
665 | 685 | |
666 | 686 | CUtils::SetApplicationName(bImeComposition); |
667 | 687 | |
668 | - if (_tcsnicmp(m_szSpecialApp[m_nApplicationID], CUtils::GetApplicationName(), 0xF) || !IsMatchWindowText(m_szWindowText[m_nApplicationID])) { // PROCESSENTRY32 has only 0xF bytes of Name | |
688 | + if (_tcsnicmp(m_Config.szSpecialApp[m_nApplicationID], CUtils::GetApplicationName(), 0xF) || !IsMatchWindowText(m_Config.szWindowText[m_nApplicationID])) { // PROCESSENTRY32 has only 0xF bytes of Name | |
669 | 689 | m_nApplicationID = -1; |
670 | 690 | |
671 | 691 | for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) { |
672 | - if (!_tcsnicmp(m_szSpecialApp[nApplicationID], CUtils::GetApplicationName(), 0xF) && IsMatchWindowText(m_szWindowText[nApplicationID])) { | |
692 | + if (!_tcsnicmp(m_Config.szSpecialApp[nApplicationID], CUtils::GetApplicationName(), 0xF) && IsMatchWindowText(m_Config.szWindowText[nApplicationID])) { | |
673 | 693 | |
674 | 694 | if (m_nApplicationID < 0 |
675 | - || CUtils::GetWindowTextType(m_szWindowText[m_nApplicationID]) < CUtils::GetWindowTextType(m_szWindowText[nApplicationID]) | |
676 | - || CUtils::GetWindowTextType(m_szWindowText[m_nApplicationID]) == CUtils::GetWindowTextType(m_szWindowText[nApplicationID]) | |
677 | - && _tcscmp(m_szWindowText[m_nApplicationID], m_szWindowText[nApplicationID]) <= 0) { | |
695 | + || CUtils::GetWindowTextType(m_Config.szWindowText[m_nApplicationID]) < CUtils::GetWindowTextType(m_Config.szWindowText[nApplicationID]) | |
696 | + || CUtils::GetWindowTextType(m_Config.szWindowText[m_nApplicationID]) == CUtils::GetWindowTextType(m_Config.szWindowText[nApplicationID]) | |
697 | + && _tcscmp(m_Config.szWindowText[m_nApplicationID], m_Config.szWindowText[nApplicationID]) <= 0) { | |
678 | 698 | m_nApplicationID = nApplicationID; |
679 | 699 | } |
680 | 700 | } |
@@ -682,7 +702,7 @@ void CXkeymacsDll::InitKeyboardProc(BOOL bImeComposition) | ||
682 | 702 | |
683 | 703 | if (m_nApplicationID < 0) { |
684 | 704 | for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) { |
685 | - if (!_tcsicmp(m_szSpecialApp[nApplicationID], _T("Default"))) { | |
705 | + if (!_tcsicmp(m_Config.szSpecialApp[nApplicationID], _T("Default"))) { | |
686 | 706 | m_nApplicationID = nApplicationID; |
687 | 707 | break; |
688 | 708 | } |
@@ -694,15 +714,15 @@ void CXkeymacsDll::InitKeyboardProc(BOOL bImeComposition) | ||
694 | 714 | } |
695 | 715 | } |
696 | 716 | |
697 | - if (m_nSettingStyle[m_nApplicationID] != SETTING_DISABLE | |
698 | - && (_tcsicmp(m_szSpecialApp[m_nApplicationID], _T("Default")) || !CUtils::IsDefaultIgnoreApplication()) | |
717 | + if (m_Config.nSettingStyle[m_nApplicationID] != SETTING_DISABLE | |
718 | + && (_tcsicmp(m_Config.szSpecialApp[m_nApplicationID], _T("Default")) || !CUtils::IsDefaultIgnoreApplication()) | |
699 | 719 | && !bImeComposition |
700 | 720 | && CUtils::IsDialog()) { |
701 | 721 | // Use Dialog Setting |
702 | - if (m_bUseDialogSetting[m_nApplicationID]) { | |
722 | + if (m_Config.bUseDialogSetting[m_nApplicationID]) { | |
703 | 723 | int nOriginalApplicationID = m_nApplicationID; |
704 | 724 | for (m_nApplicationID = 0; m_nApplicationID < MAX_APP; ++m_nApplicationID) { |
705 | - if (!_tcsicmp(m_szSpecialApp[m_nApplicationID], _T("Dialog"))) { | |
725 | + if (!_tcsicmp(m_Config.szSpecialApp[m_nApplicationID], _T("Dialog"))) { | |
706 | 726 | break; |
707 | 727 | } |
708 | 728 | } |
@@ -803,8 +823,8 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
803 | 823 | || nKey == VK_LMENU |
804 | 824 | || nKey == VK_RMENU) { |
805 | 825 | for (int i = 0; i < MAX_COMMAND_TYPE; ++i) { |
806 | - if (Commands[m_nCommandID[m_nApplicationID][i][nKey]].fCommand | |
807 | - && (Commands[m_nCommandID[m_nApplicationID][i][nKey]].fCommand != CCommands::MetaAlt | |
826 | + if (Commands[m_Config.nCommandID[m_nApplicationID][i][nKey]].fCommand | |
827 | + && (Commands[m_Config.nCommandID[m_nApplicationID][i][nKey]].fCommand != CCommands::MetaAlt | |
808 | 828 | || nKey != VK_MENU && nKey != VK_LMENU && nKey != VK_RMENU)) { |
809 | 829 | goto HOOK; |
810 | 830 | } |
@@ -824,12 +844,12 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
824 | 844 | goto DO_NOTHING; |
825 | 845 | } |
826 | 846 | |
827 | - if (m_nSettingStyle[m_nApplicationID] == SETTING_DISABLE) { | |
847 | + if (m_Config.nSettingStyle[m_nApplicationID] == SETTING_DISABLE) { | |
828 | 848 | goto DO_NOTHING; |
829 | 849 | } |
830 | 850 | |
831 | 851 | // Do Nothing for Meadow, Mule for Win32, ... if those use default setting. |
832 | - if (!_tcsicmp(m_szSpecialApp[m_nApplicationID], _T("Default")) | |
852 | + if (!_tcsicmp(m_Config.szSpecialApp[m_nApplicationID], _T("Default")) | |
833 | 853 | && CUtils::IsDefaultIgnoreApplication()) { |
834 | 854 | goto DO_NOTHING; |
835 | 855 | } |
@@ -864,9 +884,9 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
864 | 884 | |
865 | 885 | // Ignore undefined C-x ? |
866 | 886 | if (nCommandType & CONTROLX) { |
867 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == NULL | |
868 | - && m_nFunctionID[m_nApplicationID][nCommandType][nKey] < 0) { | |
869 | - if (m_bIgnoreUndefinedC_x[m_nApplicationID]) { | |
887 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == NULL | |
888 | + && m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey] < 0) { | |
889 | + if (m_Config.bIgnoreUndefinedC_x[m_nApplicationID]) { | |
870 | 890 | CCommands::Reset(GOTO_HOOK); |
871 | 891 | goto HOOK; |
872 | 892 | } |
@@ -876,9 +896,9 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
876 | 896 | |
877 | 897 | // Ignore undefined Meta Ctrl+? |
878 | 898 | if (CCommands::bM_() && (nCommandType & CONTROL)) { |
879 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == NULL | |
880 | - && m_nFunctionID[m_nApplicationID][nCommandType][nKey] < 0) { | |
881 | - if (m_bIgnoreUndefinedMetaCtrl[m_nApplicationID]) { | |
899 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == NULL | |
900 | + && m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey] < 0) { | |
901 | + if (m_Config.bIgnoreUndefinedMetaCtrl[m_nApplicationID]) { | |
882 | 902 | if (Original(CONTROL, nKey)) { |
883 | 903 | Original(CONTROL, nKey, -1); |
884 | 904 | goto DO_NOTHING; |
@@ -910,17 +930,17 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
910 | 930 | } |
911 | 931 | } |
912 | 932 | |
913 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableOrDisableXKeymacs) { | |
933 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableOrDisableXKeymacs) { | |
914 | 934 | SetKeyboardHookFlag(!m_bHook); |
915 | 935 | goto HOOK; |
916 | 936 | } |
917 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableXKeymacs) { | |
937 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EnableXKeymacs) { | |
918 | 938 | if (!m_bHook) { |
919 | 939 | SetKeyboardHookFlag(!m_bHook); |
920 | 940 | } |
921 | 941 | goto HOOK; |
922 | 942 | } |
923 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DisableXKeymacs) { | |
943 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DisableXKeymacs) { | |
924 | 944 | if (m_bHook) { |
925 | 945 | SetKeyboardHookFlag(!m_bHook); |
926 | 946 | } |
@@ -936,42 +956,42 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
936 | 956 | |
937 | 957 | if (lParam & BEING_RELEASED) { |
938 | 958 | // ignore |
939 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::BackwardChar) { | |
959 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::BackwardChar) { | |
940 | 960 | if (index) { |
941 | 961 | --index; |
942 | 962 | } |
943 | 963 | goto HOOKX; |
944 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::BeginningOfLine) { | |
964 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::BeginningOfLine) { | |
945 | 965 | index = 0; |
946 | 966 | goto HOOKX; |
947 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DeleteBackwardChar) { | |
967 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DeleteBackwardChar) { | |
948 | 968 | if (index) { |
949 | 969 | --index; |
950 | 970 | memmove(&szPath[index], &szPath[index + 1], _tcslen(szPath) - index); |
951 | 971 | SetM_xTip(szPath); |
952 | 972 | } |
953 | 973 | goto HOOKX; |
954 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DeleteChar) { | |
974 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::DeleteChar) { | |
955 | 975 | if (index < _tcslen(szPath)) { |
956 | 976 | memmove(&szPath[index], &szPath[index + 1], _tcslen(szPath) - index); |
957 | 977 | SetM_xTip(szPath); |
958 | 978 | } |
959 | 979 | goto HOOKX; |
960 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EndOfLine) { | |
980 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::EndOfLine) { | |
961 | 981 | index = _tcslen(szPath); |
962 | 982 | goto HOOKX; |
963 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::ForwardChar) { | |
983 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::ForwardChar) { | |
964 | 984 | if (index < _tcslen(szPath)) { |
965 | 985 | ++index; |
966 | 986 | } |
967 | 987 | goto HOOKX; |
968 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::KeyboardQuit) { | |
988 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::KeyboardQuit) { | |
969 | 989 | CCommands::bM_x(FALSE); |
970 | 990 | index = 0; |
971 | 991 | memset(szPath, 0, sizeof(szPath)); |
972 | 992 | goto HOOK; |
973 | 993 | } else if (nKey == VK_RETURN |
974 | - || Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::Newline) { | |
994 | + || Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::Newline) { | |
975 | 995 | InvokeM_x(szPath); |
976 | 996 | |
977 | 997 | CCommands::bM_x(FALSE); |
@@ -1006,47 +1026,47 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
1006 | 1026 | } |
1007 | 1027 | } |
1008 | 1028 | |
1009 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~CONTROL][nKey]].fCommand == CCommands::OneShotModifierCtrl) { | |
1029 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~CONTROL][nKey]].fCommand == CCommands::OneShotModifierCtrl) { | |
1010 | 1030 | nOneShotModifier[nKey] = VK_LCONTROL; |
1011 | 1031 | DepressKey(nOneShotModifier[nKey]); |
1012 | 1032 | bCherryOneShotModifier = TRUE; |
1013 | 1033 | goto HOOK; |
1014 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierCtrlRepeat) { | |
1034 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierCtrlRepeat) { | |
1015 | 1035 | nOneShotModifier[nKey] = VK_LCONTROL; |
1016 | 1036 | DepressKey(nOneShotModifier[nKey]); |
1017 | 1037 | bCherryOneShotModifier = TRUE; |
1018 | 1038 | goto HOOK; |
1019 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~CONTROL][nKey]].fCommand == CCommands::OneShotModifierCtrlRepeat) { | |
1039 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~CONTROL][nKey]].fCommand == CCommands::OneShotModifierCtrlRepeat) { | |
1020 | 1040 | ReleaseKey(nOneShotModifier[nKey]); |
1021 | 1041 | bCherryOneShotModifier = FALSE; |
1022 | 1042 | Kdu(nKey); |
1023 | 1043 | goto HOOK; |
1024 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~META][nKey]].fCommand == CCommands::OneShotModifierAlt) { | |
1044 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~META][nKey]].fCommand == CCommands::OneShotModifierAlt) { | |
1025 | 1045 | nOneShotModifier[nKey] = VK_LMENU; |
1026 | 1046 | DepressKey(nOneShotModifier[nKey]); |
1027 | 1047 | bCherryOneShotModifier = TRUE; |
1028 | 1048 | goto HOOK; |
1029 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierAltRepeat) { | |
1049 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierAltRepeat) { | |
1030 | 1050 | nOneShotModifier[nKey] = VK_LMENU; |
1031 | 1051 | DepressKey(nOneShotModifier[nKey]); |
1032 | 1052 | bCherryOneShotModifier = TRUE; |
1033 | 1053 | goto HOOK; |
1034 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~META][nKey]].fCommand == CCommands::OneShotModifierAltRepeat) { | |
1054 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~META][nKey]].fCommand == CCommands::OneShotModifierAltRepeat) { | |
1035 | 1055 | ReleaseKey(nOneShotModifier[nKey]); |
1036 | 1056 | bCherryOneShotModifier = FALSE; |
1037 | 1057 | Kdu(nKey); |
1038 | 1058 | goto HOOK; |
1039 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~SHIFT][nKey]].fCommand == CCommands::OneShotModifierShift) { | |
1059 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~SHIFT][nKey]].fCommand == CCommands::OneShotModifierShift) { | |
1040 | 1060 | nOneShotModifier[nKey] = VK_SHIFT; |
1041 | 1061 | DepressKey(nOneShotModifier[nKey]); |
1042 | 1062 | bCherryOneShotModifier = TRUE; |
1043 | 1063 | goto HOOK; |
1044 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierShiftRepeat) { | |
1064 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand == CCommands::OneShotModifierShiftRepeat) { | |
1045 | 1065 | nOneShotModifier[nKey] = VK_SHIFT; |
1046 | 1066 | DepressKey(nOneShotModifier[nKey]); |
1047 | 1067 | bCherryOneShotModifier = TRUE; |
1048 | 1068 | goto HOOK; |
1049 | - } else if (Commands[m_nCommandID[m_nApplicationID][nCommandType & ~SHIFT][nKey]].fCommand == CCommands::OneShotModifierShiftRepeat) { | |
1069 | + } else if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType & ~SHIFT][nKey]].fCommand == CCommands::OneShotModifierShiftRepeat) { | |
1050 | 1070 | ReleaseKey(nOneShotModifier[nKey]); |
1051 | 1071 | bCherryOneShotModifier = FALSE; |
1052 | 1072 | Kdu(nKey); |
@@ -1062,15 +1082,15 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
1062 | 1082 | } |
1063 | 1083 | } |
1064 | 1084 | |
1065 | - if (0 <= m_nFunctionID[m_nApplicationID][nCommandType][nKey] | |
1066 | - && m_nFunctionID[m_nApplicationID][nCommandType][nKey] < MAX_FUNCTION | |
1067 | - && _tcslen(m_szFunctionDefinition[m_nFunctionID[m_nApplicationID][nCommandType][nKey]])) { | |
1068 | - CallFunction(m_nFunctionID[m_nApplicationID][nCommandType][nKey]); | |
1085 | + if (0 <= m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey] | |
1086 | + && m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey] < MAX_FUNCTION | |
1087 | + && _tcslen(m_Config.szFunctionDefinition[m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey]])) { | |
1088 | + CallFunction(m_Config.nFunctionID[m_nApplicationID][nCommandType][nKey]); | |
1069 | 1089 | CCommands::Reset(GOTO_HOOK); |
1070 | 1090 | goto HOOK; |
1071 | 1091 | } |
1072 | 1092 | |
1073 | - if (!Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand) { | |
1093 | + if (!Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand) { | |
1074 | 1094 | if (nKey == VK_CONTROL |
1075 | 1095 | || nKey == VK_LCONTROL |
1076 | 1096 | || nKey == VK_RCONTROL |
@@ -1103,12 +1123,12 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
1103 | 1123 | } |
1104 | 1124 | |
1105 | 1125 | if (CCommands::IsTemporarilyDisableXKeymacs() |
1106 | - && Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand != CCommands::KeyboardQuit) { | |
1126 | + && Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand != CCommands::KeyboardQuit) { | |
1107 | 1127 | CCommands::SetTemporarilyDisableXKeymacs(FALSE); |
1108 | 1128 | goto DO_NOTHING; |
1109 | 1129 | } |
1110 | 1130 | |
1111 | - if (m_bAtIbeamCursorOnly[m_nApplicationID][nCommandType][nKey]) { | |
1131 | + if (m_Config.bAtIbeamCursorOnly[m_nApplicationID][nCommandType][nKey]) { | |
1112 | 1132 | CURSORINFO cursorinfo = { sizeof(cursorinfo) }; |
1113 | 1133 | if (GetCursorInfo(&cursorinfo) && cursorinfo.flags && cursorinfo.hCursor != LoadCursor(NULL, IDC_IBEAM)) { |
1114 | 1134 | goto DO_NOTHING; |
@@ -1121,7 +1141,7 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
1121 | 1141 | |
1122 | 1142 | if (!bLocked) { |
1123 | 1143 | bLocked = TRUE; |
1124 | - fCommand = Commands[m_nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand; | |
1144 | + fCommand = Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][nKey]].fCommand; | |
1125 | 1145 | RECURSIVE_COMMAND: |
1126 | 1146 | switch (fCommand()) { |
1127 | 1147 | case GOTO_DO_NOTHING: |
@@ -1218,46 +1238,46 @@ void CXkeymacsDll::SetModifierIcons() | ||
1218 | 1238 | |
1219 | 1239 | void CXkeymacsDll::SetApplicationName(int nApplicationID, CString szApplicationName) |
1220 | 1240 | { |
1221 | - ZeroMemory(m_szSpecialApp[nApplicationID], sizeof(m_szSpecialApp[nApplicationID])); | |
1222 | - _tcsncpy(m_szSpecialApp[nApplicationID], szApplicationName, sizeof(m_szSpecialApp[nApplicationID])); | |
1241 | + ZeroMemory(m_Config.szSpecialApp[nApplicationID], sizeof(m_Config.szSpecialApp[nApplicationID])); | |
1242 | + _tcsncpy(m_Config.szSpecialApp[nApplicationID], szApplicationName, sizeof(m_Config.szSpecialApp[nApplicationID])); | |
1223 | 1243 | } |
1224 | 1244 | |
1225 | 1245 | void CXkeymacsDll::SetWindowText(int nApplicationID, CString szWindowText) |
1226 | 1246 | { |
1227 | - ZeroMemory(m_szWindowText[nApplicationID], sizeof(m_szWindowText[nApplicationID])); | |
1228 | - _tcsncpy(m_szWindowText[nApplicationID], szWindowText, sizeof(m_szWindowText[nApplicationID])); | |
1247 | + ZeroMemory(m_Config.szWindowText[nApplicationID], sizeof(m_Config.szWindowText[nApplicationID])); | |
1248 | + _tcsncpy(m_Config.szWindowText[nApplicationID], szWindowText, sizeof(m_Config.szWindowText[nApplicationID])); | |
1229 | 1249 | } |
1230 | 1250 | |
1231 | 1251 | void CXkeymacsDll::SetCommandID(int nApplicationID, int nCommandType, int nKey, int nCommandID) |
1232 | 1252 | { |
1233 | - m_nCommandID[nApplicationID][nCommandType][nKey] = nCommandID; | |
1253 | + m_Config.nCommandID[nApplicationID][nCommandType][nKey] = nCommandID; | |
1234 | 1254 | } |
1235 | 1255 | |
1236 | 1256 | void CXkeymacsDll::SetAtIbeamCursorOnly(int nApplicationID, int nCommandType, int nKey, BOOL bAtIbeamCursorOnly) |
1237 | 1257 | { |
1238 | - m_bAtIbeamCursorOnly[nApplicationID][nCommandType][nKey] = bAtIbeamCursorOnly; | |
1258 | + m_Config.bAtIbeamCursorOnly[nApplicationID][nCommandType][nKey] = bAtIbeamCursorOnly; | |
1239 | 1259 | } |
1240 | 1260 | |
1241 | 1261 | void CXkeymacsDll::SetKillRingMax(int nApplicationID, int nKillRingMax) |
1242 | 1262 | { |
1243 | - m_nKillRingMax[nApplicationID] = nKillRingMax; | |
1263 | + m_Config.nKillRingMax[nApplicationID] = nKillRingMax; | |
1244 | 1264 | } |
1245 | 1265 | |
1246 | 1266 | void CXkeymacsDll::SetUseDialogSetting(int nApplicationID, BOOL bUseDialogSetting) |
1247 | 1267 | { |
1248 | - m_bUseDialogSetting[nApplicationID] = bUseDialogSetting; | |
1268 | + m_Config.bUseDialogSetting[nApplicationID] = bUseDialogSetting; | |
1249 | 1269 | } |
1250 | 1270 | |
1251 | 1271 | // Clear data of nApplicationID |
1252 | 1272 | void CXkeymacsDll::Clear(int nApplicationID) |
1253 | 1273 | { |
1254 | 1274 | if (0 <= nApplicationID && nApplicationID < MAX_APP) { |
1255 | - ZeroMemory(m_szSpecialApp[nApplicationID], sizeof(m_szSpecialApp[nApplicationID])); | |
1256 | - ZeroMemory(m_nCommandID[nApplicationID], sizeof(m_nCommandID[nApplicationID])); | |
1257 | - ZeroMemory(m_bAtIbeamCursorOnly[nApplicationID], sizeof(m_bAtIbeamCursorOnly[nApplicationID])); | |
1258 | - m_nKillRingMax[nApplicationID] = 0; | |
1259 | - m_bUseDialogSetting[nApplicationID] = FALSE; | |
1260 | - m_nSettingStyle[nApplicationID] = 0; | |
1275 | + ZeroMemory(m_Config.szSpecialApp[nApplicationID], sizeof(m_Config.szSpecialApp[nApplicationID])); | |
1276 | + ZeroMemory(m_Config.nCommandID[nApplicationID], sizeof(m_Config.nCommandID[nApplicationID])); | |
1277 | + ZeroMemory(m_Config.bAtIbeamCursorOnly[nApplicationID], sizeof(m_Config.bAtIbeamCursorOnly[nApplicationID])); | |
1278 | + m_Config.nKillRingMax[nApplicationID] = 0; | |
1279 | + m_Config.bUseDialogSetting[nApplicationID] = FALSE; | |
1280 | + m_Config.nSettingStyle[nApplicationID] = 0; | |
1261 | 1281 | } else { |
1262 | 1282 | ASSERT(0); |
1263 | 1283 | } |
@@ -1287,7 +1307,7 @@ BOOL CXkeymacsDll::IsDepressedModifier(int (__cdecl *Modifier)(void), BOOL bPhys | ||
1287 | 1307 | do { |
1288 | 1308 | if (IsValidKey(bVk) |
1289 | 1309 | && IsDown(bVk, bPhysicalKey) |
1290 | - && Commands[m_nCommandID[m_nApplicationID][NONE][bVk]].fCommand == Modifier) { | |
1310 | + && Commands[m_Config.nCommandID[m_nApplicationID][NONE][bVk]].fCommand == Modifier) { | |
1291 | 1311 | return TRUE; |
1292 | 1312 | } |
1293 | 1313 | } while (++bVk); |
@@ -1329,7 +1349,7 @@ BOOL CXkeymacsDll::IsMeta() | ||
1329 | 1349 | |
1330 | 1350 | void CXkeymacsDll::AddKillRing(BOOL bNewData) |
1331 | 1351 | { |
1332 | - if (m_nKillRingMax[m_nApplicationID] == 0) { | |
1352 | + if (m_Config.nKillRingMax[m_nApplicationID] == 0) { | |
1333 | 1353 | return; |
1334 | 1354 | } |
1335 | 1355 |
@@ -1359,7 +1379,7 @@ void CXkeymacsDll::AddKillRing(BOOL bNewData) | ||
1359 | 1379 | |
1360 | 1380 | m_nKillRing = 0; |
1361 | 1381 | |
1362 | - if (m_nKillRingMax[m_nApplicationID] < m_oKillRing.GetCount()) { | |
1382 | + if (m_Config.nKillRingMax[m_nApplicationID] < m_oKillRing.GetCount()) { | |
1363 | 1383 | CClipboardSnap *pSnap = m_oKillRing.GetTail(); |
1364 | 1384 | delete pSnap; |
1365 | 1385 | pSnap = NULL; |
@@ -1371,7 +1391,7 @@ void CXkeymacsDll::AddKillRing(BOOL bNewData) | ||
1371 | 1391 | // Return FALSE if there is no more data |
1372 | 1392 | CClipboardSnap* CXkeymacsDll::GetKillRing(CClipboardSnap* pSnap, BOOL bForce) |
1373 | 1393 | { |
1374 | - if (m_nKillRingMax[m_nApplicationID] == 0) { | |
1394 | + if (m_Config.nKillRingMax[m_nApplicationID] == 0) { | |
1375 | 1395 | return NULL; |
1376 | 1396 | } |
1377 | 1397 |
@@ -1481,27 +1501,27 @@ int CXkeymacsDll::GetMickey(int nDifferential, int nThreshold1, int nThreshold2, | ||
1481 | 1501 | |
1482 | 1502 | void CXkeymacsDll::SetSettingStyle(int nApplicationID, int nSettingStyle) |
1483 | 1503 | { |
1484 | - m_nSettingStyle[nApplicationID] = nSettingStyle; | |
1504 | + m_Config.nSettingStyle[nApplicationID] = nSettingStyle; | |
1485 | 1505 | } |
1486 | 1506 | |
1487 | 1507 | void CXkeymacsDll::SetIgnoreUndefinedMetaCtrl(int nApplicationID, BOOL bIgnoreUndefinedMetaCtrl) |
1488 | 1508 | { |
1489 | - m_bIgnoreUndefinedMetaCtrl[nApplicationID] = bIgnoreUndefinedMetaCtrl; | |
1509 | + m_Config.bIgnoreUndefinedMetaCtrl[nApplicationID] = bIgnoreUndefinedMetaCtrl; | |
1490 | 1510 | } |
1491 | 1511 | |
1492 | 1512 | void CXkeymacsDll::SetIgnoreUndefinedC_x(int nApplicationID, BOOL bIgnoreUndefinedC_x) |
1493 | 1513 | { |
1494 | - m_bIgnoreUndefinedC_x[nApplicationID] = bIgnoreUndefinedC_x; | |
1514 | + m_Config.bIgnoreUndefinedC_x[nApplicationID] = bIgnoreUndefinedC_x; | |
1495 | 1515 | } |
1496 | 1516 | |
1497 | 1517 | void CXkeymacsDll::SetEnableCUA(int nApplicationID, BOOL bEnableCUA) |
1498 | 1518 | { |
1499 | - m_bEnableCUA[nApplicationID] = bEnableCUA; | |
1519 | + m_Config.bEnableCUA[nApplicationID] = bEnableCUA; | |
1500 | 1520 | } |
1501 | 1521 | |
1502 | 1522 | BOOL CXkeymacsDll::GetEnableCUA() |
1503 | 1523 | { |
1504 | - return m_bEnableCUA[m_nApplicationID]; | |
1524 | + return m_Config.bEnableCUA[m_nApplicationID]; | |
1505 | 1525 | } |
1506 | 1526 | |
1507 | 1527 | void CXkeymacsDll::DefiningMacro(BOOL bDefiningMacro) |
@@ -1621,12 +1641,12 @@ void CXkeymacsDll::CallMacro() // for debug | ||
1621 | 1641 | |
1622 | 1642 | void CXkeymacsDll::Set106Keyboard(BOOL b106Keyboard) |
1623 | 1643 | { |
1624 | - m_b106Keyboard = b106Keyboard; | |
1644 | + m_Config.b106Keyboard = b106Keyboard; | |
1625 | 1645 | } |
1626 | 1646 | |
1627 | 1647 | BOOL CXkeymacsDll::Is106Keyboard() |
1628 | 1648 | { |
1629 | - return m_b106Keyboard; | |
1649 | + return m_Config.b106Keyboard; | |
1630 | 1650 | } |
1631 | 1651 | |
1632 | 1652 | int CXkeymacsDll::IsPassThrough(BYTE nKey) |
@@ -1634,7 +1654,7 @@ int CXkeymacsDll::IsPassThrough(BYTE nKey) | ||
1634 | 1654 | BYTE bVk = 0; |
1635 | 1655 | do { |
1636 | 1656 | if (IsDown(bVk) |
1637 | - && (Commands[m_nCommandID[m_nApplicationID][NONE][bVk]].fCommand == CCommands::PassThrough)) { | |
1657 | + && (Commands[m_Config.nCommandID[m_nApplicationID][NONE][bVk]].fCommand == CCommands::PassThrough)) { | |
1638 | 1658 | if (bVk == nKey) { |
1639 | 1659 | return GOTO_HOOK; |
1640 | 1660 | } |
@@ -1658,13 +1678,13 @@ void CXkeymacsDll::SetFunctionKey(int nFunctionID, int nApplicationID, int nComm | ||
1658 | 1678 | return; |
1659 | 1679 | } |
1660 | 1680 | |
1661 | - m_nFunctionID[nApplicationID][nCommandType][nKey] = nFunctionID; | |
1681 | + m_Config.nFunctionID[nApplicationID][nCommandType][nKey] = nFunctionID; | |
1662 | 1682 | } |
1663 | 1683 | |
1664 | 1684 | void CXkeymacsDll::ClearFunctionDefinition() |
1665 | 1685 | { |
1666 | - memset(m_nFunctionID, -1, sizeof(m_nFunctionID)); | |
1667 | - memset(m_szFunctionDefinition, 0, sizeof(m_szFunctionDefinition)); | |
1686 | + memset(m_Config.nFunctionID, -1, sizeof(m_Config.nFunctionID)); | |
1687 | + memset(m_Config.szFunctionDefinition, 0, sizeof(m_Config.szFunctionDefinition)); | |
1668 | 1688 | } |
1669 | 1689 | |
1670 | 1690 | void CXkeymacsDll::SetFunctionDefinition(int nFunctionID, CString szDefinition) |
@@ -1673,8 +1693,8 @@ void CXkeymacsDll::SetFunctionDefinition(int nFunctionID, CString szDefinition) | ||
1673 | 1693 | return; |
1674 | 1694 | } |
1675 | 1695 | |
1676 | - memset(m_szFunctionDefinition[nFunctionID], 0, sizeof(m_szFunctionDefinition[nFunctionID])); | |
1677 | - _stprintf(m_szFunctionDefinition[nFunctionID], _T("%s"), szDefinition); | |
1696 | + memset(m_Config.szFunctionDefinition[nFunctionID], 0, sizeof(m_Config.szFunctionDefinition[nFunctionID])); | |
1697 | + _stprintf(m_Config.szFunctionDefinition[nFunctionID], _T("%s"), szDefinition); | |
1678 | 1698 | |
1679 | 1699 | return; |
1680 | 1700 |
@@ -1685,7 +1705,7 @@ void CXkeymacsDll::CallFunction(int nFunctionID) | ||
1685 | 1705 | { |
1686 | 1706 | CArray<KeyBind, KeyBind> keybinds; |
1687 | 1707 | |
1688 | - if (nFunctionID < 0 || MAX_FUNCTION <= nFunctionID || !_tcslen(m_szFunctionDefinition[nFunctionID])) { | |
1708 | + if (nFunctionID < 0 || MAX_FUNCTION <= nFunctionID || !_tcslen(m_Config.szFunctionDefinition[nFunctionID])) { | |
1689 | 1709 | return; |
1690 | 1710 | } |
1691 | 1711 |
@@ -1693,18 +1713,18 @@ void CXkeymacsDll::CallFunction(int nFunctionID) | ||
1693 | 1713 | BOOL bIsAltDown = CXkeymacsDll::IsDown(VK_MENU); |
1694 | 1714 | BOOL bIsShiftDown = CXkeymacsDll::IsDown(VK_SHIFT); |
1695 | 1715 | |
1696 | - if (m_szFunctionDefinition[nFunctionID][0] == _T('"') && m_szFunctionDefinition[nFunctionID][_tcslen(m_szFunctionDefinition[nFunctionID]) - 1] == _T('"')) { | |
1697 | - for (unsigned int i = 1; i < _tcslen(m_szFunctionDefinition[nFunctionID]) - 1; ++i) { // skip '"' | |
1716 | + if (m_Config.szFunctionDefinition[nFunctionID][0] == _T('"') && m_Config.szFunctionDefinition[nFunctionID][_tcslen(m_Config.szFunctionDefinition[nFunctionID]) - 1] == _T('"')) { | |
1717 | + for (unsigned int i = 1; i < _tcslen(m_Config.szFunctionDefinition[nFunctionID]) - 1; ++i) { // skip '"' | |
1698 | 1718 | keybinds.Add(ParseKey(nFunctionID, i)); |
1699 | 1719 | } |
1700 | - } else if (m_szFunctionDefinition[nFunctionID][0] == _T('[') && m_szFunctionDefinition[nFunctionID][_tcslen(m_szFunctionDefinition[nFunctionID]) - 1] == _T(']')) { | |
1701 | - for (unsigned int i = 1; i < _tcslen(m_szFunctionDefinition[nFunctionID]) - 1; ++i) { // skip '[' and ']' | |
1702 | - if (m_szFunctionDefinition[nFunctionID][i] == _T('?')) { // [?f ?o ?o] | |
1720 | + } else if (m_Config.szFunctionDefinition[nFunctionID][0] == _T('[') && m_Config.szFunctionDefinition[nFunctionID][_tcslen(m_Config.szFunctionDefinition[nFunctionID]) - 1] == _T(']')) { | |
1721 | + for (unsigned int i = 1; i < _tcslen(m_Config.szFunctionDefinition[nFunctionID]) - 1; ++i) { // skip '[' and ']' | |
1722 | + if (m_Config.szFunctionDefinition[nFunctionID][i] == _T('?')) { // [?f ?o ?o] | |
1703 | 1723 | ++i; |
1704 | 1724 | keybinds.Add(ParseKey(nFunctionID, i)); |
1705 | 1725 | } else { // [ControlCharacter] |
1706 | 1726 | for (int nKeyID = 0; nKeyID < sizeof(ControlCharacters) / sizeof(ControlCharacters[0]); ++nKeyID) { |
1707 | - if (!_tcsncmp(m_szFunctionDefinition[nFunctionID] + i, ControlCharacters[nKeyID].name, _tcslen(ControlCharacters[nKeyID].name))) { | |
1727 | + if (!_tcsncmp(m_Config.szFunctionDefinition[nFunctionID] + i, ControlCharacters[nKeyID].name, _tcslen(ControlCharacters[nKeyID].name))) { | |
1708 | 1728 | KeyBind keybind = {NONE, ControlCharacters[nKeyID].bVk}; |
1709 | 1729 | keybinds.Add(keybind); |
1710 | 1730 | i += _tcslen(ControlCharacters[nKeyID].name); |
@@ -1726,8 +1746,8 @@ void CXkeymacsDll::CallFunction(int nFunctionID) | ||
1726 | 1746 | const int nCommandType = keybinds.GetAt(i).nCommandType; |
1727 | 1747 | const BYTE bVk = keybinds.GetAt(i).bVk; |
1728 | 1748 | |
1729 | - if (nCommandType < MAX_COMMAND_TYPE && Commands[m_nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand) { | |
1730 | - if (Commands[m_nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand == CCommands::ExecuteExtendedCommand) { | |
1749 | + if (nCommandType < MAX_COMMAND_TYPE && Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand) { | |
1750 | + if (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand == CCommands::ExecuteExtendedCommand) { | |
1731 | 1751 | bM_x = TRUE; |
1732 | 1752 | } else if (!bInitialized) { |
1733 | 1753 | if (bIsCtrlDown) { |
@@ -1745,8 +1765,8 @@ void CXkeymacsDll::CallFunction(int nFunctionID) | ||
1745 | 1765 | |
1746 | 1766 | bInitialized = TRUE; |
1747 | 1767 | } |
1748 | -// CUtils::Log("CallFunction: Command Name: %s", Commands[m_nCommandID[m_nApplicationID][nCommandType][bVk]].szCommandName); | |
1749 | - while (Commands[m_nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand() == GOTO_RECURSIVE) { | |
1768 | +// CUtils::Log("CallFunction: Command Name: %s", Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][bVk]].szCommandName); | |
1769 | + while (Commands[m_Config.nCommandID[m_nApplicationID][nCommandType][bVk]].fCommand() == GOTO_RECURSIVE) { | |
1750 | 1770 | ; |
1751 | 1771 | } |
1752 | 1772 | } else if (bM_x) { |
@@ -1833,14 +1853,14 @@ KeyBind CXkeymacsDll::ParseKey(const int nFunctionID, unsigned int &i) | ||
1833 | 1853 | { |
1834 | 1854 | KeyBind keybind = {NONE}; |
1835 | 1855 | |
1836 | - if (m_szFunctionDefinition[nFunctionID][i] == _T('\\')) { | |
1856 | + if (m_Config.szFunctionDefinition[nFunctionID][i] == _T('\\')) { | |
1837 | 1857 | ++i; |
1838 | 1858 | BOOL bFound = FALSE; |
1839 | 1859 | do { |
1840 | 1860 | bFound = FALSE; |
1841 | 1861 | for (int ModifierID = 0; ModifierID < sizeof(Modifiers) / sizeof(Modifiers[0]); ++ModifierID) { |
1842 | - if (!_tcsncmp(m_szFunctionDefinition[nFunctionID] + i, Modifiers[ModifierID].name, _tcslen(Modifiers[ModifierID].name)) | |
1843 | - && _tcslen(Modifiers[ModifierID].name) < _tcslen(m_szFunctionDefinition[nFunctionID] + i)) { | |
1862 | + if (!_tcsncmp(m_Config.szFunctionDefinition[nFunctionID] + i, Modifiers[ModifierID].name, _tcslen(Modifiers[ModifierID].name)) | |
1863 | + && _tcslen(Modifiers[ModifierID].name) < _tcslen(m_Config.szFunctionDefinition[nFunctionID] + i)) { | |
1844 | 1864 | keybind.nCommandType |= Modifiers[ModifierID].id; |
1845 | 1865 | i+= _tcslen(Modifiers[ModifierID].name); |
1846 | 1866 | bFound = TRUE; |
@@ -1848,12 +1868,12 @@ KeyBind CXkeymacsDll::ParseKey(const int nFunctionID, unsigned int &i) | ||
1848 | 1868 | } |
1849 | 1869 | } while (bFound); |
1850 | 1870 | } |
1851 | - if (IsShift(m_szFunctionDefinition[nFunctionID][i]) && !(keybind.nCommandType & (WIN_CTRL | WIN_ALT | WIN_WIN))) { | |
1871 | + if (IsShift(m_Config.szFunctionDefinition[nFunctionID][i]) && !(keybind.nCommandType & (WIN_CTRL | WIN_ALT | WIN_WIN))) { | |
1852 | 1872 | keybind.nCommandType |= SHIFT; |
1853 | 1873 | } |
1854 | 1874 | |
1855 | 1875 | for (int nKeyID = 0; nKeyID < sizeof(ControlCharacters) / sizeof(ControlCharacters[0]); ++nKeyID) { |
1856 | - if (!_tcsncmp(m_szFunctionDefinition[nFunctionID] + i, ControlCharacters[nKeyID].name, _tcslen(ControlCharacters[nKeyID].name))) { | |
1876 | + if (!_tcsncmp(m_Config.szFunctionDefinition[nFunctionID] + i, ControlCharacters[nKeyID].name, _tcslen(ControlCharacters[nKeyID].name))) { | |
1857 | 1877 | i += _tcslen(ControlCharacters[nKeyID].name); |
1858 | 1878 | break; |
1859 | 1879 | } |
@@ -1861,7 +1881,7 @@ KeyBind CXkeymacsDll::ParseKey(const int nFunctionID, unsigned int &i) | ||
1861 | 1881 | if (nKeyID < sizeof(ControlCharacters) / sizeof(ControlCharacters[0])) { |
1862 | 1882 | keybind.bVk = ControlCharacters[nKeyID].bVk; |
1863 | 1883 | } else { |
1864 | - keybind.bVk = a2v(m_szFunctionDefinition[nFunctionID][i]); | |
1884 | + keybind.bVk = a2v(m_Config.szFunctionDefinition[nFunctionID][i]); | |
1865 | 1885 | } |
1866 | 1886 | |
1867 | 1887 | return keybind; |
@@ -1880,7 +1900,7 @@ BOOL CXkeymacsDll::IsShift(TCHAR nAscii) | ||
1880 | 1900 | case _T('&'): |
1881 | 1901 | return TRUE; |
1882 | 1902 | case _T('\''): |
1883 | - return m_b106Keyboard; | |
1903 | + return m_Config.b106Keyboard; | |
1884 | 1904 | case _T('('): |
1885 | 1905 | case _T(')'): |
1886 | 1906 | case _T('*'): |
@@ -1893,18 +1913,18 @@ BOOL CXkeymacsDll::IsShift(TCHAR nAscii) | ||
1893 | 1913 | case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'): case _T('5'): case _T('6'): case _T('7'): case _T('8'): case _T('9'): |
1894 | 1914 | return FALSE; |
1895 | 1915 | case _T(':'): |
1896 | - return !m_b106Keyboard; | |
1916 | + return !m_Config.b106Keyboard; | |
1897 | 1917 | case _T(';'): |
1898 | 1918 | return FALSE; |
1899 | 1919 | case _T('<'): |
1900 | 1920 | return TRUE; |
1901 | 1921 | case _T('='): |
1902 | - return m_b106Keyboard; | |
1922 | + return m_Config.b106Keyboard; | |
1903 | 1923 | case _T('>'): |
1904 | 1924 | case _T('?'): |
1905 | 1925 | return TRUE; |
1906 | 1926 | case _T('@'): |
1907 | - return !m_b106Keyboard; | |
1927 | + return !m_Config.b106Keyboard; | |
1908 | 1928 | case _T('A'): case _T('B'): case _T('C'): case _T('D'): case _T('E'): case _T('F'): case _T('G'): case _T('H'): case _T('I'): case _T('J'): |
1909 | 1929 | case _T('K'): case _T('L'): case _T('M'): case _T('N'): case _T('O'): case _T('P'): case _T('Q'): case _T('R'): case _T('S'): case _T('T'): |
1910 | 1930 | case _T('U'): case _T('V'): case _T('W'): case _T('X'): case _T('Y'): case _T('Z'): |
@@ -1914,11 +1934,11 @@ BOOL CXkeymacsDll::IsShift(TCHAR nAscii) | ||
1914 | 1934 | case _T(']'): |
1915 | 1935 | return FALSE; |
1916 | 1936 | case _T('^'): |
1917 | - return !m_b106Keyboard; | |
1937 | + return !m_Config.b106Keyboard; | |
1918 | 1938 | case _T('_'): |
1919 | 1939 | return TRUE; |
1920 | 1940 | case _T('`'): |
1921 | - return m_b106Keyboard; | |
1941 | + return m_Config.b106Keyboard; | |
1922 | 1942 | case _T('a'): case _T('b'): case _T('c'): case _T('d'): case _T('e'): case _T('f'): case _T('g'): case _T('h'): case _T('i'): case _T('j'): |
1923 | 1943 | case _T('k'): case _T('l'): case _T('m'): case _T('n'): case _T('o'): case _T('p'): case _T('q'): case _T('r'): case _T('s'): case _T('t'): |
1924 | 1944 | case _T('u'): case _T('v'): case _T('w'): case _T('x'): case _T('y'): case _T('z'): |
@@ -1941,7 +1961,7 @@ BYTE CXkeymacsDll::a2v(TCHAR nAscii) | ||
1941 | 1961 | case _T('!'): |
1942 | 1962 | return '1'; |
1943 | 1963 | case _T('"'): |
1944 | - return m_b106Keyboard ? '2' : (BYTE) 0xde; // VK_OEM_7 | |
1964 | + return m_Config.b106Keyboard ? '2' : (BYTE) 0xde; // VK_OEM_7 | |
1945 | 1965 | case _T('#'): |
1946 | 1966 | return '3'; |
1947 | 1967 | case _T('$'): |
@@ -1949,15 +1969,15 @@ BYTE CXkeymacsDll::a2v(TCHAR nAscii) | ||
1949 | 1969 | case _T('%'): |
1950 | 1970 | return '5'; |
1951 | 1971 | case _T('&'): |
1952 | - return m_b106Keyboard ? '6' : '7'; | |
1972 | + return m_Config.b106Keyboard ? '6' : '7'; | |
1953 | 1973 | case _T('\''): |
1954 | - return m_b106Keyboard ? '7' : (BYTE) 0xde; // VK_OEM_7 | |
1974 | + return m_Config.b106Keyboard ? '7' : (BYTE) 0xde; // VK_OEM_7 | |
1955 | 1975 | case _T('('): |
1956 | - return m_b106Keyboard ? '8' : '9'; | |
1976 | + return m_Config.b106Keyboard ? '8' : '9'; | |
1957 | 1977 | case _T(')'): |
1958 | - return m_b106Keyboard ? '9' : '0'; | |
1978 | + return m_Config.b106Keyboard ? '9' : '0'; | |
1959 | 1979 | case _T('*'): |
1960 | - return m_b106Keyboard ? (BYTE) 0xba : '8'; // VK_OEM_1 | |
1980 | + return m_Config.b106Keyboard ? (BYTE) 0xba : '8'; // VK_OEM_1 | |
1961 | 1981 | case _T('+'): |
1962 | 1982 | return 0xbb; // VK_OEM_PLUS |
1963 | 1983 | case _T(','): |
@@ -1973,17 +1993,17 @@ BYTE CXkeymacsDll::a2v(TCHAR nAscii) | ||
1973 | 1993 | case _T(':'): |
1974 | 1994 | return 0xba; // VK_OEM_1 |
1975 | 1995 | case _T(';'): |
1976 | - return m_b106Keyboard ? (BYTE) 0xbb : (BYTE) 0xba; // VK_OEM_PLUS VK_OEM_1 | |
1996 | + return m_Config.b106Keyboard ? (BYTE) 0xbb : (BYTE) 0xba; // VK_OEM_PLUS VK_OEM_1 | |
1977 | 1997 | case _T('<'): |
1978 | 1998 | return 0xbc; // VK_OEM_COMMA |
1979 | 1999 | case _T('='): |
1980 | - return m_b106Keyboard ? (BYTE) 0xbd : (BYTE) 0xbb; // VK_OEM_MINUS VK_OEM_PLUS | |
2000 | + return m_Config.b106Keyboard ? (BYTE) 0xbd : (BYTE) 0xbb; // VK_OEM_MINUS VK_OEM_PLUS | |
1981 | 2001 | case _T('>'): |
1982 | 2002 | return 0xbe; // VK_OEM_PERIOD |
1983 | 2003 | case _T('?'): |
1984 | 2004 | return 0xbf; // VK_OEM_2 |
1985 | 2005 | case _T('@'): |
1986 | - return m_b106Keyboard ? (BYTE) 0xc0 : '2'; | |
2006 | + return m_Config.b106Keyboard ? (BYTE) 0xc0 : '2'; | |
1987 | 2007 | case _T('A'): case _T('B'): case _T('C'): case _T('D'): case _T('E'): case _T('F'): case _T('G'): case _T('H'): case _T('I'): case _T('J'): |
1988 | 2008 | case _T('K'): case _T('L'): case _T('M'): case _T('N'): case _T('O'): case _T('P'): case _T('Q'): case _T('R'): case _T('S'): case _T('T'): |
1989 | 2009 | case _T('U'): case _T('V'): case _T('W'): case _T('X'): case _T('Y'): case _T('Z'): |
@@ -1995,9 +2015,9 @@ BYTE CXkeymacsDll::a2v(TCHAR nAscii) | ||
1995 | 2015 | case _T(']'): |
1996 | 2016 | return 0xdd; // VK_OEM_6 |
1997 | 2017 | case _T('^'): |
1998 | - return m_b106Keyboard ? (BYTE) 0xde : '6'; // VK_OEM_7 | |
2018 | + return m_Config.b106Keyboard ? (BYTE) 0xde : '6'; // VK_OEM_7 | |
1999 | 2019 | case _T('_'): |
2000 | - return m_b106Keyboard ? (BYTE) 0xe2 : (BYTE) 0xbd; // VK_OEM_102 VK_OEM_MINUS | |
2020 | + return m_Config.b106Keyboard ? (BYTE) 0xe2 : (BYTE) 0xbd; // VK_OEM_102 VK_OEM_MINUS | |
2001 | 2021 | case _T('`'): |
2002 | 2022 | return 0xc0; // VK_OEM_3 |
2003 | 2023 | case _T('a'): case _T('b'): case _T('c'): case _T('d'): case _T('e'): case _T('f'): case _T('g'): case _T('h'): case _T('i'): case _T('j'): |
@@ -2011,7 +2031,7 @@ BYTE CXkeymacsDll::a2v(TCHAR nAscii) | ||
2011 | 2031 | case _T('}'): |
2012 | 2032 | return 0xdd; // VK_OEM_6 |
2013 | 2033 | case _T('~'): |
2014 | - return m_b106Keyboard ? (BYTE) 0xde : (BYTE) 0xc0; // VK_OEM_7 VK_OEM_3 | |
2034 | + return m_Config.b106Keyboard ? (BYTE) 0xde : (BYTE) 0xc0; // VK_OEM_7 VK_OEM_3 | |
2015 | 2035 | default: |
2016 | 2036 | return 0; |
2017 | 2037 | } |
@@ -2096,12 +2116,12 @@ void CXkeymacsDll::DoSetCursor() | ||
2096 | 2116 | |
2097 | 2117 | void CXkeymacsDll::Set326Compatible(int nApplicationID, BOOL b326Compatible) |
2098 | 2118 | { |
2099 | - m_b326Compatible[nApplicationID] = b326Compatible; | |
2119 | + m_Config.b326Compatible[nApplicationID] = b326Compatible; | |
2100 | 2120 | } |
2101 | 2121 | |
2102 | 2122 | BOOL CXkeymacsDll::Get326Compatible() |
2103 | 2123 | { |
2104 | - return m_b326Compatible[m_nApplicationID]; | |
2124 | + return m_Config.b326Compatible[m_nApplicationID]; | |
2105 | 2125 | } |
2106 | 2126 | |
2107 | 2127 | void CXkeymacsDll::InvokeM_x(const TCHAR *const szPath) |
@@ -53,6 +53,8 @@ struct KeyName | ||
53 | 53 | class AFX_EXT_CLASS CXkeymacsDll |
54 | 54 | { |
55 | 55 | public: |
56 | + static BOOL SaveConfig(); | |
57 | + static BOOL LoadConfig(); | |
56 | 58 | static void SetM_xTip(const TCHAR *const szPath); |
57 | 59 | static BOOL Get326Compatible(); |
58 | 60 | static void Set326Compatible(int nApplicationID, BOOL b326Compatible); |
@@ -74,6 +76,7 @@ public: | ||
74 | 76 | static void SetIgnoreUndefinedC_x(int nApplicationID, BOOL bIgnoreUndefinedC_x); |
75 | 77 | static void SetIgnoreUndefinedMetaCtrl(int nApplicationID, BOOL bIgnoreUndefinedMetaCtrl); |
76 | 78 | static void SetHooks(); |
79 | + static void EnableKeyboardHook(); | |
77 | 80 | static void SetKeyboardHook(); |
78 | 81 | static void SetSettingStyle(int nApplicationID, int nSettingStyle); |
79 | 82 | static void SetUseDialogSetting(int nApplicationID, BOOL bUseDialogSetting); |
@@ -100,7 +103,6 @@ public: | ||
100 | 103 | private: |
101 | 104 | static TCHAR m_M_xTip[128]; |
102 | 105 | static void InvokeM_x(const TCHAR* const szPath); |
103 | - static BOOL m_b326Compatible[MAX_APP]; | |
104 | 106 | static void LogCallWndProcMessage(WPARAM wParam, LPARAM lParam); |
105 | 107 | static void DoSetCursor(); |
106 | 108 | static HCURSOR m_hCurrentCursor; |
@@ -111,7 +113,6 @@ private: | ||
111 | 113 | static HHOOK m_hHookCallWndRet; |
112 | 114 | static LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam); |
113 | 115 | static BOOL IsMatchWindowText(CString szWindowText); |
114 | - static TCHAR m_szWindowText[MAX_APP][WINDOW_TEXT_LENGTH]; | |
115 | 116 | static BOOL m_bEnableKeyboardHook; |
116 | 117 | static HHOOK m_hHookCallWnd; |
117 | 118 | static HHOOK m_hHookGetMessage; |
@@ -128,12 +129,7 @@ private: | ||
128 | 129 | static KeyBind ParseKey(const int nFunctionID, unsigned int &i); |
129 | 130 | static BYTE a2v(TCHAR nAscii); |
130 | 131 | static BOOL IsShift(TCHAR nAscii); |
131 | - static TCHAR m_szFunctionDefinition[MAX_FUNCTION][MAX_DEFINITION]; | |
132 | 132 | static void CallFunction(int nFunctionID); |
133 | - static int m_nFunctionID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
134 | - static BOOL m_bEnableCUA[MAX_APP]; | |
135 | - static TCHAR m_szOldApplicationName[MAX_PATH]; | |
136 | - static TCHAR m_szApplicationName[MAX_PATH]; | |
137 | 133 | static int IsPassThrough(BYTE nKey); |
138 | 134 | static BOOL IsDepressedShiftKeyOnly(BYTE nKey); |
139 | 135 | static BOOL IsDepressedModifier(int Modifier(), BOOL bPhysicalKey = TRUE); |
@@ -142,25 +138,17 @@ private: | ||
142 | 138 | static BOOL m_bDefiningMacro; |
143 | 139 | static void Original(int nCommandType, BYTE bVk, int nOriginal); |
144 | 140 | static int Original(int nCommandType, BYTE bVk); |
145 | - static BOOL m_bUseDialogSetting[MAX_APP]; | |
146 | 141 | static void InitKeyboardProc(BOOL bImeComposition); |
147 | - static BOOL m_bIgnoreUndefinedC_x[MAX_APP]; | |
148 | - static BOOL m_bIgnoreUndefinedMetaCtrl[MAX_APP]; | |
149 | - static int m_nSettingStyle[MAX_APP]; | |
150 | 142 | static int m_nApplicationID; |
151 | 143 | static int m_nOriginal[MAX_COMMAND_TYPE][MAX_KEY]; |
152 | 144 | static int m_nKillRing; |
153 | 145 | static CList<CClipboardSnap *, CClipboardSnap *> m_oKillRing; |
154 | - static int m_nKillRingMax[MAX_APP]; | |
155 | 146 | static int GetMickey(int nDifferential, int nThreshold1, int nThreshold2, int nAcceleration, int nSpeed); |
156 | 147 | static BOOL m_bHook; |
157 | 148 | static BOOL m_bRightShift; |
158 | 149 | static BOOL m_bRightAlt; |
159 | 150 | static BOOL m_bRightControl; |
160 | - static TCHAR m_szSpecialApp[MAX_APP][CLASS_NAME_LENGTH]; | |
161 | - static int m_nCommandID[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
162 | - static BOOL m_bAtIbeamCursorOnly[MAX_APP][MAX_COMMAND_TYPE][MAX_KEY]; | |
163 | - static BOOL m_b106Keyboard; | |
151 | + static CONFIG m_Config; | |
164 | 152 | }; |
165 | 153 | |
166 | 154 | #endif // !defined(AFX_XKEYMACS_H__88552DEC_1233_4A0A_BE62_9EF7BC618EC6__INCLUDED_) |