1 |
=head1 RCU::Receipts |
2 |
|
3 |
This manpage contains some examples that should help you getting started |
4 |
with the module and solving common problems. |
5 |
|
6 |
=head2 THE BASICS |
7 |
|
8 |
=over 4 |
9 |
|
10 |
=item Debugging The Connection |
11 |
|
12 |
To find out wether the connection actually works, you can try this very simple program: |
13 |
|
14 |
use RCU; |
15 |
|
16 |
$rcu = new RCU "RCU:Lirc"; |
17 |
|
18 |
# endless loop |
19 |
while () { |
20 |
my ($key, $repeat) = $rcu->get; |
21 |
print "EVENT $key (= $repeat)\n"; |
22 |
} |
23 |
|
24 |
If you do not use the lirc interface you would have to specify another |
25 |
one on the call to C<new>, like C<RCU:Irman> for your irman (very nice) |
26 |
or C<RCU:Irman:/dev/ttyS1> if you know that your irman is connected to |
27 |
C</dev/ttyS1>. |
28 |
|
29 |
Here is some example output: |
30 |
|
31 |
EVENT sony-cd-next (= 0) |
32 |
EVENT sony-cd-next (= 1) |
33 |
EVENT sony-cd-next (= 0) |
34 |
EVENT sony-cd-next (= 1) |
35 |
EVENT sony-cd-next (= 2) |
36 |
EVENT sony-cd-fwd (= 0) |
37 |
EVENT sony-cd-fwd (= 1) |
38 |
EVENT sony-cd-4 (= 0) |
39 |
EVENT sony-cd-4 (= 1) |
40 |
|
41 |
... correspong to two times "sony-cd-next", and one press for |
42 |
"sony-cd-fwd" and "sony-cd-4". |
43 |
|
44 |
=item Using Event |
45 |
|
46 |
If you don't know how the Event module works you should read about that |
47 |
one first and come back. |
48 |
|
49 |
In general, the Event-API is easy to use. The only (seeming) complication |
50 |
is that you have to think a bit about your setup. The reason you should |
51 |
use this API is that using repeated keypresses has one major drawback: It |
52 |
does not let you know when the user stopped pressing the key (the events |
53 |
just do not occur) and different remotes repeat their pulses with |
54 |
different frequency. The only thing that you should use to measure the |
55 |
duration of a keypress is therefore wallclock time. |
56 |
|
57 |
This is what the Event-API does: It translates normal key-events into |
58 |
key-down/key-up pairs, on which you can bind any action you want (See |
59 |
L<RCU::Context>). Since keypresses usually do not happen in some |
60 |
informational void but depend on previous keys and e.g. the mode of the |
61 |
application, you have to put all your events into some context (actually, |
62 |
into some L<RCU::Context>-object), like this: |
63 |
|
64 |
use Event; |
65 |
use RCU::Event; |
66 |
use RCU::Context; |
67 |
|
68 |
# create a new context |
69 |
$ctx = new RCU::Context; |
70 |
|
71 |
# and bind some actions to some events |
72 |
$ctx->bind( |
73 |
"sony-cd-stop" => sub { print "T$_[1]: STOP pressed\n" }, |
74 |
"~sony-cd-1" => sub { print "T$_[1]: 'one' key released\n" }, |
75 |
"=.*" => sub { print "T$_[1]: unknown event '$_[0]'\n" }, |
76 |
); |
77 |
|
78 |
# connect to the RCU |
79 |
$rcu = new RCU::Event "RCU:Irman"; |
80 |
$rcu->set_context($ctx); |
81 |
|
82 |
# jump into the main event loop |
83 |
Event::loop; |
84 |
|
85 |
Here is some sample output: |
86 |
|
87 |
T965403699.132146: STOP pressed |
88 |
T965403703.059969: unknown event 'sony-cd-stop:=sony-cd-1' |
89 |
T965403703.621847: 'one' key released |
90 |
|
91 |
As you can see, I first pressed the STOP button, followed by a press of |
92 |
the "1" button, for which the default handler was used, since we haven't |
93 |
bound "STOP followed by 1" to any event, followed by the button-release |
94 |
event. |
95 |
|
96 |
|
97 |
|
98 |
=back |
99 |
|
100 |
=head2 RECEIPTS |
101 |
|
102 |
... not written yet ... |
103 |
|
104 |
=over 4 |
105 |
|
106 |
=item A Volume Slider |
107 |
|
108 |
=item Digit Input |
109 |
|
110 |
=back |
111 |
|
112 |
=head1 AUTHOR |
113 |
|
114 |
This document was wirtten by Marc Lehmann <schmorp@schmorp.de> |