public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Houghton <h@realh.co.uk>
To: Jan Panteltje <panteltje@yahoo.com>, linux-media@vger.kernel.org
Subject: Re: General question about IR remote signals  from USB DVB tuner
Date: Fri, 10 Feb 2012 18:25:56 +0000	[thread overview]
Message-ID: <20120210182556.005b6b47@junior> (raw)
In-Reply-To: <1328891689.25568.YahooMailClassic@web39302.mail.mud.yahoo.com>

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

On Fri, 10 Feb 2012 08:34:49 -0800 (PST)
Jan Panteltje <panteltje@yahoo.com> wrote:

> I recently bought a Terratec cinergy S2 USB  HD receiver.
> I got everything working just fine in Linux and get excellent
> reception.
> This thing came with a small remote controller, and I notice
> that the  output of this remote appears as ASCII characters on stdin,
> on any terminal that I open...
> Wrote a small GUI application that sets the input focus to a hidden
> input field, and can process the numbers from this remote that way,
> but of course this only works if the mouse has selected that
> application.
> 
> Thinking about this I think that the driver dumps the received remote
> control characters simply to stdout.

Something fairly low level processes the input events and converts them
to keyboard events. IIRC this happens on the console as well as in X.

> If this is so, does there perhaps exists a /dev/dvb/adapterX/remoteX
> interface in the specs so I could modify that driver to send the codes
> there?

The events can be read from /dev/input/eventX. You can do something like
parse /proc/bus/input/devices to work out which device corresponds to
your remote. The structure of the events etc is defined in
/usr/include/linux/input.h. The EVIOCGRAB ioctl is useful to grab the
events exclusively for your application and stop them appearing on the
console.

I don't know exactly what the fields in input_event are supposed to
mean, and IME their significance can vary with remote and with kernel
version. If you can find more information about this, please send a copy
to me because I'm about to unsubscribe from linux-media. If you can't
find the information you'll probably find it useful to experiment with
the attached python script (treat as Public Domain).

[-- Attachment #2: testdevinput.py --]
[-- Type: text/x-python, Size: 886 bytes --]

#!/usr/bin/env python

import os
import struct
import sys

SIZEOF_INPUT_EVENT = struct.calcsize('llHHi')
# time (2 * long), type, code, value

quiet = False

def main_loop(fd):
    while True:
        s = os.read(fd, SIZEOF_INPUT_EVENT)
        if len(s) != SIZEOF_INPUT_EVENT:
            print >>sys.stderr, "Read %d bytes, expected %d" % \
                    (len(s), SIZEOF_INPUT_EVENT)
            break
        [tsec, tusec, type, code, value] = struct.unpack('llHHi', s)
        if not quiet or type:
            print "T:%10.2f t:%02x c:%02x v:%02x" % \
                    (tsec + float(tusec) / 1000000, type, code, value)

def main():
    if sys.argv[1] == '-q':
        global quiet
        quiet = True
        filename = sys.argv[2]
    else:
        filename = sys.argv[1]
    fd = os.open(filename, os.O_RDONLY)
    main_loop(fd)

if __name__ == '__main__':
    main()

  reply	other threads:[~2012-02-10 18:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10 16:34 General question about IR remote signals from USB DVB tuner Jan Panteltje
2012-02-10 18:25 ` Tony Houghton [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-11 19:01 Jan Panteltje

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120210182556.005b6b47@junior \
    --to=h@realh.co.uk \
    --cc=linux-media@vger.kernel.org \
    --cc=panteltje@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox