📄 wio.c
字号:
CloseHandle(g_hKey);
return 0;
}
/* -------------------------------- */
/* Function: */
/* LockKbd */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* 0---- success */
/* -1---- failure */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.7.25 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int LockKbd()
{
int ch[2];
int rtAPI;
DWORD nNumber = 0;
ch[0] = 0;
rtAPI = WriteFile(g_hKey, ch, 1, &nNumber, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* LockBar */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.7.25 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
/*int LockBar()
{
int ch[2];
int rtAPI;
DWORD nRead = 0;
ch[0] = 0;
rtAPI = ReadFile(g_hPms, ch, 1, &nRead, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}*/
/* -------------------------------- */
/* Function: */
/* LockDis */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* 0---- success */
/* -1---- failure */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.7.25 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int LockDis()
{
int ch[2];
int rtAPI;
DWORD nRead = 0;
ch[0] = 0;
rtAPI = ReadFile(hDspIns, ch, 1, &nRead, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* KbdGet */
/* Parameter: */
/* NULL */
/* Return Value */
/* char kbd_cha */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
char KeyGet()
{
char kbd_char;
DWORD nRead = 0;
unsigned char ch[5];
ch[0] = 0;
ReadFile(g_hKey, ch, 1, &nRead, NULL);
kbd_char = ch[0];
ResetTimer();
return kbd_char;
}
/* ------------------------
input function KbdRead()
Waits for a character,
and returns the character
value
------------------------ */
/* -------------------------------- */
/* Function: */
/* KbdRead */
/* Parameter: */
/* NULL */
/* Return Value */
/* unsigned char szKey */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
#define KEYSHIFT 0xa0
#define KEYX 0x80 //shift + *
#define ENCODE 0x90
#define EICODE 0x91
#define EMCODE 0x99
#define KEYNOENG 0xfc
#define KEYCFOUT 0xfb
char EnKeyMap[11][5] = {0x20,0x20,0x20,0x20,0x20,
'T', 'U', 'V', 0x00, 0x00,
'W', 'X', 'Y', 'Z', 0x00,
' ', 0x00, 0x00, 0x00, 0x00,
'J', 'K', 'L', 0x00, 0x00,
'M', 'N', 'O', 0x00, 0x00,
'P', 'Q', 'R', 'S', 0x00,
'A', 'B', 'C', 0x00, 0x00,
'D', 'E', 'F', 0x00, 0x00,
'G', 'H', 'I', 0x00, 0x00,
'X', '/', '+', '-', 0x2e};
// 'X',0x76,0x0d,'-',0x2e};
char KbdRead()
{
unsigned char szKey;
unsigned char szTmpKey;
int iCode; /* 0-4 */
while(1)
{
szTmpKey = KeyGet();
if ((szTmpKey == KEYSHIFT) || (szTmpKey == 0xff))
{
continue;
}
else
{
break;
}
}
/* if (x_flg == 1) //if "shift + *" have been pressed
{
while(1)
{
szTmpKey = KeyGet();
if (szTmpKey == KEYSHIFT)
{
continue;
}
else
{
x_flg = 0;
break;
}
}
}
else
{
szTmpKey = KeyGet();
}*/
// if (szTmpKey == 0x80)
// {
// x_flg = 1;
// return EnKeyMap[10][0];
// }
//<==2007.2.26
// if (cf_flg != 1)
if (read_cf() != 1)
//<==2007.2.26
{
return KEYCFOUT;
}
if ((szTmpKey < EICODE || szTmpKey > EMCODE) && (szTmpKey != KEYX)) // not English Key Code
{
szKey = szTmpKey;
return szKey;
}
else
{
if(g_engflg ==0)
{
szKey = szTmpKey;
iCode = 0;
if( szKey == KEYX)
{
SetLine(3);
printX("En: %c", EnKeyMap[10][iCode]);
}
else
{
SetLine(3);
printX("En: %c", EnKeyMap[szKey-ENCODE][iCode]);
}
while(1)
{
szTmpKey = KeyGet();
/* ERROR KEY. EG: SHITF+ENTER */
if((szTmpKey<ENCODE || szTmpKey>EMCODE) && (szTmpKey != KEYSHIFT) && (szTmpKey != KEYX))
{
continue;
}
/* SHIFT BUTTON UP */
if(szTmpKey == KEYSHIFT)
{
SetLine(3);
printX(" ");
if (szKey == KEYX)
{
return EnKeyMap[10][iCode];
}
else
{
return EnKeyMap[szKey-ENCODE][iCode];
}
}
/* press the same button */
else if(szTmpKey == szKey)
{
if (EnKeyMap[szKey-ENCODE][iCode+1] == 0x00 || (iCode == 4))
{
iCode = 0;
}
else
{
iCode = iCode + 1;
}
if( szKey == KEYX)
{
SetLine(3);
printX("En: %c", EnKeyMap[10][iCode]);
}
else
{
SetLine(3);
printX("En: %c", EnKeyMap[szKey-ENCODE][iCode]);
}
// SetLine(3);
// printX("En: %c", EnKeyMap[szKey-ENCODE][iCode]);
}
/* PRESS ANOTHER KEY */
else if(szTmpKey != szKey)
{
iCode = 0;
szKey = szTmpKey;
if( szKey == KEYX)
{
SetLine(3);
printX("En: %c", EnKeyMap[10][iCode]);
}
else
{
SetLine(3);
printX("En: %c", EnKeyMap[szKey-ENCODE][iCode]);
}
// SetLine(3);
// printX("En: %c", EnKeyMap[szKey-ENCODE][iCode]);
}
}//end while
}//end if
else
{
return KEYNOENG;
}
}//end else
}
/* -------------------------------- */
/* Function: */
/* OpenEng */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2006.7.12 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int OpenEng()
{
g_engflg = 0; //Enable input English
return 0;
}
/* -------------------------------- */
/* Function: */
/* CloseEng */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.7.25 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int CloseEng()
{
g_engflg = 1; //Disable input English
return 0;
}
/* -------------------------------- */
/* Function: */
/* KbdHit */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int KbdHit()
{
DWORD nRead = 0;
int rtAPI;
unsigned char ch[5];
ch[0] = 1;
Sleep(1);
rtAPI = ReadFile(g_hKey, ch, 1, &nRead, NULL);
if (!rtAPI)
{
return 0;
}
/* if((ch[0] == 0xff) && (cf_flg==1 || cf_flg==2))
{
if(com_reset() == 9600)
{
com_off();
com_init(0, 9600, 16);
SBar_Close();
}
}*/
//2006.7.13 /*resolve the bug 14 */
// if (cf_flg == 2)
// {
// SBar_Close();
// }
//2006.7.13
/* if (ch[0] == 0xff)
{
if(cf_flg == 0)
{
spe_flg = 1;
ResetTimer();
}
else
{
if(com_reset() == 9600)
{
com_off();
com_init(0, 9600, 16);
SBar_Close();
}
}
ReadFile(g_hKey, ch, 1, &nRead, NULL);
return 0;
}
if ((cf_flg == 1)&& (spe_flg == 1))
{
if(com_reset() == 9600)
{
com_off();
com_init(0, 9600, 16);
}
spe_flg = 0;
}*/
if (ch[0] == 0xa0)
{
ReadFile(g_hKey, ch, 1, &nRead, NULL);
ResetTimer();
return 0;
}
if (ch[0] != 0xfa)
{
ResetTimer();
// if ((cf_flg == 0) || (wake_flg == 0))
// if (cf_flg == 0)
//<==2007.2.26
// if (cf_flg != 1)
if (read_cf() != 1)
//<==2007.2.26
{
Beep(1);
ReadFile(g_hKey, ch, 1, &nRead, NULL);
return 0;
}
else
{
return 1;
}
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* printX */
/* Parameter: */
/* const char *pszFormat,... */
/* the content of output */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int printX(const char *pszFormat,...)
{
int i;
int j;
int k;
int nCount;
int n_flg = 1;
int iPos = 0;
int rtAPI;
DWORD nNumber;
char szMsz[1024];
wchar swzMsz[1024];
wchar DispBuffer[30];
int iDspCmd[100];
va_list arg_ptr;
for (i = 0; i < 30; i++)
{
DispBuffer[i] = 0x20;
}
if (g_initbuf == 0)
{
for (i = 0;i < 4; i++)
{
wcsncpy(&Buffer[i][0], DispBuffer, 30);
}
g_initbuf = 1;
}
va_start (arg_ptr, pszFormat);
i = vsprintf(szMsz, pszFormat, arg_ptr);
nCount = strlen(szMsz);
wcsncpy(swzMsz, DispBuffer, 120);
MultiByteToWideChar(CP_ACP, 0, szMsz,
nCount + 1, swzMsz, dim(swzMsz));
EnterCriticalSection (&LinSection);
for (i = 0; i < nCount; i++)
{
if (swzMsz[i] == '\n')
{
iDspLine++;
if(iDspLine == g_lines)
{
iDspLine = g_lines - 1;
for (j = 1; j < g_lines; j++)
{
if (g_twoflg == 1)
{
wcsncpy(&Buffer[1][0], &Buffer[2][0], 30);
break;
}
else
{
wcsncpy(&Buffer[j - 1][0], &Buffer[j][0], 30);
}
}
}
wcsncpy(&Buffer[iDspLine][0], DispBuffer, 30);
iPos = 0;
n_flg = g_lines;
}
else
{
if (n_flg ==1)
{
Buffer[iDspLine1][iPos] = swzMsz[i];
}
else
{
Buffer[iDspLine][iPos] = swzMsz[i];
}
iPos++;
}
}
for (k = 0; k < n_flg; k++)
{
if (n_flg == 1)
{
k = iDspLine1;
}
else
{
nCount = 26;
}
for (i = 0; i < nCount; i++)
{
iDsp[k][i] = CodeCharacter(Buffer[k][i]);
}
memset(iDspCmd, 0x00, 100);
// Write Cmd
iDspCmd[0] = 1;
// Write Line Number
iDspCmd[1] = k;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -