Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Convert an AWT key constant to a Slick2D input constant  (Read 605 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Member


Projects: 3



« Posted 2013-06-05 18:30:41 »

Is there a quick way, or existing code that converts an input key from awt to slick?
Offline ctomni231

JGO Wizard


Medals: 98
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2013-06-07 20:56:52 »

Haha, I actually created a chart that does that. You can find this page here.

Offline P0jahn

Senior Member


Projects: 3



« Reply #2 - Posted 2013-06-08 14:16:38 »

How do we use that?
Here is my code, buggy:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
   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);
   }
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ctomni231

JGO Wizard


Medals: 98
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #3 - Posted 2013-06-08 20:54:46 »

Well, I didn't write the code for it, I just gave you a chart with the conversions.  Pointing

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)...

1  
2  
3  
4  
5  
"/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)...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
...

       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

...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (46 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (32 views)
2014-07-23 20:56:16
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!