Mercurial > louis > kiibohd-controller
annotate main.c @ 15:8b6ef979a50e
Seems to be compiling now...finally after many months.
author | Jacob Alexander <triplehaata@gmail.com> |
---|---|
date | Wed, 07 Sep 2011 18:04:06 -0700 |
parents | 31e2022f06a0 |
children | f74b797ac060 |
rev | line source |
---|---|
0 | 1 /* Copyright (C) 2011 by Jacob Alexander |
2 * | |
3 * Permission is hereby granted, free of charge, to any person obtaining a copy | |
4 * of this software and associated documentation files (the "Software"), to deal | |
5 * in the Software without restriction, including without limitation the rights | |
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
7 * copies of the Software, and to permit persons to whom the Software is | |
8 * furnished to do so, subject to the following conditions: | |
9 * | |
10 * The above copyright notice and this permission notice shall be included in | |
11 * all copies or substantial portions of the Software. | |
12 * | |
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
19 * THE SOFTWARE. | |
20 */ | |
21 | |
22 #include <avr/io.h> | |
23 #include <avr/pgmspace.h> | |
24 #include <avr/interrupt.h> | |
25 #include <util/delay.h> | |
10
f35ea5de4456
Adding all of the USB keycodes, and proper key ordering.
Jacob Alexander <triplehaata@gmail.com>
parents:
9
diff
changeset
|
26 #include "usb_keys.h" |
12
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
27 #include "layouts.h" |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
28 //#include "usb_keyboard.h" |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
29 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
30 // TEMP INCLUDES |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
31 #include "usb_keyboard_debug.h" |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
32 #include <print.h> |
0 | 33 |
34 #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) | |
35 | |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
36 // Number of keys |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
37 #define KEYBOARD_SIZE 63 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
38 #define KEYPAD_SIZE 16 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
39 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
40 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
41 // Debouncing Defines |
13
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
42 #define SAMPLE_THRESHOLD 110 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
43 #define MAX_SAMPLES 127 // Max is 127, reaching 128 is very bad |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
44 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
45 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
46 // Verified Keypress Defines |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
47 #define USB_TRANSFER_DIVIDER 10 // 1024 == 1 Send of keypresses per second, 1 == 1 Send of keypresses per ~1 millisecond |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
48 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
49 |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
50 // Drive Pin Defines |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
51 #define DRIVE_reg_1 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
52 #define DRIVE_reg_2 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
53 #define DRIVE_reg_3 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
54 #define DRIVE_reg_4 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
55 #define DRIVE_reg_5 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
56 #define DRIVE_reg_6 PORTD |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
57 #define DRIVE_reg_7 PORTE |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
58 #define DRIVE_reg_8 PORTE |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
59 #define DRIVE_reg_9 PORTE |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
60 #define DRIVE_reg_10 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
61 #define DRIVE_reg_11 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
62 #define DRIVE_reg_12 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
63 |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
64 #define DRIVE_pin_1 2 |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
65 #define DRIVE_pin_2 3 |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
66 #define DRIVE_pin_3 4 |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
67 #define DRIVE_pin_4 5 |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
68 #define DRIVE_pin_5 6 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
69 #define DRIVE_pin_6 7 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
70 #define DRIVE_pin_7 0 |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
71 #define DRIVE_pin_8 1 |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
72 #define DRIVE_pin_9 6 |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
73 #define DRIVE_pin_10 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
74 #define DRIVE_pin_11 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
75 #define DRIVE_pin_12 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
76 |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
77 // Detect Pin/Group Defines |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
78 #define DETECT_group_1 1 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
79 #define DETECT_group_2 2 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
80 #define DETECT_group_3 3 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
81 #define DETECT_group_4 4 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
82 #define DETECT_group_5 5 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
83 #define DETECT_group_6 6 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
84 #define DETECT_group_7 7 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
85 #define DETECT_group_8 8 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
86 #define DETECT_group_9 9 |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
87 #define DETECT_group_10 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
88 #define DETECT_group_11 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
89 #define DETECT_group_12 <blank> |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
90 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
91 #define DETECT_group_size_1 7 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
92 #define DETECT_group_size_2 7 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
93 #define DETECT_group_size_3 6 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
94 #define DETECT_group_size_4 8 |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
95 #define DETECT_group_size_5 7 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
96 #define DETECT_group_size_6 7 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
97 #define DETECT_group_size_7 8 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
98 #define DETECT_group_size_8 8 |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
99 #define DETECT_group_size_9 4 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
100 #define DETECT_group_size_10 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
101 #define DETECT_group_size_11 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
102 #define DETECT_group_size_12 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
103 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
104 // Switch Codes |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
105 #define DETECT_group_array_1 {55,22,6 ,40,43,27,11} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
106 #define DETECT_group_array_2 {56,23,7 ,41,58,26,10} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
107 #define DETECT_group_array_3 {57,24,8 ,42,25,9} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
108 #define DETECT_group_array_4 {54,21,5 ,39,44,28,12,59} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
109 #define DETECT_group_array_5 {53,20,4 ,38,45,29,13} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
110 #define DETECT_group_array_6 {52,19,3 ,37,46,30,14} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
111 #define DETECT_group_array_7 {51,18,2 ,36,61,31,15,63} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
112 #define DETECT_group_array_8 {50,17,1 ,35,47,32,16,62} |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
113 #define DETECT_group_array_9 {48,49,33,34} // 49/60 are the same line |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
114 #define DETECT_group_array_10 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
115 #define DETECT_group_array_11 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
116 #define DETECT_group_array_12 <blank> |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
117 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
118 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
119 |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
120 // Drive Macros (Generally don't need to be changed), except for maybe DRIVE_DETECT |
14
31e2022f06a0
Correcting debounce issues.
Jacob Alexander <triplehaata@gmail.com>
parents:
13
diff
changeset
|
121 // Sleep is for signal debouncing |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
122 #define DRIVE_DETECT(reg,pin,group) \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
123 reg &= ~(1 << pin); \ |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
124 detection(group); \ |
14
31e2022f06a0
Correcting debounce issues.
Jacob Alexander <triplehaata@gmail.com>
parents:
13
diff
changeset
|
125 reg |= (1 << pin); \ |
31e2022f06a0
Correcting debounce issues.
Jacob Alexander <triplehaata@gmail.com>
parents:
13
diff
changeset
|
126 _delay_us(1); |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
127 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
128 #define DD_CASE(number) \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
129 case number:\ |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
130 DRIVE_DETECT(DRIVE_reg_##number, DRIVE_pin_##number, DETECT_group_##number) |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
131 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
132 #define DD_CASE_ORD(number) \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
133 DD_CASE(number) \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
134 break; |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
135 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
136 #define DD_CASE_END(number,var) \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
137 DD_CASE(number) \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
138 var = -1; \ |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
139 break; |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
140 |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
141 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
142 // Updates the current detection sample and last sample bit |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
143 // Detection Macros (Probably don't need to be changed, but depending the matrix, may have to be) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
144 // Determine if key is either normal or a modifier |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
145 #define DET_GROUP_CHECK(index,test) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
146 if ( test ) { \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
147 keyDetectArray[groupArray[index]]++; \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
148 } |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
149 |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
150 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
151 // XXX - Detection Groups |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
152 // Checks each of the specified pins, and then if press detected, determine if the key is normal or a modifier |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
153 // Inverse logic applies for the PINs |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
154 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
155 // Used for 1 detection group (Special group) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
156 #define DET_GROUP_1 \ |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
157 DET_GROUP_CHECK(0,!( PINB & (1 << 7) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
158 DET_GROUP_CHECK(1,!( PINC & (1 << 0) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
159 DET_GROUP_CHECK(2,!( PIND & (1 << 0) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
160 DET_GROUP_CHECK(3,!( PIND & (1 << 1) )) \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
161 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
162 // Used for 4 detection groups (Skips J1 P9) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
163 #define DET_GROUP_2 \ |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
164 DET_GROUP_CHECK(0,!( PINE & (1 << 7) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
165 DET_GROUP_CHECK(1,!( PINB & (1 << 0) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
166 DET_GROUP_CHECK(2,!( PINB & (1 << 1) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
167 DET_GROUP_CHECK(3,!( PINB & (1 << 2) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
168 DET_GROUP_CHECK(4,!( PINB & (1 << 3) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
169 DET_GROUP_CHECK(5,!( PINB & (1 << 4) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
170 DET_GROUP_CHECK(6,!( PINB & (1 << 5) )) \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
171 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
172 // Used for 1 detection group (Skips J1 P6 and J1 P9) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
173 #define DET_GROUP_3 \ |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
174 DET_GROUP_CHECK(0,!( PINE & (1 << 7) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
175 DET_GROUP_CHECK(1,!( PINB & (1 << 0) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
176 DET_GROUP_CHECK(2,!( PINB & (1 << 1) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
177 DET_GROUP_CHECK(3,!( PINB & (1 << 2) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
178 DET_GROUP_CHECK(4,!( PINB & (1 << 4) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
179 DET_GROUP_CHECK(5,!( PINB & (1 << 5) )) \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
180 |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
181 // Used for 3 detection groups (No skips, except special group 1) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
182 #define DET_GROUP_4 \ |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
183 DET_GROUP_CHECK(0,!( PINE & (1 << 7) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
184 DET_GROUP_CHECK(1,!( PINB & (1 << 0) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
185 DET_GROUP_CHECK(2,!( PINB & (1 << 1) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
186 DET_GROUP_CHECK(3,!( PINB & (1 << 2) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
187 DET_GROUP_CHECK(4,!( PINB & (1 << 3) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
188 DET_GROUP_CHECK(5,!( PINB & (1 << 4) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
189 DET_GROUP_CHECK(6,!( PINB & (1 << 5) )) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
190 DET_GROUP_CHECK(7,!( PINB & (1 << 6) )) \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
191 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
192 // Combines the DET_GROUP_Xs above for the given groupArray |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
193 #define DET_GROUP(group,det_group) \ |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
194 case group: \ |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
195 { \ |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
196 uint8_t groupArray[DETECT_group_size_##group] = DETECT_group_array_##group; \ |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
197 _delay_us(1); \ |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
198 DET_GROUP_##det_group \ |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
199 } \ |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
200 break; |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
201 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
202 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
203 // Loop over all of the sampled keys of the given array |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
204 // If the number of samples is higher than the sample threshold, flag the high bit, clear otherwise |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
205 // This should be resetting VERY quickly, cutting off a potentially valid keypress is not an issue |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
206 #define DEBOUNCE_ASSESS(table,size) \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
207 for ( uint8_t key = 1; key < size + 1; key++ ) {\ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
208 table[key] = ( table[key] & ~(1 << 7) ) > SAMPLE_THRESHOLD ? (1 << 7) : 0x00; \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
209 } \ |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
210 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
211 |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
212 // Keypad detection |
8
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
213 // Each switch has it's own detection line, inverse logic |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
214 #define KEYPAD_DETECT(test,switch_code) \ |
8
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
215 if ( !(test) ) { \ |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
216 keypadDetectArray[switch_code]++; \ |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
217 } \ |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
218 |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
219 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
220 // NOTE: Highest Bit: Valid keypress (0x80 is valid keypress) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
221 // Other Bits: Pressed state sample counter |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
222 uint8_t keyDetectArray[KEYBOARD_SIZE + 1]; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
223 uint8_t keypadDetectArray[KEYPAD_SIZE + 1]; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
224 |
12
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
225 // Interrupt Variables |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
226 uint16_t sendKeypressCounter = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
227 volatile uint8_t sendKeypresses = 0; |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
228 |
11
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
229 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
230 void detection( int group ) |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
231 { |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
232 // XXX Modify for different detection groups <-> groupArray mappings |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
233 switch ( group ) { |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
234 DET_GROUP(1,2) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
235 DET_GROUP(2,2) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
236 DET_GROUP(3,3) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
237 DET_GROUP(4,4) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
238 DET_GROUP(5,2) |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
239 DET_GROUP(6,2) |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
240 DET_GROUP(7,4) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
241 DET_GROUP(8,4) |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
242 DET_GROUP(9,1) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
243 } |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
244 } |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
245 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
246 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
247 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
248 // XXX This part is configurable |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
249 inline void pinSetup(void) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
250 { |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
251 // For each pin, 0=input, 1=output |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
252 DDRA = 0x00; |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
253 DDRB = 0x00; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
254 DDRC = 0x00; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
255 DDRD = 0xFC; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
256 DDRE = 0x43; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
257 DDRF = 0x00; |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
258 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
259 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
260 // Setting pins to either high or pull-up resistor |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
261 PORTA = 0xFF; |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
262 PORTB = 0xFF; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
263 PORTC = 0x01; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
264 PORTD = 0xFF; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
265 PORTE = 0xC3; |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
266 PORTF = 0xFF; |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
267 } |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
268 |
10
f35ea5de4456
Adding all of the USB keycodes, and proper key ordering.
Jacob Alexander <triplehaata@gmail.com>
parents:
9
diff
changeset
|
269 // Given a sampling array, and the current number of detected keypress |
f35ea5de4456
Adding all of the USB keycodes, and proper key ordering.
Jacob Alexander <triplehaata@gmail.com>
parents:
9
diff
changeset
|
270 // Add as many keypresses from the sampling array to the USB key send array as possible. |
11
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
271 void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys, uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map ) { |
9
102b7ec2ce6b
Adding array sizes (fixing the extra key problem)
Jacob Alexander <triplehaata@gmail.com>
parents:
8
diff
changeset
|
272 for ( uint8_t key = 0; key < numberOfKeys + 1; key++ ) { |
8
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
273 if ( keys[key] & (1 << 7) ) { |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
274 pint8( key ); |
15
8b6ef979a50e
Seems to be compiling now...finally after many months.
Jacob Alexander <triplehaata@gmail.com>
parents:
14
diff
changeset
|
275 //print(" "); |
11
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
276 uint8_t modFound = 0; |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
277 |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
278 // Determine if the key is a modifier |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
279 for ( uint8_t mod = 0; mod < numberOfModifiers; mod++ ) { |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
280 // Modifier found |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
281 if ( modifiers[mod] == key ) { |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
282 keyboard_modifier_keys |= map[key]; |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
283 modFound = 1; |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
284 break; |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
285 } |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
286 } |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
287 if ( modFound ) |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
288 continue; |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
289 |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
290 // Too many keys |
8
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
291 if ( *validKeys == 6 ) |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
292 break; |
13
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
293 |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
294 // Allow ignoring keys with 0's |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
295 if ( map[key] != 0 ) |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
296 keyboard_keys[(*validKeys)++] = map[key]; |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
297 } |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
298 } |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
299 } |
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
300 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
301 int main( void ) |
0 | 302 { |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
303 // Setup with 16 MHz clock |
0 | 304 CPU_PRESCALE( 0 ); |
305 | |
306 // Configuring Pins | |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
307 pinSetup(); |
0 | 308 |
309 // Initialize the USB, and then wait for the host to set configuration. | |
310 // If the Teensy is powered without a PC connected to the USB port, | |
311 // this will wait forever. | |
312 usb_init(); | |
313 while ( !usb_configured() ) /* wait */ ; | |
314 | |
315 // Wait an extra second for the PC's operating system to load drivers | |
316 // and do whatever it does to actually be ready for input | |
317 _delay_ms(1000); | |
318 | |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
319 // Setup ISR Timer for flagging a kepress send to USB |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
320 // Set to 256 * 1024 (8 bit timer with Clock/1024 prescalar) timer |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
321 TCCR0A = 0x00; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
322 TCCR0B = 0x03; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
323 TIMSK0 = (1 << TOIE0); |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
324 |
0 | 325 // Main Detection Loop |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
326 int8_t group = 1; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
327 uint8_t count = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
328 for ( ;;group++ ) { |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
329 // XXX Change number of ORDs if number of lines (RowsxColumns) differ |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
330 // Determine which keys are being pressed |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
331 switch ( group ) { |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
332 DD_CASE_ORD(1) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
333 DD_CASE_ORD(2) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
334 DD_CASE_ORD(3) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
335 DD_CASE_ORD(4) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
336 DD_CASE_ORD(5) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
337 DD_CASE_ORD(6) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
338 DD_CASE_ORD(7) |
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
339 DD_CASE_ORD(8) |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
340 DD_CASE_END(9,group) |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
341 } |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
342 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
343 // Check all Keyboard keys first |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
344 if ( group != -1 ) |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
345 continue; |
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
346 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
347 // Check Keypad keys |
8
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
348 KEYPAD_DETECT(PINA & (1 << 0),11) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
349 KEYPAD_DETECT(PINA & (1 << 1),3) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
350 KEYPAD_DETECT(PINA & (1 << 2),7) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
351 KEYPAD_DETECT(PINA & (1 << 3),4) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
352 KEYPAD_DETECT(PINA & (1 << 4),15) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
353 KEYPAD_DETECT(PINA & (1 << 5),6) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
354 KEYPAD_DETECT(PINA & (1 << 6),2) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
355 KEYPAD_DETECT(PINA & (1 << 7),10) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
356 KEYPAD_DETECT(PINF & (1 << 0),8) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
357 KEYPAD_DETECT(PINF & (1 << 1),12) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
358 KEYPAD_DETECT(PINF & (1 << 2),16) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
359 KEYPAD_DETECT(PINF & (1 << 3),13) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
360 KEYPAD_DETECT(PINF & (1 << 4),1) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
361 KEYPAD_DETECT(PINF & (1 << 5),5) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
362 KEYPAD_DETECT(PINF & (1 << 6),9) |
1e71d8e52392
Working keypad switch code detection.
Jacob Alexander <triplehaata@gmail.com>
parents:
7
diff
changeset
|
363 KEYPAD_DETECT(PINF & (1 << 7),14) |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
364 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
365 // Check count to see if the sample threshold may have been reached, otherwise collect more data |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
366 count++; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
367 if ( count < MAX_SAMPLES ) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
368 continue; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
369 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
370 // Reset Sample Counter |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
371 count = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
372 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
373 // Assess debouncing sample table |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
374 DEBOUNCE_ASSESS(keyDetectArray,KEYBOARD_SIZE) |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
375 DEBOUNCE_ASSESS(keypadDetectArray,KEYPAD_SIZE) |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
376 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
377 // Send keypresses over USB if the ISR has signalled that it's time |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
378 if ( !sendKeypresses ) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
379 continue; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
380 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
381 // Detect Valid Keypresses - TODO |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
382 uint8_t validKeys = 0; |
12
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
383 |
13
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
384 uint8_t *keyboard_MODMASK = keyboard_modifierMask; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
385 uint8_t keyboard_NUMMODS = MODIFIERS_KEYBOARD; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
386 uint8_t *keyboard_MAP = defaultMap; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
387 uint8_t *keypad_MODMASK = keypad_modifierMask; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
388 uint8_t keypad_NUMMODS = MODIFIERS_KEYPAD; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
389 uint8_t *keypad_MAP = keypadDefaultMap; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
390 |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
391 // Map selection - CapsLock FN |
12
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
392 if ( keyDetectArray[34] & (1 << 7) ) { // CapsLock FN Modifier |
13
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
393 keyboard_MAP = colemakMap; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
394 keyboard_MODMASK = alternate_modifierMask; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
395 keyboard_NUMMODS = 5; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
396 |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
397 // Function Key |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
398 if ( keyDetectArray[61] & (1 << 7) ) { |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
399 keyboard_MAP = navigationMap; |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
400 } |
12
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
401 } |
d42d16dd7393
Moving the layouts to a separate file.
Jacob Alexander <triplehaata@gmail.com>
parents:
11
diff
changeset
|
402 |
13
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
403 keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_MODMASK, keyboard_NUMMODS, keyboard_MAP ); |
932f34404318
Adding the HHKB style navigation layer.
Jacob Alexander <triplehaata@gmail.com>
parents:
12
diff
changeset
|
404 keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_MODMASK, keypad_NUMMODS, keypad_MAP ); |
15
8b6ef979a50e
Seems to be compiling now...finally after many months.
Jacob Alexander <triplehaata@gmail.com>
parents:
14
diff
changeset
|
405 //print(":\n"); |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
406 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
407 // TODO undo potentially old keys |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
408 for ( uint8_t c = validKeys; c < 6; c++ ) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
409 keyboard_keys[c] = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
410 |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
411 // Send keypresses |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
412 usb_keyboard_send(); |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
413 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
414 // Clear sendKeypresses Flag |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
415 sendKeypresses = 0; |
11
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
416 |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
417 // Clear modifiers |
c033251c3e6b
Minor modifications.
Jacob Alexander <triplehaata@gmail.com>
parents:
10
diff
changeset
|
418 keyboard_modifier_keys = 0; |
3
7b9bde7ba7ef
Key detection complete.
Jacob Alexander <triplehaata@gmail.com>
parents:
2
diff
changeset
|
419 } |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
420 |
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
421 return 0; |
0 | 422 } |
423 | |
10
f35ea5de4456
Adding all of the USB keycodes, and proper key ordering.
Jacob Alexander <triplehaata@gmail.com>
parents:
9
diff
changeset
|
424 // Timer Interrupt for flagging a send of the sampled key detection data to the USB host |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
425 ISR( TIMER0_OVF_vect ) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
426 { |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
427 sendKeypressCounter++; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
428 if ( sendKeypressCounter > USB_TRANSFER_DIVIDER ) { |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
429 sendKeypressCounter = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
430 sendKeypresses = 1; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
431 } |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
432 } |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
433 |