⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ui.c

📁 手机上的韩文输入法 saenaru20031212.zip
💻 C
📖 第 1 页 / 共 4 页
字号:
        return FALSE;
    return TRUE;
}

BOOL WINAPI UnsetHookFunc(void)
{
    if(UnhookWindowsHookEx(hHookWnd) == 0)
        return FALSE;
    return TRUE;
}

static const WCHAR dvorak2qwerty_table[] = {
    /* imported from the nabi */
    0x021,    /* GDK_exclam */
    0x051,    /* GDK_quotedbl */
    0x023,    /* GDK_numbersign */
    0x024,    /* GDK_dollar */
    0x025,    /* GDK_percent */
    0x026,    /* GDK_ampersand */
    0x071,    /* GDK_apostrophe */
    0x028,    /* GDK_parenleft */
    0x029,    /* GDK_parenright */
    0x02a,    /* GDK_asterisk */
    0x07d,    /* GDK_plus */
    0x077,    /* GDK_comma */
    0x027,    /* GDK_minus */
    0x065,    /* GDK_period */
    0x05b,    /* GDK_slash */
    0x030,    /* GDK_0 */
    0x031,    /* GDK_1 */
    0x032,    /* GDK_2 */
    0x033,    /* GDK_3 */
    0x034,    /* GDK_4 */
    0x035,    /* GDK_5 */
    0x036,    /* GDK_6 */
    0x037,    /* GDK_7 */
    0x038,    /* GDK_8 */
    0x039,    /* GDK_9 */
    0x05a,    /* GDK_colon */
    0x07a,    /* GDK_semicolon */
    0x057,    /* GDK_less */
    0x05d,    /* GDK_qual */
    0x045,    /* GDK_greater */
    0x07b,    /* GDK_question */
    0x040,    /* GDK_at */
    0x041,    /* GDK_A */
    0x04e,    /* GDK_B */
    0x049,    /* GDK_C */
    0x048,    /* GDK_D */
    0x044,    /* GDK_E */
    0x059,    /* GDK_F */
    0x055,    /* GDK_G */
    0x04a,    /* GDK_H */
    0x047,    /* GDK_I */
    0x043,    /* GDK_J */
    0x056,    /* GDK_K */
    0x050,    /* GDK_L */
    0x04d,    /* GDK_M */
    0x04c,    /* GDK_N */
    0x053,    /* GDK_O */
    0x052,    /* GDK_P */
    0x058,    /* GDK_Q */
    0x04f,    /* GDK_R */
    0x03a,    /* GDK_S */
    0x04b,    /* GDK_T */
    0x046,    /* GDK_U */
    0x03e,    /* GDK_V */
    0x03c,    /* GDK_W */
    0x042,    /* GDK_X */
    0x054,    /* GDK_Y */
    0x03f,    /* GDK_Z */
    0x02d,    /* GDK_bracketleft */
    0x05c,    /* GDK_backslash */
    0x03d,    /* GDK_bracketright */
    0x05e,    /* GDK_asciicircum */
    0x022,    /* GDK_underscore */
    0x060,    /* GDK_grave */
    0x061,    /* GDK_a */
    0x06e,    /* GDK_b */
    0x069,    /* GDK_c */
    0x068,    /* GDK_d */
    0x064,    /* GDK_e */
    0x079,    /* GDK_f */
    0x075,    /* GDK_g */
    0x06a,    /* GDK_h */
    0x067,    /* GDK_i */
    0x063,    /* GDK_j */
    0x076,    /* GDK_k */
    0x070,    /* GDK_l */
    0x06d,    /* GDK_m */
    0x06c,    /* GDK_n */
    0x073,    /* GDK_o */
    0x072,    /* GDK_p */
    0x078,    /* GDK_q */
    0x06f,    /* GDK_r */
    0x03b,    /* GDK_s */
    0x06b,    /* GDK_t */
    0x066,    /* GDK_u */
    0x02e,    /* GDK_v */
    0x02c,    /* GDK_w */
    0x062,    /* GDK_x */
    0x074,    /* GDK_y */
    0x02f,    /* GDK_z */
    0x05f,    /* GDK_braceleft */
    0x07c,    /* GDK_bar */
    0x02b,    /* GDK_braceright */
    0x07e,    /* GDK_asciitilde */
};

static const WCHAR qwerty2dvorak_table[] = {
    0x021,    /* GDK_exclam */
    0x05f,    /* GDK_underscore */
    0x023,    /* GDK_numbersign */
    0x024,    /* GDK_dollar */
    0x025,    /* GDK_percent */
    0x026,    /* GDK_ampersand */
    0x02d,    /* GDK_minus */
    0x028,    /* GDK_parenleft */
    0x029,    /* GDK_parenright */
    0x02a,    /* GDK_asterisk */
    0x07d,    /* GDK_braceright */
    0x077,    /* GDK_w */
    0x05b,    /* GDK_bracketleft */
    0x076,    /* GDK_v */
    0x07a,    /* GDK_z */
    0x030,    /* GDK_0 */
    0x031,    /* GDK_1 */
    0x032,    /* GDK_2 */
    0x033,    /* GDK_3 */
    0x034,    /* GDK_4 */
    0x035,    /* GDK_5 */
    0x036,    /* GDK_6 */
    0x037,    /* GDK_7 */
    0x038,    /* GDK_8 */
    0x039,    /* GDK_9 */
    0x053,    /* GDK_S */
    0x073,    /* GDK_s */
    0x057,    /* GDK_W */
    0x05d,    /* GDK_bracketright */
    0x056,    /* GDK_V */
    0x05a,    /* GDK_Z */
    0x040,    /* GDK_at */
    0x041,    /* GDK_A */
    0x058,    /* GDK_X */
    0x04a,    /* GDK_J */
    0x045,    /* GDK_E */
    0x03e,    /* GDK_greater */
    0x055,    /* GDK_U */
    0x049,    /* GDK_I */
    0x044,    /* GDK_D */
    0x043,    /* GDK_C */
    0x048,    /* GDK_H */
    0x054,    /* GDK_T */
    0x04e,    /* GDK_N */
    0x04d,    /* GDK_M */
    0x042,    /* GDK_B */
    0x052,    /* GDK_R */
    0x04c,    /* GDK_L */
    0x022,    /* GDK_quotedbl */
    0x050,    /* GDK_P */
    0x04f,    /* GDK_O */
    0x059,    /* GDK_Y */
    0x047,    /* GDK_G */
    0x04b,    /* GDK_K */
    0x03c,    /* GDK_less */
    0x051,    /* GDK_Q */
    0x046,    /* GDK_F */
    0x03a,    /* GDK_colon */
    0x02f,    /* GDK_slash */
    0x05c,    /* GDK_backslash */
    0x03d,    /* GDK_qual */
    0x05e,    /* GDK_asciicircum */
    0x07b,    /* GDK_braceleft */
    0x060,    /* GDK_grave */
    0x061,    /* GDK_a */
    0x078,    /* GDK_x */
    0x06a,    /* GDK_j */
    0x065,    /* GDK_e */
    0x02e,    /* GDK_period */
    0x075,    /* GDK_u */
    0x069,    /* GDK_i */
    0x064,    /* GDK_d */
    0x063,    /* GDK_c */
    0x068,    /* GDK_h */
    0x074,    /* GDK_t */
    0x06e,    /* GDK_n */
    0x06d,    /* GDK_m */
    0x062,    /* GDK_b */
    0x072,    /* GDK_r */
    0x06c,    /* GDK_l */
    0x027,    /* GDK_apostrophe */
    0x070,    /* GDK_p */
    0x06f,    /* GDK_o */
    0x079,    /* GDK_y */
    0x067,    /* GDK_g */
    0x06b,    /* GDK_k */
    0x02c,    /* GDK_comma */
    0x071,    /* GDK_q */
    0x066,    /* GDK_f */
    0x03b,    /* GDK_semicolon */
    0x03f,    /* GDK_question */
    0x07c,    /* GDK_bar */
    0x02b,    /* GDK_plus */
    0x07e,    /* GDK_asciitilde */
};

LRESULT CALLBACK SAENARUKbdProc(int code, WPARAM wParam, LPARAM lParam)
{
    BYTE pbKeyState [256];
    LPMSG lpmsg;
    UINT vKey;
    SHORT ALT;

    if (code < 0)
        return CallNextHookEx(hHookWnd, code, wParam, lParam);

    lpmsg = (LPMSG)lParam;
    vKey = lpmsg->wParam;

    switch (lpmsg->message)
    {
        case WM_KEYUP:
            break;
        case WM_KEYDOWN:
#if 0
            if ((dwImeFlag & SAENARU_DVORAK ) &&
                (vKey >= '!' && vKey <= '~'))
            {
                 WORD dv;
                 SHORT sc;
                 dv = qwerty2dvorak_table[vKey - '!'];
                 sc = VkKeyScan(dv);
                 // lpmsg->wParam = sc; XXX
            }
            else
#endif
            if ( vKey == VK_SPACE)
            {
               // SHORT ShiftState = (GetAsyncKeyState(VK_LSHIFT) >> 31) & 1;
                TCHAR szDev[80];
		SHORT ShiftState;
                GetKeyboardState((LPBYTE)&pbKeyState);
		ShiftState = pbKeyState[VK_LSHIFT] & 0x80;

                wsprintf((LPTSTR)szDev,TEXT("ShiftState is %x\r\n"),ShiftState);
                OutputDebugString((LPTSTR)szDev);
                wsprintf((LPTSTR)szDev,TEXT(" * VKey %x\r\n"),lpmsg->wParam);
                OutputDebugString((LPTSTR)szDev);
                //MyDebugPrint((TEXT("\t** ShiftState is 0x%x\r\n"),ShiftState));
                MyDebugPrint((TEXT("\t** ShiftState is 0x%x\r\n"),ShiftState));
                if (ShiftState)
                {
                     lpmsg->message=WM_KEYDOWN;
                     lpmsg->wParam=VK_HANGUL;
                     lpmsg->lParam=(0xF2<<16) | 0x41000001;
                }
            }
            break;
        case WM_CHAR:
#ifndef NO_DVORAK
#define SAENARU_DVORAK_MASK    (SAENARU_DVORAK | SAENARU_HANGUL)
            if (((dwImeFlag & SAENARU_DVORAK_MASK) == SAENARU_DVORAK ) &&
                (vKey >= '!' && vKey <= '~'))
            {
                 WORD dv;
                 SHORT sc;
                 dv = qwerty2dvorak_table[vKey - '!'];
                 lpmsg->wParam = dv;
                 sc = VkKeyScan(dv);
                 lpmsg->lParam &= ~0x00ff0000;
                 lpmsg->lParam |= (sc <<16);
                 GetKeyboardState((LPBYTE)&pbKeyState);
                 pbKeyState[dv];
                 pbKeyState[vKey]=0;
                 SetKeyboardState((LPBYTE)&pbKeyState);
            }
#endif
            break;
        case WM_SYSKEYDOWN:
        case WM_SYSKEYUP:
            // hack to use RALT(VK_RMENU) as a Mode_Switch
            GetKeyboardState((LPBYTE)&pbKeyState);
            if ( pbKeyState[VK_RMENU] & 0x80 && !(lpmsg->lParam & 0x01000000))
            {
		 WORD ch;

                 ToAscii(vKey,(lpmsg->lParam | 0xff0000)>>16,pbKeyState,&ch,0);
		 ch = 0xff & ch;
                 if (ch < '!' || ch > '~')
                      break;
                 MyDebugPrint((TEXT("RALT + %x\n"), ch));
#if 1
                 lpmsg->message-=4; // WM_SYSKEYUP - WM_KEYUP = 4 See WINUSER.H
                 MyDebugPrint((TEXT("RALT %x\n"), lpmsg->lParam));

                 if ((dwImeFlag & SAENARU_DVORAK_MASK)== SAENARU_DVORAK_MASK)
		 {
                     WORD dv;
                     SHORT sc;

                     dv = qwerty2dvorak_table[ch - '!'];
                     sc = VkKeyScan(dv);
                     lpmsg->wParam = sc;
		 }
#endif
            }
            break;
        default:
            break;
    }

    return CallNextHookEx(hHookWnd, code, wParam, lParam);
}

#ifdef DEBUG
void PASCAL DumpUIExtra(LPUIEXTRA lpUIExtra)
{
    TCHAR szDev[80];
    int i;

    wsprintf((LPTSTR)szDev,TEXT("Status hWnd %lX  [%d,%d]\r\n"),
                                               lpUIExtra->uiStatus.hWnd,
                                               lpUIExtra->uiStatus.pt.x,
                                               lpUIExtra->uiStatus.pt.y);
    OutputDebugString((LPTSTR)szDev);

    wsprintf((LPTSTR)szDev,TEXT("Cand hWnd %lX  [%d,%d]\r\n"),
                                               lpUIExtra->uiCand.hWnd,
                                               lpUIExtra->uiCand.pt.x,
                                               lpUIExtra->uiCand.pt.y);
    OutputDebugString((LPTSTR)szDev);

    wsprintf((LPTSTR)szDev,TEXT("CompStyle hWnd %lX]\r\n"), lpUIExtra->dwCompStyle);
    OutputDebugString((LPTSTR)szDev);

    wsprintf((LPTSTR)szDev,TEXT("DefComp hWnd %lX  [%d,%d]\r\n"),
                                               lpUIExtra->uiDefComp.hWnd,
                                               lpUIExtra->uiDefComp.pt.x,
                                               lpUIExtra->uiDefComp.pt.y);
    OutputDebugString((LPTSTR)szDev);

    for (i=0;i<5;i++)
    {
        wsprintf((LPTSTR)szDev,TEXT("Comp hWnd %lX  [%d,%d]-[%d,%d]\r\n"),
                                               lpUIExtra->uiComp[i].hWnd,
                                               lpUIExtra->uiComp[i].rc.left,
                                               lpUIExtra->uiComp[i].rc.top,
                                               lpUIExtra->uiComp[i].rc.right,
                                               lpUIExtra->uiComp[i].rc.bottom);
        OutputDebugString((LPTSTR)szDev);
    }
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -