#include <usbdrivr.h>
#include <HIDPORT.H>



#define GET_MINIDRIVER_DEVICE_EXTENSION(DO)  \
	((PDEVICE_EXTENSION) (((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->MiniDeviceExtension))

#define GET_LOWER_DEVICE_OBJECT(DO) (((PHID_DEVICE_EXTENSION) ((DO)->DeviceExtension)) \
	->NextDeviceObject)

#define GET_PHYSICAL_DEVICE_OBJECT(DO) (((PHID_DEVICE_EXTENSION) ((DO)->DeviceExtension)) \
	->PhysicalDeviceObject)


typedef enum _DEVICE_PNP_STATE {
	DEVICE_STATE_STARTING,
	DEVICE_STATE_STARTED,
	DEVICE_STATE_STOPPED,
	DEVICE_STATE_REMOVED,
	DEVICE_STATE_UNKNOWN
} DEVICE_PNP_STATE;


/* device extension */
typedef struct _DEVICE_EXTENSION{

	/* flags */
	DEVICE_PNP_STATE		Pnp_State;

	short					Profil_Id;
	PPROFIL					Profil_Actif;
	PPROFIL					Profil_First;

	/*	Reset Axe , btn , Key , mouse */
	BOOLEAN					Reset_Input;
	BOOLEAN					ModeConfig;

	/* request count */
	LONG					RequestCount;

	/* remove event */
	KEVENT					Remove_Event;

	/* pending read report request */
	LIST_ENTRY				Pending_Read_irp;
	KSPIN_LOCK				Pending_Read_irp_Lock;

	/* Physical Device Descriptor */
	USB_DEVICE_DESCRIPTOR	DeviceDescriptor;

	/* usb handles */
	USBD_CONFIGURATION_HANDLE	usb_conf_handle;
	USBD_PIPE_HANDLE			usb_input_pipe;
	USBD_PIPE_HANDLE			usb_output_pipe;
	USBD_PIPE_HANDLE			usb_control_pipe;
	PVOID						usb_worker_thread_obj;

	/* USB Data */

	CONTROLLER_INPUT_REPORT		input_state;

	RAW_INPUT				hwInData;
	
	KEYB_STATUS				KeyB;
	MOU_REPEAT				Mouse;
	PLED_REPEAT				Led;

	SPECIAL_ACTION			Special_Action;

	/* HID datas */
	USHORT					Report_Descriptor_Size;
	UCHAR					*HID_Report_Space;
	USHORT					Size_HID_Report_Space;
	PVOID					hid_worker_thread_obj;
	KEVENT					hid_worker_wakeup_event;
	ULONG					hid_input_changed;

	UNICODE_STRING			RegPath;

} DEVICE_EXTENSION, *PDEVICE_EXTENSION;


