├── .gitattributes ├── .gitignore ├── README.org ├── fcitx-remote.sln └── fcitx-remote ├── ReadMe.txt ├── fcitx-remote.cpp ├── fcitx-remote.vcxproj ├── fcitx-remote.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | 98 | # NuGet Packages Directory 99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 100 | #packages/ 101 | 102 | # Windows Azure Build Output 103 | csx 104 | *.build.csdef 105 | 106 | # Windows Store app package directory 107 | AppPackages/ 108 | 109 | # Others 110 | sql/ 111 | *.Cache 112 | ClientBin/ 113 | [Ss]tyle[Cc]op.* 114 | ~$* 115 | *~ 116 | *.dbmdl 117 | *.[Pp]ublish.xml 118 | *.pfx 119 | *.publishsettings 120 | 121 | # RIA/Silverlight projects 122 | Generated_Code/ 123 | 124 | # Backup & report files from converting an old project file to a newer 125 | # Visual Studio version. Backup files are not needed, because we have git ;-) 126 | _UpgradeReport_Files/ 127 | Backup*/ 128 | UpgradeLog*.XML 129 | UpgradeLog*.htm 130 | 131 | # SQL Server files 132 | App_Data/*.mdf 133 | App_Data/*.ldf 134 | 135 | 136 | #LightSwitch generated files 137 | GeneratedArtifacts/ 138 | _Pvt_Extensions/ 139 | ModelManifest.xml 140 | 141 | # ========================= 142 | # Windows detritus 143 | # ========================= 144 | 145 | # Windows image file caches 146 | Thumbs.db 147 | ehthumbs.db 148 | 149 | # Folder config file 150 | Desktop.ini 151 | 152 | # Recycle Bin used on file shares 153 | $RECYCLE.BIN/ 154 | 155 | # Mac desktop service store files 156 | .DS_Store 157 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: fcitx-remote-for-windows 2 | 3 | This is a fake =fcitx-remote= for Windows so that it can be used by 4 | [[https://github.com/cute-jumper/fcitx.el][fcitx.el]]. Inspired by [[https://github.com/CodeFalling/fcitx-remote-for-osx/][fcitx-remote-for-osx]]. 5 | 6 | For Vim users: This program might also be able to be used by 7 | =fcitx.vim=. I haven't tested it and I probably won't since I don't 8 | use Vim myself. If you're interested, help me out by submitting PRs or 9 | reporting issues. 10 | 11 | * Build Instructions 12 | ** Build by Yourself 13 | You can change the key combination to toggle the input method if 14 | you build the program by yourself. 15 | 16 | In current code, =ALT+SHIFT= is set as the default key combination 17 | to toggle the input method. 18 | 19 | This project is built from Visual Studio 2013. Import the project 20 | into Visual Studio and build the executable file. 21 | 22 | ** Use pre-built releases 23 | You can download the pre-built releases in the GitHub project 24 | homepage. Two versions available: 25 | - Use =ALT+SHIFT= as the toggle key: [[https://github.com/cute-jumper/fcitx-remote-for-windows/releases/download/alt-shift/fcitx-remote.exe][download link]] 26 | - Use =WIN+SPACE= as the toggle key: [[https://github.com/cute-jumper/fcitx-remote-for-windows/releases/download/win-space/fcitx-remote.exe][download link]] 27 | 28 | Choose the one that fits you. 29 | 30 | * Windows Setup 31 | This program toggles the input method by simulating =ALT+SHIFT= or 32 | =WIN+SPACE= keys, which means you need to make sure you can use 33 | =ALT+SHIFT= or =WIN+SPACE= to switch between English and Chinese 34 | input method. 35 | 36 | * Emacs Setup 37 | If you're using =WIN+SPACE= to toggle the input method, add the 38 | following settings to your =init.el= so that =WIN+SPACE= can be 39 | handled by the Windows instead of Emacs: 40 | 41 | #+BEGIN_SRC elisp 42 | (setq w32-pass-lwindow-to-system nil) 43 | (setq w32-lwindow-modifier 'super) 44 | #+END_SRC 45 | 46 | Also, make sure =fcitx-remote= is in your =PATH= and =exec-path=. If 47 | not, use the following code in your =init.el=: 48 | 49 | #+BEGIN_SRC elisp 50 | (let ((fcitx-path "C:/path/to/fcitx-remote")) 51 | (setenv "PATH" (concat fcitx-path ";" (getenv "PATH"))) 52 | (add-to-list 'exec-path fcitx-path)) 53 | #+END_SRC 54 | 55 | * Problems 56 | Currently this program works great, but still has some minor problems: 57 | 1. =SendInput= can't guarantee the keyboard input sequence it has 58 | sent to be processed before it returns. In some sense, it is not 59 | fully /synchronized/ (please correct me if I'm wrong). Therefore, 60 | sometimes if you're typing *really fast*, the input method may 61 | not be closed before your next input. I noticed this when I 62 | tested the =prefix-keys= feature of =fcitx.el=. 63 | 2. =ALT+SHIFT= or =WIN+SPACE= is not configurable right now. 64 | 65 | * TODO TODO 66 | - Better implementation instead of using =SendInput=. 67 | - Make the toggle key (=ALT+SHIFT= or =WIN+SPACE=) configurable. 68 | - Support more command line options. Currently only =-c= and =-o= 69 | are supported. =fcitx-remote= will print the status in all the 70 | other cases. The current approach is already enough to make 71 | =fcitx.el= work properly. 72 | - Check Vim plugin compatibility: help needed, since I don't use Vim 73 | myself. 74 | -------------------------------------------------------------------------------- /fcitx-remote.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fcitx-remote", "fcitx-remote\fcitx-remote.vcxproj", "{0BE1A22F-D037-4243-B232-87640C198BA1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0BE1A22F-D037-4243-B232-87640C198BA1}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {0BE1A22F-D037-4243-B232-87640C198BA1}.Debug|Win32.Build.0 = Debug|Win32 16 | {0BE1A22F-D037-4243-B232-87640C198BA1}.Release|Win32.ActiveCfg = Release|Win32 17 | {0BE1A22F-D037-4243-B232-87640C198BA1}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /fcitx-remote/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : fcitx-remote Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this fcitx-remote application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your fcitx-remote application. 9 | 10 | 11 | fcitx-remote.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | fcitx-remote.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | fcitx-remote.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named fcitx-remote.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /fcitx-remote/fcitx-remote.cpp: -------------------------------------------------------------------------------- 1 | // fcitx-remote.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #pragma comment(lib, "user32.lib") 8 | 9 | using namespace std; 10 | 11 | // The first parameter is not correct, but it works. So it's fine here. 12 | static const HKL ENG_LAYOUT = LoadKeyboardLayout((LPCWSTR)"00000409", 2); 13 | 14 | BOOL isEngLayout() 15 | { 16 | return GetKeyboardLayout(0) == ENG_LAYOUT; 17 | } 18 | 19 | BOOL toggleInputMethod() 20 | { 21 | INPUT ips[4]; 22 | memset(ips, 0, sizeof(ips)); 23 | for (int i = 0; i < 4; i++) { 24 | ips[i].type = INPUT_KEYBOARD; 25 | } 26 | // uncomment if use win+space 27 | //ips[0].ki.wVk = ips[2].ki.wVk = VK_LWIN; 28 | //ips[1].ki.wVk = ips[3].ki.wVk = VK_SPACE; 29 | ips[0].ki.wVk = ips[2].ki.wVk = VK_MENU; 30 | ips[1].ki.wVk = ips[3].ki.wVk = VK_SHIFT; 31 | ips[2].ki.dwFlags = ips[3].ki.dwFlags = KEYEVENTF_KEYUP; 32 | SendInput(4, ips, sizeof(INPUT)); 33 | return 0; 34 | } 35 | 36 | int _tmain(int argc, _TCHAR* argv[]) 37 | { 38 | if (argc > 1) 39 | { 40 | if (!_tcscmp(argv[1], _T("-c"))) 41 | { 42 | if (!isEngLayout()) 43 | { 44 | toggleInputMethod(); 45 | } 46 | } 47 | else if (!_tccmp(argv[1], _T("-o"))) 48 | { 49 | if (isEngLayout()) 50 | { 51 | toggleInputMethod(); 52 | } 53 | } 54 | } 55 | else 56 | { 57 | cout << (2 - isEngLayout()) << endl; 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /fcitx-remote/fcitx-remote.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0BE1A22F-D037-4243-B232-87640C198BA1} 15 | Win32Proj 16 | fcitxremote 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | Use 51 | Level3 52 | Disabled 53 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 54 | true 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | Use 65 | MaxSpeed 66 | true 67 | true 68 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 69 | true 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Create 89 | Create 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /fcitx-remote/fcitx-remote.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /fcitx-remote/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // fcitx-remote.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /fcitx-remote/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /fcitx-remote/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | --------------------------------------------------------------------------------