public void HookHotkeys() { Detach(); _hooks.Clear(); var config = _config.LoadConfiguration(); var settings = config.UserSettings.HotkeySettings; _rawinput = new RawInput(_mainWindowHandle); var kb = (RawKeyboard)_rawinput.CreateKeyboard(); _rawinput.AddDevice(kb); kb.RawKeyInputReceived += Keyboard_RawKeyboardInputReceived; _kb = kb; var mouse = (RawMouse)_rawinput.CreateMouse(); _rawinput.AddDevice(mouse); mouse.RawMouseInputReceived += Mouse_RawMouseInputReceived; _mouse = mouse; foreach (var hotkey in settings.Settings.Where(hotkey => hotkey.IsEnabled)) { RubberduckHotkey assigned; if (Enum.TryParse(hotkey.Name, out assigned)) { var command = Command(assigned); Debug.Assert(command != null); AddHook(new Hotkey(_mainWindowHandle, hotkey.ToString(), command)); } } Attach(); }
public static UsbDevice Resolve(IDevice device) { IRawDevice raw = device as IRawDevice; if (raw != null) { if (ResolveUsingUsbBusAndPort(raw.Device.UdevMetadata, false) != null) { return(new UsbDevice(raw.Device)); } else if (ResolveUsingBusType(raw.Device.UdevMetadata, false) != null) { return(new UsbDevice(raw.Device)); } } return(null); }
internal static UsbDevice ResolveRootDevice(IDevice device) { // Now walk up the device tree to see if we can find a usb device // NOTE: We walk up the tree to find a UDevMetadataSource which // exposes the right usb properties, but we never use it. Maybe we // should be constructing and wrapping a new RawUsbDevice using the // correct metadata. Maybe it doesn't matter. I'm not sure. At the // moment we re-use the same RawDevice except wrap it in a UsbDevice. IRawDevice raw = device as IRawDevice; if (raw != null) { var metadata = ResolveUsingUsbBusAndPort(raw.Device.UdevMetadata, true); if (metadata == null) { metadata = ResolveUsingBusType(raw.Device.UdevMetadata, true); } if (metadata != null) { return(new UsbDevice(raw.Device)); } } return(null); }
public void AddDevice(IRawDevice device) { _devices.Add(device); }