[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/sdl.cpp gui/sdlsup.h server...
From: |
Zou Lunkai |
Subject: |
[Gnash-commit] gnash ChangeLog gui/sdl.cpp gui/sdlsup.h server... |
Date: |
Tue, 25 Sep 2007 08:53:55 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Zou Lunkai <zoulunkai> 07/09/25 08:53:54
Modified files:
. : ChangeLog
gui : sdl.cpp sdlsup.h
server : button_character_instance.cpp
Log message:
* gui/sdl.cpp, gui/sdlsup.h: add sdl_to_gnash_key() and
sdl_to_gnash_modifier(),
cleanups.
* server/button_character_instance.cpp: on_event() don't respond to
keypress event
when keycode is 0(INVALID).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4398&r2=1.4399
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl.cpp?cvsroot=gnash&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdlsup.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.59&r2=1.60
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4398
retrieving revision 1.4399
diff -u -b -r1.4398 -r1.4399
--- ChangeLog 25 Sep 2007 06:08:20 -0000 1.4398
+++ ChangeLog 25 Sep 2007 08:53:54 -0000 1.4399
@@ -8,6 +8,13 @@
2007-09-25 Zou Lunkai <address@hidden>
+ * gui/sdl.cpp, gui/sdlsup.h: add sdl_to_gnash_key() and
sdl_to_gnash_modifier(),
+ cleanups.
+ * server/button_character_instance.cpp: on_event() don't respond to
keypress event
+ when keycode is 0(INVALID).
+
+2007-09-25 Zou Lunkai <address@hidden>
+
* testsuite/misc-ming.all/registerClassTest2.c: one more test.
* testsuite/misc-swfc.all/register_class_test3.sc, Makefile.am: one
more testcase.
all passed.
Index: gui/sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/sdl.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- gui/sdl.cpp 1 Jul 2007 10:54:04 -0000 1.59
+++ gui/sdl.cpp 25 Sep 2007 08:53:54 -0000 1.60
@@ -18,7 +18,7 @@
//
//
-/* $Id: sdl.cpp,v 1.59 2007/07/01 10:54:04 bjacques Exp $ */
+/* $Id: sdl.cpp,v 1.60 2007/09/25 08:53:54 zoulunkai Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -113,13 +113,12 @@
{
return true;
}
- key_event(event.key.keysym.sym, true);
+ key_event(&event.key, true);
break;
}
case SDL_KEYUP:
{
- SDLKey key = event.key.keysym.sym;
- key_event(key, false);
+ key_event(&event.key, false);
break;
}
case SDL_VIDEORESIZE:
@@ -256,52 +255,69 @@
return false;
}
-void SDLGui::key_event(SDLKey key, bool down)
-// For forwarding SDL key events.
+key::code
+SDLGui::sdl_to_gnash_key(SDL_KeyboardEvent * key)
{
gnash::key::code c(gnash::key::INVALID);
- if (key >= SDLK_0 && key <= SDLK_9) {
- c = (gnash::key::code) ((key - SDLK_0) + gnash::key::_0);
- } else if (key >= SDLK_a && key <= SDLK_z) {
- c = (gnash::key::code) ((key - SDLK_a) + gnash::key::A);
- } else if (key >= SDLK_F1 && key <= SDLK_F15) {
- c = (gnash::key::code) ((key - SDLK_F1) + gnash::key::F1);
- } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
- c = (gnash::key::code) ((key - SDLK_KP0) + gnash::key::KP_0);
- } else {
- // many keys don't correlate, so just use a look-up table.
- struct {
- SDLKey sdlk;
- gnash::key::code gs;
- } table[] = {
- { SDLK_SPACE, gnash::key::SPACE },
- { SDLK_PAGEDOWN, gnash::key::PGDN },
- { SDLK_PAGEUP, gnash::key::PGUP },
- { SDLK_HOME, gnash::key::HOME },
- { SDLK_END, gnash::key::END },
- { SDLK_INSERT, gnash::key::INSERT },
- { SDLK_DELETE, gnash::key::DELETEKEY },
- { SDLK_BACKSPACE, gnash::key::BACKSPACE },
- { SDLK_TAB, gnash::key::TAB },
- { SDLK_RETURN, gnash::key::ENTER },
- { SDLK_ESCAPE, gnash::key::ESCAPE },
- { SDLK_LEFT, gnash::key::LEFT },
- { SDLK_UP, gnash::key::UP },
- { SDLK_RIGHT, gnash::key::RIGHT },
- { SDLK_DOWN, gnash::key::DOWN },
- // @@ TODO fill this out some more
- { SDLK_UNKNOWN, gnash::key::INVALID }
- };
-
- for (int i = 0; table[i].sdlk != SDLK_UNKNOWN; i++) {
- if (key == table[i].sdlk) {
- c = table[i].gs;
- break;
+ // TODO: take care of CAPS_LOCK and NUM_LOCK and SHIFT
+ // int mod = key->keysym.mod;
+ int code = key->keysym.sym;
+
+ if(code>= 32 && code <= 127) {
+ c = (gnash::key::code)(code);
+ }else if(code >= SDLK_KP0 && code <= SDLK_KP9) {
+ c = (gnash::key::code)(code - SDLK_KP0 + gnash::key::KP_0);
+ }else if(code >= SDLK_F1 && code <= SDLK_F15) {
+ c = (gnash::key::code)(code - SDLK_F1 + gnash::key::F1);
+ }else
+ {
+ switch(code) {
+ case SDLK_UP: c = gnash::key::UP; break;
+ case SDLK_DOWN: c = gnash::key::DOWN; break;
+ case SDLK_RIGHT: c = gnash::key::RIGHT; break;
+ case SDLK_LEFT: c = gnash::key::LEFT; break;
+ case SDLK_INSERT: c = gnash::key::INSERT; break;
+ case SDLK_HOME: c = gnash::key::HOME; break;
+ case SDLK_END: c = gnash::key::END; break;
+ case SDLK_PAGEUP: c = gnash::key::PGUP; break;
+ case SDLK_PAGEDOWN: c = gnash::key::PGDN; break;
+ case SDLK_RSHIFT:
+ case SDLK_LSHIFT: c = gnash::key::SHIFT; break;
+ case SDLK_RCTRL:
+ case SDLK_LCTRL: c = gnash::key::CONTROL; break;
+ case SDLK_RALT:
+ case SDLK_LALT: c = gnash::key::ALT; break;
+ default: c = gnash::key::INVALID; break;
+ }
+ }
+
+ return c;
+}
+
+int
+SDLGui::sdl_to_gnash_modifier(int state)
+{
+ int modifier = gnash::key::MOD_NONE;
+
+ if (state & KMOD_SHIFT) {
+ modifier = modifier | gnash::key::MOD_SHIFT;
}
+ if (state & KMOD_CTRL) {
+ modifier = modifier | gnash::key::MOD_CONTROL;
}
+ if (state & KMOD_ALT) {
+ modifier = modifier | gnash::key::MOD_ALT;
}
+ return modifier;
+}
+
+void SDLGui::key_event(SDL_KeyboardEvent* key, bool down)
+// For forwarding SDL key events.
+{
+ gnash::key::code c = sdl_to_gnash_key(key);
+
if (c != gnash::key::INVALID) {
// 0 should be any modifier instead..
// see Gui::notify_key_event in gui.h
Index: gui/sdlsup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/sdlsup.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- gui/sdlsup.h 1 Jul 2007 10:54:05 -0000 1.22
+++ gui/sdlsup.h 25 Sep 2007 08:53:54 -0000 1.23
@@ -18,7 +18,7 @@
//
//
-/* $Id: sdlsup.h,v 1.22 2007/07/01 10:54:05 bjacques Exp $ */
+/* $Id: sdlsup.h,v 1.23 2007/09/25 08:53:54 zoulunkai Exp $ */
#ifndef __SDLSUP_H__
#define __SDLSUP_H__
@@ -64,7 +64,7 @@
virtual void disableCoreTrap();
virtual void setTimeout(unsigned int timeout);
- void key_event(SDLKey key, bool down);
+ void key_event(SDL_KeyboardEvent * key, bool down);
private:
unsigned int _timeout;
@@ -76,6 +76,9 @@
/// Handle VIDEOEXPOSE event
void expose_event();
+ static key::code sdl_to_gnash_key(SDL_KeyboardEvent* key);
+ static int sdl_to_gnash_modifier(int state);
+
#ifdef RENDERER_AGG
SdlAggGlue _glue;
#elif defined(RENDERER_CAIRO)
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- server/button_character_instance.cpp 21 Sep 2007 08:29:01 -0000
1.59
+++ server/button_character_instance.cpp 25 Sep 2007 08:53:54 -0000
1.60
@@ -327,6 +327,12 @@
button_character_instance::on_event(const event_id& id)
{
+ if( (id.m_id==event_id::KEY_PRESS) && (id.m_key_code == key::INVALID) )
+ {
+ // onKeypress only responds to valid key code
+ return false;
+ }
+
bool called = false;
// Add appropriate actions to the global action list ...
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog gui/sdl.cpp gui/sdlsup.h server...,
Zou Lunkai <=