Changeset 8ff0bd2 in mainline for uspace/srv/hid/input/layout/cz.c
- Timestamp:
- 2011-09-04T11:30:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/layout/cz.c
rd2c67e7 r8ff0bd2 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief Czech QWERTZ layout. 31 31 * @{ 32 32 */ 33 33 34 #include <kbd.h> 34 #include <errno.h> 35 #include <input.h> 35 36 #include <io/console.h> 36 37 #include <io/keycode.h> 37 38 #include <bool.h> 38 39 #include <layout.h> 39 40 static void layout_reset(void); 41 static wchar_t layout_parse_ev(kbd_event_t *ev); 40 #include <stdlib.h> 41 42 static int cz_create(layout_t *); 43 static void cz_destroy(layout_t *); 44 static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev); 42 45 43 46 enum m_state { … … 47 50 }; 48 51 49 static enum m_state mstate; 50 51 layout_op_t cz_op = { 52 layout_reset, 53 layout_parse_ev 52 typedef struct { 53 enum m_state mstate; 54 } layout_cz_t; 55 56 layout_ops_t cz_ops = { 57 .create = cz_create, 58 .destroy = cz_destroy, 59 .parse_ev = cz_parse_ev 54 60 }; 55 61 … … 273 279 } 274 280 275 static wchar_t parse_ms_hacek( kbd_event_t *ev)281 static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev) 276 282 { 277 283 wchar_t c; 278 284 279 mstate = ms_start;285 cz_state->mstate = ms_start; 280 286 281 287 /* Produce no characters when Ctrl or Alt is pressed. */ … … 291 297 } 292 298 293 static wchar_t parse_ms_carka( kbd_event_t *ev)299 static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev) 294 300 { 295 301 wchar_t c; 296 302 297 mstate = ms_start;303 cz_state->mstate = ms_start; 298 304 299 305 /* Produce no characters when Ctrl or Alt is pressed. */ … … 309 315 } 310 316 311 static wchar_t parse_ms_start( kbd_event_t *ev)317 static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev) 312 318 { 313 319 wchar_t c; … … 319 325 if (ev->key == KC_EQUALS) { 320 326 if ((ev->mods & KM_SHIFT) != 0) 321 mstate = ms_hacek;327 cz_state->mstate = ms_hacek; 322 328 else 323 mstate = ms_carka;329 cz_state->mstate = ms_carka; 324 330 325 331 return 0; … … 379 385 } 380 386 381 static void layout_reset(void) 382 { 383 mstate = ms_start; 384 } 385 386 static wchar_t layout_parse_ev(kbd_event_t *ev) 387 { 387 static int cz_create(layout_t *state) 388 { 389 layout_cz_t *cz_state; 390 391 cz_state = malloc(sizeof(layout_cz_t)); 392 if (cz_state == NULL) { 393 printf("%s: Out of memory.\n", NAME); 394 return ENOMEM; 395 } 396 397 cz_state->mstate = ms_start; 398 state->layout_priv = (void *) cz_state; 399 400 return EOK; 401 } 402 403 static void cz_destroy(layout_t *state) 404 { 405 free(state->layout_priv); 406 } 407 408 static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev) 409 { 410 layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv; 411 388 412 if (ev->type != KEY_PRESS) 389 413 return 0; … … 392 416 return 0; 393 417 394 switch ( mstate) {418 switch (cz_state->mstate) { 395 419 case ms_start: 396 return parse_ms_start( ev);420 return parse_ms_start(cz_state, ev); 397 421 case ms_hacek: 398 return parse_ms_hacek( ev);422 return parse_ms_hacek(cz_state, ev); 399 423 case ms_carka: 400 return parse_ms_carka( ev);424 return parse_ms_carka(cz_state, ev); 401 425 } 402 426
Note:
See TracChangeset
for help on using the changeset viewer.