> int > key_as_object::get_last_key_pressed() const > { > - return m_last_key_pressed; > + return m_last_key_event; > }
what about renaming "get_last_key_pressed" to "get_last_key"? It could be last pressed and last released, right? > + * server/asobj/Key.{cpp,h}: rename m_last_key_pressed to > + m_last_key_event. Add SWF keycode, not gnash keycode to > + index of keys down. Fixes problems when releasing shift > + before a character key. I tried your testcase attached bug#21272. it is convincing enough, just that the behaviour is version dependent. For SWF6 and SWF7, the behaviour is like what you described(did a quick check). For SWF8, the old gnash code should be more correct, key release event won't update the 'last key'. Please make a double check. We need to be compatible with higher versions. BTW, for easier hack, uncompressed swf file is preferred:) "makeswf -c -1 xx.as" could produce an uncompressed file. --zou On 10/9/07, Benjamin Wolsey <[EMAIL PROTECTED]> wrote: > CVSROOT: /sources/gnash > Module name: gnash > Changes by: Benjamin Wolsey <bwy> 07/10/09 12:48:44 > > Modified files: > . : ChangeLog > server/asobj : Key.cpp Key.h > > Log message: > * server/asobj/Key.{cpp,h}: rename m_last_key_pressed to > m_last_key_event. Add SWF keycode, not gnash keycode to > index of keys down. Fixes problems when releasing shift > before a character key. > > CVSWeb URLs: > http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4575&r2=1.4576 > http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.36&r2=1.37 > http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&r1=1.26&r2=1.27 > > Patches: > Index: ChangeLog > =================================================================== > RCS file: /sources/gnash/gnash/ChangeLog,v > retrieving revision 1.4575 > retrieving revision 1.4576 > diff -u -b -r1.4575 -r1.4576 > --- ChangeLog 9 Oct 2007 11:19:38 -0000 1.4575 > +++ ChangeLog 9 Oct 2007 12:48:43 -0000 1.4576 > @@ -1,3 +1,10 @@ > +2007-10-09 Benjamin Wolsey <[EMAIL PROTECTED]> > + > + * server/asobj/Key.{cpp,h}: rename m_last_key_pressed to > + m_last_key_event. Add SWF keycode, not gnash keycode to > + index of keys down. Fixes problems when releasing shift > + before a character key. > + > 2007-10-09 Chad Musick <[EMAIL PROTECTED]> > > * server/AS3_OPCODES: Remove file (information up-to-date elsewhere). > > Index: server/asobj/Key.cpp > =================================================================== > RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v > retrieving revision 1.36 > retrieving revision 1.37 > diff -u -b -r1.36 -r1.37 > --- server/asobj/Key.cpp 8 Oct 2007 12:56:27 -0000 1.36 > +++ server/asobj/Key.cpp 9 Oct 2007 12:48:43 -0000 1.37 > @@ -45,7 +45,7 @@ > key_as_object::key_as_object() > : > as_object(getObjectInterface()), > - m_last_key_pressed(0) > + m_last_key_event(0) > { > memset(m_unreleased_keys, 0, sizeof(m_unreleased_keys)); > } > @@ -77,10 +77,15 @@ > { > if (code < 0 || code >= key::KEYCOUNT) return; > > - m_last_key_pressed = code; > + // This is used for getAscii() of the last key event, so we use gnash's > + // internal code. > + m_last_key_event = code; > > - int byte_index = code >> 3; > - int bit_index = code - (byte_index << 3); > + // Key.isDown() only cares about flash keycode, not character, so > + // we lookup keycode to add to m_unreleased_keys. > + > + int byte_index = key::codeMap[code][1] >> 3; > + int bit_index = key::codeMap[code][1] - (byte_index << 3); > int mask = 1 << bit_index; > > assert(byte_index >= 0 && byte_index < > int(sizeof(m_unreleased_keys)/sizeof(m_unreleased_keys[0]))); > @@ -93,10 +98,14 @@ > { > if (code < 0 || code >= key::KEYCOUNT) return; > > - m_last_key_pressed = code; > - > - int byte_index = code >> 3; > - int bit_index = code - (byte_index << 3); > + // This is used for getAscii() of the last key event, so we use gnash's > + // internal code. > + m_last_key_event = code; > + > + // Key.isDown() only cares about flash keycode, not character, so > + // we lookup keycode to add to m_unreleased_keys. > + int byte_index = key::codeMap[code][1] >> 3; > + int bit_index = key::codeMap[code][1] - (byte_index << 3); > int mask = 1 << bit_index; > > assert(byte_index >= 0 && byte_index < > int(sizeof(m_unreleased_keys)/sizeof(m_unreleased_keys[0]))); > @@ -198,7 +207,7 @@ > int > key_as_object::get_last_key_pressed() const > { > - return m_last_key_pressed; > + return m_last_key_event; > } > > > > Index: server/asobj/Key.h > =================================================================== > RCS file: /sources/gnash/gnash/server/asobj/Key.h,v > retrieving revision 1.26 > retrieving revision 1.27 > diff -u -b -r1.26 -r1.27 > --- server/asobj/Key.h 12 Sep 2007 10:57:06 -0000 1.26 > +++ server/asobj/Key.h 9 Oct 2007 12:48:44 -0000 1.27 > @@ -16,7 +16,7 @@ > // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > // > > -/* $Id: Key.h,v 1.26 2007/09/12 10:57:06 bwy Exp $ */ > +/* $Id: Key.h,v 1.27 2007/10/09 12:48:44 bwy Exp $ */ > > #ifndef __KEY_H__ > #define __KEY_H__ > @@ -62,7 +62,7 @@ > Listeners m_listeners; > #endif > > - int m_last_key_pressed; > + int m_last_key_event; > > protected: > > > > _______________________________________________ > Gnash-commit mailing list > Gnash-commit@gnu.org > http://lists.gnu.org/mailman/listinfo/gnash-commit > _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit