Good to hear someone is interested. I just got home, so as promised here is the C progam and some basic instruntions on how to use it.
I'm not sure how to do an attachment, so I have put the text in a quote box at the end of this post. I have only a very vague idea of how the keymaps were originally determined, so don't hassle me about that.
Anyway here is the process:
Ensure that usbhid has been built as a module, not into the kernel. If it is built into the kernel, then you need to rebuild your kernel and change the usbhid (DeviceDrivers->USBSupport->USB Human Interface Device (full HID) support - ensure this has an <M> next to it and not a <*>) using make menuconfig or similar.
NOTE: Knoppmyth R5C7 delivers usbhid as a module, so no kernel rebuild is necessary.
Once you have a usbhid.ko, copy the text for the C program below to a file named usbhid-twinhan.c, making sure to edit the filenamestr (line 99) to point to the usbhid.ko module for your kernel (it is setup for default KnoppMyth R5C7 install).
Compile the C program using the compile statement in the comment header (gcc usbhid-twinhan.c -o usbhid-twinhan).
Run the program with no options to "patch" the usbhid module with the updated keymap.
Reload the usbhid module "modprobe -r usbhid" followed by "modprobe usbhid".
That gets the remote working quite nicely with the default MythTV key bindings. If there are any keys you aren't happy with you can remap their binding in mythfrontend nowdays.
Now if you want the Power button, which is the main reason I went with this method of getting the remote to work (as I couldn't seem to remap the Ctrl-Alt-Shift-F6 as it seems to be hard-wired in Linux to switch consoles). Anyway with the default FluxBox GUI used in Knoppmyth I did the follwoing to remap the new Alt-F6 keystroke for the power button:
Edit the fluxbox keys file (in my Knoppmyth R5C7 install this seems to be /etc/X11/fluxbox/keys and add the following line "Mod1 F6 :ExecCommand mythpower". In my installation, there was already an entry for Alt-F6 to switch to workspace 6, but who uses workspaces?
Create a file /usr/local/bin/mythpower cotaining the following (I think I ripped this from Jarrod Wilson's FC4 Myth Guide):
Quote:
#!/bin/bash
PROG=mythfrontend
STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`
if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
then
if [ $STATUS -eq 0 ]
then
( $PROG & )
else
killall $PROG
fi
fi
exit 0
USBHID-TWINHAN.C Code:
Quote:
// 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 Ctrl-Alt-Shift-F6 1d-38-2a-40 Alt-F6 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 <stdio.h>
//#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,unk,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,
unk, 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
};
//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, **WAK**19,
// 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, **WAK**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,
// **WAK**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
// *** Change the following line to reference the correct kernel module ($KVER)
char filenamestr[]="/lib/modules/2.6.15-chw-2/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)
{
printf("Installing\n");
bsearch = hid_keyboard_orig;
breplace = hid_keyboard_new;
}
else
{
printf("UN-installing\n");
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("pos=%d byte=%d bsearch[%d]=%d\n",pos,byte,pos,bsearch[pos]);
}
// jump back to the starting byte of this match
int back=-pos;
fseek(fo, back+1, SEEK_CUR);
pos = 0;
}
/*
printf("%d, ",byte);
pos++;
if (pos==256)
{
printf("\n");
pos = 0;
}
*/
}
fclose(fo);
return 0;
}
My next step is to get ACPI working or this box. I had wakeup/shutdown working perfectly in my FC4 setup, so hopefully I can get it going again for KnoppMyth.
Then I will tackle getting my Winfast DTV1000 Remote working with lirc. Out of interest has anyone been able to get this type of remote working? It is one of thos 3.5mm jack types that plug into the Card.
Hope This Helps.