public boolean CheckEvent(Object event) { if (!KeyboardKey.isPressed(event) && !KeyboardKey.isReleased(event)) return false; int key = GetKeyCode(KeyboardKey.getKeyCode(event)); // LOG_MSG("key type %i is %x [%x // %x]",event->type,key,event->key.keysym.sym,event->key.keysym.scancode); // assert(Bitu(event->key.keysym.sym)<keys); if (KeyboardKey.isPressed(event)) ActivateBindList(lists[key], event, 0x7fff, true); else DeactivateBindList(lists[key], true); return false; }
void ActivateBindList(CBindList list, Object key, int value, boolean ev_trigger) { int validmod = 0; for (CBind it : list) { if ((it.mods & mapper.mods) == it.mods) { if (validmod < it.mods) validmod = it.mods; } } for (CBind it : list) { /*BUG:CRASH if keymapper key is removed*/ if (validmod == it.mods && (!it.isLeft() && !it.isRight() && !it.isNumpad()) || (it.isLeft() && KeyboardKey.isLeft(key)) || (it.isRight() && KeyboardKey.isRight(key)) || (it.isNumpad() && KeyboardKey.isNumPad(key))) it.ActivateBind(value, ev_trigger); } }
void MakeDefaultBind(StringRef buf) { /*Bitu*/ int key = KeyboardKey.translateMapKey(defkey); buf.value = entry + " \"key " + key + ((defmod & 1) != 0 ? " mod1" : "") + ((defmod & 2) != 0 ? " mod2" : "") + ((defmod & 4) != 0 ? " mod3" : "") + "\""; }
static void CreateDefaultBinds() { for (DefaultKey key : KeyboardKey.DefaultKeys) { CreateStringBind( "key_" + key.eventend + " \"key " + key.key + ((key.isRight ? " right" : "")) + ((key.isLeft ? " left" : "")) + ((key.isNumPad ? " numpad" : "")) + "\""); } KeyboardKey.CreateDefaultBinds(); for (CHandlerEvent it : handlergroup) { StringRef buffer = new StringRef(); it.MakeDefaultBind(buffer); CreateStringBind(buffer.value); } // /* joystick1, buttons 1-6 */ // CreateStringBind("jbutton_0_0 \"stick_0 button 0\" "); // CreateStringBind("jbutton_0_1 \"stick_0 button 1\" "); // CreateStringBind("jbutton_0_2 \"stick_0 button 2\" "); // CreateStringBind("jbutton_0_3 \"stick_0 button 3\" "); // CreateStringBind("jbutton_0_4 \"stick_0 button 4\" "); // CreateStringBind("jbutton_0_5 \"stick_0 button 5\" "); // /* joystick2, buttons 1-2 */ // CreateStringBind("jbutton_1_0 \"stick_1 button 0\" "); // CreateStringBind("jbutton_1_1 \"stick_1 button 1\" "); // // /* joystick1, axes 1-4 */ // CreateStringBind("jaxis_0_0- \"stick_0 axis 0 0\" "); // CreateStringBind("jaxis_0_0+ \"stick_0 axis 0 1\" "); // CreateStringBind("jaxis_0_1- \"stick_0 axis 1 0\" "); // CreateStringBind("jaxis_0_1+ \"stick_0 axis 1 1\" "); // CreateStringBind("jaxis_0_2- \"stick_0 axis 2 0\" "); // CreateStringBind("jaxis_0_2+ \"stick_0 axis 2 1\" "); // CreateStringBind("jaxis_0_3- \"stick_0 axis 3 0\" "); // CreateStringBind("jaxis_0_3+ \"stick_0 axis 3 1\" "); // /* joystick2, axes 1-2 */ // CreateStringBind("jaxis_1_0- \"stick_1 axis 0 0\" "); // CreateStringBind("jaxis_1_0+ \"stick_1 axis 0 1\" "); // CreateStringBind("jaxis_1_1- \"stick_1 axis 1 0\" "); // CreateStringBind("jaxis_1_1+ \"stick_1 axis 1 1\" "); // // /* joystick1, hat */ // CreateStringBind("jhat_0_0_0 \"stick_0 hat 0 1\" "); // CreateStringBind("jhat_0_0_1 \"stick_0 hat 0 2\" "); // CreateStringBind("jhat_0_0_2 \"stick_0 hat 0 4\" "); // CreateStringBind("jhat_0_0_3 \"stick_0 hat 0 8\" "); }
public CBind CreateEventBind(Object event) { if (!KeyboardKey.isPressed(event)) return null; return CreateKeyBind(GetKeyCode(KeyboardKey.getKeyCode(event))); }