Created
May 6, 2011 23:04
-
-
Save Maxdamantus/959967 to your computer and use it in GitHub Desktop.
Type in Dvorak on a QWERTY-configured Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* cc d2q.c -o d2q.exe -Wl,-subsystem,windows | |
*/ | |
#include <windows.h> | |
int mapping; | |
int remap(int o){ | |
return | |
o == 'Q'? 222 : | |
o == 'W'? 188 : | |
o == 'E'? 190 : | |
o == 219? 191 : | |
o == 221? 187 : | |
o == 188? 'W' : | |
o == 190? 'V' : | |
o == 191? 'Z' : | |
o == 186? 'S' : | |
o == 222? 189 : | |
o == 189? 219 : | |
o == 187? 221 : | |
o >= 'A' && o <= 'Z'? "AXJE\xbeUIDCHTNMBRL\xdePOYGK\xbcQF\xba"[o - 'A'] : 0; | |
} | |
LRESULT CALLBACK keyhook(int nCode, WPARAM wParam, LPARAM lParam){ | |
int k; | |
if(!mapping && nCode == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_KEYUP) && (k = remap(((PKBDLLHOOKSTRUCT)lParam)->vkCode))){ | |
mapping = 1; | |
keybd_event(k, ((PKBDLLHOOKSTRUCT)lParam)->scanCode, wParam == WM_KEYUP? KEYEVENTF_KEYUP : 0, 0); | |
mapping = 0; | |
return 1; | |
} | |
return CallNextHookEx(NULL, nCode, wParam, lParam); | |
} | |
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, PTSTR lpcmd, int show){ | |
HHOOK keyhookex; | |
keyhookex = SetWindowsHookEx(WH_KEYBOARD_LL, keyhook, hinst, 0); | |
MessageBox(NULL, TEXT("Remapping, OK to stop"), TEXT("d2q"), MB_OK); | |
UnhookWindowsHookEx(keyhookex); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment