Is there a quick way, or existing code that converts an input key from awt to slick?
How do we use that?
Here is my code, buggy:
private int convertValue(int value)
{
switch(value)
{
case '\n': return 0x1C;
case '\b': return 0x0E;
case '\t': return 0x0F;
case 0x10: return 0x2A;
case 0x11: return 0x1D;
case 0x12: return 0x38;
case 0x13: return 0xC5;
case 0x14: return 0x3A;
case 0x1B: return 0x01;
case 0x20: return 0x39;
case 0x21: return 0xC9;
case 0x22: return 0xD1;
case 0x23: return 0xCF;
case 0x24: return 0xC7;
case 0x27: return Input.KEY_RIGHT;
case 0x26: return 0xC8;
case 0x25: return Input.KEY_LEFT;
case 0x28: return 0xD0;
case 0x2C: return 0x33;
case 0x2D: return 0x0C;
case 0x2E: return 0x34;
case 0x2F: return 0x35;
case 0x30: return 0x02;
case 0x31: return 0x03;
case 0x32: return 0x04;
case 0x33: return 0x05;
case 0x34: return 0x06;
case 0x35: return 0x07;
case 0x36: return 0x08;
case 0x37: return 0x09;
case 0x38: return 0x0A;
case 0x39: return 0x0B;
case 0x3B: return 0x27;
case 0x3D: return 0x0D;
case 0x41: return 0x1E;
case 0x42: return 0x30;
case 0x43: return 0x2E;
case 0x44: return 0x20;
case 0x45: return 0x12;
case 0x46: return 0x21;
case 0x47: return 0x22;
case 0x48: return 0x23;
case 0x49: return 0x17;
case 0x4A: return 0x24;
case 0x4B: return 0x25;
case 0x4C: return 0x26;
case 0x4D: return 0x32;
case 0x4E: return 0x31;
case 0x4F: return 0x18;
case 0x50: return 0x19;
case 0x51: return 0x10;
case 0x52: return 0x13;
case 0x53: return 0x1F;
case 0x54: return 0x14;
case 0x55: return 0x16;
case 0x56: return 0x2F;
case 0x57: return 0x11;
case 0x58: return 0x2D;
case 0x59: return 0x15;
case 0x5A: return 0x2C;
case 0x5B: return 0x1A;
case 0x5C: return 0x2B;
case 0x5D: return 0x1B;
case 0x60: return 0x52;
case 0x61: return 0x4F;
case 0x62: return 0x50;
case 0x63: return 0x51;
case 0x64: return 0x4B;
case 0x65: return 0x4C;
case 0x66: return 0x4D;
case 0x67: return 0x47;
case 0x68: return 0x48;
case 0x69: return 0x49;
case 0x6A: return 0x37;
case 0x6B: return 0x4E;
case 0x6D: return 0x4A;
case 0x6E: return 0x53;
case 0x6F: return 0xB5;
case 0x7F: return 0xD3;
case 0x90: return 0x45;
case 0x91: return 0x46;
case 0x70: return 0x3B;
case 0x71: return 0x3C;
case 0x72: return 0x3D;
case 0x73: return 0x3E;
case 0x74: return 0x3F;
case 0x75: return 0x40;
case 0x76: return 0x41;
case 0x77: return 0x42;
case 0x78: return 0x43;
case 0x79: return 0x44;
case 0x7A: return 0x57;
case 0x7B: return 0x58;
case 0x9B: return 0xD2;
case 0x80: return 0x29;
case 0xF000: return 0x64;
case 0xF001: return 0x65;
case 0xF002: return 0x66;
case 0x0200: return 0x91;
case 0x0201: return 0x92;
case 0x0202: return 0x90;
case 0x020B: return 0x93;
case 0x001C: return 0x79;
case 0x001D: return 0x7B;
case 0x0015: return 0x70;
case 0x0019: return 0x94;
case 0xFFC8: return 0x95;
}
throw new RuntimeException("Unknown key: " + value);
}
Well, I didn’t write the code for it, I just gave you a chart with the conversions. :point:
I guess one of the best ways to do it is just by doing brute force. I’ll give you a small example using the chart I provided to convert an AWT key into Slick input constant.
From my chart (snippet)…
"/Escape Row\n"
"1 27 ESCAPE\n"
"59 112 F1\n"
"60 113 F2\n"
"61 114 F3\n"
Using your example (from JavaAWT to Slick)…
...
switch(value)
{
case 27: return 1;//Escape
case 112: return 59;//F1
case 113: return 60;//F2
case 114: return 61;//F3
//continue the conversions
...