Fixed keycode remapper

This commit is contained in:
pelya
2010-12-10 17:02:45 +00:00
parent 658bec6205
commit 22f21566a7
2 changed files with 10 additions and 5 deletions

View File

@@ -496,7 +496,7 @@ class SDL_Keys
public static String [] names = null; public static String [] names = null;
public static Integer [] values = null; public static Integer [] values = null;
static final JAVA_KEYCODE_LAST = android.view.KeyEvent.KEYCODE_MUTE; // = 91 static final int JAVA_KEYCODE_LAST = android.view.KeyEvent.KEYCODE_MUTE; // = 91
static static
{ {

View File

@@ -62,7 +62,7 @@ class Settings
out.writeInt(SDL_Keys.JAVA_KEYCODE_LAST); out.writeInt(SDL_Keys.JAVA_KEYCODE_LAST);
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
{ {
out.writeInt(RemapHwKeycode[i]); out.writeInt(Globals.RemapHwKeycode[i]);
} }
out.close(); out.close();
@@ -83,7 +83,12 @@ class Settings
nativeInitKeymap(); nativeInitKeymap();
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
{ {
RemapHwKeycode[i] = nativeGetKeymapKey(i); int sdlKey = nativeGetKeymapKey(i);
int idx = 0;
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
if(SDL_Keys.values[ii] == sdlKey)
idx = ii;
Globals.RemapHwKeycode[i] = idx;
} }
try { try {
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName )); ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
@@ -115,7 +120,7 @@ class Settings
throw new IOException(); throw new IOException();
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
{ {
RemapHwKeycode[i] = settingsFile.readInt(); Globals.RemapHwKeycode[i] = settingsFile.readInt();
} }
settingsLoaded = true; settingsLoaded = true;
@@ -921,7 +926,7 @@ class Settings
SetupTouchscreenKeyboardGraphics(p); SetupTouchscreenKeyboardGraphics(p);
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
{ {
nativeSetKeymapKey(i, RemapHwKeycode[i]); nativeSetKeymapKey(i, SDL_Keys.values[Globals.RemapHwKeycode[i]]);
} }
String lang = new String(Locale.getDefault().getLanguage()); String lang = new String(Locale.getDefault().getLanguage());