2 * hw_livedrive_seq.c - lirc routines for a Creative Labs LiveDrive.
4 * Copyright (C) 2003 Stephen Beahm <stephenbeahm@adelphia.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
23 #include "ir_remote.h"
24 #include "hw_livedrive_common.h"
26 char *livedrive_rec_seq(struct ir_remote
*remotes
)
29 struct sequencer_packet seq
;
30 struct midi_packet midi
;
31 unsigned char *bytep
= (unsigned char *) &midi
;
36 gettimeofday(&start
, NULL
);
37 /* poll for system exclusive status byte so we don't try to
38 record other midi events */
40 read(hw
.fd
, &seq
, sizeof(seq
));
42 while (seq
.data
!= SYSEX
);
44 for (i
= 0; i
< sizeof(midi
); i
++) {
45 read(hw
.fd
, &seq
, sizeof(seq
));
46 if (midi
.dev
== NONREMOTE
&& i
== 4) /* skip 2 missing filler bytes for audigy2 non-infrared messages */
48 *(bytep
+i
) = seq
.data
;
50 gettimeofday(&end
, NULL
);
52 /* test for correct system exclusive end byte so we don't try
53 to record other midi events */
54 if (midi
.sysex_end
!= SYSEX_END
)
57 bit
[0] = (midi
.keygroup
>> 3) & 0x1;
58 bit
[1] = (midi
.keygroup
>> 2) & 0x1;
59 bit
[2] = (midi
.keygroup
>> 1) & 0x1;
60 bit
[3] = (midi
.keygroup
>> 0) & 0x1;
62 pre
= reverse(midi
.remote
[0] |
63 (midi
.remote
[1] << 8), 16) | (bit
[0] << 8) | bit
[1];
64 code
= reverse(midi
.key
[0] |
65 (midi
.key
[1] << 8), 16) | (bit
[2] << 8) | bit
[3];
67 return (decode_all(remotes
));
70 struct hardware hw_livedrive_seq
= {
71 "/dev/sequencer", /* simple device */
73 LIRC_CAN_REC_LIRCCODE
, /* features */
75 LIRC_MODE_LIRCCODE
, /* rec_mode */
77 livedrive_init
, /* init_func */
78 NULL
, /* config_func */
79 livedrive_deinit
, /* deinit_func */
81 livedrive_rec_seq
, /* rec_func */
82 livedrive_decode
, /* decode_func */
83 NULL
, /* ioctl_func */