2
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include "gnashconfig.h"
35
// this number camne from the lirc irw program. If this size works for
36
// them, it should work for us.
37
const int LIRC_PACKET_SIZE = 128;
38
const int TIMEOUT = 10;
39
const int BUTTONSIZE = 10;
42
: _sockname("/tmp/lircd"), _button(0)
44
// GNASH_REPORT_FUNCTION;
45
_button = new char[BUTTONSIZE];
50
// GNASH_REPORT_FUNCTION;
60
// GNASH_REPORT_FUNCTION;
61
return connectSocket(_sockname);
65
Lirc::init(const char *sockpath)
67
// GNASH_REPORT_FUNCTION;
68
_connected = connectSocket(sockpath);
72
// Whenever lircd receives a IR signal it will broadcast the
73
// following string to each client:
74
// <code> <repeat count> <button name> <remote control name>
75
// 0000000000000003 1 PREV LIRCEMU
76
// 0000000000000006 1 NEXT LIRCEMU
77
// 0000000000000012 1 A LIRCEMU
82
// GNASH_REPORT_FUNCTION;
85
char buf[LIRC_PACKET_SIZE];
86
memset(buf, 0, LIRC_PACKET_SIZE);
88
// read the data if there is any
89
readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
92
string::size_type space1 = packet.find(" ") +1;
93
string::size_type space2 = packet.find(" ", space1) + 1;
94
string::size_type space3 = packet.find(" ", space2) +1;
96
string code_str = packet.substr(0, space1);
97
string count_str = packet.substr(space1, space2-space1);
98
string button_str = packet.substr(space2,space3-space2);
99
string control_str = packet.substr(space3);
101
if (button_str[0] > 'A' && button_str[0] < 'Z') {
102
cerr << "Character: " << button_str << endl;
103
key = (gnash::key::code)button_str[0];
112
// GNASH_REPORT_FUNCTION;
114
char buf[LIRC_PACKET_SIZE];
115
memset(buf, 0, LIRC_PACKET_SIZE);
117
// read the data if there is any
118
readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
121
string::size_type space1 = packet.find(" ") + 1;
122
string::size_type space2 = packet.find(" ", space1) + 1;
123
string::size_type space3 = packet.find(" ", space2) + 1;
125
string button_str = packet.substr(space2, space3-space2-1);
127
memset(_button, 0, BUTTONSIZE);
128
strncpy(_button, button_str.c_str(), BUTTONSIZE);
132
} // end of gnash namespace
136
// indent-tabs-mode: t