public void OnControlRequestReceived(ControlRequestEventArgs e)
 {
     if (e.bmRequestType == 0xA1 && e.bRequest == 0xFE)
       {
     //Return max LUN
     e.ReturnData = new byte[] { 0x00 };
     e.Ignore = false;
       }
 }
Пример #2
0
 public void OnControlRequestReceived(ControlRequestEventArgs e)
 {
     if (e.bmRequestType == 0xA1 && e.bRequest == 0xFE)
     {
         //Return max LUN
         e.ReturnData = new byte[] { 0x00 };
         e.Ignore     = false;
     }
 }
Пример #3
0
 public void OnControlRequestReceived(ControlRequestEventArgs e)
 {
     //Mark some HID requests as handled
     if (e.bmRequestType == 0x21 && e.bRequest == 0x0A)
     {
         e.Ignore = false;
     }
     if (e.bmRequestType == 0x00 && e.bRequest == 0x09)
     {
         _configured = true; //save configured state
     }
 }
Пример #4
0
        public void OnControlRequestReceived(ControlRequestEventArgs e)
        {
            switch (e.bmRequestType)
            {
            case 0x40:
            {
                switch (e.bRequest)
                {
                case 0x00: //reset
                case 0x01: //set modem control
                case 0x02: //set flow control
                case 0x03: //set baud rate
                case 0x04: //set data characteristics
                {
                    e.Ignore = false;
                    break;
                }

                default:
                    break;
                }
                break;
            }

            case 0xC0:
            {
                switch (e.bRequest)
                {
                case 0x05: //get status
                case 0x90: //don't know
                {
                    e.ReturnData = new byte[e.wLength];
                    e.Ignore     = false;
                    break;
                }

                default:
                    break;
                }

                e.Ignore = false;
                break;
            }

            default:
                break;
            }
        }
Пример #5
0
        public void OnControlRequestReceived(ControlRequestEventArgs e)
        {
            if ((e.bmRequestType == 0x80) && (e.bRequest == 0x06))
              {
            //Descriptor request, let the other event handle it
              }
              else if ((e.bmRequestType == 0x00) && (e.bRequest == 0x05))
              {
            //Let the library handle it, needs it to set the address in the Teensy
              }
              else if ((e.bmRequestType == 0x00) && (e.bRequest == 0x09))
              {
            //Let the library handle it, needs it to configure the endpoints in the Teensy
              }
              else
              {
            //Issue the request to the real device, and return whatever it did
            var setup = new UsbSetupPacket((byte)e.bmRequestType, (byte)e.bRequest,
              (short)e.wValue, (short)e.wIndex, (short)e.wLength);
            int transferred;

            if ((e.bmRequestType & 0x80) > 0)
            {
              var ret = new byte[e.wLength];
              _forwardee.ControlTransfer(ref setup, ret, ret.Length, out transferred);
              e.ReturnData = new byte[transferred];
              Array.Copy(ret, 0, e.ReturnData, 0, e.ReturnData.Length);
            }
            else
            {
              _forwardee.ControlTransfer(ref setup, e.AttachedData, e.AttachedData.Length, out transferred);
            }

            e.Ignore = false;
              }
        }
Пример #6
0
        public void OnControlRequestReceived(ControlRequestEventArgs e)
        {
            if ((e.bmRequestType == 0x80) && (e.bRequest == 0x06))
            {
                //Descriptor request, let the other event handle it
            }
            else if ((e.bmRequestType == 0x00) && (e.bRequest == 0x05))
            {
                //Let the library handle it, needs it to set the address in the Teensy
            }
            else if ((e.bmRequestType == 0x00) && (e.bRequest == 0x09))
            {
                //Let the library handle it, needs it to configure the endpoints in the Teensy
            }
            else
            {
                //Issue the request to the real device, and return whatever it did
                var setup = new UsbSetupPacket((byte)e.bmRequestType, (byte)e.bRequest,
                                               (short)e.wValue, (short)e.wIndex, (short)e.wLength);
                int transferred;

                if ((e.bmRequestType & 0x80) > 0)
                {
                    var ret = new byte[e.wLength];
                    _forwardee.ControlTransfer(ref setup, ret, ret.Length, out transferred);
                    e.ReturnData = new byte[transferred];
                    Array.Copy(ret, 0, e.ReturnData, 0, e.ReturnData.Length);
                }
                else
                {
                    _forwardee.ControlTransfer(ref setup, e.AttachedData, e.AttachedData.Length, out transferred);
                }

                e.Ignore = false;
            }
        }
Пример #7
0
 public void OnControlRequestReceived(ControlRequestEventArgs e)
 {
     //Mark some HID requests as handled
       if (e.bmRequestType == 0x21 && e.bRequest == 0x0A)
     e.Ignore = false;
       if (e.bmRequestType == 0x00 && e.bRequest == 0x09)
     _configured = true; //save configured state
 }