public bool Add(object key, object obj) { if (mKeyType == KEY_TYPE.KEY_TYPE_ERROR) { Type type = key.GetType(); if (type == intType || type == longType || type == uintType || type == shortType) { mKeyType = KEY_TYPE.KEY_TYPE_INT; IntDic = new Dictionary <long, object>(); } else if (type == stringType) { mKeyType = KEY_TYPE.KEY_TYPE_STRING; StringDic = new Dictionary <string, object>(); } else { GameDebug.LogError("DataTable 不支持的Key类型"); return(false); } } if (mKeyType == KEY_TYPE.KEY_TYPE_INT) { return(Add(Convert.ToInt64(key), obj)); } else if (mKeyType == KEY_TYPE.KEY_TYPE_STRING) { return(Add((string)key, obj)); } return(false); }
public bool GetKeyPress(KEY_TYPE type) { if (GetKeyDown(type)) { _state = KEY_STATE.PRESS; return(true); } return(false); }
public bool GetKeyDown(KEY_TYPE type) { if (_state != KEY_STATE.DOWN) { if (Keyboard.IsKeyDown((Key)type)) { _type = type; _state = KEY_STATE.DOWN; return(true); } } return(false); }
private static char keyUpDownMap(char c, KEY_TYPE type) { if (c == 'a' && type == KEY_TYPE.DOWN) return 'k'; if (c == 'a' && type == KEY_TYPE.UP) return 'l'; if (c == 'd' && type == KEY_TYPE.DOWN) return 'o'; if (c == 'd' && type == KEY_TYPE.UP) return 'p'; throw new NotImplementedException(); }
public static void keyPress(string c, KEY_TYPE type, bool ignore = false) { if (!ignore) if (TBConst.pid != foregroundPID) return; if (c.Length == 1) { byte b; if (type == KEY_TYPE.PRESS) b = char2int(c[0]); else b = char2int(keyUpDownMap(c[0], type)); //SendKeys.SendWait("{r}"); keybd_event(b, 0, KEYEVENTF_EXTENDEDKEY, 0); Thread.Sleep(10); keybd_event(b, 0, KEYEVENTF_KEYUP, 0); Thread.Sleep(10); } }
public static bool Press(KEY_TYPE type) { return(InputKey.I.GetKeyPress(type)); }
public static bool Down(KEY_TYPE type) { return(InputKey.I.GetKeyDown(type)); }
private InputKey() { _type = KEY_TYPE.NONE; _state = KEY_STATE.UN_PRESS; }