HW_Lib/sim/key/key.cpp

83 lines
1.7 KiB
C++

#include "sim_key.h"
#include "log.h"
#include<easyx.h>
#include<conio.h>
uint8_t SIM_Key_Scan() {
uint8_t key = 0;
if (_kbhit()) {
char keys = _getch();
switch (keys) {
//上键
case 72:
case 'w':
case 'W':
key = SIM_KEY_UP;
break;
case 80:
case 's':
case 'S':
key = SIM_KEY_DOWN;
break;
//左键
case 75:
case 'a':
case 'A':
key = SIM_KEY_LEFT;
break;
//右键
case 77:
case 'd':
case 'D':
key = SIM_KEY_RIGHT;
break;
case 'q':
case 'Q':
key = SIM_KEY_SET;
break;
case 'e':
case 'E':
key = SIM_KEY_ENABLE;
break;
case 'r':
case 'R':
key = SIM_KEY_RESET;
break;
}
}
return key;
}
uint8_t SIM_Key_UP(uint8_t) {
return GetAsyncKeyState(VK_UP);
}
uint8_t SIM_Key_DOWN(uint8_t l) {
// uint8_t k=GetAsyncKeyState(VK_DOWN);
// LOGT("SIM","KEYID:%d-DOWN:%d",l,k);
return GetAsyncKeyState(VK_DOWN);
}
uint8_t SIM_Key_LEFT(uint8_t) {
return GetAsyncKeyState(VK_LEFT);
}
uint8_t SIM_Key_RIGHT(uint8_t) {
return GetAsyncKeyState(VK_RIGHT);
}
uint8_t SIM_Key_ENABLE(uint8_t) {
return GetAsyncKeyState(VK_RETURN);
}
uint8_t SIM_Key_SET(uint8_t) {
return GetAsyncKeyState(VK_RSHIFT);
}
uint8_t SIM_Key_RESET(uint8_t) {
return GetAsyncKeyState(VK_END);
}