freebsd-ports/multimedia/vdr-plugin-remote/files/patch-uhid1
Juergen Lock a90cfac7f1 http://www.linuxtv.org/vdrwiki/index.php/Remote-plugin
This plugin extends the remote control capabilities of vdr.
The following remote control devices are supported:

(a) linux input device driver ('/dev/input/eventX', X=0,1,2,...)
    (currently not supported on FreeBSD)

(b) keyboard (tty driver): /dev/console, /dev/ttyX

(c) TCP connection (telnet)

(d) LIRC

(e) some(?) FreeBSD uhid(4) devices (experimental support added by this port)
    To use, add something like this to vdr_flags: '-Premote -h /dev/uhid0',
    (re)start vdr, then the osd should ask you to configure the
    remote by pressing the buttons you want to assign.

    Note:  If your remote is detected as a keyboard you'll have to
    tell ukbd(4) to ignore it first by doing (as root) something like:

	usbconfig add_dev_quirk_vplh 0x1241 0xe000 0 0xffff UQ_KBD_IGNORE

    (and possibly unplug it for a moment or reset it via usbconfig,
    0x1241 there is the vendor id, 0xe000 the product id of the
    device, you can get yours by doing

	usbconfig -d 1.2 dump_device_desc

    and looking for idVendor and idProduct, -d 1.2 there corresponds
    to ugen1.2 listed by usbconfig w/o args.)

    You can check with:

	usbconfig show_ifdrv

    if the device is then listed as ugen...: uhid... you're good to go.

    2nd note:  If vdr cannot open your uhid device check it is not claimed
    by xorg:

	fstat |grep uhid

    If it is you may need an xorg.conf(5) with manually defined
    InputDevice sections for mouse and keyboard and

	Option		"AutoAddDevices" "False"

    in the ServerFlags section.

    And if for some reason you want to reassign the buttons on the
    remote you can stop vdr and do:

	touch /usr/local/etc/vdr/channels.conf

    and/or remove uhid entries from

	/usr/local/etc/vdr/remote.conf .

    When you then start vdr again it should ask to configure the
    remote again.

WWW: http://escape-edv.de/endriss/vdr
2011-03-26 19:19:38 +00:00

255 lines
7.2 KiB
Text

--- a/remote.c
+++ a/remote.c
@@ -15,7 +15,9 @@
#include <sys/fcntl.h>
#include <getopt.h>
#include <termios.h>
+#ifdef REMOTE_FEATURE_DEVINPUT
#include <linux/input.h>
+#endif
#include "i18n.h"
#include "remote.h"
#ifdef REMOTE_FEATURE_TCPIP
@@ -25,6 +27,9 @@
#define NUMREMOTES 10 // maximum number of remote control devices
+#ifdef REMOTE_FEATURE_UHID
+#define UHID_DEFAULT_READSIZE 8 // default size of uhid reads
+#endif
#define AV7110_KEYMAP_DEVICE "/proc/av7110_ir"
#if 0
@@ -183,6 +188,7 @@ void cRemoteGeneric::Action(void)
int identifyInputDevice(const int fh, char *name)
// ---------------------------------------------------------------------------
{
+#ifdef REMOTE_FEATURE_DEVINPUT
char description[256];
// check name of input device
@@ -196,11 +202,13 @@ int identifyInputDevice(const int fh, ch
if (strstr(description, "DVB") || strstr(description, "dvb"))
return 2;
+#endif
return 0;
}
+#ifdef REMOTE_FEATURE_DEVINPUT
// ---------------------------------------------------------------------------
bool cRemoteDevInput::loadKeymap(const char *devname, uint32_t options)
// ---------------------------------------------------------------------------
@@ -454,6 +462,68 @@ bool cRemoteDevInput::keyPressed(uint64_
{
return (code & 0xFFFF00000000ULL);
}
+#endif // REMOTE_FEATURE_DEVINPUT
+
+
+/*****************************************************************************/
+
+
+#ifdef REMOTE_FEATURE_UHID
+// ---------------------------------------------------------------------------
+cRemoteUhid::cRemoteUhid(const char *name, int f, char *d, int size)
+ :cRemoteGeneric(name, f, d)
+// ---------------------------------------------------------------------------
+{
+ Start();
+
+ readsize = size;
+ repeatcode = 0;
+ fcntl(f, F_SETFL, O_NONBLOCK);
+}
+
+
+// ---------------------------------------------------------------------------
+bool cRemoteUhid::Initialize()
+// ---------------------------------------------------------------------------
+{
+ return true;
+}
+
+
+// ---------------------------------------------------------------------------
+uint64_t cRemoteUhid::getKey(void)
+// ---------------------------------------------------------------------------
+{
+ int n;
+ uint64_t code = 0;
+
+ // XXX handle short reads properly on big-endian
+ n = read(fh, &code, readsize);
+ if (n <= 0) {
+ if (n < 0 && (errno == EAGAIN || errno == EINTR))
+ code = repeatcode;
+ else {
+ code = INVALID_KEY;
+ repeatcode = 0;
+ }
+ } else {
+ repeatcode = code;
+#if 1 //def PRINTFDEBUGGING
+ printf("code %jx\n", code);
+#endif
+ }
+
+ return code;
+}
+
+
+// ---------------------------------------------------------------------------
+bool cRemoteUhid::keyPressed(uint64_t code)
+// ---------------------------------------------------------------------------
+{
+ return ((code & ~0xffULL) != 0LL);
+}
+#endif // REMOTE_FEATURE_UHID
/*****************************************************************************/
@@ -557,6 +627,9 @@ private:
int devcnt;
char devtyp[NUMREMOTES];
char *devnam[NUMREMOTES];
+#ifdef REMOTE_FEATURE_UHID
+ int devsize[NUMREMOTES];
+#endif
int fh[NUMREMOTES];
public:
cPluginRemote(void);
@@ -604,6 +677,10 @@ const char *cPluginRemote::CommandLineHe
// ---------------------------------------------------------------------------
{
return " -i dev, --input=dev input device (/dev/input/... | autodetect)\n"
+#ifdef REMOTE_FEATURE_UHID
+ " -h dev, --uhid=dev uhid(4) device (/dev/uhidX)\n"
+ " -s size, --uhidsize=size uhid device read size\n"
+#endif
#ifdef REMOTE_FEATURE_LIRC
" -l dev, --lirc=dev lirc device (/dev/lircd)\n"
#endif
@@ -624,6 +701,10 @@ bool cPluginRemote::ProcessArgs(int argc
{
static struct option long_options[] =
{ { "input", required_argument, NULL, 'i' },
+#ifdef REMOTE_FEATURE_UHID
+ { "uhid", required_argument, NULL, 'h' },
+ { "uhidsize", required_argument, NULL, 's' },
+#endif
{ "lirc", required_argument, NULL, 'l' },
{ "port", required_argument, NULL, 'p' },
{ "tty", required_argument, NULL, 't' },
@@ -631,11 +712,20 @@ bool cPluginRemote::ProcessArgs(int argc
{ NULL } };
int c;
+#ifndef REMOTE_FEATURE_UHID
while ((c = getopt_long(argc, argv, "i:l:p:t:T:", long_options, NULL)) != -1)
+#else
+ while ((c = getopt_long(argc, argv, "i:h:s:l:p:t:T:", long_options, NULL)) != -1)
+#endif
{
+#ifdef REMOTE_FEATURE_UHID
+ int size;
+#endif
+
switch (c)
{
case 'i':
+ case 'h':
case 'l':
case 'p':
case 't':
@@ -647,8 +737,27 @@ bool cPluginRemote::ProcessArgs(int argc
}
devtyp[devcnt] = c;
devnam[devcnt] = optarg;
+#ifdef REMOTE_FEATURE_UHID
+ devsize[devcnt] = UHID_DEFAULT_READSIZE;
+#endif
devcnt++;
break;
+#ifdef REMOTE_FEATURE_UHID
+ case 's':
+ if (!devcnt || devcnt > NUMREMOTES)
+ {
+ esyslog("%s: uhidsize must come after uhid device", Name());
+ return false;
+ }
+ size = atoi(optarg);
+ if (size <= 0 || size_t(size) > sizeof (int64_t))
+ {
+ esyslog("%s: bad uhidsize %s", Name(), optarg);
+ return false;
+ }
+ devsize[devcnt] = size;
+ break;
+#endif
default:
esyslog("%s: invalid argument", Name());
@@ -671,6 +780,7 @@ bool cPluginRemote::Start(void)
RegisterI18n(remotePhrases);
#endif
+#ifdef REMOTE_FEATURE_DEVINPUT
// no device specified by the user, set default
if (devcnt == 0)
{
@@ -719,6 +829,7 @@ bool cPluginRemote::Start(void)
if (devtyp[i] == 'i' && strcmp(devnam[i], "autodetect") == 0)
devnam[i] = "/dev/input/ir";
} // for i
+#endif
for (int i = 0; i < devcnt; i++)
{
@@ -769,9 +880,17 @@ bool cPluginRemote::Start(void)
switch (devtyp[i])
{
+#ifdef REMOTE_FEATURE_DEVINPUT
case 'i':
new cRemoteDevInput(nam,fh[i],devnam[i]);
break;
+#endif
+
+#ifdef REMOTE_FEATURE_UHID
+ case 'h':
+ new cRemoteUhid(nam,fh[i],devnam[i],devsize[i]);
+ break;
+#endif
#ifdef REMOTE_FEATURE_LIRC
case 'l':
--- a/remote.h
+++ a/remote.h
@@ -82,6 +82,24 @@ public:
+#ifdef REMOTE_FEATURE_UHID
+/*****************************************************************************/
+class cRemoteUhid : protected cRemoteGeneric
+/*****************************************************************************/
+{
+private:
+ uint64_t repeatcode;
+ int readsize;
+protected:
+ virtual uint64_t getKey(void);
+ virtual bool keyPressed(uint64_t code);
+public:
+ cRemoteUhid(const char *name, int f, char *d, int size);
+ virtual bool Initialize(void);
+};
+#endif
+
+
#ifdef REMOTE_FEATURE_LIRCOLD
/*****************************************************************************/
class cRemoteDevLirc : protected cRemoteGeneric