Skip to content

Commit f40604d

Browse files
committed
TAB to space conversion
Done to consistently use space characters for whitespace. The current practice of using a mix of TAB and space leads to editor-dependent indentation.
1 parent 01bc7ae commit f40604d

File tree

1 file changed

+90
-90
lines changed

1 file changed

+90
-90
lines changed

src/HID/HID.cpp

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323

2424
HID_& HID()
2525
{
26-
static HID_ obj;
27-
return obj;
26+
static HID_ obj;
27+
return obj;
2828
}
2929

3030
int HID_::getInterface(uint8_t* interfaceCount)
3131
{
32-
*interfaceCount += 1; // uses 1
33-
HIDDescriptor hidInterface = {
34-
D_INTERFACE(pluggedInterface, 2, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE),
35-
D_HIDREPORT(descriptorSize),
36-
D_ENDPOINT(USB_ENDPOINT_IN(HID_TX), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x14),
32+
*interfaceCount += 1; // uses 1
33+
HIDDescriptor hidInterface = {
34+
D_INTERFACE(pluggedInterface, 2, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE),
35+
D_HIDREPORT(descriptorSize),
36+
D_ENDPOINT(USB_ENDPOINT_IN(HID_TX), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x14),
3737
D_ENDPOINT(USB_ENDPOINT_OUT(HID_RX), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x0A)
38-
};
39-
return USB_SendControl(0, &hidInterface, sizeof(hidInterface));
38+
};
39+
return USB_SendControl(0, &hidInterface, sizeof(hidInterface));
4040
}
4141

4242
// Since this function is not exposed in USBCore API, had to replicate here.
@@ -76,27 +76,27 @@ int HID_::getDescriptor(USBSetup& setup)
7676
}
7777
}
7878

79-
// Check if this is a HID Class Descriptor request
80-
if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
81-
if (HID_REPORT_DESCRIPTOR_TYPE != t) { return 0; }
82-
83-
// In a HID Class Descriptor wIndex cointains the interface number
84-
if (setup.wIndex != pluggedInterface) { return 0; }
85-
86-
int total = 0;
87-
HIDSubDescriptor* node;
88-
for (node = rootNode; node; node = node->next) {
89-
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
90-
if (res == -1)
91-
return -1;
92-
total += res;
93-
}
94-
95-
// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
96-
// due to the USB specs, but Windows and Linux just assumes its in report mode.
97-
protocol = HID_REPORT_PROTOCOL;
98-
99-
return total;
79+
// Check if this is a HID Class Descriptor request
80+
if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
81+
if (HID_REPORT_DESCRIPTOR_TYPE != t) { return 0; }
82+
83+
// In a HID Class Descriptor wIndex cointains the interface number
84+
if (setup.wIndex != pluggedInterface) { return 0; }
85+
86+
int total = 0;
87+
HIDSubDescriptor* node;
88+
for (node = rootNode; node; node = node->next) {
89+
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
90+
if (res == -1)
91+
return -1;
92+
total += res;
93+
}
94+
95+
// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
96+
// due to the USB specs, but Windows and Linux just assumes its in report mode.
97+
protocol = HID_REPORT_PROTOCOL;
98+
99+
return total;
100100
}
101101

102102
uint8_t HID_::getShortName(char *name)
@@ -111,27 +111,27 @@ uint8_t HID_::getShortName(char *name)
111111

112112
// default serial number
113113

114-
name[0] = 'H';
115-
name[1] = 'I';
116-
name[2] = 'D';
117-
name[3] = 'A' + (descriptorSize & 0x0F);
118-
name[4] = 'A' + ((descriptorSize >> 4) & 0x0F);
119-
return 5;
114+
name[0] = 'H';
115+
name[1] = 'I';
116+
name[2] = 'D';
117+
name[3] = 'A' + (descriptorSize & 0x0F);
118+
name[4] = 'A' + ((descriptorSize >> 4) & 0x0F);
119+
return 5;
120120
}
121121
}
122122

123123
void HID_::AppendDescriptor(HIDSubDescriptor *node)
124124
{
125-
if (!rootNode) {
126-
rootNode = node;
127-
} else {
128-
HIDSubDescriptor *current = rootNode;
129-
while (current->next) {
130-
current = current->next;
131-
}
132-
current->next = node;
133-
}
134-
descriptorSize += node->length;
125+
if (!rootNode) {
126+
rootNode = node;
127+
} else {
128+
HIDSubDescriptor *current = rootNode;
129+
while (current->next) {
130+
current = current->next;
131+
}
132+
current->next = node;
133+
}
134+
descriptorSize += node->length;
135135
}
136136

137137
int HID_::SetFeature(uint16_t id, const void* data, int len)
@@ -174,11 +174,11 @@ bool HID_::LockFeature(uint16_t id, bool lock) {
174174

175175
int HID_::SendReport(uint16_t id, const void* data, int len)
176176
{
177-
auto ret = USB_Send(HID_TX, &id, 1);
178-
if (ret < 0) return ret;
179-
auto ret2 = USB_Send(HID_TX | TRANSFER_RELEASE, data, len);
180-
if (ret2 < 0) return ret2;
181-
return ret + ret2;
177+
auto ret = USB_Send(HID_TX, &id, 1);
178+
if (ret < 0) return ret;
179+
auto ret2 = USB_Send(HID_TX | TRANSFER_RELEASE, data, len);
180+
if (ret2 < 0) return ret2;
181+
return ret + ret2;
182182
}
183183

184184
HIDReport* HID_::GetFeature(uint16_t id)
@@ -195,16 +195,16 @@ HIDReport* HID_::GetFeature(uint16_t id)
195195

196196
bool HID_::setup(USBSetup& setup)
197197
{
198-
if (pluggedInterface != setup.wIndex) {
199-
return false;
200-
}
198+
if (pluggedInterface != setup.wIndex) {
199+
return false;
200+
}
201201

202-
uint8_t request = setup.bRequest;
203-
uint8_t requestType = setup.bmRequestType;
202+
uint8_t request = setup.bRequest;
203+
uint8_t requestType = setup.bmRequestType;
204204

205-
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE)
206-
{
207-
if (request == HID_GET_REPORT) {
205+
if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE)
206+
{
207+
if (request == HID_GET_REPORT) {
208208

209209
if(setup.wValueH == HID_REPORT_TYPE_FEATURE)
210210
{
@@ -219,31 +219,31 @@ bool HID_::setup(USBSetup& setup)
219219
return false;
220220

221221
}
222-
return true;
223-
}
224-
if (request == HID_GET_PROTOCOL) {
225-
// TODO: Send8(protocol);
226-
return true;
227-
}
228-
if (request == HID_GET_IDLE) {
229-
// TODO: Send8(idle);
230-
}
231-
}
232-
233-
if (requestType == REQUEST_HOSTTODEVICE_CLASS_INTERFACE)
234-
{
235-
if (request == HID_SET_PROTOCOL) {
236-
// The USB Host tells us if we are in boot or report mode.
237-
// This only works with a real boot compatible device.
238-
protocol = setup.wValueL;
239-
return true;
240-
}
241-
if (request == HID_SET_IDLE) {
242-
idle = setup.wValueL;
243-
return true;
244-
}
245-
if (request == HID_SET_REPORT)
246-
{
222+
return true;
223+
}
224+
if (request == HID_GET_PROTOCOL) {
225+
// TODO: Send8(protocol);
226+
return true;
227+
}
228+
if (request == HID_GET_IDLE) {
229+
// TODO: Send8(idle);
230+
}
231+
}
232+
233+
if (requestType == REQUEST_HOSTTODEVICE_CLASS_INTERFACE)
234+
{
235+
if (request == HID_SET_PROTOCOL) {
236+
// The USB Host tells us if we are in boot or report mode.
237+
// This only works with a real boot compatible device.
238+
protocol = setup.wValueL;
239+
return true;
240+
}
241+
if (request == HID_SET_IDLE) {
242+
idle = setup.wValueL;
243+
return true;
244+
}
245+
if (request == HID_SET_REPORT)
246+
{
247247
if(setup.wValueH == HID_REPORT_TYPE_FEATURE)
248248
{
249249

@@ -259,24 +259,24 @@ bool HID_::setup(USBSetup& setup)
259259

260260
}
261261

262-
}
263-
}
262+
}
263+
}
264264

265-
return false;
265+
return false;
266266
}
267267

268268
HID_::HID_(void) : PluggableUSBModule(2, 1, epType),
269269
rootNode(NULL), descriptorSize(0),
270270
protocol(HID_REPORT_PROTOCOL), idle(1)
271271
{
272-
epType[0] = EP_TYPE_INTERRUPT_IN;
272+
epType[0] = EP_TYPE_INTERRUPT_IN;
273273
epType[1] = EP_TYPE_INTERRUPT_OUT;
274-
PluggableUSB().plug(this);
274+
PluggableUSB().plug(this);
275275
}
276276

277277
int HID_::begin(void)
278278
{
279-
return 0;
279+
return 0;
280280
}
281281

282282
#endif /* if defined(USBCON) */

0 commit comments

Comments
 (0)