📄 keyboard.c
字号:
/*
Motorola LTE Keyboard Driver
----------------------------
(c) DmT, motoprogger 2008
*/
#include "../libs/motolibs.h"#include "rtr.h"#include "kpp.h"#include "watchdog.h"#ifdef DRIVER_CONFIG_CAP#include "cap.h"#endif#define set_bit_in_int(v,n) v|(1<<n)byte KEYS_TABLE[]={ 0x68, //0 0x78, //1 0x30, //2 0x79, //3 0x31, //4 0x70, //5 0x32, //6 0x39, //7 0x38, //8 0x48, //9 0x71, //0xA - * 0x69, //0xB - # 0xFF, //0xC - not used 0xFF, //0xD - not used 0x62, //0xE - left soft key 0x61, //0xF - right soft key 0x59, //0x10 - center (joystick press) 0xAA, //0x11 - end call 0x60, //0x12 - send call 0xFF, //0x13 - not used 0x72, //0x14 - menu 0x51, //0x15 - left smart 0x52, //0x16 - right smart 0x59, //0x17 - volume up 0x50, //0x18 - volume down 0xFF, //0x19 - not used 0xFF, //0x1A - not used 0xFF, //0x1B - not used 0x40, //0x1C - up (joystick up) 0x42, //0x1D - down (joystick down) 0x41, //0x1E - left (joystick left) 0x49}; //0x1F - right (joystick right)bool was_power_key_pressed(void)
{
#ifdef DRIVER_CONFIG_CAP
return cap_read_pwrkey();
#else
return 0;
#endif
}
int keyb_peek_direct(void)
{
hword a;
a=kpp_peek();
return ((~a)&0x3FF)|was_power_key_pressed()<<10;}
hword keyb_peek(void){ #define DEBOUNCE_DELAY 16 hword last_rtr; hword last_keys_status; hword rtr; hword keys_status; last_keys_status=0xFFFF; do { rtr=rtr_get_lsb(); keys_status=keyb_peek_direct(); if (keys_status!=last_keys_status) { last_rtr=rtr; last_keys_status=keys_status; } wdog_service(); } while (rtr-last_rtr<DEBOUNCE_DELAY); return last_keys_status;}byte check_key(hword keys, byte bits){ byte bit1, bit2; hword mask; bit1=bits&0xF; bit2=(bits>>4)&0xF; mask=(1<<bit1)|(1<<bit2); if (!(~keys&mask)) { if (keys!=mask) return 2; else return 1; } return 0;}bool keyb_check_two_keys(byte key1, byte key2){ hword keys; keys=keyb_peek_direct(); return (check_key(keys,KEYS_TABLE[key1]) && check_key(keys,KEYS_TABLE[key2]));}byte keyb_peek_key(void){ hword keys; word i; keys=keyb_peek(); for (i=0; i<0x20; i++) switch(check_key(keys,KEYS_TABLE[i])) { case 1: return i; case 2: return 0xFE; } return 0xFF; //No key pressed}byte keyb_get_key(void){ byte key; do { key=0; while (key!=0xFF) key=keyb_peek_key(); while (key==0xFF) key=keyb_peek_key(); } while (key==0xFE); return key;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -