private int DirKeyMap(SDL_keysym keysym) { // map directions to key symbols for (int i = 0; i < dirMap.Length; i++) { if (dirMap[i].Symbol == keysym.sym) { return(dirMap[i].Value); } } return(0xffff); }
private InputEvent EventKeyDown(SDL_keysym keysym) { InputEvent e = null; switch (keysym.sym) { case SDL_Keycode.SDLK_KP5: case SDL_Keycode.SDLK_CLEAR: e = this.stopEgoEvent; break; case SDL_Keycode.SDLK_SCROLLOCK: this.interpreter.ToggleTrace(); break; default: int index = -1; for (int i = 0; i < keySpecial.Length; i++) { if (keySpecial[i].Symbol == keysym.sym) { index = i; break; } } if (index != -1) { if (keySpecial[index].Value == 0) { // first press (not repeat) for (int i = 0; i < keySpecial.Length; i++) { keySpecial[i].Value = 0; } keySpecial[index].Value++; e = this.KeyParse(keysym); } } else { // normal key e = this.KeyParse(keysym); } break; } return(e); }
private int SystemKeyMap(SDL_keysym keysym) { if (keysym.sym >= SDL_Keycode.SDLK_F1 && keysym.sym <= SDL_Keycode.SDLK_F10) { return((keysym.sym - SDL_Keycode.SDLK_F1 + 0x3b) << 8); } else if ((keysym.mod & SDL_Keymod.KMOD_ALT) != 0) { if (keysym.sym >= SDL_Keycode.SDLK_a && keysym.sym <= SDL_Keycode.SDLK_z) { return(systemAltAtoZMap[keysym.sym - SDL_Keycode.SDLK_a] << 8); } } else if ((keysym.mod & SDL_Keymod.KMOD_CTRL) != 0) { if (keysym.sym >= SDL_Keycode.SDLK_a && keysym.sym <= SDL_Keycode.SDLK_z) { return(keysym.sym - SDL_Keycode.SDLK_a + 1); } } else { switch (keysym.sym) { case SDL_Keycode.SDLK_TAB: return(InputEventAscii.Tab); case SDL_Keycode.SDLK_ESCAPE: return(InputEventAscii.Esc); case SDL_Keycode.SDLK_BACKSPACE: case SDL_Keycode.SDLK_DELETE: return(InputEventAscii.Backspace); case SDL_Keycode.SDLK_KP_ENTER: case SDL_Keycode.SDLK_RETURN: return(InputEventAscii.Enter); default: if ((keysym.unicode & 0xff80) == 0 && keysym.unicode != 0) { return(keysym.unicode & 0x7f); } return(keysym.unicode & 0xff); } } return(0); }
private InputEvent EventKeyUp(SDL_keysym keysym) { InputEvent e = null; for (int i = 0; i < keySpecial.Length; i++) { if (keySpecial[i].Symbol == keysym.sym && keySpecial[i].Value != 0) { keySpecial[i].Value = 0; if (this.interpreter.State.WalkMode == WalkMode.HoldKey) { e = this.stopEgoEvent; break; } } } return(e); }
private InputEvent KeyParse(SDL_keysym keysym) { // if the key is a direction, then map it to that // else, return the ascii thing back InputEvent e = new InputEvent(); int direction = this.DirKeyMap(keysym); if (direction != 0xffff) { e.Type = InputEventType.Direction; e.Data = direction; } else { e.Type = InputEventType.Ascii; e.Data = this.SystemKeyMap(keysym); } return(e); }