Re: General question about IR remote signals from USB DVB tuner

2012-02-11 Thread Jan Panteltje
This little demo C program looks for the IR input device,
parses the IR output and can start any application on any remote key press
or release.
Compile with gcc -o test50 test50.c
I have added a start xterm, a start firefox, and a kill firefox
as example.
add your own as needed.
Have fun:-)



test50.c
Description: Binary data


General question about IR remote signals from USB DVB tuner

2012-02-10 Thread Jan Panteltje
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.
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?
If not how about adding such a thing?
The application can then in a separate thread for example open
this device and use those codes.
This little remote has it all:
 numbers 0 to 9, ENTER, channel up /down, power, mute, EPG,
volume, what not.
Sorry I a am bit rusty, been many years since I did any programming
for DVB, so may be this already exists?
So much seems to have changed.
 
Any suggestions would be appreciated

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: General question about IR remote signals from USB DVB tuner

2012-02-10 Thread Tony Houghton
On Fri, 10 Feb 2012 08:34:49 -0800 (PST)
Jan Panteltje pantel...@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).
#!/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) / 100, 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()