2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "gnashconfig.h"
35 #include "as_object.h"
36 #include "Global_as.h"
37 #include "builtin_function.h" // need builtin_function
43 struct lirc_config
*config
;
44 as_value
lirc_ext_init(const fn_call
& fn
);
45 as_value
lirc_ext_getkey(const fn_call
& fn
);
46 as_value
lirc_ext_getbutton(const fn_call
& fn
);
48 class LircRelay
: public Relay
55 attachInterface(as_object
& obj
)
57 GNASH_REPORT_FUNCTION
;
58 Global_as
& gl
= getGlobal(obj
);
60 obj
.init_member("lirc_init", gl
.createFunction(lirc_ext_init
));
61 obj
.init_member("lirc_getKey", gl
.createFunction(lirc_ext_getkey
));
62 obj
.init_member("lirc_getButton", gl
.createFunction(lirc_ext_getbutton
));
66 lirc_ctor(const fn_call
& fn
)
68 as_object
* obj
= ensure
<ValidThis
>(fn
);
70 obj
->setRelay(new LircRelay());
78 GNASH_REPORT_FUNCTION
;
83 GNASH_REPORT_FUNCTION
;
87 lirc_ext_init(const fn_call
& fn
)
89 GNASH_REPORT_FUNCTION
;
90 LircRelay
* ptr
= ensure
<ThisIsNative
<LircRelay
> >(fn
);
93 const std::string
& text
= fn
.arg(0).to_string();
94 return as_value(ptr
->obj
.init(text
.c_str()));
96 return as_value(false);
100 lirc_ext_getkey(const fn_call
& fn
)
102 GNASH_REPORT_FUNCTION
;
103 LircRelay
* ptr
= ensure
<ThisIsNative
<LircRelay
> >(fn
);
106 key::code key
= ptr
->obj
.getKey();
107 return as_value(key
);
109 return as_value(false);
113 lirc_ext_getbutton(const fn_call
& fn
)
115 LircRelay
* ptr
= ensure
<ThisIsNative
<LircRelay
> >(fn
);
116 return as_value(ptr
->obj
.getButton());
121 lirc_class_init(as_object
&obj
)
124 Global_as
& gl
= getGlobal(obj
);
125 as_object
* proto
= createObject(gl
);
126 attachInterface(*proto
);
127 as_object
* cl
= gl
.createClass(&lirc_ctor
, proto
);
128 obj
.init_member("Lirc", cl
);
133 } // end of gnash namespace
137 // indent-tabs-mode: t