📄 kbd_old.cpp
字号:
ScanKeyStat[i][j] = 1;
CurKeyStat[i][j] = 1;
key_code[i][j] = key_code1[i][j];
}
}
//enable the interrupt
//pGpioHead->pGpio1Regs->GPIODir5 = 0xF0;
pGpioHead->pGpio1Regs->GPIODir5 &= 0xF0;
//pGpioHead->pGpio1Regs->GPIOIS5 = 0x0;
pGpioHead->pGpio1Regs->GPIOIS5 &= 0xF0;
//pGpioHead->pGpio1Regs->GPIOIBE5 = 0xFF;
pGpioHead->pGpio1Regs->GPIOIBE5 |= 0x0F;
//pGpioHead->pGpio1Regs->GPIOIE5 = 0x0F;
pGpioHead->pGpio1Regs->GPIOIE5 |= 0x0F;
//pGpioHead->pGpio1Regs->GPIOIC5 = 0xFF;
pGpioHead->pGpio1Regs->GPIOIC5 |= 0x0F;
//pGpioHead->pGpio2Regs->GPIODir5 = 0xFF;
pGpioHead->pGpio2Regs->GPIODir5 |= 0x07;
pGpioHead->pGpio2Regs->GPIODir5 &= 0xF7;
//pGpioHead->pGpio2Regs->GPIOIS = 0x0;
pGpioHead->pGpio2Regs->GPIOIS5 &= 0xF7;
//pGpioHead->pGpio2Regs->GPIOIBE = 0xFF;
pGpioHead->pGpio2Regs->GPIOIBE5 &= 0xF7;
pGpioHead->pGpio2Regs->GPIOIEV5 &= 0xF7;
//pGpioHead->pGpio2Regs->GPIOIEV5 |= 0x08;
//pGpioHead->pGpio2Regs->GPIOIE5 |= 0x08;
pGpioHead->pGpio2Regs->GPIOIE5 = 0x08;
pGpioHead->pGpio2Regs->GPIOIC5 = 0x08;
pGpioHead->pGpio2Regs->Padding1[254] &= 0xF8;
pGpioHead->pGpio1Regs->GPIOIC5 = 0x0F;
while(1)
{
dwEvent = WaitForSingleObject(g_GPIO1Event, INFINITE);
RETAILMSG (DBG_KBD, (TEXT("keybd INT 1.0!\r\n")));
//RETAILMSG (1, (TEXT("keybd INT 1.0!\r\n")));
//just sleep
Sleep(20);
//InterruptDone(SYSINTR_KBD); // Acknowledge the GPIO interrupt
//yz_add for digital
#if 1
if((pGpioHead->pGpio2Regs->GPIORIS5 & 0x08) && (!(pGpioHead->pGpio2Regs->Padding1[254]&0x08)))
{
PROCESS_INFORMATION pi;
//if(!CreateProcess(L"\\windows\\TazkMan.exe",L".EXE",NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&pi))
//RETAILMSG (1, (TEXT("open TazkMan.exe FAIL!\r\n")));
//if(!CreateProcess(L"\\windows\\connmc.exe",L".EXE",NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&pi))
//RETAILMSG (DBG_KBD, (TEXT("open connmc.exe FAIL!\r\n")));
if(!CreateProcess(L"\\windows\\ds.exe",L".EXE",NULL,NULL,NULL,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&pi))
RETAILMSG (DBG_KBD, (TEXT("open ds.exe FAIL!\r\n")));
//RETAILMSG (DBG_KBD, (TEXT("open connmc.exe \r\n")));
//pGpioHead->pGpio2Regs->GPIOIC5 = 0x08;
pGpioHead->pGpio2Regs->GPIOIC5 = 0xff;
RETAILMSG (DBG_KBD, (TEXT("GP6:: RIS: %x, data: %x \r\n"), pGpioHead->pGpio2Regs->GPIORIS5 & 0x08, pGpioHead->pGpio2Regs->Padding1[254]&0x08));
yz_run = TRUE;
Sleep(100);
//pGpioHead->pGpio2Regs->GPIOIC5 = 0x08;
//pGpioHead->pGpio2Regs->GPIOIC5 = 0xff;
InterruptDone(SYSINTR_KBD); // Acknowledge the GPIO interrupt
continue;
}
#endif
pGpioHead->pGpio2Regs->GPIOIC5 = 0xff;
keychange = 0;
// Fetch the raw INT status and the GPIO5 data
cIntStatus = GET_GPIO5_RIS();
cdata = GET_GPIO5_DAT();
RETAILMSG (DBG_KBD, (TEXT("cIntStatus: %x, cdata: %x \r\n"),cIntStatus, cdata));
//RETAILMSG (1, (TEXT("cIntStatus: %x, cdata: %x \r\n"),cIntStatus, cdata));
if(cIntStatus == 0)
{
RETAILMSG (DBG_KBD, (TEXT("why we get the INT??\r\n")));
pGpioHead->pGpio1Regs->GPIOIC5 = 0x0F;
InterruptDone(SYSINTR_KBD); // Acknowledge the GPIO interrupt
continue;
}
//yz_add 1226
//pGpioHead->pGpio1Regs->GPIOIE5 = 0x00;
//scan the GPIO keybd first
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
ScanKeyStat[i][j] = 1;
}
}
for(i = 0; i < 3; i++)
{
if(((cIntStatus>>i)&0x01)==0x01) //which GPIO5_x INT?
{
RETAILMSG (DBG_KBD, (TEXT("GPIO5_%d INT\r\n"), i));
//RETAILMSG (1, (TEXT("GPIO5_%d INT\r\n"), i));
for(j = 0; j < 3; j++)
{
//temp = GET_GPIO6_DAT();
temp = 0xff; //just for test
temph = temp & (~0x07);
templ = (~(0x1 << j)) & 0x07;
temp = temph | templ;
//change GP6 dir
//pGpioHead->pGpio2Regs->GPIODir5 = (0x01<<j); //caution just test!
pGpioHead->pGpio2Regs->GPIODir5 = (pGpioHead->pGpio2Regs->GPIODir5&0xF8) | (0x01<<j); //GP6_j OUT, other IN
//SET_GPIO6_DAT(temp);
pGpioHead->pGpio2Regs->Padding1[254] = (pGpioHead->pGpio2Regs->Padding1[254]&0xF8)|(~(0x01<<j));
cdata2 = GET_GPIO5_DAT();
//RETAILMSG (1, (TEXT("temp: %x, temph: %x, templ: %x, cdata2: %x\r\n"), temp, temph, templ, cdata2));
RETAILMSG (DBG_KBD, (TEXT("cdata2: %x\r\n"), cdata2));
//RETAILMSG (1, (TEXT("cdata2: %x\r\n"), cdata2));
//for(k = 0; k < 3; k++)
//ScanKeyStat[k][j] = (cdata2>>k)&0x01; //0 = down, 1 = up
if((cdata2&(0x01<<i)) == 0x00)
ScanKeyStat[i][j] = 0x00; //0 = down, 1 = up
//yz_add 1227
pGpioHead->pGpio2Regs->Padding1[254] = (pGpioHead->pGpio2Regs->Padding1[254]&0xF8)|0x7;
}
}
}
//pGpioHead->pGpio1Regs->GPIODir5 &= 0xF0; //GP5 in
pGpioHead->pGpio2Regs->GPIODir5 |= 0x07; //GP6 out
pGpioHead->pGpio2Regs->Padding1[254] &= 0xF8;
//yz for test
#if 0
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
RETAILMSG (DBG_KBD, (TEXT("Scan[%d][%d]: %x "),i,j, ScanKeyStat[i][j]));
}
}
RETAILMSG (DBG_KBD, (TEXT("\r\n")));
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
RETAILMSG (DBG_KBD, (TEXT("Curr[%d][%d]: %x "),i,j, CurKeyStat[i][j]));
}
}
RETAILMSG (DBG_KBD, (TEXT("\r\n")));
#endif
//yz_add 1227
keydown = 0;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
if(CurKeyStat[i][j] == 0 || ScanKeyStat[i][j] == 0)
keydown++;
}
}
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
if(ScanKeyStat[i][j] != CurKeyStat[i][j])
{
CurKeyStat[i][j] = ScanKeyStat[i][j];
if(CurKeyStat[i][j] == 0) //key down
{
RETAILMSG (DBG_KBD, (TEXT("****** key down: %d-%d ******\r\n"),i,j));
if(i == 0 && j == 0 && keydown == 1)
{
static char keystate = 0;
char ii = 0, jj = 0;
if(keystate == 0) //Game key
{
SHELLEXECUTEINFO sei;
//LPCTSTR lpVerb;
sei.lpVerb=_T("open");
ZeroMemory(&sei, sizeof(sei));
sei.cbSize =sizeof(sei);
sei.lpFile=_T("explorer.exe");
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpParameters=_T("\\NandFlash\\MyGame");
sei.nShow = SW_SHOW;
ShellExecuteEx(&sei);
//yz_add for key code change 1230
for(ii = 0; ii < 3; ii++)
for(jj = 0; jj < 3; jj++)
key_code[ii][jj] = key_code2[ii][jj];
keystate = 1;
}
else //usual key
{
//yz_add for key code change 1230
for(ii = 0; ii < 3; ii++)
for(jj = 0; jj < 3; jj++)
key_code[ii][jj] = key_code1[ii][jj];
keystate = 0;
}
}
else
KbdISRUpcall(false, key_code[i][j]);
}
else //key up
{
RETAILMSG (DBG_KBD, (TEXT("****** key up: %d-%d ******\r\n"),i,j));
//if(yz_key == 0x1F)
//KbdISRUpcall(false, 0xe0);
if(i == 0 && j == 0)
{
continue;
}
else
{
KbdISRUpcall(false, 0xF0);
KbdISRUpcall(false, key_code[i][j]);
}
}
keychange++;
}
}
if((CurKeyStat[i][0] == 1)&&(CurKeyStat[i][1] == 1)&&(CurKeyStat[i][2] == 1))
{
pGpioHead->pGpio1Regs->GPIOIC5 = 0x01<<i;
RETAILMSG (DBG_KBD, (TEXT("GPIO5_%d all up!\r\n"),i));
}
}
if(keychange == 0)
RETAILMSG (DBG_KBD, (TEXT("INT, but no key stat change, Ignore!\r\n")));
//pGpioHead->pGpio2Regs->GPIODir5 = 0x07; //caution just test!
//SET_GPIO6_DAT(GET_GPIO6_DAT() & 0xF8);
//pGpioHead->pGpio1Regs->GPIOIC5 = 0x0F;
//yz_add 1226
Sleep(180);
//pGpioHead->pGpio1Regs->GPIOIE5 |= 0x0F;
InterruptDone(SYSINTR_KBD); // Acknowledge the GPIO interrupt
}
pGpioHead->fGpio1ISTExit = FALSE; // Signal we have terminated
RETAILMSG (DBG_KBD, (TEXT("GPIO1 IST thread ERROR\r\n")));
return 0;
}
/* EOF kbdmouse.cpp */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -