Skip to content

Commit

Permalink
Introduce a new Siemens layout, and update Canvas game action code
Browse files Browse the repository at this point in the history
This should make the siemens jar UX a bit better, though there are
still some that will get stuck on the lcdui menu, maybe because
lcdui is still missing commands.
  • Loading branch information
AShiningRay committed Nov 18, 2024
1 parent 6029d56 commit 711ad0c
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 41 deletions.
42 changes: 11 additions & 31 deletions src/javax/microedition/lcdui/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,7 @@ protected Canvas()
platformImage = new PlatformImage(width, height);
}

public int getGameAction(int keyCode)
{
switch(keyCode)
{
case Mobile.KEY_NUM2: return UP;
case Mobile.KEY_NUM8: return DOWN;
case Mobile.KEY_NUM4: return LEFT;
case Mobile.KEY_NUM6: return RIGHT;
case Mobile.KEY_NUM5: return FIRE;
case Mobile.KEY_NUM1: return GAME_A;
case Mobile.KEY_NUM3: return GAME_B;
case Mobile.KEY_NUM7: return GAME_C;
case Mobile.KEY_NUM9: return GAME_D;
case Mobile.NOKIA_UP: return UP;
case Mobile.NOKIA_DOWN: return DOWN;
case Mobile.NOKIA_LEFT: return LEFT;
case Mobile.NOKIA_RIGHT: return RIGHT;
case Mobile.NOKIA_SOFT3: return FIRE;
}
return 0;
}
public int getGameAction(int keyCode) { return Mobile.getGameAction(keyCode); }

public int getKeyCode(int gameAction)
{
Expand All @@ -88,17 +68,17 @@ public int getKeyCode(int gameAction)
//case Mobile.GAME_LEFT: return Mobile.KEY_NUM4;
//case Mobile.GAME_RIGHT: return Mobile.KEY_NUM6;
//case Mobile.GAME_FIRE: return Mobile.KEY_NUM5;
case Mobile.GAME_UP: return Mobile.NOKIA_UP;
case Mobile.GAME_DOWN: return Mobile.NOKIA_DOWN;
case Mobile.GAME_LEFT: return Mobile.NOKIA_LEFT;
case Mobile.GAME_RIGHT: return Mobile.NOKIA_RIGHT;
case Mobile.GAME_FIRE: return Mobile.NOKIA_SOFT3;
case Mobile.GAME_A: return Mobile.KEY_NUM1;
case Mobile.GAME_B: return Mobile.KEY_NUM3;
case Mobile.GAME_C: return Mobile.KEY_NUM7;
case Mobile.GAME_D: return Mobile.KEY_NUM9;
case Mobile.GAME_UP: return Mobile.getMobileKey(0, true);
case Mobile.GAME_DOWN: return Mobile.getMobileKey(1, true);
case Mobile.GAME_LEFT: return Mobile.getMobileKey(2, true);
case Mobile.GAME_RIGHT: return Mobile.getMobileKey(3, true);
case Mobile.GAME_FIRE: return Mobile.getMobileKey(7, true);
case Mobile.GAME_A: return Mobile.getMobileKey(10, true);
case Mobile.GAME_B: return Mobile.getMobileKey(11, true);
case Mobile.GAME_C: return Mobile.getMobileKey(5, true);
case Mobile.GAME_D: return Mobile.getMobileKey(4, true);
}
return Mobile.NOKIA_SOFT3;
return 0;
}

public String getKeyName(int keyCode)
Expand Down
1 change: 1 addition & 0 deletions src/libretro/freej2me_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ static void check_variables(bool first_time_startup)
else if (!strcmp(var.value, "Nokia Keyboard")) { phoneType = 6; }
else if (!strcmp(var.value, "Sagem")) { phoneType = 7; }
else if (!strcmp(var.value, "Siemens")) { phoneType = 8; }
else if (!strcmp(var.value, "Siemens Old")) { phoneType = 9; }
}


Expand Down
4 changes: 3 additions & 1 deletion src/libretro/freej2me_libretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct retro_core_option_v2_definition core_options[] =
{ "Nokia Keyboard", NULL },
{ "Sagem", NULL },
{ "Siemens", NULL },
{ "Siemens Old", NULL },
{ NULL, NULL },
},
"J2ME Standard"
Expand Down Expand Up @@ -434,6 +435,7 @@ struct retro_core_option_definition core_options_v1 [] =
{ "Nokia Keyboard", NULL },
{ "Sagem", NULL },
{ "Siemens", NULL },
{ "Siemens Old", NULL },
{ NULL, NULL },
},
"J2ME Standard"
Expand Down Expand Up @@ -617,7 +619,7 @@ static const struct retro_variable vars[] =
},
{ /* Phone Control Type */
"freej2me_phone",
"Phone Key Layout; J2ME Standard|LG|Motorola/SoftBank|Motorola Triplets|Motorola V8|Nokia/Sony/Samsung|Nokia Keyboard|Sagem|Siemens"
"Phone Key Layout; J2ME Standard|LG|Motorola/SoftBank|Motorola Triplets|Motorola V8|Nokia/Sony/Samsung|Nokia Keyboard|Sagem|Siemens|Siemens Old"
},
{ /* Game FPS limit */
"freej2me_fps",
Expand Down
34 changes: 34 additions & 0 deletions src/org/recompile/freej2me/AWTGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public final class AWTGUI
final CheckboxMenuItem nokiaKbLayout = new CheckboxMenuItem("Nokia Keyboard", false);
final CheckboxMenuItem sagemLayout = new CheckboxMenuItem("Sagem", false);
final CheckboxMenuItem siemensLayout = new CheckboxMenuItem("Siemens", false);
final CheckboxMenuItem siemensOldLayout = new CheckboxMenuItem("Siemens Old", false);

final CheckboxMenuItem fpsCapNone = new CheckboxMenuItem("No Limit", true);
final CheckboxMenuItem fpsCap60 = new CheckboxMenuItem("60 FPS", false);
Expand Down Expand Up @@ -447,6 +448,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -468,6 +470,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -489,6 +492,7 @@ public void itemStateChanged(ItemEvent e)
nokiaLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -510,6 +514,7 @@ public void itemStateChanged(ItemEvent e)
nokiaLayout.setState(false);
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -531,6 +536,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -552,6 +558,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -573,6 +580,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -594,6 +602,7 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
sagemLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
Expand All @@ -615,6 +624,29 @@ public void itemStateChanged(ItemEvent e)
nokiaKbLayout.setState(false);
tripletsLayout.setState(false);
siemensLayout.setState(false);
siemensOldLayout.setState(false);
hasPendingChange = true;
}
}
});

siemensOldLayout.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(!siemensOldLayout.getState()){ siemensOldLayout.setState(true); }
if(siemensOldLayout.getState())
{
config.updatePhone("SiemensOld");
stdLayout.setState(false);
lgLayout.setState(false);
motov8Layout.setState(false);
motorolaLayout.setState(false);
nokiaLayout.setState(false);
nokiaKbLayout.setState(false);
tripletsLayout.setState(false);
siemensLayout.setState(false);
sagemLayout.setState(false);
hasPendingChange = true;
}
}
Expand Down Expand Up @@ -853,6 +885,7 @@ private void buildMenuBar()
phoneType.add(nokiaKbLayout);
phoneType.add(sagemLayout);
phoneType.add(siemensLayout);
phoneType.add(siemensOldLayout);

fpsCap.add(fpsCapNone);
fpsCap.add(fpsCap60);
Expand Down Expand Up @@ -880,6 +913,7 @@ public void updateOptions()
stdLayout.setState(config.settings.get("phone").equals("Standard"));
nokiaLayout.setState(config.settings.get("phone").equals("Nokia"));
siemensLayout.setState(config.settings.get("phone").equals("Siemens"));
siemensOldLayout.setState(config.settings.get("phone").equals("SiemensOld"));
motov8Layout.setState(config.settings.get("phone").equals("MotoV8"));
tripletsLayout.setState(config.settings.get("phone").equals("MotoTriplets"));
sagemLayout.setState(config.settings.get("phone").equals("Sagem"));
Expand Down
2 changes: 2 additions & 0 deletions src/org/recompile/freej2me/FreeJ2ME.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ private void settingsChanged()
Mobile.nokiaKeyboard = false;
Mobile.sagem = false;
Mobile.siemens = false;
Mobile.siemensold = false;
if(phone.equals("LG")) { Mobile.lg = true;}
if(phone.equals("Motorola")) { Mobile.motorola = true;}
if(phone.equals("MotoTriplets")) { Mobile.motoTriplets = true;}
Expand All @@ -379,6 +380,7 @@ private void settingsChanged()
if(phone.equals("NokiaKeyboard")) { Mobile.nokiaKeyboard = true;}
if(phone.equals("Sagem")) { Mobile.sagem = true;}
if(phone.equals("Siemens")) { Mobile.siemens = true;}
if(phone.equals("SiemensOld")) { Mobile.siemensold = true;}

String rotate = config.settings.get("rotate");
if(rotate.equals("on")) { rotateDisplay = true; }
Expand Down
25 changes: 16 additions & 9 deletions src/org/recompile/freej2me/Libretro.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ public Libretro(String args[])

if(Integer.parseInt(args[2]) == 1) { rotateDisplay = true; }

if(Integer.parseInt(args[3]) == 1) { Mobile.lg = true; }
else if(Integer.parseInt(args[3]) == 2) { Mobile.motorola = true; }
else if(Integer.parseInt(args[3]) == 3) { Mobile.motoTriplets = true; }
else if(Integer.parseInt(args[3]) == 4) { Mobile.motoV8 = true; }
else if(Integer.parseInt(args[3]) == 5) { Mobile.nokia = true; }
else if(Integer.parseInt(args[3]) == 6) { Mobile.nokiaKeyboard = true; }
else if(Integer.parseInt(args[3]) == 7) { Mobile.sagem = true; }
else if(Integer.parseInt(args[3]) == 8) { Mobile.siemens = true; }

Mobile.lg = false;
Mobile.motorola = false;
Mobile.motoTriplets = false;
Expand All @@ -117,6 +108,17 @@ public Libretro(String args[])
Mobile.nokiaKeyboard = false;
Mobile.sagem = false;
Mobile.siemens = false;
Mobile.siemensold = false;

if(Integer.parseInt(args[3]) == 1) { Mobile.lg = true; }
else if(Integer.parseInt(args[3]) == 2) { Mobile.motorola = true; }
else if(Integer.parseInt(args[3]) == 3) { Mobile.motoTriplets = true; }
else if(Integer.parseInt(args[3]) == 4) { Mobile.motoV8 = true; }
else if(Integer.parseInt(args[3]) == 5) { Mobile.nokia = true; }
else if(Integer.parseInt(args[3]) == 6) { Mobile.nokiaKeyboard = true; }
else if(Integer.parseInt(args[3]) == 7) { Mobile.sagem = true; }
else if(Integer.parseInt(args[3]) == 8) { Mobile.siemens = true; }
else if(Integer.parseInt(args[3]) == 9) { Mobile.siemensold = true; }

Mobile.limitFPS = Integer.parseInt(args[4]);

Expand Down Expand Up @@ -287,6 +289,7 @@ public void run()
else if(Mobile.nokiaKeyboard) { config.settings.put("phone", "NokiaKeyboard"); }
else if(Mobile.sagem) { config.settings.put("phone", "Sagem"); }
else if(Mobile.siemens) { config.settings.put("phone", "Siemens"); }
else if(Mobile.siemensold) { config.settings.put("phone", "SiemensOld"); }
else { config.settings.put("phone", "Standard"); }

if(soundEnabled) { config.settings.put("sound", "on"); }
Expand Down Expand Up @@ -354,6 +357,7 @@ public void run()
if(Integer.parseInt(cfgtokens[4])==6) { config.settings.put("phone", "NokiaKeyboard"); }
if(Integer.parseInt(cfgtokens[4])==7) { config.settings.put("phone", "Sagem"); }
if(Integer.parseInt(cfgtokens[4])==8) { config.settings.put("phone", "Siemens"); }
if(Integer.parseInt(cfgtokens[4])==9) { config.settings.put("phone", "SiemensOld"); }

config.settings.put("fps", ""+cfgtokens[5]);

Expand Down Expand Up @@ -444,6 +448,7 @@ private void settingsChanged()
Mobile.nokiaKeyboard = false;
Mobile.sagem = false;
Mobile.siemens = false;
Mobile.siemensold = false;
if(phone.equals("LG")) { Mobile.lg = true;}
if(phone.equals("Motorola")) { Mobile.motorola = true;}
if(phone.equals("MotoTriplets")) { Mobile.motoTriplets = true;}
Expand All @@ -452,6 +457,8 @@ private void settingsChanged()
if(phone.equals("NokiaKeyboard")) { Mobile.nokiaKeyboard = true;}
if(phone.equals("Sagem")) { Mobile.sagem = true;}
if(phone.equals("Siemens")) { Mobile.siemens = true;}
if(phone.equals("SiemensOld")) { Mobile.siemensold = true;}


String rotate = config.settings.get("rotate");
if(rotate.equals("on")) { rotateDisplay = true; frameHeader[5] = (byte)1; }
Expand Down
Loading

0 comments on commit 711ad0c

Please sign in to comment.