From: Carsten W. <ca...@us...> - 2004-12-14 17:41:48
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22895/src/jake2/sys Modified Files: LWJGLKBD.java Log Message: mouse uses delta --> freelook is ok; keycode translation is now ok Index: LWJGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/LWJGLKBD.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LWJGLKBD.java 14 Dec 2004 00:11:01 -0000 1.2 --- LWJGLKBD.java 14 Dec 2004 17:41:38 -0000 1.3 *************** *** 14,19 **** public class LWJGLKBD extends KBD { ! static private int win_w2; ! static private int win_h2; public void Init() --- 14,21 ---- public class LWJGLKBD extends KBD { ! private int win_w2; ! private int win_h2; ! ! private char[] lwjglKeycodeMap = null; public void Init() *************** *** 25,32 **** --- 27,37 ---- if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); + if (!Keyboard.isTranslationEnabled()) Keyboard.enableTranslation(); if (!Mouse.isBuffered()) Mouse.enableBuffer(); win_w2=Display.getDisplayMode().getWidth()/2; win_h2=Display.getDisplayMode().getHeight()/2; + + if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; } catch (Exception e) {;} *************** *** 41,66 **** Keyboard.destroy(); Mouse.destroy(); } private void HandleEvents() { if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! ! for (int i=0; i<Keyboard.getNumKeyboardEvents(); i++) { ! Keyboard.next(); ! int key=Keyboard.getEventKey(); ! char ch=Keyboard.getEventCharacter(); ! Do_Key_Event(XLateKey(key,ch),Keyboard.getEventKeyState()); } if (IN.mouse_active) { ! mx=(Mouse.getX()-win_w2)*2; ! my=(Mouse.getY()-win_h2)*2; } else --- 46,82 ---- Keyboard.destroy(); Mouse.destroy(); + // free the memory for GC + lwjglKeycodeMap = null; } private void HandleEvents() { + Keyboard.poll(); + if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! int key; ! char ch; ! boolean down; ! while (Keyboard.next()) { ! key = Keyboard.getEventKey(); ! ch = Keyboard.getEventCharacter(); ! down = Keyboard.getEventKeyState(); ! // fill the character translation table ! // this is needed because the getEventCharacter() returns \0 if a key is released ! // keycode is correct but the charachter value is not ! if (down) lwjglKeycodeMap[key] = ch; ! ! Do_Key_Event(XLateKey(key,ch), down); } if (IN.mouse_active) { ! mx = Mouse.getDX() << 1; ! my = -Mouse.getDY() << 1; } else *************** *** 80,84 **** } ! private static int XLateKey(int code, int ch) { int key = 0; --- 96,100 ---- } ! private int XLateKey(int code, int ch) { int key = 0; *************** *** 151,164 **** case Keyboard.KEY_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; ! default: ! key = ch; if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; break; } if (key > 255) key = 0; - return key; } --- 167,180 ---- case Keyboard.KEY_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards + case Keyboard.KEY_GRAVE: case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; ! default: ! key = lwjglKeycodeMap[code]; if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } |