Benjamin Otte
2007-Aug-05 11:59 UTC
[Swfdec] 7 commits - doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_object.c libswfdec/swfdec.h libswfdec/swfdec_key.h libswfdec/swfdec_marshal.list libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h test/trace
doc/swfdec-sections.txt | 3 + libswfdec/Makefile.am | 1 libswfdec/swfdec.h | 1 libswfdec/swfdec_as_object.c | 1 libswfdec/swfdec_key.h | 32 ++++++++++++++ libswfdec/swfdec_marshal.list | 1 libswfdec/swfdec_player.c | 83 +++++++++++++++++++++++++++++++++++-- libswfdec/swfdec_player.h | 5 ++ libswfdec/swfdec_player_internal.h | 3 + test/trace/swfdec_interaction.c | 34 +++++++++++++++ test/trace/swfdec_interaction.h | 11 +++- 11 files changed, 168 insertions(+), 7 deletions(-) New commits: diff-tree ee784e2bc20dc17a4e842d70d661f228903d32ae (from parents) Merge: 0bd1263afd1d7738eab08f2264a453f03908db3c e35c5dd07e4e4e870e0ce916919ca798ba736bc5 Author: Benjamin Otte <otte at gnome.org> Date: Sun Aug 5 13:54:38 2007 +0200 Merge branch 'master' of ssh://company at git.freedesktop.org/git/swfdec/swfdec diff-tree 0bd1263afd1d7738eab08f2264a453f03908db3c (from d19ac4b569501dae4eb5e40a6ebaadd9e6c9d318) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 13:04:55 2007 +0200 guess who forgot to add a file... diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am index b8d2e07..1c25bee 100644 --- a/libswfdec/Makefile.am +++ b/libswfdec/Makefile.am @@ -130,6 +130,7 @@ public_headers = \ swfdec_audio.h \ swfdec_buffer.h \ swfdec_file_loader.h \ + swfdec_key.h \ swfdec_loader.h \ swfdec_player.h \ swfdec_url.h diff --git a/libswfdec/swfdec_key.h b/libswfdec/swfdec_key.h new file mode 100644 index 0000000..f87c9ab --- /dev/null +++ b/libswfdec/swfdec_key.h @@ -0,0 +1,32 @@ +/* Swfdec + * Copyright (C) 2007 Benjamin Otte <otte at gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef _SWFDEC_KEY_H_ +#define _SWFDEC_KEY_H_ + +#include <glib.h> + +G_BEGIN_DECLS + +/* can't make this a guint8 because of signal handlers, but it should be a guint8 */ +typedef guint SwfdecKey; + + +G_END_DECLS +#endif diff-tree d19ac4b569501dae4eb5e40a6ebaadd9e6c9d318 (from fafe076b291915253f1434b59979061a28811e5f) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 13:04:03 2007 +0200 make key handling work diff --git a/test/trace/swfdec_interaction.c b/test/trace/swfdec_interaction.c index 40b093c..914f8ff 100644 --- a/test/trace/swfdec_interaction.c +++ b/test/trace/swfdec_interaction.c @@ -244,7 +244,10 @@ swfdec_interaction_advance (SwfdecIntera command->args.mouse.y, command->args.mouse.button); break; case SWFDEC_COMMAND_PRESS: + swfdec_player_key_press (player, command->args.key); + break; case SWFDEC_COMMAND_RELEASE: + swfdec_player_key_release (player, command->args.key); break; case SWFDEC_COMMAND_UP: case SWFDEC_COMMAND_DOWN: diff-tree fafe076b291915253f1434b59979061a28811e5f (from d9c4918cbf14898f7aeedd6111d5005da9f6c171) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 13:02:12 2007 +0200 the native flag is gone, no need to document it diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c index 2931172..f7b0e98 100644 --- a/libswfdec/swfdec_as_object.c +++ b/libswfdec/swfdec_as_object.c @@ -66,7 +66,6 @@ * to delete this variable. * @SWFDEC_AS_VARIABLE_READONLY: Do not allow changing the value with * swfdec_as_object_set_variable(). - * @SWFDEC_AS_VARIABLE_NATIVE: The variable is implemented natively. * * These flags are used to describe various properties of a variable inside * Swfdec. You can manually set them with swfdec_as_object_set_variable_flags(). diff-tree d9c4918cbf14898f7aeedd6111d5005da9f6c171 (from e6a06ac5bf092521506a046c1624e8f6f1a45248) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 13:00:12 2007 +0200 make documentation key function aware diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt index a58478d..69d7785 100644 --- a/doc/swfdec-sections.txt +++ b/doc/swfdec-sections.txt @@ -91,6 +91,8 @@ swfdec_player_set_alignment swfdec_player_render swfdec_player_advance swfdec_player_handle_mouse +swfdec_player_key_press +swfdec_player_key_release swfdec_player_render_audio swfdec_player_get_audio <SUBSECTION Standard> @@ -142,6 +144,7 @@ SwfdecLoaderDataType SwfdecLoaderRequest swfdec_loader_data_type_get_extension SwfdecAlignment +SwfdecKey SwfdecMouseCursor SwfdecScaleMode </SECTION> diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index 393519d..4ea85e6 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -1636,8 +1636,9 @@ swfdec_init (void) * probably want to call swfdec_player_advance() before to update the player to * the correct time when calling this function. * - * Returns: TRUE if the mouse event was handled. A mouse event may not be - * handled if the user clicked on a translucent area for example. + * Returns: %TRUE if the mouse event was handled. %FALSE to propagate the event + * further. A mouse event may not be handled if the user clicked on a + * translucent area. **/ gboolean swfdec_player_handle_mouse (SwfdecPlayer *player, @@ -1653,6 +1654,17 @@ swfdec_player_handle_mouse (SwfdecPlayer return ret; } +/** + * swfdec_player_key_press: + * @player: a #SwfdecPlayer + * @key: the key that was pressed + * + * Call this function to make the @player react to a key press. Be sure to + * transform the keycode to the right #SwfdecKey. + * + * Returns: %TRUE if the key press was handled by the @player, %FALSE if it + * should be propagated further + **/ gboolean swfdec_player_key_press (SwfdecPlayer *player, SwfdecKey key) { @@ -1666,6 +1678,17 @@ swfdec_player_key_press (SwfdecPlayer *p return ret; } +/** + * swfdec_player_key_release: + * @player: a #SwfdecPlayer + * @key: the key that was released + * + * Call this function to make the @player react to a key being released. Be + * sure to transform the keycode to the right #SwfdecKey. + * + * Returns: %TRUE if the key press was handled by the @player, %FALSE if it + * should be propagated further + **/ gboolean swfdec_player_key_release (SwfdecPlayer *player, SwfdecKey key) { diff-tree e6a06ac5bf092521506a046c1624e8f6f1a45248 (from fcd20f5796889b82472ac54a08be02b4a9c45ec0) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 12:54:06 2007 +0200 add infrastructure for handling key events diff --git a/libswfdec/swfdec.h b/libswfdec/swfdec.h index d49dc69..9a82dd1 100644 --- a/libswfdec/swfdec.h +++ b/libswfdec/swfdec.h @@ -31,6 +31,7 @@ #include <libswfdec/swfdec_buffer.h> #include <libswfdec/swfdec_enums.h> #include <libswfdec/swfdec_file_loader.h> +#include <libswfdec/swfdec_key.h> #include <libswfdec/swfdec_loader.h> #include <libswfdec/swfdec_player.h> #include <libswfdec/swfdec_url.h> diff --git a/libswfdec/swfdec_marshal.list b/libswfdec/swfdec_marshal.list index e2322a3..e04f7f5 100644 --- a/libswfdec/swfdec_marshal.list +++ b/libswfdec/swfdec_marshal.list @@ -1,4 +1,5 @@ BOOLEAN:DOUBLE,DOUBLE,INT +BOOLEAN:UINT,BOOLEAN VOID:DOUBLE,DOUBLE,DOUBLE,DOUBLE VOID:STRING,STRING VOID:UINT,UINT diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c index ff786ce..393519d 100644 --- a/libswfdec/swfdec_player.c +++ b/libswfdec/swfdec_player.c @@ -407,6 +407,7 @@ swfdec_player_remove_all_external_action enum { INVALIDATE, ADVANCE, + HANDLE_KEY, HANDLE_MOUSE, AUDIO_ADDED, AUDIO_REMOVED, @@ -890,6 +891,14 @@ swfdec_player_emit_signals (SwfdecPlayer } static gboolean +swfdec_player_do_handle_key (SwfdecPlayer *player, SwfdecKey key, gboolean down) +{ + g_assert (key < 256); + + return TRUE; +} + +static gboolean swfdec_player_do_handle_mouse (SwfdecPlayer *player, double x, double y, int button) { @@ -1155,13 +1164,31 @@ swfdec_player_class_init (SwfdecPlayerCl NULL, NULL, swfdec_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); /** + * SwfdecPlayer::handle-key: + * @player: the #SwfdecPlayer affected + * @key: #SwfdecKey that was pressed or released + * @pressed: %TRUE if the @key was pressed or %FALSE if it was released + * + * This signal is emitted whenever @player should respond to a key event. If + * any of the handlers returns TRUE, swfdec_player_key_press() or + * swfdec_player_key_release() will return TRUE. Note that unlike many event + * handlers in gtk, returning TRUE will not stop further event handlers from + * being invoked. Use g_signal_stop_emission() in that case. + * + * Returns: TRUE if this handler handles the event. + **/ + signals[HANDLE_KEY] = g_signal_new ("handle-key", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, handle_key), + swfdec_accumulate_or, NULL, swfdec_marshal_BOOLEAN__UINT_BOOLEAN, + G_TYPE_BOOLEAN, 2, G_TYPE_UINT, G_TYPE_BOOLEAN); + /** * SwfdecPlayer::handle-mouse: * @player: the #SwfdecPlayer affected * @x: new x coordinate of the mouse * @y: new y coordinate of the mouse * @button: 1 if the button is pressed, 0 if not * - * this signal is emitted whenever @player should respond to a mouse event. If + * This signal is emitted whenever @player should respond to a mouse event. If * any of the handlers returns TRUE, swfdec_player_handle_mouse() will return * TRUE. Note that unlike many event handlers in gtk, returning TRUE will not * stop further event handlers from being invoked. Use g_signal_stop_emission() @@ -1244,6 +1271,7 @@ swfdec_player_class_init (SwfdecPlayerCl context_class->get_time = swfdec_player_get_time; klass->advance = swfdec_player_do_advance; + klass->handle_key = swfdec_player_do_handle_key; klass->handle_mouse = swfdec_player_do_handle_mouse; } @@ -1625,6 +1653,32 @@ swfdec_player_handle_mouse (SwfdecPlayer return ret; } +gboolean +swfdec_player_key_press (SwfdecPlayer *player, SwfdecKey key) +{ + gboolean ret; + + g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE); + g_return_val_if_fail (key >= 256, FALSE); + + g_signal_emit (player, signals[HANDLE_KEY], 0, key, TRUE, &ret); + + return ret; +} + +gboolean +swfdec_player_key_release (SwfdecPlayer *player, SwfdecKey key) +{ + gboolean ret; + + g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE); + g_return_val_if_fail (key >= 256, FALSE); + + g_signal_emit (player, signals[HANDLE_KEY], 0, key, FALSE, &ret); + + return ret; +} + /** * swfdec_player_render: * @player: a #SwfdecPlayer diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h index e712583..11333b0 100644 --- a/libswfdec/swfdec_player.h +++ b/libswfdec/swfdec_player.h @@ -22,6 +22,7 @@ #include <glib-object.h> #include <cairo.h> +#include <libswfdec/swfdec_key.h> #include <libswfdec/swfdec_loader.h> G_BEGIN_DECLS @@ -111,6 +112,10 @@ gboolean swfdec_player_handle_mouse (Swf double x, double y, int button); +gboolean swfdec_player_key_press (SwfdecPlayer * player, + SwfdecKey key); +gboolean swfdec_player_key_release (SwfdecPlayer * player, + SwfdecKey key); /* audio - see swfdec_audio.c */ void swfdec_player_render_audio (SwfdecPlayer * player, gint16 * dest, diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h index 0667e20..b02e573 100644 --- a/libswfdec/swfdec_player_internal.h +++ b/libswfdec/swfdec_player_internal.h @@ -121,6 +121,9 @@ struct _SwfdecPlayerClass void (* advance) (SwfdecPlayer * player, guint msecs, guint audio_samples); + gboolean (* handle_key) (SwfdecPlayer * player, + SwfdecKey key, + gboolean down); gboolean (* handle_mouse) (SwfdecPlayer * player, double x, double y, diff-tree fcd20f5796889b82472ac54a08be02b4a9c45ec0 (from 6c9bb2836becc35805d599c3f4e942c97fbe09f1) Author: Benjamin Otte <otte at gnome.org> Date: Fri Aug 3 09:55:30 2007 +0200 add initial support for tracking key presses and releases diff --git a/test/trace/swfdec_interaction.c b/test/trace/swfdec_interaction.c index 371d786..40b093c 100644 --- a/test/trace/swfdec_interaction.c +++ b/test/trace/swfdec_interaction.c @@ -81,6 +81,16 @@ swfdec_command_append_mouse (SwfdecInter } static void +swfdec_command_append_key (SwfdecInteraction *inter, guint key, SwfdecCommandType type) +{ + SwfdecCommand command; + + command.command = type; + command.args.key = key; + g_array_append_val (inter->commands, command); +} + +static void swfdec_command_append_wait (SwfdecInteraction *inter, int msecs) { SwfdecCommand command; @@ -108,6 +118,8 @@ swfdec_interaction_new (const char *data g_scanner_scope_add_symbol (scanner, 0, "move", GINT_TO_POINTER (SWFDEC_COMMAND_MOVE)); g_scanner_scope_add_symbol (scanner, 0, "down", GINT_TO_POINTER (SWFDEC_COMMAND_DOWN)); g_scanner_scope_add_symbol (scanner, 0, "up", GINT_TO_POINTER (SWFDEC_COMMAND_UP)); + g_scanner_scope_add_symbol (scanner, 0, "press", GINT_TO_POINTER (SWFDEC_COMMAND_PRESS)); + g_scanner_scope_add_symbol (scanner, 0, "release", GINT_TO_POINTER (SWFDEC_COMMAND_RELEASE)); g_scanner_input_text (scanner, data, length); /* setup inter */ @@ -146,6 +158,22 @@ swfdec_interaction_new (const char *data case SWFDEC_COMMAND_UP: swfdec_command_append_mouse (inter, inter->mouse_x, inter->mouse_y, 0); break; + case SWFDEC_COMMAND_PRESS: + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) { + g_scanner_unexp_token (scanner, G_TOKEN_INT, NULL, NULL, NULL, NULL, TRUE); + goto error; + } + swfdec_command_append_key (inter, scanner->value.v_int, SWFDEC_COMMAND_PRESS); + break; + case SWFDEC_COMMAND_RELEASE: + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) { + g_scanner_unexp_token (scanner, G_TOKEN_INT, NULL, NULL, NULL, NULL, TRUE); + goto error; + } + swfdec_command_append_key (inter, scanner->value.v_int, SWFDEC_COMMAND_RELEASE); + break; default: g_scanner_unexp_token (scanner, SWFDEC_COMMAND_WAIT, NULL, NULL, NULL, NULL, TRUE); goto error; @@ -215,6 +243,9 @@ swfdec_interaction_advance (SwfdecIntera swfdec_player_handle_mouse (player, command->args.mouse.x, command->args.mouse.y, command->args.mouse.button); break; + case SWFDEC_COMMAND_PRESS: + case SWFDEC_COMMAND_RELEASE: + break; case SWFDEC_COMMAND_UP: case SWFDEC_COMMAND_DOWN: /* these 2 get synthetisized into SWFDEC_COMMAND_MOVE */ diff --git a/test/trace/swfdec_interaction.h b/test/trace/swfdec_interaction.h index c7d5d9b..0258474 100644 --- a/test/trace/swfdec_interaction.h +++ b/test/trace/swfdec_interaction.h @@ -29,10 +29,14 @@ typedef enum { SWFDEC_COMMAND_WAIT = G_TOKEN_LAST + 1, /* move (int x, int y) */ SWFDEC_COMMAND_MOVE, - /* press (void) */ + /* mouse press (void) */ SWFDEC_COMMAND_DOWN, - /* release (void) */ - SWFDEC_COMMAND_UP + /* mouse release (void) */ + SWFDEC_COMMAND_UP, + /* key press (int key) */ + SWFDEC_COMMAND_PRESS, + /* key release (int key) */ + SWFDEC_COMMAND_RELEASE } SwfdecCommandType; typedef struct _SwfdecCommand SwfdecCommand; @@ -45,6 +49,7 @@ struct _SwfdecCommand { int button; } mouse; guint time; + guint key; } args; };
Reasonably Related Threads
- 5 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_keys.h libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_sprite_movie_as.c player/swfdebug.c player/swfdec_debug_movies.c player/swfdec_debug_movies.h test/trace
- 13 commits - libswfdec-gtk/Makefile.am libswfdec-gtk/swfdec_gtk_keys.c libswfdec-gtk/swfdec_gtk_keys.h libswfdec-gtk/swfdec_gtk_widget.c libswfdec/Makefile.am libswfdec/swfdec_as_types.c libswfdec/swfdec.h libswfdec/swfdec_initialize.as
- 9 commits - configure.ac test/custom test/Makefile.am test/swfdec_test_initialize.as test/swfdec_test_initialize.h test/swfdec_test_test.c test/trace
- 9 commits - configure.ac doc/Makefile.am libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_keys.h libswfdec/swfdec_pattern.c libswfdec/swfdec_player.c test/trace
- Changes to 'refs/tags/0.5.2'