git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ted.mutabah.net:acess2
[tpg/acess2.git]
/
KernelLand
/
Modules
/
USB
/
HID
/
main.c
diff --git
a/KernelLand/Modules/USB/HID/main.c
b/KernelLand/Modules/USB/HID/main.c
index
68e301e
..
6b36809
100644
(file)
--- a/
KernelLand/Modules/USB/HID/main.c
+++ b/
KernelLand/Modules/USB/HID/main.c
@@
-5,13
+5,14
@@
* main.c
* - Driver Core
*/
* main.c
* - Driver Core
*/
-#define DEBUG
1
+#define DEBUG
0
#define VERSION VER2(0,1)
#include <acess.h>
#include <modules.h>
#include <usb_core.h>
#include "hid.h"
#include "hid_reports.h"
#define VERSION VER2(0,1)
#include <acess.h>
#include <modules.h>
#include <usb_core.h>
#include "hid.h"
#include "hid_reports.h"
+#include <fs_devfs.h>
// === TYPES ===
typedef struct sHID_Device tHID_Device;
// === TYPES ===
typedef struct sHID_Device tHID_Device;
@@
-23,6
+24,10
@@
struct sHID_Device
// ... Device-specific data
};
// ... Device-specific data
};
+// === IMPORTS ===
+extern tHID_ReportCallbacks gHID_Mouse_ReportCBs;
+extern tHID_ReportCallbacks gHID_Kb_ReportCBs;
+
// === PROTOTYPES ===
int HID_Initialise(char **Arguments);
void HID_InterruptCallback(tUSBInterface *Dev, int EndPt, int Length, void *Data);
// === PROTOTYPES ===
int HID_Initialise(char **Arguments);
void HID_InterruptCallback(tUSBInterface *Dev, int EndPt, int Length, void *Data);
@@
-35,7
+40,7
@@
static void _AddItems(struct sHID_IntList *List, Uint32 First, Uint32 Last);
static void _FreeList(struct sHID_IntList *List);
// === GLOBALS ===
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}},
tUSBDriver gHID_USBDriver = {
.Name = "HID",
.Match = {.Class = {0x030000, 0xFF0000}},
@@
-54,6
+59,7
@@
tHID_ReportCallbacks gHID_RootCallbacks = {
int HID_Initialise(char **Arguments)
{
USB_RegisterDriver( &gHID_USBDriver );
int HID_Initialise(char **Arguments)
{
USB_RegisterDriver( &gHID_USBDriver );
+
return 0;
}
return 0;
}
@@
-71,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_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);
}
info->DataAvail(Dev, EndPt, Length, Data);
}
@@
-146,6
+153,19
@@
void HID_DeviceConnected(tUSBInterface *Dev, void *Descriptors, size_t Descripto
USB_ReadDescriptor(Dev, 0x1022, 0, report_len, report_data);
HID_int_ParseReport(Dev, report_data, report_len, &gHID_RootCallbacks);
USB_ReadDescriptor(Dev, 0x1022, 0, report_len, report_data);
HID_int_ParseReport(Dev, report_data, report_len, &gHID_RootCallbacks);
+ // --- Start polling ---
+ // Only if the device was initialised
+ if( USB_GetDeviceDataPtr(Dev) )
+ {
+ // Poll Endpoint .+1 (interupt)
+ USB_StartPollingEndpoint(Dev, 1);
+ }
+ else
+ {
+ Log_Log("USB_HID", "Device not intitialised");
+ }
+
+
LEAVE('-');
}
LEAVE('-');
}
@@
-178,19
+198,19
@@
tHID_ReportCallbacks *HID_RootCollection(
break;
case 0x0002: // Mouse
LOG("Desktop->Mouse");
break;
case 0x0002: // Mouse
LOG("Desktop->Mouse");
-
break
;
+
return &gHID_Mouse_ReportCBs
;
case 0x0004: // Joystick
case 0x0005: // Game Pad
LOG("Desktop->Gamepad");
break;
case 0x0006: // Keyboard
LOG("Desktop->Keyboard");
case 0x0004: // Joystick
case 0x0005: // Game Pad
LOG("Desktop->Gamepad");
break;
case 0x0006: // Keyboard
LOG("Desktop->Keyboard");
-
break
;
+
return &gHID_Kb_ReportCBs
;
}
break;
case 0x0007: // Keyboard / Keypad
LOG("Keyboard");
}
break;
case 0x0007: // Keyboard / Keypad
LOG("Keyboard");
-
break
;
+
return &gHID_Kb_ReportCBs
;
}
return NULL;
}
}
return NULL;
}
@@
-275,7
+295,7
@@
void HID_int_ParseReport(tUSBInterface *Dev, Uint8 *Data, size_t Length, tHID_Re
else
next_cbs = NULL;
cur_cbs = next_cbs;
else
next_cbs = NULL;
cur_cbs = next_cbs;
-
break
;
+
goto _clear_local
;
// - Feature
case 0xB0:
LOG("Feature 0x%x", val);
// - Feature
case 0xB0:
LOG("Feature 0x%x", val);
@@
-321,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;
// - 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;
_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;
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)
_AddItems(&local_state.Usages, local_state.UsageMin, val);
break;
// - Designators (Index into Physical report)
@@
-384,6
+407,7
@@
static void _AddItem(struct sHID_IntList *List, Uint32 Value)
List->Items = realloc( List->Items, List->Space * sizeof(List->Items[0]) );
}
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 ++;
}
List->Items[ List->nItems ] = Value;
List->nItems ++;
}
UCC
git Repository :: git.ucc.asn.au