1/*- 2 * Copyright (c) 2003 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_kbd_sun.c 166100 2007-01-18 22:01:19Z marius $"); |
29 30#include "opt_compat.h" 31#include "opt_kbd.h" 32#include "opt_sunkbd.h" 33 34#if (defined(SUNKBD_EMULATE_ATKBD) && defined(SUNKBD_DFLT_KEYMAP)) || \ 35 !defined(SUNKBD_EMULATE_ATKBD) 36#define KBD_DFLT_KEYMAP --- 30 unchanged lines hidden (view full) --- 67 68#define TODO printf("%s: unimplemented", __func__) 69 70struct sunkbd_softc { 71 keyboard_t sc_kbd; 72 struct uart_softc *sc_uart; 73 struct uart_devinfo *sc_sysdev; 74 |
75 struct callout sc_repeat_callout; 76 int sc_repeat_key; 77 78 int sc_accents; 79 int sc_composed_char; 80 int sc_flags; 81#define KPCOMPOSE (1 << 0) 82 int sc_mode; --- 313 unchanged lines hidden (view full) --- 396 397 if (sc->sc_repeating) 398 return (TRUE); 399 400 if (sc->sc_uart != NULL && !uart_rx_empty(sc->sc_uart)) 401 return (TRUE); 402 403 if (sc->sc_polling != 0 && sc->sc_sysdev != NULL && |
404 uart_rxready(sc->sc_sysdev)) |
405 return (TRUE); 406 407 return (FALSE); 408} 409 410static u_int 411sunkbd_read_char(keyboard_t *kbd, int wait) 412{ --- 21 unchanged lines hidden (view full) --- 434 repeated = 1; 435 sc->sc_repeating = 0; 436 callout_reset(&sc->sc_repeat_callout, hz / 10, 437 sunkbd_repeat, sc); 438 suncode = sc->sc_repeat_key; 439 goto process_code; 440 } 441 |
442 for (;;) { 443 next_code: 444 if (!(sc->sc_flags & KPCOMPOSE) && (sc->sc_composed_char > 0)) { 445 key = sc->sc_composed_char; 446 sc->sc_composed_char = 0; 447 if (key > UCHAR_MAX) 448 return (ERRKEY); 449 return (key); --- 9 unchanged lines hidden (view full) --- 459 } else { 460 return (NOKEY); 461 } 462 463 switch (suncode) { 464 case SKBD_RSP_IDLE: 465 break; 466 default: |
467 process_code: 468 ++kbd->kb_count; 469 key = SKBD_KEY_CHAR(suncode); 470 release = suncode & SKBD_KEY_RELEASE; 471 if (!repeated) { 472 if (release == 0) { 473 callout_reset(&sc->sc_repeat_callout, 474 hz / 2, sunkbd_repeat, sc); --- 76 unchanged lines hidden (view full) --- 551#endif 552 553#if defined(SUNKBD_EMULATE_ATKBD) 554 if (key == 0x38) { /* left alt (KP compose key) */ 555#else 556 if (key == 0x13) { /* left alt (KP compose key) */ 557#endif 558 if (release != 0) { |
559 if (sc->sc_flags & KPCOMPOSE) { 560 sc->sc_flags &= ~KPCOMPOSE; 561 if (sc->sc_composed_char > 562 UCHAR_MAX) 563 sc->sc_composed_char = 564 0; |
565 } 566 } else { 567 if (!(sc->sc_flags & KPCOMPOSE)) { 568 sc->sc_flags |= KPCOMPOSE; 569 sc->sc_composed_char = 0; 570 } 571 } 572 } --- 183 unchanged lines hidden (view full) --- 756} 757 758static void 759sunkbd_clear_state(keyboard_t *kbd) 760{ 761 struct sunkbd_softc *sc; 762 763 sc = (struct sunkbd_softc *)kbd; |
764 sc->sc_repeat_key = -1; 765 sc->sc_accents = 0; 766 sc->sc_composed_char = 0; 767 sc->sc_flags = 0; 768 sc->sc_polling = 0; 769 sc->sc_repeating = 0; 770 sc->sc_state &= LOCK_MASK; /* Preserve locking key state. */ 771 --- 97 unchanged lines hidden --- |