1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-02-02 22:41:22 +00:00

HID: add special handling for Keyrah V2.

This commit is contained in:
sorgelig
2016-12-23 02:05:59 +08:00
parent 00fea219ee
commit a400aedf2b

View File

@@ -584,6 +584,52 @@ static uint16_t collect_bits(uint8_t *p, uint16_t offset, uint8_t size, bool is_
return rval;
}
static char kr_fn_table[] =
{
0x54, 0x48, // pause/break
0x55, 0x46, // prnscr
0x50, 0x4a, // home
0x4f, 0x4d, // end
0x52, 0x4b, // pgup
0x51, 0x4e, // pgdown
0x3a, 0x44, // f11
0x3b, 0x45 // f12
};
static void keyrah_trans(unsigned char *m, unsigned char *k)
{
char fn = 0;
char rctrl = 0;
int i = 0;
while(i<6)
{
if((k[i] == 0x64) || (k[i] == 0x32))
{
if(k[i] == 0x64) fn = 1;
if(k[i] == 0x32) rctrl = 1;
for(int n = i; n<5; n++) k[n] = k[n+1];
k[5] = 0;
}
else
{
i++;
}
}
if(fn)
{
for(i=0; i<6; i++)
{
for(int n = 0; n<(sizeof(kr_fn_table)/(2*sizeof(kr_fn_table[0]))); n++)
{
if(k[i] == kr_fn_table[n*2]) k[i] = kr_fn_table[(n*2)+1];
}
}
}
*m = rctrl ? (*m) | 0x10 : (*m) & ~0x10;
}
/* processes a single USB interface */
static void usb_process_iface (usb_hid_iface_info_t *iface,
uint16_t read,
@@ -601,6 +647,8 @@ static void usb_process_iface (usb_hid_iface_info_t *iface,
if(iface->device_type == HID_DEVICE_KEYBOARD) {
// boot kbd needs at least eight bytes
if(read >= 8) {
//Keyrah v2: USB\VID_18D8&PID_0002\A600/A1200_MULTIMEDIA_EXTENSION_VERSION
if((iface->conf.vid == 0x18D8) && (iface->conf.pid == 0x0002)) keyrah_trans(buf, buf+2);
user_io_kbd(buf[0], buf+2, UIO_PRIORITY_KEYBOARD);
}
}