// TwinHan VisionPlus DVB-T card remote // Changes the keymaping for usb keyboards so the remote better matches MythTV // gcc usbhid-twinhan.c -o usbhid-twinhan // no options for install // some options for uninstall // Copyright 2005/07/13 Paul Andreassen /* Button keyboard key showkey new key code MythWeb fullscreen z 2c SKIPCOMMERCIAL power Alt-Ctrl-Shift-F6 1d-2a-38-40 changes to console 6 1-9-0 1-9-0 02-0a-0b 1-9-0 record Home 66 r 13 TOGGLERECORD favourite v 2f / 35 NEXTFAV NEXTFAV rewind i 17 home 66 PREVVIEW PREVTRACK CLEARMAP DAYLEFT SKIPCOMMBACK forward n 31 end 6b NEXTVIEW NEXTTRACK LOADCOMMSKIP DAYRIGHT SKIPCOMMERICAL CH+ pageup 68 up 67 UP CHANNELUP CH- pagedown 6d down 6c DOWN CHANNELDOWN play return 1c SELECT vol+ SHIFT-up 2a-67 right 2a-6a RIGHT RANKINC SEEKFFWD vol- SHIFT-down 2a-6c left 2a-69 LEFT RACKDEC SEEKRWND recall c 2e i 17 INFO RETRIEVENEWS INVERTMAP stop End 6b d 20 DELETE DELETE DELETE DELETE timeshift/pause t 14 p 19 PAUSE PLAYBACK PAUSE PAUSE mute m 32 F9 43 MUTE MUTE cancel Escape 01 ESCAPE capture p 19 w 11 TOGGLEASPECT preview k 25 a 1e TOGGLESTRETCH EPG e 12 s 1f GUIDE record list l 26 m 32 MENU tab Tab(beeps) 0f pageup 68 PAGEUP RWND PREVCUT JUMPRWND teletext a 1e pagedown 6d PAGEDOWN FFWD NEXTCUT JUMPFFWD */ #include //#define unk KEY_UNKNOWN #define unk 240 static unsigned char hid_keyboard_orig[256] = { 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106, 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, 115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95,unk,unk,unk, 122,123, 90, 91, 85,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk }; static unsigned char hid_keyboard_new[256] = { 0, 0, 0, 0,109, 48, 23, 32, 31, 33, 34, 35,102, 36, 30, 50, 67,107, 24, 17, 16, 19, 31, 25, 22, 53, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14,104, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 99, 70,119,110, 19,103,111, 32,108,106, 105,105,106, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, 115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95,unk,unk,unk, 122,123, 90, 91, 85,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, 29, 0, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk }; #define SIZE 256 char filenamestr[]="/lib/modules/%s/kernel/drivers/usb/input/usbhid.ko"; int main(int argc, char *argv[]) { unsigned char *bsearch, *breplace; FILE *fo; char unamer[SIZE]; char filename[SIZE]; int pos=0; unsigned char byte; if (argc == 1) { bsearch = hid_keyboard_orig; breplace = hid_keyboard_new; } else { bsearch = hid_keyboard_new; breplace = hid_keyboard_orig; } if ((fo=popen("uname -r","r"))==NULL) { printf("Can't popen uname -r\n"); exit(1); } pos=fread(unamer,1,SIZE,fo); if ((pclose(fo)==-1)||(pos==0)||(pos==SIZE)) { printf("Error with uname -r\n"); exit(1); } unamer[pos-1]=0; // remove trailing \n pos=snprintf(filename,SIZE,filenamestr,unamer); if ((pos<0)||(pos>=SIZE)) { printf("Error with snprintf (%s)\n",filename); exit(1); } if ((fo=fopen(filename,"r+b"))==NULL) { printf("Can't open %s\n",filename); exit(1); } printf("Searching %s\n",filename); pos=0; while (fread(&byte, 1, 1, fo) == 1) { if (byte==bsearch[pos]) { pos++; if (pos==256) { printf("Found\n"); int back=-pos; fseek(fo, back, SEEK_CUR); if (fwrite(breplace, 1, pos, fo)==pos) { printf("Wrote ok\n"); } else { printf("Error wrote short\n"); } pos=0; break; } } else { if (pos>4) printf("sorry %d == %d\n",byte,bsearch[pos]); pos=0; } } fclose(fo); return 0; }