Modules/USB HID - Shell USB Keyboard
[tpg/acess2.git] / KernelLand / Modules / USB / HID / keyboard.c
1 /*
2  * Acess2 USB Stack HID Driver
3  * - By John Hodge (thePowersGang)
4  *
5  * keyboard.c
6  * - Keyboard translation
7  */
8 #define DEBUG   0
9 #include <fs_devfs.h>
10 #include <Input/Keyboard/include/keyboard.h>
11
12 typedef struct sUSB_Keyboard    tUSB_Keyboard;
13
14 // === STRUCTURES ===
15 struct sUSB_Keyboard
16 {
17         tKeyboard *Info;
18 };
19
20 // === PROTOTYPES ===
21 void    HID_Kb_DataAvail(tUSBInterface *Dev, int EndPt, int Length, void *Data);
22
23 tHID_ReportCallbacks    *HID_Kb_Report_Collection(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value);
24 void    HID_Kb_Report_EndCollection(tUSBInterface *Dev);
25 void    HID_Kb_Report_Input(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value);
26
27 // === GLOBALS ===
28 tHID_ReportCallbacks    gHID_Kb_ReportCBs = {
29         .Collection = HID_Kb_Report_Collection,
30         .EndCollection = HID_Kb_Report_EndCollection,
31         .Input = HID_Kb_Report_Input
32 };
33
34 // === CODE ===
35 void HID_Kb_DataAvail(tUSBInterface *Dev, int EndPt, int Length, void *Data)
36 {
37         
38 }
39
40 // --- ---
41 tHID_ReportCallbacks *HID_Kb_Report_Collection(
42         tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local,
43         Uint32 Value
44         )
45 {
46         tUSB_Keyboard   *info;
47         
48         info = USB_GetDeviceDataPtr(Dev);
49         if( !info )
50         {
51                 info = malloc( sizeof(tUSB_Keyboard) );
52                 USB_SetDeviceDataPtr(Dev, info);
53                 info->Keyboard = NULL;
54                 info->CollectionDepth = 1;
55         }
56         else
57         {
58                 info->CollectionDepth ++;
59         }
60
61         return &gHID_Kb_ReportCBs;
62 }
63
64 void HID_Kb_Report_EndCollection(tUSBInterface *Dev)
65 {
66         tUSB_Keyboard   *info;
67         
68         info = USB_GetDeviceDataPtr(Dev);
69         if( !info )     return ;
70         
71         info->CollectionDepth --;
72         if( info->CollectionDepth == 0 )
73         {
74                 info->Keyboard = Keyboard_CreateInstance(0, "USBKeyboard");
75         }
76 }
77
78 void HID_Kb_Report_Input(tUSBInterface *Dev, tHID_ReportGlobalState *Global, tHID_ReportLocalState *Local, Uint32 Value)
79 {
80
81 }
82

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