/* * USB keyboard/mouse constants */ typedef struct Chain Chain; typedef struct HidInterface HidInterface; typedef struct HidRepTempl HidRepTempl; enum { Stack = 32 * 1024, /* HID class subclass protocol ids */ PtrCSP = 0x020103, /* mouse.boot.hid */ KbdCSP = 0x010103, /* keyboard.boot.hid */ /* Requests */ Getreport = 1, Getidle = 2, Getproto = 3, Setreport = 9, Setidle = 0xa, Setproto = 0xb, /* protocols for SET_PROTO request */ Bootproto = 0, Reportproto = 1, /* report type for get/set report. or'd with reportid */ Reportin = 1<<8, Reportout = 2<<8, Reportfeat = 3<<8, /* report ids */ Ledreport = 0, /* unsure if this isn't just "no id" */ }; enum { /* led report bits. led report is 1 byte long */ Lnum = 1<<0, /* num lock led */ Lcaps = 1<<1, Lscroll = 1<<2, Lcompose = 1<<3, Lkana = 1<<4, }; enum { /* keyboard modifier bits */ Mlctrl = 0, Mlshift = 1, Mlalt = 2, Mlgui = 3, Mrctrl = 4, Mrshift = 5, Mralt = 6, Mrgui = 7, /* masks for byte[0] */ Mctrl = 1< 0) enum { KindPad = 0, KindButtons, KindX, KindY, KindWheel, MaxVals = 16, MaxIfc = 8, }; struct HidInterface { ulong v[MaxVals]; /* one ulong per val should be enough */ uchar kind[MaxVals]; int nbits; int count; }; struct HidRepTempl{ int id; /* id which may not be present */ uint sz; /* in bytes */ int nifcs; HidInterface ifcs[MaxIfc]; }; enum { /* report types */ HidReportApp = 0x01, HidTypeUsgPg = 0x05, HidPgButts = 0x09, HidTypeRepSz = 0x75, HidTypeCnt = 0x95, HidCollection = 0xa1, HidTypeUsg = 0x09, HidPtr = 0x01, HidX = 0x30, HidY = 0x31, HidZ = 0x32, HidWheel = 0x38, HidInput = 0x81, HidReportId = 0x85, HidReportIdPtr = 0x01, HidEnd = 0xc0, }; void dumpreport(HidRepTempl *templ); int hidifcval(HidRepTempl *templ, int kind, int n); int parsereport(HidRepTempl *templ, Chain *rep); int parsereportdesc(HidRepTempl *temp, uchar *repdesc, int repsz);