/********************************** (C) COPYRIGHT ******************************
* File Name          :HidReport.h
* Author             : DL
* Version            : V1.1
* Date               : 2018/10/21
* Description        : A demo for USB compound device created by CH552, support
					   touch panel , and HID-compliant device.
********************************************************************************/
#ifndef	__HID_REPORT_H__
#define __HID_REPORT_H__
#include  "TouchCommon.h"
#include "typedef.h"

typedef enum _EN_COMMAND_TYPE {
  I2C_READ = 0,
  I2C_WRITE = 1,
  I2C_READ_BLOCK = 2,
  GET_VERSION = 3,
  RESET_TOUCH_IC = 4,
  REBOOT_FROM_SRAM = 5,
  ENTRY_DEBUG_MODE = 6,
  QUIT_DEBUG_MODE = 7,
  HID_RECONNECT = 8,
  HID_DISCONNECT = 9,
  CHECK_HID_CONNECTION = 10,
  CHECK_TOUCH_IC_CONNECTION = 11,
  WRITE_ASYNC = 12,
  READ_ASYNC = 13,
  S818X_ENTER_UPDATE_MODE = 14,
  NULL_COMMAND = 15,
  NO_OPERATE = 16,
  ENABLE_DIGITER_INTERFACE = 17,
  DISABLE_DIGITER_INTERFACE =18,
  CHECK_I2C_CONNECT = 19,
  CHECK_BLE_CONNECT = 20,
  DEBUG_PIPE = 21,
  SYS_PIPE = 22,
  START_SCAN_DEVICE = 23,
  STOP_SCAN_DEVICE = 24,
  ERASE_BONDING = 25,
  BONDING = 26,
  GET_BONDING_MAC = 27,
  GET_DEVICE_MAC = 28,
  DEVICE_ADDR = 29,
  DEVICE_NAME = 30,
  DEVICE_RSSI	= 31,
  STOP_PRINT_LOG = 32,
  NOTIFY = 33,
  FORCE_TEMINATE_BLE_AND_ADV = 34,
  RESET_USB_DEVICE = 35,
  GTXXX_ENTER_UPDATE_MODE = 36,
  BLE_RF_TEST = 37,
  GET_TOUCH_CHIP_INFO = 38,
  COOR_PIPE = 39,
  ENABLE_INT_IRQ = 40,
  DISABLE_INT_IRQ = 41,
  ENABLE_ESD_CHECK = 42,
  DISABLE_ESD_CHECK = 43,
  FIRST_PACKAGE = 44,
  SUBSEQUENT_PACKAGE  = 45,
  LAST_PACKAGE = 46,
  CET_TOUCH_CHIP_TYPE = 47,
  GET_CONFIG = 48,
  SET_CONFIG = 49,
  GET_TEST_STATE = 59,
  SET_TEST_RESULT = 60,
} COMMAND_TYPE;


typedef enum _BUFF_STATE {
    BUFF_FREE,
    BUFF_DATA_READY,
} BUFF_STATE;


typedef struct _PACKAGE_INFO {
    COMMAND_TYPE command;
    COMMAND_TYPE sub_command;
    UINT32 address;
    UINT8 buf[128];
    UINT16 len;
    UINT16 offset;
} PACKAGE_INFO;

#define COMMAND_HEARD_LEN 	7


/*******************************************************************************/
/* Macro Definition */
// HID Report IDs for the service
#define HID_RPT_ID_TOUCH_IN      13 // Mouse input report ID
#define HID_RPT_ID_FEATURE       7  // Feature report ID

#define HID_RPT_ID_KEY_IN        3  // Keyboard input report ID
#define HID_RPT_ID_KEY_IN1        4  // Keyboard input report ID
#define HID_RPT_ID_ABS_MOUSE_IN      5    // Mouse input report ID
#define HID_RPT_ID_MOUSE_IN      11  // Mouse input report ID

#define HID_RPT_ID_KEY_IN2       1  // LED output report ID
#define HID_RPT_ID_MOUSE_IN2   8  // Feature report ID
#define HID_RPT_ID_MOUSE_FEATURE       9  // Feature report ID

#define HID_RPT_ID_APPLESTYLUS_IN        10
#define HID_RPT_ID_STYLUS_IN         6

#define HID_RPT_ID_APPLE_IN          14
#define HID_RPT_ID_APPLE_IN1         15
#define HID_RPT_ID_APPLE_IN2         16
#define HID_RPT_ID_APPLE_IN3         17
#define HID_RPT_ID_APPLE_IN4         18

#define HID_BUTTOM_TYPE_FEATRUE              12
#define HID_DEVICE_IDENTIFIER_FEATRUE                33

#define HID_NUM_REPORTS          20

#define EDP2_INPUT_REPORT_ID    2
#define EDP2_OUTPUT_REPORT_ID0      3
#define EDP2_OUTPUT_REPORT_ID1      4
#define EDP2_ACK_REPORT_ID          5

#define REPORTID_EXT_INFO 11
#define REPORTID_EXT_INFO_SWITCH 12
#define REPORTID_USB_BUS_TEST 0

#define EXT_INFO_BEEP  0x01

//#define REPORTID_PEN  	8

#define PEN_TIP					0x01
#define PEN_BARREL			0x02
#define PEN_INVERT			0x04
#define PEN_ERASER		  0x08
#define PEN_HOVER				0x20

void SoftResetChip();
extern BOOL Ep2ReporteParse(UINT8* buf);
extern UINT8 Absolute_Up_Pack( POINTER * pTP);
extern UINT8 Append_Up_Pack( void );
extern void CommandHandle( void );
extern void Ep2OutputReport( void );
extern void Ep2InputReport( void );
extern void ReportInit( void );
extern void ReportMousePos(POINTER * pTP);
//extern void ReportToApple( POINTER * pTP);
#if (defined S558 || defined S538 || defined S518 || defined S528F)
extern UINT8 ProcessUSBCommand(COMMAND_TYPE cmd, PUINT8 buf);
#endif

#define  TOUCH_RELEASE_TIMES 	5
#define USB_COMMAND_EVT									0x0001

extern BOOL IsDebugMode;
extern BOOL DisableDigiterInterface;
extern BOOL OutDebugMode;
extern BOOL ReportExtInfoEn;
#endif
/**************************** END *************************************/
