From: John Hodge Date: Mon, 5 Mar 2012 08:47:33 +0000 (+0800) Subject: Modules/USB HID - Shell USB Keyboard X-Git-Tag: rel0.15~739 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=2372d1276286d88393205042599ec2b389cc05d6;p=tpg%2Facess2.git Modules/USB HID - Shell USB Keyboard --- diff --git a/KernelLand/Modules/USB/HID/keyboard.c b/KernelLand/Modules/USB/HID/keyboard.c index 90ad63fb..839bb1e7 100644 --- a/KernelLand/Modules/USB/HID/keyboard.c +++ b/KernelLand/Modules/USB/HID/keyboard.c @@ -7,8 +7,76 @@ */ #define DEBUG 0 #include +#include + +typedef struct sUSB_Keyboard tUSB_Keyboard; + +// === STRUCTURES === +struct sUSB_Keyboard +{ + tKeyboard *Info; +}; + +// === PROTOTYPES === +void HID_Kb_DataAvail(tUSBInterface *Dev, int EndPt, int Length, void *Data); + +tHID_ReportCallbacks *HID_Kb_Report_Collection(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value); +void HID_Kb_Report_EndCollection(tUSBInterface *Dev); +void HID_Kb_Report_Input(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value); // === GLOBALS === -tDevFS_Driver gHID_DevFS_Keyboard = { - .Name = "USBKeyboard", +tHID_ReportCallbacks gHID_Kb_ReportCBs = { + .Collection = HID_Kb_Report_Collection, + .EndCollection = HID_Kb_Report_EndCollection, + .Input = HID_Kb_Report_Input }; + +// === CODE === +void HID_Kb_DataAvail(tUSBInterface *Dev, int EndPt, int Length, void *Data) +{ + +} + +// --- --- +tHID_ReportCallbacks *HID_Kb_Report_Collection( + tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, + Uint32 Value + ) +{ + tUSB_Keyboard *info; + + info = USB_GetDeviceDataPtr(Dev); + if( !info ) + { + info = malloc( sizeof(tUSB_Keyboard) ); + USB_SetDeviceDataPtr(Dev, info); + info->Keyboard = NULL; + info->CollectionDepth = 1; + } + else + { + info->CollectionDepth ++; + } + + return &gHID_Kb_ReportCBs; +} + +void HID_Kb_Report_EndCollection(tUSBInterface *Dev) +{ + tUSB_Keyboard *info; + + info = USB_GetDeviceDataPtr(Dev); + if( !info ) return ; + + info->CollectionDepth --; + if( info->CollectionDepth == 0 ) + { + info->Keyboard = Keyboard_CreateInstance(0, "USBKeyboard"); + } +} + +void HID_Kb_Report_Input(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value) +{ + +} +