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.
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
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
)
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
)
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
)
52 swfdec_key_isDown (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
53 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*retval
)
56 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
61 id
= swfdec_as_value_to_integer (cx
, argv
[0]);
63 SWFDEC_FIXME ("id %u too big for a keycode", id
);
67 // special case for the mouse buttons, with Adobe's player these are only
68 // supported on Windows
70 SWFDEC_AS_VALUE_SET_BOOLEAN (retval
, swfdec_player_is_mouse_pressed (player
));
72 SWFDEC_FIXME ("Key.isDown (2) should give status of the second mouse button");
73 SWFDEC_AS_VALUE_SET_BOOLEAN (retval
, FALSE
);
75 SWFDEC_FIXME ("Key.isDown (4) should give status of the middle mouse button");
76 SWFDEC_AS_VALUE_SET_BOOLEAN (retval
, FALSE
);
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
)
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
)
94 swfdec_key_isAccessible (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
95 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*retval
)
97 SWFDEC_STUB ("Key.isAccessible (static)");