Skip to content

Commit 4850f09

Browse files
committed
add platformio example
1 parent a9f5827 commit 4850f09

File tree

6 files changed

+868
-0
lines changed

6 files changed

+868
-0
lines changed

examples/mad-mouse/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
TARGET := usbasp
2+
3+
all: src/main.cpp
4+
platformio run -e $(TARGET)
5+
6+
install: .pioenvs/$(TARGET)/firmware.hex
7+
platformio run --target upload -e $(TARGET)
8+
9+
clean:
10+
platformio run --target clean -e $(TARGET)
11+
12+
com:
13+
platformio device monitor -b 115200
14+
15+
init:
16+
platformio init --board $(TARGET)
17+
18+
.PHONY: clean

examples/mad-mouse/platformio.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter, extra scripting
4+
; Upload options: custom port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
;
7+
; Please visit documentation for the other options and examples
8+
; http://docs.platformio.org/en/stable/projectconf.html
9+
10+
[env:usbasp]
11+
platform = atmelavr
12+
board = usbasp
13+
framework = arduino
14+
build_flags = -I lib
15+
lib_deps =
16+
v-usb

examples/mad-mouse/src/hid.h

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
//------------------------------------------------------------------------------
2+
// HID constants
3+
//
4+
// LICENCE: http://opensource.org/licenses/MIT
5+
// Vladimir Dronnikov <dronnikov@gmail.com>
6+
//
7+
// Thanks https://github.com/adafruit
8+
//------------------------------------------------------------------------------
9+
10+
#ifndef __hid_h_included__
11+
#define __hid_h_included__
12+
13+
// use these masks with the "move" function
14+
#define MOUSEBTN_LEFT_MASK 0x01
15+
#define MOUSEBTN_RIGHT_MASK 0x02
16+
#define MOUSEBTN_MIDDLE_MASK 0x04
17+
18+
// LED state masks
19+
#define KB_LED_NUM 0x01
20+
#define KB_LED_CAPS 0x02
21+
#define KB_LED_SCROLL 0x04
22+
23+
// some convenience definitions for modifier keys
24+
#define KEYCODE_MOD_LEFT_CONTROL 0x01
25+
#define KEYCODE_MOD_LEFT_SHIFT 0x02
26+
#define KEYCODE_MOD_LEFT_ALT 0x04
27+
#define KEYCODE_MOD_LEFT_GUI 0x08
28+
#define KEYCODE_MOD_RIGHT_CONTROL 0x10
29+
#define KEYCODE_MOD_RIGHT_SHIFT 0x20
30+
#define KEYCODE_MOD_RIGHT_ALT 0x40
31+
#define KEYCODE_MOD_RIGHT_GUI 0x80
32+
33+
// some more keycodes
34+
#define KEYCODE_LEFT_CONTROL 0xE0
35+
#define KEYCODE_LEFT_SHIFT 0xE1
36+
#define KEYCODE_LEFT_ALT 0xE2
37+
#define KEYCODE_LEFT_GUI 0xE3
38+
#define KEYCODE_RIGHT_CONTROL 0xE4
39+
#define KEYCODE_RIGHT_SHIFT 0xE5
40+
#define KEYCODE_RIGHT_ALT 0xE6
41+
#define KEYCODE_RIGHT_GUI 0xE7
42+
#define KEYCODE_1 0x1E
43+
#define KEYCODE_2 0x1F
44+
#define KEYCODE_3 0x20
45+
#define KEYCODE_4 0x21
46+
#define KEYCODE_5 0x22
47+
#define KEYCODE_6 0x23
48+
#define KEYCODE_7 0x24
49+
#define KEYCODE_8 0x25
50+
#define KEYCODE_9 0x26
51+
#define KEYCODE_0 0x27
52+
#define KEYCODE_A 0x04
53+
#define KEYCODE_B 0x05
54+
#define KEYCODE_C 0x06
55+
#define KEYCODE_D 0x07
56+
#define KEYCODE_E 0x08
57+
#define KEYCODE_F 0x09
58+
#define KEYCODE_G 0x0A
59+
#define KEYCODE_H 0x0B
60+
#define KEYCODE_I 0x0C
61+
#define KEYCODE_J 0x0D
62+
#define KEYCODE_K 0x0E
63+
#define KEYCODE_L 0x0F
64+
#define KEYCODE_M 0x10
65+
#define KEYCODE_N 0x11
66+
#define KEYCODE_O 0x12
67+
#define KEYCODE_P 0x13
68+
#define KEYCODE_Q 0x14
69+
#define KEYCODE_R 0x15
70+
#define KEYCODE_S 0x16
71+
#define KEYCODE_T 0x17
72+
#define KEYCODE_U 0x18
73+
#define KEYCODE_V 0x19
74+
#define KEYCODE_W 0x1A
75+
#define KEYCODE_X 0x1B
76+
#define KEYCODE_Y 0x1C
77+
#define KEYCODE_Z 0x1D
78+
#define KEYCODE_COMMA 0x36
79+
#define KEYCODE_PERIOD 0x37
80+
#define KEYCODE_MINUS 0x2D
81+
#define KEYCODE_EQUAL 0x2E
82+
#define KEYCODE_BACKSLASH 0x31
83+
#define KEYCODE_SQBRAK_LEFT 0x2F
84+
#define KEYCODE_SQBRAK_RIGHT 0x30
85+
#define KEYCODE_SLASH 0x38
86+
#define KEYCODE_F1 0x3A
87+
#define KEYCODE_F2 0x3B
88+
#define KEYCODE_F3 0x3C
89+
#define KEYCODE_F4 0x3D
90+
#define KEYCODE_F5 0x3E
91+
#define KEYCODE_F6 0x3F
92+
#define KEYCODE_F7 0x40
93+
#define KEYCODE_F8 0x41
94+
#define KEYCODE_F9 0x42
95+
#define KEYCODE_F10 0x43
96+
#define KEYCODE_F11 0x44
97+
#define KEYCODE_F12 0x45
98+
#define KEYCODE_APP 0x65
99+
#define KEYCODE_ENTER 0x28
100+
#define KEYCODE_BACKSPACE 0x2A
101+
#define KEYCODE_ESC 0x29
102+
#define KEYCODE_TAB 0x2B
103+
#define KEYCODE_SPACE 0x2C
104+
#define KEYCODE_INSERT 0x49
105+
#define KEYCODE_HOME 0x4A
106+
#define KEYCODE_PAGE_UP 0x4B
107+
#define KEYCODE_DELETE 0x4C
108+
#define KEYCODE_END 0x4D
109+
#define KEYCODE_PAGE_DOWN 0x4E
110+
#define KEYCODE_PRINTSCREEN 0x46
111+
#define KEYCODE_ARROW_RIGHT 0x4F
112+
#define KEYCODE_ARROW_LEFT 0x50
113+
#define KEYCODE_ARROW_DOWN 0x51
114+
#define KEYCODE_ARROW_UP 0x52
115+
116+
// multimedia keys
117+
#define MMKEY_KB_VOL_UP 0x80 // do not use
118+
#define MMKEY_KB_VOL_DOWN 0x81 // do not use
119+
#define MMKEY_VOL_UP 0xE9
120+
#define MMKEY_VOL_DOWN 0xEA
121+
#define MMKEY_SCAN_NEXT_TRACK 0xB5
122+
#define MMKEY_SCAN_PREV_TRACK 0xB6
123+
#define MMKEY_STOP 0xB7
124+
#define MMKEY_PLAYPAUSE 0xCD
125+
#define MMKEY_MUTE 0xE2
126+
#define MMKEY_BASSBOOST 0xE5
127+
#define MMKEY_LOUDNESS 0xE7
128+
#define MMKEY_KB_EXECUTE 0x74
129+
#define MMKEY_KB_HELP 0x75
130+
#define MMKEY_KB_MENU 0x76
131+
#define MMKEY_KB_SELECT 0x77
132+
#define MMKEY_KB_STOP 0x78
133+
#define MMKEY_KB_AGAIN 0x79
134+
#define MMKEY_KB_UNDO 0x7A
135+
#define MMKEY_KB_CUT 0x7B
136+
#define MMKEY_KB_COPY 0x7C
137+
#define MMKEY_KB_PASTE 0x7D
138+
#define MMKEY_KB_FIND 0x7E
139+
#define MMKEY_KB_MUTE 0x7F // do not use
140+
141+
// system control keys
142+
#define SYSCTRLKEY_POWER 0x01
143+
#define SYSCTRLKEY_SLEEP 0x02
144+
#define SYSCTRLKEY_WAKE 0x03
145+
146+
#endif /* __hid_h_included__ */

0 commit comments

Comments
 (0)