コード例 #1
0
ファイル: UsbHID.cs プロジェクト: koson/hiddriver
 public bool sendBytes(byte[] sendingBytes)
 {
     if (!usb.write(sendingBytes))
     {
         usbLog.ErrorLog(USBErrorTypes.SEND);
         return(false);
     }
     usbLog.IntractionLog(sendingBytes, USBTransactionTypes.Send);
     return(true);
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: piepieonline/H800-Controller
        private void Form1_Load(object sender, EventArgs e)
        {
            keyMapping["101"] = 0xAF; //"VOLUME_UP"
            keyMapping["102"] = 0xAE; //"VOLUME_DOWN"
            keyMapping["110"] = 0xB3; //"MEDIA_PLAY_PAUSE"
            keyMapping["120"] = 0xB0; //"MEDIA_NEXT"
            keyMapping["140"] = 0xB1; //"MEDIA_PREVIOUS"

            if (usb.Connect())
            {
                updateConnectionStatus(true);
            }
            else
            {
                updateConnectionStatus(false);
            }

            usb.write(new byte[] { 0 });

            usb.enableUsbBufferEvent(new System.EventHandler(headsetEventCatcher));
            usb.startRead();

            this.Show();

            while (true)
            {
                Application.DoEvents();
                if (usbOut != "" && usbOut.Length == 3)
                {
                    if (keyMapping.ContainsKey(usbOut))
                    {
                        if (settingsMode)
                        {
                            //pressedLabel.Text = usbOut;
                            currentAssignmentText.Text = keyMapping[usbOut].ToString();
                        }
                        else
                        {
                            //SendKeys.Send("{" + keyMapping[usbOut] + "}");
                            keybd_event(keyMapping[usbOut], 0, KEYEVENTF_EXTENDEDKEY, 0);
                            keybd_event(keyMapping[usbOut], 0, KEYEVENTF_KEYUP, 0);
                        }
                    }
                    usbOut = "";
                }
                System.Threading.Thread.Sleep(100);
            }
        }