public void Init() { client.Uevent += Client_Uevent; foreach (var device in client.QueryBySubsystem(hidraw_subsystem)) { var args = new UeventArgs() { Args = new object[] { "add", device } }; Client_Uevent(this, args); } }
void Client_Uevent(object o, UeventArgs args) { var usb = args.Device.GetParentWithSubsystem(usb_subsystem, "usb_device"); var hid = args.Device.GetParentWithSubsystem(hid_subsystem, null); var idVendor = usb.GetSysfsAttr("idVendor"); var idProduct = usb.GetSysfsAttr("idProduct"); if (idVendor != "0694" || idProduct != "0006") { return; } switch (args.Action) { case "add": onDeviceAdded(new Device(hid.GetProperty("HID_NAME"), args.Device.DeviceFile)); break; case "remove": break; } }
protected static void HandleClientUevent(object o, UeventArgs args) { Console.WriteLine("Received a {0} signal on {1}", args.Action, (args.Device.HasProperty("ID_VENDOR") ? args.Device.GetProperty("ID_VENDOR") : "nameless device")); }
protected static void HandleClientUevent(object o, UeventArgs args) { Console.WriteLine ("Received a {0} signal on {1}", args.Action, (args.Device.HasProperty ("ID_VENDOR") ? args.Device.GetProperty ("ID_VENDOR") : "nameless device")); }