swfdec 0.8.2 does not respond to keyboard events. This problem occurres when using both the GTK player and a directfb player. The gtk-player distributed with Ubuntu 8.04 which is based on a previous library shows the same problem and can be used for reproducing. swfdec_player_do_handle_key() is invoked as a result of sending a key press message in swfdec_player_key_press() with the proper key value, therefore I assume the problem is located in further processing of the key event. Please confirm this problem by starting the simple swf file attached to this issue. It contains an OnClipEvent(keyDown) handler and should put a trace message to the console when pressing the 'cursor left' key. Playback using Gnash works fine, as well as testing it with CS4.
Created attachment 20955 [details] Simple flash file tracing a text message when pressing 'cursor left'
I haven't try the test with GTK(I don't use GTK). But by reviewing the swfdec source code, I think the key code translation part might need to be imporved. I suspect the function swfdec_gtk_keycode_from_hardware_keycode() doesn't work quite well on some systems. It's strange to me that someone want to translate the hardware code directly. Why not translate GdkEventKey->keyval or the unicode represented by the keyval instead? Isn't hardware keycode hardware dependent, thus not portable? To helmut.jahns: If you'd like to take a test, you may want check if function swfdec_gtk_event_to_keycode() works as expected on your platform. See file swfdec_gtk_widget.c, function swfdec_gtk_widget_key_press(), line170(git head), that's where swfdec get the key code. When you press the 'LEFT' key, the return value should be 37. Add some printings there, you should see if it works as expected. --zou
We are aware of possible conversion mismatches between keyboard keycode to swfdec keycode, but we think the problem is not related to it. The 'cursor left' keycode is converted to 37 which corresponds to SWFDEC_KEY_LEFT, and this keycode value is forwarded to swfdec_player_key_press().
It seems there is no valid keyboard focus. In swfdec_player_do_handle_key(), there is a keypress operation executed dependent on a pointer in priv->focus, a pointer which is said do represent the keyboard focus. Although priv->has_focus is set to 'true' in swfdec_player_init(), priv->focus always remains NULL, because neither swfdec_player_set_focus() nor swfdec_player_update_focus() is invoked. The result is that klass->key_press() is not called. This is possibly the reason for the failure of processing key events ('possibly', because I could not check the right behavior). Can anyone more familiar with swfdec confirm this conclusion? Does anyone know a proper fix for it?
Interesting. I just make sure that Swfdec (both 0.8.2 and 0.9.2) handle keyboard fine by playing the tennis game. So it looks like it's an internal issue. There's roughly infinite ways to deliver key events in Flash, among them: - Key.onKeyDown and Key.onKeyUp - MovieClip.onKeyDown and MovieClip.onKeyUp - onPress(key) events defined in the flash file - built-in keyboard handlers, like the TextField object Some of these events are triggered all the time, some are only delivered to the movieclip that has keyboard focus and then keypress delivery is probably also restricted by the security system. It seems that you've found a case that we do wrong: Delivery of onPress() events. The other stuff should still work fine.
It turned out to be that this problem is only occuring when using OnClipEvents(keyDown). If AddListener() is used, it works fine.
Created attachment 23130 [details] [review] patch to fix key event handling fixed hanlding key event onClipEvent(keyDown) and on(keyPress, keycode). I't would be great if anyone like to have a test. --zou
The above patch only applys to git-head. But the same logic should also work for 0.8.2. --zou
Created attachment 23173 [details] [review] patch updated. patch updated, to handle both onClipEvent(keyDown/keyUp) and on(keyPress, keyCode). onClipEvent(keyUp) was not handled in last patch and git-head. --zou
Changed the title of this bug item, since it's not only 0.8.2 specific. Again, it would be nice if any one could do some tests with some little swfs that didn't work before. --zou
OK, tested myself, the patch to swfdec_player.c is NOT correct. The SWFDEC_EVENT_KEY_DOWN/UP event shouldn't be queued unconditionally. otherwise, each event handler might be triggered twice due to later swfdec_player_broadcast(). The problem is that for swf actors, there are two types of keyDown/up event handlers. One is defined in PlaceObject2 tags(built-in handlers), with actions like onClipEvent(keyDown); the other is defined in normal actionscript blocks, with actions like actor.onKeyDown = function () {}; Key.addListener(actor). As far as I can, there is more work to handle this situation correctly without changing the current interfaces. --zou
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.