atkbd.c (50477) | atkbd.c (54382) |
---|---|
1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/atkbdc/atkbd.c 50477 1999-08-28 01:08:13Z peter $ | 26 * $FreeBSD: head/sys/dev/atkbdc/atkbd.c 54382 1999-12-10 04:31:33Z yokota $ |
27 */ 28 29#include "atkbd.h" 30#include "opt_kbd.h" 31#include "opt_atkbd.h" 32 33#if NATKBD > 0 34 --- 474 unchanged lines hidden (view full) --- 509atkbd_read(keyboard_t *kbd, int wait) 510{ 511 int c; 512 513 if (wait) 514 c = read_kbd_data(((atkbd_state_t *)kbd->kb_data)->kbdc); 515 else 516 c = read_kbd_data_no_wait(((atkbd_state_t *)kbd->kb_data)->kbdc); | 27 */ 28 29#include "atkbd.h" 30#include "opt_kbd.h" 31#include "opt_atkbd.h" 32 33#if NATKBD > 0 34 --- 474 unchanged lines hidden (view full) --- 509atkbd_read(keyboard_t *kbd, int wait) 510{ 511 int c; 512 513 if (wait) 514 c = read_kbd_data(((atkbd_state_t *)kbd->kb_data)->kbdc); 515 else 516 c = read_kbd_data_no_wait(((atkbd_state_t *)kbd->kb_data)->kbdc); |
517 if (c != -1) 518 ++kbd->kb_count; |
|
517 return (KBD_IS_ACTIVE(kbd) ? c : -1); 518} 519 520/* check if data is waiting */ 521static int 522atkbd_check(keyboard_t *kbd) 523{ 524 if (!KBD_IS_ACTIVE(kbd)) --- 26 unchanged lines hidden (view full) --- 551 do { 552 scancode = read_kbd_data(state->kbdc); 553 } while (scancode == -1); 554 } else { 555 scancode = read_kbd_data_no_wait(state->kbdc); 556 if (scancode == -1) 557 return NOKEY; 558 } | 519 return (KBD_IS_ACTIVE(kbd) ? c : -1); 520} 521 522/* check if data is waiting */ 523static int 524atkbd_check(keyboard_t *kbd) 525{ 526 if (!KBD_IS_ACTIVE(kbd)) --- 26 unchanged lines hidden (view full) --- 553 do { 554 scancode = read_kbd_data(state->kbdc); 555 } while (scancode == -1); 556 } else { 557 scancode = read_kbd_data_no_wait(state->kbdc); 558 if (scancode == -1) 559 return NOKEY; 560 } |
561 ++kbd->kb_count; |
|
559 | 562 |
563#if KBDIO_DEBUG >= 10 564 printf("atkbd_read_char(): scancode:0x%x\n", scancode); 565#endif 566 |
|
560 /* return the byte as is for the K_RAW mode */ 561 if (state->ks_mode == K_RAW) 562 return scancode; 563 564 /* translate the scan code into a keycode */ 565 keycode = scancode & 0x7F; 566 switch (state->ks_prefix) { 567 case 0x00: /* normal scancode */ --- 136 unchanged lines hidden (view full) --- 704 705 /* compose a character code */ 706 if (state->ks_flags & COMPOSE) { 707 switch (keycode | (scancode & 0x80)) { 708 /* key pressed, process it */ 709 case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */ 710 state->ks_composed_char *= 10; 711 state->ks_composed_char += keycode - 0x40; | 567 /* return the byte as is for the K_RAW mode */ 568 if (state->ks_mode == K_RAW) 569 return scancode; 570 571 /* translate the scan code into a keycode */ 572 keycode = scancode & 0x7F; 573 switch (state->ks_prefix) { 574 case 0x00: /* normal scancode */ --- 136 unchanged lines hidden (view full) --- 711 712 /* compose a character code */ 713 if (state->ks_flags & COMPOSE) { 714 switch (keycode | (scancode & 0x80)) { 715 /* key pressed, process it */ 716 case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */ 717 state->ks_composed_char *= 10; 718 state->ks_composed_char += keycode - 0x40; |
719 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
712 if (state->ks_composed_char > UCHAR_MAX) 713 return ERRKEY; 714 goto next_code; 715 case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */ 716 state->ks_composed_char *= 10; 717 state->ks_composed_char += keycode - 0x47; | 720 if (state->ks_composed_char > UCHAR_MAX) 721 return ERRKEY; 722 goto next_code; 723 case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */ 724 state->ks_composed_char *= 10; 725 state->ks_composed_char += keycode - 0x47; |
726 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
718 if (state->ks_composed_char > UCHAR_MAX) 719 return ERRKEY; 720 goto next_code; 721 case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */ 722 state->ks_composed_char *= 10; 723 state->ks_composed_char += keycode - 0x4E; | 727 if (state->ks_composed_char > UCHAR_MAX) 728 return ERRKEY; 729 goto next_code; 730 case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */ 731 state->ks_composed_char *= 10; 732 state->ks_composed_char += keycode - 0x4E; |
733 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
724 if (state->ks_composed_char > UCHAR_MAX) 725 return ERRKEY; 726 goto next_code; 727 case 0x52: /* keypad 0 */ 728 state->ks_composed_char *= 10; | 734 if (state->ks_composed_char > UCHAR_MAX) 735 return ERRKEY; 736 goto next_code; 737 case 0x52: /* keypad 0 */ 738 state->ks_composed_char *= 10; |
739 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
729 if (state->ks_composed_char > UCHAR_MAX) 730 return ERRKEY; 731 goto next_code; 732 733 /* key released, no interest here */ 734 case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */ 735 case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */ 736 case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */ 737 case 0xD2: /* keypad 0 */ | 740 if (state->ks_composed_char > UCHAR_MAX) 741 return ERRKEY; 742 goto next_code; 743 744 /* key released, no interest here */ 745 case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */ 746 case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */ 747 case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */ 748 case 0xD2: /* keypad 0 */ |
749 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
738 goto next_code; 739 740 case 0x38: /* left alt key */ 741 break; 742 743 default: 744 if (state->ks_composed_char > 0) { 745 state->ks_flags &= ~COMPOSE; 746 state->ks_composed_char = 0; | 750 goto next_code; 751 752 case 0x38: /* left alt key */ 753 break; 754 755 default: 756 if (state->ks_composed_char > 0) { 757 state->ks_flags &= ~COMPOSE; 758 state->ks_composed_char = 0; |
759 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
747 return ERRKEY; 748 } 749 break; 750 } 751 } 752 753 /* keycode to key action */ 754 action = genkbd_keyaction(kbd, keycode, scancode & 0x80, 755 &state->ks_state, &state->ks_accents); | 760 return ERRKEY; 761 } 762 break; 763 } 764 } 765 766 /* keycode to key action */ 767 action = genkbd_keyaction(kbd, keycode, scancode & 0x80, 768 &state->ks_state, &state->ks_accents); |
769 kbd->kb_prev_key = keycode | (scancode & 0x80); |
|
756 if (action == NOKEY) 757 goto next_code; 758 else 759 return action; 760} 761 762/* check if char is waiting */ 763static int --- 287 unchanged lines hidden (view full) --- 1051 int c; 1052 1053 if (!kbdc_lock(kbdc, TRUE)) { 1054 /* driver error? */ 1055 return EIO; 1056 } 1057 1058 /* save the current controller command byte */ | 770 if (action == NOKEY) 771 goto next_code; 772 else 773 return action; 774} 775 776/* check if char is waiting */ 777static int --- 287 unchanged lines hidden (view full) --- 1065 int c; 1066 1067 if (!kbdc_lock(kbdc, TRUE)) { 1068 /* driver error? */ 1069 return EIO; 1070 } 1071 1072 /* save the current controller command byte */ |
1059 empty_both_buffers(kbdc, 10); | 1073 empty_both_buffers(kbdc, 200); |
1060 c = get_controller_command_byte(kbdc); 1061 if (c == -1) { 1062 /* CONTROLLER ERROR */ 1063 kbdc_lock(kbdc, FALSE); 1064 printf("atkbd: unable to get the current command byte value.\n"); 1065 return EIO; 1066 } 1067 if (bootverbose) --- 232 unchanged lines hidden --- | 1074 c = get_controller_command_byte(kbdc); 1075 if (c == -1) { 1076 /* CONTROLLER ERROR */ 1077 kbdc_lock(kbdc, FALSE); 1078 printf("atkbd: unable to get the current command byte value.\n"); 1079 return EIO; 1080 } 1081 if (bootverbose) --- 232 unchanged lines hidden --- |