#include "usb.h"
#include "hid.h"
#include "usbcfg.h"
#include "usbcore.h"
#include "hiduser.h"


BYTE HID_Protocol;
BYTE HID_IdleTime[HID_REPORT_NUM];

extern BYTE Data;

BOOL HID_GetReport (void) {
  /* ReportID = SetupPacket.wValue.WB.L; */
  switch (SetupPacket.wValue.WB.H) {
    case HID_REPORT_INPUT:
      GetInReport();
//	  EP0Buf[0] = InReport[0];   //**********
//      EP0Buf[1] = InReport[1];   //**********
//    EP0Buf[0] = b_UsbIn;
//	  EP0Buf[1] = InReport + 1;
//	  EP0Buf[2] = InReport + 2;
//	  EP0Buf[3] = InReport + 3;
//	  EP0Buf[4] = InReport + 4;
//	  EP0Buf[5] = InReport + 5;
//	  EP0Buf[6] = InReport + 6;
      break;
    case HID_REPORT_OUTPUT:
      return (FALSE);          /* Not Supported */
    case HID_REPORT_FEATURE:
      return (FALSE);          /* Not Supported */
  }
  return (TRUE);
}

BOOL HID_SetReport (void) {

  /* ReportID = SetupPacket.wValue.WB.L; */
  switch (SetupPacket.wValue.WB.H) {
    case HID_REPORT_INPUT:
      return (FALSE);          /* Not Supported */
    case HID_REPORT_OUTPUT:
      b_UsbOut = EP0Buf[0];
      SetOutReport();
      break;
//	  return (FALSE);          /* Not Supported */
    case HID_REPORT_FEATURE:
      return (FALSE);          /* Not Supported */
  }
  return (TRUE);
}

BOOL HID_GetIdle (void) {
  EP0Buf[0] = HID_IdleTime[SetupPacket.wValue.WB.L];
  return (TRUE);
}

BOOL HID_SetIdle (void) {
  HID_IdleTime[SetupPacket.wValue.WB.L] = SetupPacket.wValue.WB.H;
  return (TRUE);
}

BOOL HID_GetProtocol (void) {
  EP0Buf[0] = HID_Protocol;
  return (TRUE);
}

BOOL HID_SetProtocol (void) {
  HID_Protocol = SetupPacket.wValue.WB.L;
  return (TRUE);
}
