Bug 22803 - Make header conform to implementation
[swfdec.git] / swfdec / swfdec_key_as.c
blob2c349e2161d38acca06e8ccfbe331a7b37845a03
1 /* Swfdec
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "swfdec_as_internal.h"
25 #include "swfdec_as_object.h"
26 #include "swfdec_as_strings.h"
27 #include "swfdec_debug.h"
28 #include "swfdec_player_internal.h"
30 SWFDEC_AS_NATIVE (800, 0, swfdec_key_getAscii)
31 void
32 swfdec_key_getAscii (SwfdecAsContext *cx, SwfdecAsObject *object,
33 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
35 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
37 *retval = swfdec_as_value_from_integer (cx, player->priv->last_character);
40 SWFDEC_AS_NATIVE (800, 1, swfdec_key_getCode)
41 void
42 swfdec_key_getCode (SwfdecAsContext *cx, SwfdecAsObject *object,
43 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
45 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
47 *retval = swfdec_as_value_from_integer (cx, player->priv->last_keycode);
50 SWFDEC_AS_NATIVE (800, 2, swfdec_key_isDown)
51 void
52 swfdec_key_isDown (SwfdecAsContext *cx, SwfdecAsObject *object,
53 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
55 guint id;
56 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
58 if (argc < 1)
59 return;
61 id = swfdec_as_value_to_integer (cx, argv[0]);
62 if (id >= 256) {
63 SWFDEC_FIXME ("id %u too big for a keycode", id);
64 id %= 256;
67 // special case for the mouse buttons, with Adobe's player these are only
68 // supported on Windows
69 if (id == 1) {
70 SWFDEC_AS_VALUE_SET_BOOLEAN (retval, swfdec_player_is_mouse_pressed (player));
71 } else if (id == 2) {
72 SWFDEC_FIXME ("Key.isDown (2) should give status of the second mouse button");
73 SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
74 } else if (id == 4) {
75 SWFDEC_FIXME ("Key.isDown (4) should give status of the middle mouse button");
76 SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
77 } else {
78 if (id < 8)
79 SWFDEC_FIXME ("Should Key.isDown (%i) give mouse button status?", id);
80 SWFDEC_AS_VALUE_SET_BOOLEAN (retval, (player->priv->key_pressed[id / 8] & (1 << (id % 8))) ? TRUE : FALSE);
84 SWFDEC_AS_NATIVE (800, 3, swfdec_key_isToggled)
85 void
86 swfdec_key_isToggled (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
87 SwfdecAsValue *argv, SwfdecAsValue *retval)
89 SWFDEC_STUB ("Key.isToggled (static)");
92 SWFDEC_AS_NATIVE (800, 4, swfdec_key_isAccessible)
93 void
94 swfdec_key_isAccessible (SwfdecAsContext *cx, SwfdecAsObject *object,
95 guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
97 SWFDEC_STUB ("Key.isAccessible (static)");