/// <summary> /// [Event] GLFW keyboard event occurred. /// </summary> private void OnKey(GlfwWindowPtr wnd, Key key, int scanCode, KeyAction action, KeyModifiers mods) { string inputString = "vk." + key.ToString(); if (action == KeyAction.Press) { CurrentInputState.ReportPress(inputString); } else if (action == KeyAction.Release) { CurrentInputState.ReportRelease(inputString); } }
public InputSnapshot CloneAndClear() { Dictionary <Type, IInputCommand> temp; InputStateData state; using (new WriteLockSlim(loker)) { state = CurrentInputState?.Clone(); temp = cache; cache = new Dictionary <Type, IInputCommand>(); } var cloned = new InputSnapshot(); foreach (var cmd in temp) { cloned.cache.Add(cmd.Key, cmd.Value); } //Console.WriteLine($"CloneAndClear {cloned.cache.Count}"); cloned.CurrentInputState = state; return(cloned); }
private void ReportInputStates(byte bank, IEnumerable <bool> states) { if (CurrentInputState.ContainsKey(bank)) { var curBankState = CurrentInputState[bank].ToArray(); var inputState = states.ToArray(); for (byte i = 0; i < 8; i++) { var tuple = Tuple.Create(bank, i); if (!EndpointCoupleDictionary.ContainsKey(tuple)) { continue; } var couple = EndpointCoupleDictionary[tuple]; if (!couple.Item1.Live) { if (curBankState[i] != inputState[i]) { CurrentInputState[bank] = inputState; } External.FireInputEvent(couple.Item1.Name, inputState[i] ? "In" : "Out"); } else { if (curBankState[i] != inputState[i]) { CurrentInputState[bank] = inputState; External.FireInputEvent(couple.Item1.Name, inputState[i] ? "In" : "Out"); } } } } else { CurrentInputState.Add(bank, states); } }
/// <summary> /// [Event] GLFW filtered keyboard event occurred. /// </summary> private void OnChar(GlfwWindowPtr wnd, char ch) { CurrentInputState.ReportConsoleInput(ch); }