Skip to content

Commit 93ece8d

Browse files
committed
Cleanup code style
1 parent 94f55a3 commit 93ece8d

File tree

4 files changed

+1092
-1092
lines changed

4 files changed

+1092
-1092
lines changed

src/Keyboard.cpp

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/*
2-
Keyboard.cpp
3-
4-
Copyright (c) 2015, Arduino LLC
5-
Original code (pre-library): Copyright (c) 2011, Peter Barrett
6-
Contributor: MRNIU
7-
8-
This library is free software; you can redistribute it and/or
9-
modify it under the terms of the GNU Lesser General Public
10-
License as published by the Free Software Foundation; either
11-
version 2.1 of the License, or (at your option) any later version.
12-
13-
This library is distributed in the hope that it will be useful,
14-
but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16-
Lesser General Public License for more details.
17-
18-
You should have received a copy of the GNU Lesser General Public
19-
License along with this library; if not, write to the Free Software
20-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2+
Keyboard.cpp
3+
4+
Copyright (c) 2015, Arduino LLC
5+
Original code (pre-library): Copyright (c) 2011, Peter Barrett
6+
Contributor: MRNIU
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2121
*/
2222

2323
#include "Keyboard.h"
@@ -29,44 +29,44 @@
2929
// Keyboard
3030

3131
static const uint8_t _hidReportDescriptor[] PROGMEM = {
32-
// Keyboard
33-
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 47 */
34-
0x09, 0x06, /* USAGE (Keyboard) */
35-
0xa1, 0x01, /* COLLECTION (Application) */
36-
0x85, HID_REPORTID_KEYBOARD, /* REPORT_ID TODO order important? */
37-
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
38-
39-
/* Keyboard Modifiers (shift, alt, ...) */
40-
0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */
41-
0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
42-
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
43-
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
44-
0x75, 0x01, /* REPORT_SIZE (1) */
45-
0x95, 0x08, /* REPORT_COUNT (8) */
46-
0x81, 0x02, /* INPUT (Data,Var,Abs) */
47-
48-
/* Reserved byte, used for consumer reports, only works with linux */
49-
0x05, 0x0C, /* Usage Page (Consumer) */
50-
0x95, 0x01, /* REPORT_COUNT (1) */
51-
0x75, 0x08, /* REPORT_SIZE (8) */
52-
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
53-
0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (255) */
54-
0x19, 0x00, /* USAGE_MINIMUM (0) */
55-
0x29, 0xFF, /* USAGE_MAXIMUM (255) */
56-
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
57-
58-
/* 6 Keyboard keys */
59-
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
60-
0x95, 0x06, /* REPORT_COUNT (6) */
61-
0x75, 0x08, /* REPORT_SIZE (8) */
62-
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
63-
0x26, 0xE7, 0x00, /* LOGICAL_MAXIMUM (231) */
64-
0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */
65-
0x29, 0xE7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
66-
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
67-
68-
/* End */
69-
0xc0 /* END_COLLECTION */
32+
// Keyboard
33+
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 47 */
34+
0x09, 0x06, /* USAGE (Keyboard) */
35+
0xa1, 0x01, /* COLLECTION (Application) */
36+
0x85, HID_REPORTID_KEYBOARD, /* REPORT_ID TODO order important? */
37+
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
38+
39+
/* Keyboard Modifiers (shift, alt, ...) */
40+
0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */
41+
0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
42+
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
43+
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
44+
0x75, 0x01, /* REPORT_SIZE (1) */
45+
0x95, 0x08, /* REPORT_COUNT (8) */
46+
0x81, 0x02, /* INPUT (Data,Var,Abs) */
47+
48+
/* Reserved byte, used for consumer reports, only works with linux */
49+
0x05, 0x0C, /* Usage Page (Consumer) */
50+
0x95, 0x01, /* REPORT_COUNT (1) */
51+
0x75, 0x08, /* REPORT_SIZE (8) */
52+
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
53+
0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (255) */
54+
0x19, 0x00, /* USAGE_MINIMUM (0) */
55+
0x29, 0xFF, /* USAGE_MAXIMUM (255) */
56+
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
57+
58+
/* 6 Keyboard keys */
59+
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
60+
0x95, 0x06, /* REPORT_COUNT (6) */
61+
0x75, 0x08, /* REPORT_SIZE (8) */
62+
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
63+
0x26, 0xE7, 0x00, /* LOGICAL_MAXIMUM (231) */
64+
0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */
65+
0x29, 0xE7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
66+
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
67+
68+
/* End */
69+
0xc0 /* END_COLLECTION */
7070
};
7171

7272
Keyboard_::Keyboard_(void)
@@ -159,26 +159,26 @@ uint8_t USBPutChar(uint8_t c);
159159
// call release(), releaseAll(), or otherwise clear the report and resend.
160160
size_t Keyboard_::press(uint8_t k)
161161
{
162-
// Press key and send report to host
163-
uint8_t i;
162+
// Press key and send report to host
163+
uint8_t i;
164164
auto ret = set((KeyboardKeycode)k, true);
165165
if(ret){
166-
sendReport(&_keyReport);
167-
return 1;
166+
sendReport(&_keyReport);
167+
return 1;
168168
}
169-
return 0;
169+
return 0;
170170
}
171171

172172
// release() takes the specified key out of the persistent key report and
173173
// sends the report. This tells the OS the key is no longer pressed and that
174174
// it shouldn't be repeated any more.
175175
size_t Keyboard_::release(uint8_t k)
176176
{
177-
uint8_t i;
177+
uint8_t i;
178178
auto ret = set((KeyboardKeycode)k, false);
179-
if(ret){
180-
sendReport(&_keyReport);
181-
return 1;
179+
if(ret){
180+
sendReport(&_keyReport);
181+
return 1;
182182
}
183183
return 0;
184184
}
@@ -197,19 +197,19 @@ void Keyboard_::releaseAll(void)
197197

198198
size_t Keyboard_::write(uint8_t c)
199199
{
200-
uint8_t p = press(c); // Keydown
201-
release(c); // Keyup
202-
return p; // just return the result of press() since release() almost always returns 1
200+
uint8_t p = press(c); // Keydown
201+
release(c); // Keyup
202+
return p; // just return the result of press() since release() almost always returns 1
203203
}
204204

205205
size_t Keyboard_::write(const uint8_t *buffer, size_t size) {
206206
size_t n = 0;
207207
while (size--) {
208208
if (*buffer != '\r') {
209209
if (write(*buffer)) {
210-
n++;
210+
n++;
211211
} else {
212-
break;
212+
break;
213213
}
214214
}
215215
buffer++;

src/Keyboard.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/*
2-
Keyboard.h
3-
4-
Copyright (c) 2015, Arduino LLC
5-
Original code (pre-library): Copyright (c) 2011, Peter Barrett
6-
Contributor: MRNIU
7-
8-
This library is free software; you can redistribute it and/or
9-
modify it under the terms of the GNU Lesser General Public
10-
License as published by the Free Software Foundation; either
11-
version 2.1 of the License, or (at your option) any later version.
12-
13-
This library is distributed in the hope that it will be useful,
14-
but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16-
Lesser General Public License for more details.
17-
18-
You should have received a copy of the GNU Lesser General Public
19-
License along with this library; if not, write to the Free Software
20-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2+
Keyboard.h
3+
4+
Copyright (c) 2015, Arduino LLC
5+
Original code (pre-library): Copyright (c) 2011, Peter Barrett
6+
Contributor: MRNIU
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2121
*/
2222

2323
#ifndef KEYBOARD_h
@@ -34,26 +34,26 @@
3434
// Low level key report: up to 6 keys and shift, ctrl etc at once
3535
typedef struct
3636
{
37-
uint8_t modifiers;
38-
uint8_t reserved;
39-
uint8_t keycodes[6];
37+
uint8_t modifiers;
38+
uint8_t reserved;
39+
uint8_t keycodes[6];
4040
} KeyReport;
4141

4242
class Keyboard_ : public Print
4343
{
4444
private:
45-
KeyReport _keyReport;
46-
void sendReport(KeyReport* keys);
47-
size_t set(KeyboardKeycode k, bool s);
45+
KeyReport _keyReport;
46+
void sendReport(KeyReport* keys);
47+
size_t set(KeyboardKeycode k, bool s);
4848
public:
49-
Keyboard_(void);
50-
void begin(void);
51-
void end(void);
52-
size_t write(uint8_t k);
53-
size_t write(const uint8_t *buffer, size_t size);
54-
size_t press(uint8_t k);
55-
size_t release(uint8_t k);
56-
void releaseAll(void);
49+
Keyboard_(void);
50+
void begin(void);
51+
void end(void);
52+
size_t write(uint8_t k);
53+
size_t write(const uint8_t *buffer, size_t size);
54+
size_t press(uint8_t k);
55+
size_t release(uint8_t k);
56+
void releaseAll(void);
5757
};
5858
extern Keyboard_ Keyboard;
5959

0 commit comments

Comments
 (0)