On Sat, Sep 4, 2010 at 12:24 AM, Mikko Vartiainen <mvartiai...@gmail.com> wrote:
> I made another approach to this problem, see attached patch.

Sorry the patch was bad. This new patch should be against the latest svn.
Index: data/wormux_default_maemo_config.xml
===================================================================
--- data/wormux_default_maemo_config.xml	(revision 8351)
+++ data/wormux_default_maemo_config.xml	(working copy)
@@ -12,10 +12,8 @@
   <bind key="right" action="move_right" />
   <bind key="right" action="move_right_slowly" shift="true" />
   <bind key="up" action="up" />
-  <bind key="left" action="up" alt="true" />
   <bind key="up" action="up_slowly" shift="true" />
   <bind key="down" action="down" />
-  <bind key="right" action="down" alt="true" />
   <bind key="down" action="down_slowly" shift="true" />
   <bind key="left" action="move_camera_left" control="true" />
   <bind key="right" action="move_camera_right" control="true" />
Index: src/gui/control_config.cpp
===================================================================
--- src/gui/control_config.cpp	(revision 8351)
+++ src/gui/control_config.cpp	(working copy)
@@ -100,21 +100,23 @@
 
   virtual bool SendKey(const SDL_keysym & key)
   {
-    if (read_only || key.sym == SDLK_UNKNOWN)
+    SDLKey key_code = key.sym;
+
+    if (read_only || key_code == SDLK_UNKNOWN)
       return false;
 
     // Ignore modifiers-only key presses
-    if (key.sym >= SDLK_NUMLOCK && key.sym <= SDLK_COMPOSE)
+    if (key_code >= SDLK_NUMLOCK && key_code <= SDLK_COMPOSE)
       return true;
 
     Keyboard *kbd = Keyboard::GetInstance();
 
     // Reset some configs
-    if (SDLK_BACKSPACE == key.sym ||
+    if (SDLK_BACKSPACE == key_code ||
 #ifdef ANDROID
-        SDLK_ESCAPE == key.sym ||
+        SDLK_ESCAPE == key_code ||
 #endif
-        SDLK_DELETE == key.sym) {
+        SDLK_DELETE == key_code) {
       kbd->ClearKeyAction(key_action);
       label_key->SetText(_("None"));
       ctrl_box->SetValue(false);
@@ -131,13 +133,21 @@
     bool has_shift = mod_bits & KMOD_SHIFT;
     bool has_alt = mod_bits & KMOD_ALT;
     bool has_ctrl = mod_bits & KMOD_CTRL;
+#ifdef MAEMO
+    bool has_mode = mod_bits & KMOD_MODE;
 
+    if (has_mode) {
+      if (key_code == SDLK_LEFT) key_code = SDLK_UP;
+      if (key_code == SDLK_RIGHT) key_code = SDLK_DOWN;
+    }
+#endif
+
     for (std::vector<ControlItem*>::const_iterator it = selves->begin();
          it != selves->end();
          ++it) {
       const ControlItem *c = (*it);
 
-      if (c!=this && c->key_value==key.sym
+      if (c!=this && c->key_value==key_code
           && has_ctrl  == c->ctrl_box->GetValue()
           && has_alt   == c->alt_box->GetValue()
           && has_shift == c->shift_box->GetValue()) {
@@ -153,7 +163,7 @@
       }
     }
 
-    key_value = key.sym;
+    key_value = key_code;
     label_key->SetText(kbd->GetKeyNameFromKey(key_value));
 
     ctrl_box->SetValue(has_ctrl);
Index: src/interface/keyboard.cpp
===================================================================
--- src/interface/keyboard.cpp	(revision 8351)
+++ src/interface/keyboard.cpp	(working copy)
@@ -37,10 +37,6 @@
 #  define SDLK_LAST  SDL_NUM_SCANCODES
 #endif
 
-#ifdef MAEMO
-#  undef KMOD_ALT
-#  define KMOD_ALT KMOD_MODE
-#endif
 
 int  Keyboard::GetRawKeyCode(int key_code) const
 {
@@ -104,10 +100,6 @@
 void Keyboard::SetDefaultConfig()
 {
   SetKeyAction(SDLK_ESCAPE, ManMachineInterface::KEY_QUIT);
-#ifdef MAEMO
-  SaveKeyEvent(ManMachineInterface::KEY_UP, SDLK_LEFT, false, true, false);
-  SaveKeyEvent(ManMachineInterface::KEY_DOWN, SDLK_RIGHT, false, true, false);
-#endif
 }
 
 void Keyboard::SetConfig(const xmlNode *node)
@@ -293,6 +285,12 @@
   SDLKey basic_key_code = event.key.keysym.sym;
   if (basic_key_code >= MODIFIER_OFFSET)
     return;
+#ifdef MAEMO
+  if (SDL_GetModState() & KMOD_MODE) {
+    if (basic_key_code == SDLK_LEFT) basic_key_code = SDLK_UP;
+    if (basic_key_code == SDLK_RIGHT) basic_key_code = SDLK_DOWN;
+  }
+#endif
   int key_code;
   if (modifier_bits != previous_modifier_bits) {
     std::set<SDLKey>::iterator it;
Index: src/interface/man_machine_interface.cpp
===================================================================
--- src/interface/man_machine_interface.cpp	(revision 8351)
+++ src/interface/man_machine_interface.cpp	(working copy)
@@ -40,10 +40,6 @@
 #include "sound/jukebox.h"
 #include "weapon/weapons_list.h"
 
-#ifdef MAEMO
-#  undef SDLK_RALT
-#  define SDLK_RALT SDLK_MODE
-#endif
 
 void ManMachineInterface::Reset()
 {
@@ -755,11 +751,7 @@
   if(name == "lshift") return SDLK_LSHIFT;
   if(name == "rctrl") return SDLK_RCTRL;
   if(name == "lctrl") return SDLK_LCTRL;
-#ifdef MAEMO
-  if(name == "ralt") return SDLK_MODE;
-#else
   if(name == "ralt") return SDLK_RALT;
-#endif
   if(name == "lalt") return SDLK_LALT;
   if(name == "rmeta") return SDLK_RMETA;
   if(name == "lmeta") return SDLK_LMETA;
@@ -1016,11 +1008,7 @@
   if(key == SDLK_LSHIFT) return "lshift";
   if(key == SDLK_RCTRL) return "rctrl";
   if(key == SDLK_LCTRL) return "lctrl";
-#ifdef MAEMO
-  if(key == SDLK_MODE) return "ralt";
-#else
   if(key == SDLK_RALT) return "ralt";
-#endif
   if(key == SDLK_LALT) return "lalt";
   if(key == SDLK_RMETA) return "rmeta";
   if(key == SDLK_LMETA) return "lmeta";
_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à