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

📄 ascii_kbde.c

📁 开源的键盘模拟程序
💻 C
字号:
/*    keyboard emulator project     Copyright (C) 1998-2003 Reznic Valery <valery_reznic@users.sourceforge.net>     This program is free software; you can redistribute it and/or modify    it under the terms of the GNU Library General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.     This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details. */#include <kbde.h>typedef struct {   int modificator;   int key_code;} ascii_key;#define KBDE_KEY_EMPTY    -1#define K(x)         {KBDE_KEY_EMPTY , KBDE_KEY_##x}#define C(x)         {KBDE_KEY_LCtrl , KBDE_KEY_##x}#define S(x)         {KBDE_KEY_LShift, KBDE_KEY_##x}#define A(x)         {KBDE_KEY_LAlt  , KBDE_KEY_##x}#define KBDE_KEY_BSlash KBDE_KEY_BackSlash#define KBDE_KEY_BS     KBDE_KEY_BackSpace#define KBDE_KEY_SC     KBDE_KEY_SemiColonstatic const ascii_key ascii_keyboard[] = {//0       1       2         3          4          5          6         7C(2),     C(A),   C(B),     C(C),      C(D),      C(E),      C(F),     C(G),K(BS),    K(Tab), C(J),     C(K),      C(L),      K(Enter),  C(N),     C(O),C(P),     C(Q),   C(R),     C(S),      C(T),      C(U),      C(V),     C(W),C(X),     C(Y),   C(Z),     K(Escape), C(BSlash), C(RBrace), C(6),     C(Minus),K(Space), S(1),   S(Quote), S(3),      S(4),      S(5),      S(7),     K(Quote),S(9),     S(0),   S(8),     S(Equal),  K(Comma),  K(Minus),  K(Period),K(Slash),K(0),     K(1),   K(2),     K(3),      K(4),      K(5),      K(6),     K(7),K(8),     K(9),   S(SC),    K(SC),     S(Comma),  K(Equal),  S(Period),S(Slash),S(2),     S(A),   S(B),     S(C),      S(D),      S(E),      S(F),     S(G),S(H),     S(I),   S(J),     S(K),      S(L),      S(M),      S(N),     S(O),S(P),     S(Q),   S(R),     S(S),      S(T),      S(U),      S(V),     S(W),S(X),     S(Y),   S(Z),     K(LBrace), K(BSlash), K(RBrace), S(6),     S(Minus),K(Tilde), K(A),   K(B),     K(C),      K(D),      K(E),      K(F),     K(G),K(H),     K(I),   K(J),     K(K),      K(L),      K(M),      K(N),     K(O),K(P),     K(Q),   K(R),     K(S),      K(T),      K(U),      K(V),     K(W),K(X),     K(Y),   K(Z),     S(LBrace), S(BSlash), S(RBrace), S(Tilde), K(Delete)};#define ARRAYSIZE(X)  (sizeof(X)/sizeof(X[0])) #define A_KEY         ascii_keyboard[ascii].key_code#define A_MODIFICATOR ascii_keyboard[ascii].modificatorint kbde_ascii_key_press(int ascii, char *buffer){   int count = 0;   if( (ascii < 0) || (ascii >= ARRAYSIZE(ascii_keyboard) ) ) return -1;    // if we got here, both kbd_key_press/release SHOULD NOT return -1   if (A_MODIFICATOR != KBDE_KEY_EMPTY) {      count += kbde_key_press(A_MODIFICATOR, buffer);   }   count += kbde_key_press(A_KEY, buffer + count);   return count;}int kbde_ascii_key_release(int ascii, char *buffer){   int count = 0;   if ( (ascii < 0) || (ascii >= ARRAYSIZE(ascii_keyboard) ) ) return -1;    // if we got here, both kbd_key_press/release SHOULD NOT return -1   count = kbde_key_release(A_KEY, buffer);   if (A_MODIFICATOR != KBDE_KEY_EMPTY) {      count += kbde_key_release(A_MODIFICATOR, buffer + count);   }   return count;}int kbde_ascii_key_press_release(int ascii, char *buffer){   int count;   count  = kbde_ascii_key_press  (ascii, buffer);   if (count < 0) return -1;   count += kbde_ascii_key_release(ascii, buffer + count);   return count;}

⌨️ 快捷键说明

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