Beispiel #1
0
        //static USBHIDDRIVER.USBInterface usbI = new USBInterface("vid_3353", "pid_3713");
        public static void Main(string[] args)
        {
            bool conn = usbI.Connect();

            usbI.enableUsbBufferEvent(new EventHandler(handler));
            Thread.Sleep(5);
            usbI.startRead();
            //Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Beispiel #2
0
        public static void Start()
        {
            usb = new USBInterface(vid, pid);
            Console.WriteLine("USB Connection: "+usb.Connect());

            usb.startRead();

            //usb.stopRead();

            //MyPause();
        }
Beispiel #3
0
 public void startRead()
 {
     sendStartCMD();
     usb.enableUsbBufferEvent(new System.EventHandler(usbReadacher));
     Thread.Sleep(5);
     usb.startRead();
     Thread.Sleep(5);
     for (int i = 0; i < 200; i++)
     {
         //Assert.IsNotNull(USBHIDDRIVER.USBInterface.usbBuffer);
         Thread.Sleep(2);
     }
     usb.stopRead();
     sendStopCMD();
 }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            try
            {

                if (args.Length > 0)
                    VirtualKeys = false;
                string VID = ConfigurationManager.AppSettings["VID"] ?? "vid_05f3";
                string PID = ConfigurationManager.AppSettings["PID"] ?? "pid_00ff";

                Left = ConfigurationManager.AppSettings["Left"] ?? "L";
                Middle = ConfigurationManager.AppSettings["Middle"] ?? "M";
                Right = ConfigurationManager.AppSettings["Right"] ?? "R";

                VKeyLeft = ConfigurationManager.AppSettings["Left"] ?? "{LEFT}";
                VKeyMiddle = ConfigurationManager.AppSettings["Middle"] ?? " ";
                VKeyRight = ConfigurationManager.AppSettings["Right"] ?? "{RIGHT}";

                usbI = new USBInterface(VID, PID);
                savehandle = new EventHandler(HIDhandler);

                bool conn = usbI.Connect();

                if (conn)
                {
                    usbI.enableUsbBufferEvent(savehandle);
                    Thread.Sleep(5);
                    usbI.startRead();

                }

                Console.Read();
                if (conn)
                {
                    usbI.stopRead();
                    try
                    {
                        usbI.Disconnect();
                    }
                    catch { }
                }

            }
            finally
            {
                Environment.Exit(0); //Force close application
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
                VirtualKeys = false;
            string VID = ConfigurationManager.AppSettings["VID"] ?? "vid_05f3";
            string PID = ConfigurationManager.AppSettings["PID"] ?? "pid_00ff";

            Left = ConfigurationManager.AppSettings["Left"] ?? "L";
            Middle = ConfigurationManager.AppSettings["Middle"] ?? "M";
            Right = ConfigurationManager.AppSettings["Right"] ?? "R";

            VKeyLeft = ConfigurationManager.AppSettings["Left"] ?? "{LEFT}";
            VKeyMiddle = ConfigurationManager.AppSettings["Middle"] ?? " ";
            VKeyRight = ConfigurationManager.AppSettings["Right"] ?? "{RIGHT}";
            usbI = new USBInterface(VID, PID);

            savehandle = new EventHandler(HIDhandler);
            bool conn = usbI.Connect();
            if (conn)
            {
                usbI.enableUsbBufferEvent(savehandle);
                Thread.Sleep(5);
                usbI.startRead();

            }
            else
                Console.WriteLine("Cannot connect to device");

            Console.Read();
            if (conn)
            {
                usbI.stopRead();
                try
                {
                    usbI.Disconnect();
                }
                catch { }
            }
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }