Rev 4344 | Rev 4348 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4344 | Rev 4345 | ||
|---|---|---|---|
| Line 25... | Line 25... | ||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | /** @addtogroup kbd |
29 | /** @addtogroup kbd |
| 30 | * @brief US Dvorak Simplified Keyboard layout. |
30 | * @brief US Dvorak Simplified Keyboard layout. |
| 31 | * @{ |
31 | * @{ |
| 32 | */ |
32 | */ |
| 33 | 33 | ||
| 34 | #include <kbd.h> |
34 | #include <kbd.h> |
| 35 | #include <kbd/kbd.h> |
35 | #include <kbd/kbd.h> |
| 36 | #include <kbd/keycode.h> |
36 | #include <kbd/keycode.h> |
| 37 | #include <layout.h> |
37 | #include <layout.h> |
| Line 163... | Line 163... | ||
| 163 | }; |
163 | }; |
| 164 | 164 | ||
| 165 | static char map_neutral[] = { |
165 | static char map_neutral[] = { |
| 166 | [KC_BACKSPACE] = '\b', |
166 | [KC_BACKSPACE] = '\b', |
| 167 | [KC_TAB] = '\t', |
167 | [KC_TAB] = '\t', |
| 168 | [KC_ENTER] = '\n' |
168 | [KC_ENTER] = '\n', |
| - | 169 | [KC_SPACE] = ' ', |
|
| - | 170 | ||
| - | 171 | [KC_NSLASH] = '/', |
|
| - | 172 | [KC_NTIMES] = '*', |
|
| - | 173 | [KC_NMINUS] = '-', |
|
| - | 174 | [KC_NPLUS] = '+', |
|
| - | 175 | [KC_NENTER] = '\n' |
|
| - | 176 | }; |
|
| - | 177 | ||
| - | 178 | static char map_numeric[] = { |
|
| - | 179 | [KC_N7] = '7', |
|
| - | 180 | [KC_N8] = '8', |
|
| - | 181 | [KC_N9] = '9', |
|
| - | 182 | [KC_N4] = '4', |
|
| - | 183 | [KC_N5] = '5', |
|
| - | 184 | [KC_N6] = '6', |
|
| - | 185 | [KC_N1] = '1', |
|
| - | 186 | [KC_N2] = '2', |
|
| - | 187 | [KC_N3] = '3', |
|
| - | 188 | ||
| - | 189 | [KC_N0] = '0', |
|
| - | 190 | [KC_NPERIOD] = '.' |
|
| 169 | }; |
191 | }; |
| 170 | 192 | ||
| 171 | static int translate(unsigned int key, char *map, size_t map_length) |
193 | static int translate(unsigned int key, char *map, size_t map_length) |
| 172 | { |
194 | { |
| 173 | if (key >= map_length) return 0; |
195 | if (key >= map_length) |
| - | 196 | return 0; |
|
| 174 | return map[key]; |
197 | return map[key]; |
| 175 | } |
198 | } |
| 176 | 199 | ||
| 177 | char layout_parse_ev(kbd_event_t *ev) |
200 | char layout_parse_ev(kbd_event_t *ev) |
| 178 | { |
201 | { |
| 179 | char c; |
202 | char c; |
| Line 181... | Line 204... | ||
| 181 | /* Produce no characters when Ctrl or Alt is pressed. */ |
204 | /* Produce no characters when Ctrl or Alt is pressed. */ |
| 182 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
205 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
| 183 | return 0; |
206 | return 0; |
| 184 | 207 | ||
| 185 | c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char)); |
208 | c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char)); |
| 186 | if (c != 0) return c; |
209 | if (c != 0) |
| - | 210 | return c; |
|
| 187 | 211 | ||
| 188 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
212 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
| 189 | c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char)); |
213 | c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char)); |
| 190 | else |
214 | else |
| 191 | c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char)); |
215 | c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char)); |
| 192 | 216 | ||
| 193 | if (c != 0) return c; |
217 | if (c != 0) |
| - | 218 | return c; |
|
| 194 | 219 | ||
| 195 | if ((ev->mods & KM_SHIFT) != 0) |
220 | if ((ev->mods & KM_SHIFT) != 0) |
| 196 | c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char)); |
221 | c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char)); |
| 197 | else |
222 | else |
| 198 | c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char)); |
223 | c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char)); |
| 199 | 224 | ||
| 200 | if (c != 0 ) return c; |
225 | if (c != 0) |
| - | 226 | return c; |
|
| 201 | 227 | ||
| - | 228 | if ((ev->mods & KM_NUM_LOCK) != 0) |
|
| - | 229 | c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char)); |
|
| 202 | } |
230 | else |
| - | 231 | c = 0; |
|
| 203 | 232 | ||
| - | 233 | return c; |
|
| - | 234 | } |
|
| 204 | 235 | ||
| 205 | /** |
236 | /** |
| 206 | * @} |
237 | * @} |
| 207 | */ |
238 | */ |