USB Host Shield 2.0
Loading...
Searching...
No Matches
hiduniversal.h
Go to the documentation of this file.
1/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3This software may be distributed and modified under the terms of the GNU
4General Public License version 2 (GPL2) as published by the Free Software
5Foundation and appearing in the file GPL2.TXT included in the packaging of
6this file. Please note that GPL2 Section 2[b] requires that all works based
7on this software must also be made publicly available under the terms of
8the GPL2 ("Copyleft").
9
10Contact information
11-------------------
12
13Circuits At Home, LTD
14Web : http://www.circuitsathome.com
15e-mail : support@circuitsathome.com
16 */
17
18#if !defined(__HIDUNIVERSAL_H__)
19#define __HIDUNIVERSAL_H__
20
21#include "hidcomposite.h"
22
23class HIDUniversal : public HIDComposite {
24
25 bool SelectInterface(uint8_t iface __attribute__((unused)), uint8_t proto __attribute__((unused))) final {
26 // the original HIDUniversal didn't have this at all so make it a no-op
27 // (and made it final so users don't override this - if they want to use
28 // SelectInterface() they should be deriving from HIDComposite directly)
29 return true;
30 }
31
32 void ParseHIDData(USBHID *hid, uint8_t ep __attribute__((unused)), bool is_rpt_id, uint8_t len, uint8_t *buf) final {
33 // override the HIDComposite version of this method to call the HIDUniversal version
34 // (which doesn't use the endpoint), made it final to make sure users
35 // of HIDUniversal override the right version of ParseHIDData() (the other one, below)
36 ParseHIDData(hid, is_rpt_id, len, buf);
37 }
38
39protected:
40 virtual void ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) {
41 return;
42 }
43
44public:
46
47 uint8_t Poll() override;
48
49 // UsbConfigXtracter implementation
51 {
52 // If the first configuration satisfies, the others are not considered.
53 if(bNumEP > 1 && conf != bConfNum)
54 return;
55 // otherwise HIDComposite does what HIDUniversal needs
57 }
58};
59
60#endif // __HIDUNIVERSAL_H__
uint8_t bConfNum
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
uint8_t bNumEP
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) override
virtual void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
uint8_t Poll() override
HIDUniversal(USB *p)
Definition UsbCore.h:220