Skip to content

Commit 359af3f

Browse files
committed
moved hid descriptors hid file
1 parent a7d7f1a commit 359af3f

File tree

5 files changed

+34
-40
lines changed

5 files changed

+34
-40
lines changed

klib/usb/cdc/descriptor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace klib::usb::cdc::detail {
5454
const uint8_t bFunctionLength = sizeof(Base);
5555

5656
// descriptor type (CS_INTERFACE)
57-
const uint8_t bDescriptorType = 0x24;
57+
const descriptor::descriptor_type bDescriptorType = descriptor::descriptor_type::cs_interface;
5858

5959
// header functional descriptor subtype
6060
const uint8_t bDescriptorSubtype = static_cast<uint8_t>(SubType);

klib/usb/descriptor.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ namespace klib::usb::descriptor {
6565
interface_association = 11,
6666
bos = 15,
6767
device_capability = 16,
68+
cs_interface = 36,
69+
cs_endpoint = 37,
6870
superspeed_usb_endpoint_compainion = 48,
6971
};
7072

@@ -118,7 +120,7 @@ namespace klib::usb::descriptor {
118120
const uint8_t bLength = sizeof(device);
119121

120122
// descriptorType
121-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::device);
123+
const descriptor_type bDescriptionType = descriptor_type::device;
122124

123125
// usb specification number which device compies to
124126
uint16_t bcdUSB;
@@ -169,7 +171,7 @@ namespace klib::usb::descriptor {
169171
const uint8_t bLength = sizeof(configuration);
170172

171173
// descriptorType
172-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::configuration);
174+
const descriptor_type bDescriptionType = descriptor_type::configuration;
173175

174176
// total length in bytes of data returned
175177
uint16_t wTotalLength;
@@ -220,7 +222,7 @@ namespace klib::usb::descriptor {
220222
const uint8_t bLength = sizeof(string<Size>);
221223

222224
// descriptorType
223-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::string);
225+
const descriptor_type bDescriptionType = descriptor_type::string;
224226

225227
// unicode encoded string
226228
char16_t bString[Size];
@@ -239,7 +241,7 @@ namespace klib::usb::descriptor {
239241
const uint8_t bLength = sizeof(interface);
240242

241243
// descriptorType
242-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::interface);
244+
const descriptor_type bDescriptionType = descriptor_type::interface;
243245

244246
// number of interface
245247
uint8_t bInterfaceNumber;
@@ -277,7 +279,7 @@ namespace klib::usb::descriptor {
277279
const uint8_t bLength = sizeof(endpoint);
278280

279281
// descriptorType
280-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::endpoint);
282+
const descriptor_type bDescriptionType = descriptor_type::endpoint;
281283

282284
// endpoint address
283285
// b[0..3] = endpoint number
@@ -327,7 +329,7 @@ namespace klib::usb::descriptor {
327329
const uint8_t bLength = sizeof(qualifier);
328330

329331
// descriptorType
330-
const uint8_t bDescriptionType = static_cast<uint8_t>(descriptor_type::device_qualifier);
332+
const descriptor_type bDescriptionType = descriptor_type::device_qualifier;
331333

332334
// usb specification number which device compies to
333335
uint16_t bcdUSB;
@@ -362,7 +364,7 @@ namespace klib::usb::descriptor {
362364
const uint8_t bLength = sizeof(bos);
363365

364366
// the BOS descriptor type
365-
const uint8_t bDescriptorType = static_cast<uint8_t>(descriptor_type::bos);
367+
const descriptor_type bDescriptorType = descriptor_type::bos;
366368

367369
// the length of this descriptor and all of
368370
// its sub descriptors
@@ -386,7 +388,7 @@ namespace klib::usb::descriptor {
386388
const uint8_t bLength = sizeof(capability<T>);
387389

388390
// the device capability descriptor type
389-
const uint8_t bDescriptorType = static_cast<uint8_t>(descriptor_type::device_capability);
391+
const descriptor_type bDescriptorType = descriptor_type::device_capability;
390392

391393
// device capability type (valid values are
392394
// listed in table 9-11)
@@ -407,7 +409,7 @@ namespace klib::usb::descriptor {
407409
const uint8_t bLength = sizeof(interface_association);
408410

409411
// the device capability descriptor type
410-
const uint8_t bDescriptorType = static_cast<uint8_t>(descriptor_type::interface_association);
412+
const descriptor_type bDescriptorType = descriptor_type::interface_association;
411413

412414
// first interface number of the next
413415
// descriptor

klib/usb/device/keyboard.hpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ namespace klib::usb::device {
2323
serial = 3
2424
};
2525

26-
/**
27-
* @brief Class specific descriptors
28-
*
29-
*/
30-
enum class class_type {
31-
hid = 0x21,
32-
report = 0x22
33-
};
34-
3526
/**
3627
* @brief Class specific requests for the handle class packet function
3728
*
@@ -136,11 +127,11 @@ namespace klib::usb::device {
136127
.iInterface = 0x00
137128
},
138129
{
139-
.bDescriptorType = 0x21,
130+
.bDescriptorType = hid::class_type::hid,
140131
.bcdHID = 0x0110,
141132
.bCountryCode = 0x00,
142133
.bNumDescriptors = 0x01,
143-
.bClassDescriptorType = static_cast<uint8_t>(class_type::report),
134+
.bClassDescriptorType = hid::class_type::report,
144135
.wDescriptorLength = sizeof(report)
145136
},
146137
{
@@ -554,11 +545,11 @@ namespace klib::usb::device {
554545
}
555546

556547
// check if we have a class specific descriptor
557-
switch (static_cast<class_type>(type)) {
558-
case class_type::hid:
548+
switch (static_cast<hid::class_type>(type)) {
549+
case hid::class_type::hid:
559550
// return the hid descriptor only
560551
return to_description(config.hid, config.hid.bLength);
561-
case class_type::report:
552+
case hid::class_type::report:
562553
// return the raw report.
563554
return to_description(report, sizeof(report));
564555
default:

klib/usb/device/mouse.hpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ namespace klib::usb::device {
2323
serial = 3
2424
};
2525

26-
/**
27-
* @brief Class specific descriptors
28-
*
29-
*/
30-
enum class class_type {
31-
hid = 0x21,
32-
report = 0x22
33-
};
34-
3526
/**
3627
* @brief Class specific requests for the handle class packet function
3728
*
@@ -137,11 +128,11 @@ namespace klib::usb::device {
137128
.iInterface = 0x00
138129
},
139130
{
140-
.bDescriptorType = 0x21,
131+
.bDescriptorType = hid::class_type::hid,
141132
.bcdHID = 0x0110,
142133
.bCountryCode = 0x00,
143134
.bNumDescriptors = 0x01,
144-
.bClassDescriptorType = static_cast<uint8_t>(class_type::report),
135+
.bClassDescriptorType = hid::class_type::report,
145136
.wDescriptorLength = sizeof(report)
146137
},
147138
{
@@ -389,11 +380,11 @@ namespace klib::usb::device {
389380
}
390381

391382
// check if we have a class specific descriptor
392-
switch (static_cast<class_type>(type)) {
393-
case class_type::hid:
383+
switch (static_cast<hid::class_type>(type)) {
384+
case hid::class_type::hid:
394385
// return the hid descriptor only
395386
return to_description(config.hid, config.hid.bLength);
396-
case class_type::report:
387+
case hid::class_type::report:
397388
// return the raw report.
398389
return to_description(report, sizeof(report));
399390
default:

klib/usb/hid/descriptor.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
#pragma pack(push, 1)
99

1010
namespace klib::usb::hid {
11+
/**
12+
* @brief Class specific descriptors
13+
*
14+
*/
15+
enum class class_type: uint8_t {
16+
hid = 0x21,
17+
report = 0x22,
18+
pyhisical = 0x23
19+
};
20+
1121
/**
1222
* @brief Hid device descriptor
1323
*
@@ -17,7 +27,7 @@ namespace klib::usb::hid {
1727
const uint8_t bLength = sizeof(descriptor);
1828

1929
// descriptor type
20-
uint8_t bDescriptorType;
30+
class_type bDescriptorType;
2131

2232
// Hid class specification number which device complies to
2333
uint16_t bcdHID;
@@ -29,7 +39,7 @@ namespace klib::usb::hid {
2939
uint8_t bNumDescriptors;
3040

3141
// report descriptor type
32-
uint8_t bClassDescriptorType;
42+
class_type bClassDescriptorType;
3343

3444
// total length of the report descriptor
3545
uint16_t wDescriptorLength;

0 commit comments

Comments
 (0)