X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FHID%2Fmain.c;h=c2802737dabca2747c2a613f5fc53b60f158e58d;hb=f7ec06bee2b80613d80c314bf864c69209d09829;hp=25b533dbcb3cec531fe796c36b8e5189514dd7c5;hpb=1797e6eb24e9840405ef348ed5b7cb73b12fdc7d;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/HID/main.c b/KernelLand/Modules/USB/HID/main.c index 25b533db..c2802737 100644 --- a/KernelLand/Modules/USB/HID/main.c +++ b/KernelLand/Modules/USB/HID/main.c @@ -5,7 +5,7 @@ * main.c * - Driver Core */ -#define DEBUG 1 +#define DEBUG 0 #define VERSION VER2(0,1) #include #include @@ -26,7 +26,7 @@ struct sHID_Device // === IMPORTS === extern tHID_ReportCallbacks gHID_Mouse_ReportCBs; -extern tDevFS_Driver gHID_Mouse_DevFS; +extern tHID_ReportCallbacks gHID_Kb_ReportCBs; // === PROTOTYPES === int HID_Initialise(char **Arguments); @@ -40,7 +40,7 @@ static void _AddItems(struct sHID_IntList *List, Uint32 First, Uint32 Last); static void _FreeList(struct sHID_IntList *List); // === GLOBALS === -MODULE_DEFINE(0, VERSION, USB_HID, HID_Initialise, NULL, "USB_Core", NULL); +MODULE_DEFINE(0, VERSION, USB_HID, HID_Initialise, NULL, "USB_Core", "Keyboard", "Mouse", NULL); tUSBDriver gHID_USBDriver = { .Name = "HID", .Match = {.Class = {0x030000, 0xFF0000}}, @@ -60,8 +60,6 @@ int HID_Initialise(char **Arguments) { USB_RegisterDriver( &gHID_USBDriver ); - DevFS_AddDevice( &gHID_Mouse_DevFS ); - return 0; } @@ -79,7 +77,8 @@ void HID_InterruptCallback(tUSBInterface *Dev, int EndPt, int Length, void *Data Log_Error("USB HID", "Device %p doesn't have a data pointer.", Dev); return ; } - + + LOG("Data for %p", info->DataAvail); info->DataAvail(Dev, EndPt, Length, Data); } @@ -150,7 +149,7 @@ void HID_DeviceConnected(tUSBInterface *Dev, void *Descriptors, size_t Descripto // --- Read and parse report descriptor --- // NOTE: Also does sub-driver selection and initialisation - Uint8 *report_data = alloca(report_len); + Uint8 report_data[report_len]; USB_ReadDescriptor(Dev, 0x1022, 0, report_len, report_data); HID_int_ParseReport(Dev, report_data, report_len, &gHID_RootCallbacks); @@ -206,12 +205,12 @@ tHID_ReportCallbacks *HID_RootCollection( break; case 0x0006: // Keyboard LOG("Desktop->Keyboard"); - break; + return &gHID_Kb_ReportCBs; } break; case 0x0007: // Keyboard / Keypad LOG("Keyboard"); - break; + return &gHID_Kb_ReportCBs; } return NULL; } @@ -296,7 +295,7 @@ void HID_int_ParseReport(tUSBInterface *Dev, Uint8 *Data, size_t Length, tHID_Re else next_cbs = NULL; cur_cbs = next_cbs; - break; + goto _clear_local; // - Feature case 0xB0: LOG("Feature 0x%x", val); @@ -342,14 +341,17 @@ void HID_int_ParseReport(tUSBInterface *Dev, Uint8 *Data, size_t Length, tHID_Re // - Usages case 0x08: // Single if( (byte & 3) != 3 ) val |= global_state.UsagePage; + LOG("Usage %x", val); _AddItem(&local_state.Usages, val); break; case 0x18: // Range start if( (byte & 3) != 3 ) val |= global_state.UsagePage; + LOG("Usage start %x", val); local_state.UsageMin = val; break; case 0x28: // Range end (apply) if( (byte & 3) != 3 ) val |= global_state.UsagePage; + LOG("Usage end %x (from %x)", val, local_state.UsageMin); _AddItems(&local_state.Usages, local_state.UsageMin, val); break; // - Designators (Index into Physical report) @@ -405,6 +407,7 @@ static void _AddItem(struct sHID_IntList *List, Uint32 Value) List->Items = realloc( List->Items, List->Space * sizeof(List->Items[0]) ); } +// LOG("Added %x to %p", Value, List); List->Items[ List->nItems ] = Value; List->nItems ++; }