UP 模拟器 加入key的模拟支持

This commit is contained in:
JiXieShi
2024-06-22 22:51:58 +08:00
parent 0c7c6bb1e9
commit 5876461531
9 changed files with 201 additions and 35 deletions

View File

@@ -1,17 +1,17 @@
#include <stdio.h>
#include "key.h"
#include "log.h"
#include "tool.h"
#include "t_key.h"
#include <windows.h>
#include <process.h>
#include "sim_key.h"
uint8_t Key_Pin(uint8_t l) {
uint8_t k = rand() % 2;
// LOGT("KEY", "P:%d-%d", l,k);
return k;
if (SIM_Key_Scan() == SIM_KEY_UP) {
// LOGT("SCAN","ID:%d-UP",l);
return 1;
} else return 0;
}
void Key_Call(Key_t *key) {
switch (key->event) {
case KEY_PRESS_DOWN:
@@ -39,18 +39,33 @@ void Key_Call(Key_t *key) {
}
void Test_Key() {
Key_t k1, k2, k3, k4, k5, k6, ks;
key_init(&k1, SIM_Key_UP, 1, SIM_KEY_UP);
key_init(&k2, SIM_Key_DOWN, 1, SIM_KEY_DOWN);
key_init(&k3, SIM_Key_LEFT, 1, SIM_KEY_LEFT);
key_init(&k4, SIM_Key_RIGHT, 1, SIM_KEY_RIGHT);
key_init(&k5, SIM_Key_ENABLE, 1, SIM_KEY_ENABLE);
key_init(&k6, SIM_Key_SET, 1, SIM_KEY_SET);
// key_init(&ks,Key_Pin,1,7);
Key_t k1, k2;
key_init(&k1, Key_Pin, 1, 0);
key_init(&k2, Key_Pin, 1, 1);
key_attach(&k1, KEY_ALL_EVENT, Key_Call);
key_attach(&k2, KEY_ALL_EVENT, Key_Call);
key_attach(&k3, KEY_ALL_EVENT, Key_Call);
key_attach(&k4, KEY_ALL_EVENT, Key_Call);
key_attach(&k5, KEY_ALL_EVENT, Key_Call);
key_attach(&k6, KEY_ALL_EVENT, Key_Call);
// key_attach(&ks, KEY_ALL_EVENT, Key_Call);
key_start(&k1);
key_start(&k2);
key_start(&k3);
key_start(&k4);
key_start(&k5);
key_start(&k6);
// key_start(&ks);
while (1) {
// 每5ms调用一次key_ticks函数
key_ticks();
Sleep(5); // 使用Windows平台的Sleep函数进行5ms延时
Sleep(5);
}
}