Modules/USB_HID - Fixed report parsing bug that caused mouse not not detect buttons...
authorJohn Hodge <[email protected]>
Wed, 29 Feb 2012 13:40:38 +0000 (21:40 +0800)
committerJohn Hodge <[email protected]>
Wed, 29 Feb 2012 13:40:38 +0000 (21:40 +0800)
KernelLand/Modules/USB/HID/main.c
KernelLand/Modules/USB/HID/mouse.c

index 25b533d..b6a477a 100644 (file)
@@ -296,7 +296,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 +342,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 +408,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 ++;
 }
index d5c4be4..6ca88a5 100644 (file)
@@ -5,7 +5,7 @@
  * mouse.c
  * - USB Mouse driver
  */
-#define DEBUG  1
+#define DEBUG  0
 #include <acess.h>
 #include "hid_reports.h"
 #include <fs_devfs.h>
@@ -270,11 +270,13 @@ void HID_Mouse_DataAvail(tUSBInterface *Dev, int EndPt, int Length, void *Data)
                {
                        // Axis
                        info->Axies[ dest & 0x7F ].CurValue = value;
+                       LOG("Axis %i = %i", dest & 0x7F, info->Axies[dest & 0x7F].CurValue);
                }
                else
                {
                        // Button
                        info->Buttons[ dest & 0x7F ] = (value == 0) ? 0 : 0xFF;
+                       LOG("Button %i = %x", dest & 0x7F, info->Buttons[dest & 0x7F]);
                }
        }
        
@@ -400,6 +402,8 @@ void HID_int_AddInput(tUSBInterface *Dev, Uint32 Usage, Uint8 Size, Uint32 Min,
        default:        tag = 0xFF;     break;
        }
        
+       LOG("Usage = 0x%08x, tag = 0x%2x", Usage, tag);
+
        // --- Add to list of mappings ---
        info->nMappings ++;
        info->Mappings = realloc(info->Mappings, info->nMappings * sizeof(info->Mappings[0]));
@@ -426,11 +430,13 @@ void HID_Mouse_Report_Input(
        )
 {
        Uint32  usage = 0;
+       LOG("Local->Usages.nItems = %i", Local->Usages.nItems);
        for( int i = 0; i < Global->ReportCount; i ++ )
        {
                // - Update usage
                if( i < Local->Usages.nItems )
                        usage = Local->Usages.Items[i];
+               LOG("%i: usage = %x", i, usage);
                // - Add to list
                HID_int_AddInput(Dev, usage, Global->ReportSize, Global->LogMin, Global->LogMax);
        }

UCC git Repository :: git.ucc.asn.au