Home | History | Annotate | Line # | Download | only in boot
      1  1.5  tsutsui /*	$NetBSD: kbd.c,v 1.5 2021/09/03 16:21:15 tsutsui Exp $	*/
      2  1.1  tsutsui 
      3  1.1  tsutsui /*
      4  1.1  tsutsui  * Copyright (c) 1992 OMRON Corporation.
      5  1.1  tsutsui  *
      6  1.1  tsutsui  * This code is derived from software contributed to Berkeley by
      7  1.1  tsutsui  * OMRON Corporation.
      8  1.1  tsutsui  *
      9  1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     10  1.1  tsutsui  * modification, are permitted provided that the following conditions
     11  1.1  tsutsui  * are met:
     12  1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     13  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     14  1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     17  1.1  tsutsui  * 3. All advertising materials mentioning features or use of this software
     18  1.1  tsutsui  *    must display the following acknowledgement:
     19  1.1  tsutsui  *	This product includes software developed by the University of
     20  1.1  tsutsui  *	California, Berkeley and its contributors.
     21  1.1  tsutsui  * 4. Neither the name of the University nor the names of its contributors
     22  1.1  tsutsui  *    may be used to endorse or promote products derived from this software
     23  1.1  tsutsui  *    without specific prior written permission.
     24  1.1  tsutsui  *
     25  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  1.1  tsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  1.1  tsutsui  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  1.1  tsutsui  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  1.1  tsutsui  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  1.1  tsutsui  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  1.1  tsutsui  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  1.1  tsutsui  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  1.1  tsutsui  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  1.1  tsutsui  * SUCH DAMAGE.
     36  1.1  tsutsui  *
     37  1.1  tsutsui  *	@(#)kbd.c	8.1 (Berkeley) 6/10/93
     38  1.1  tsutsui  */
     39  1.1  tsutsui /*
     40  1.1  tsutsui  * Copyright (c) 1992, 1993
     41  1.1  tsutsui  *	The Regents of the University of California.  All rights reserved.
     42  1.1  tsutsui  *
     43  1.1  tsutsui  * This code is derived from software contributed to Berkeley by
     44  1.1  tsutsui  * OMRON Corporation.
     45  1.1  tsutsui  *
     46  1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     47  1.1  tsutsui  * modification, are permitted provided that the following conditions
     48  1.1  tsutsui  * are met:
     49  1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     50  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     51  1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     52  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     53  1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     54  1.1  tsutsui  * 3. Neither the name of the University nor the names of its contributors
     55  1.1  tsutsui  *    may be used to endorse or promote products derived from this software
     56  1.1  tsutsui  *    without specific prior written permission.
     57  1.1  tsutsui  *
     58  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59  1.1  tsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60  1.1  tsutsui  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61  1.1  tsutsui  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62  1.1  tsutsui  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63  1.1  tsutsui  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64  1.1  tsutsui  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65  1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66  1.1  tsutsui  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67  1.1  tsutsui  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68  1.1  tsutsui  * SUCH DAMAGE.
     69  1.1  tsutsui  *
     70  1.1  tsutsui  *	@(#)kbd.c	8.1 (Berkeley) 6/10/93
     71  1.1  tsutsui  */
     72  1.1  tsutsui 
     73  1.1  tsutsui /*
     74  1.1  tsutsui  * kbd.c -- key-code decoding routine
     75  1.1  tsutsui  *   by A.Fujita, Dec-12-1992
     76  1.1  tsutsui  */
     77  1.1  tsutsui 
     78  1.1  tsutsui #include <sys/param.h>
     79  1.1  tsutsui #include <luna68k/stand/boot/samachdep.h>
     80  1.1  tsutsui #include <luna68k/stand/boot/kbdreg.h>
     81  1.1  tsutsui 
     82  1.4  tsutsui static const struct kbd_keymap kbd_keymap[] = {
     83  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   0 [0x00]	      */
     84  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   1 [0x01]	      */
     85  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   2 [0x02]	      */
     86  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   3 [0x03]	      */
     87  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   4 [0x04]	      */
     88  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   5 [0x05]	      */
     89  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   6 [0x06]	      */
     90  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   7 [0x07]	      */
     91  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*   8 [0x08]	      */
     92  1.1  tsutsui 	{ KC_CODE,	{ 0x09,     0x09     } },	/*   9 [0x09]	TAB   */
     93  1.1  tsutsui 	{ KC_SHIFT,	{ KS_CTRL,  KS_CTRL  } },	/*  10 [0x0A]	CTRL  */
     94  1.1  tsutsui 	{ KC_IGNORE,	{ 0,        0        } },	/*  11 [0x0B]	      */
     95  1.1  tsutsui 	{ KC_SHIFT,	{ KS_SHIFT, KS_SHIFT } },	/*  12 [0x0C]	SHIFT */
     96  1.1  tsutsui 	{ KC_SHIFT,	{ KS_SHIFT, KS_SHIFT } },	/*  13 [0x0D]	SHIFT */
     97  1.1  tsutsui 	{ KC_IGNORE,	{ 0,        0        } },	/*  14 [0x0E]	      */
     98  1.1  tsutsui 	{ KC_SHIFT,	{ KS_META,  KS_META  } },	/*  15 [0x0F]	META  */
     99  1.1  tsutsui 	{ KC_CODE,	{ 0x1B,     0x1B     } },	/*  16 [0x10]	ESC   */
    100  1.1  tsutsui 	{ KC_CODE,	{ 0x08,	    0x08     } },	/*  17 [0x11]	BS    */
    101  1.1  tsutsui 	{ KC_CODE,	{ 0x0D,	    0x0D     } },	/*  18 [0x12]	CR    */
    102  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  19 [0x13]	      */
    103  1.1  tsutsui 	{ KC_CODE,	{ 0x20,	    0x20     } },	/*  20 [0x14]	SP    */
    104  1.1  tsutsui 	{ KC_CODE,	{ 0x7F,	    0x7F     } },	/*  21 [0x15]	DEL   */
    105  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  22 [0x16]	      */
    106  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  23 [0x17]	      */
    107  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  24 [0x18]	      */
    108  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  25 [0x19]	      */
    109  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  26 [0x1A]	      */
    110  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  27 [0x1B]	      */
    111  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  28 [0x1C]	      */
    112  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  29 [0x1D]	      */
    113  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  30 [0x1E]	      */
    114  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  31 [0x1F]	      */
    115  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  32 [0x20]	      */
    116  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  33 [0x21]	      */
    117  1.1  tsutsui 	{ KC_CODE,	{ 0x31,	    0x21     } },	/*  34 [0x22]	 1    */
    118  1.1  tsutsui 	{ KC_CODE,	{ 0x32,	    0x22     } },	/*  35 [0x23]	 2    */
    119  1.1  tsutsui 	{ KC_CODE,	{ 0x33,	    0x23     } },	/*  36 [0x24]	 3    */
    120  1.1  tsutsui 	{ KC_CODE,	{ 0x34,	    0x24     } },	/*  37 [0x25]	 4    */
    121  1.1  tsutsui 	{ KC_CODE,	{ 0x35,	    0x25     } },	/*  38 [0x26]	 5    */
    122  1.1  tsutsui 	{ KC_CODE,	{ 0x36,	    0x26     } },	/*  39 [0x27]	 6    */
    123  1.1  tsutsui 	{ KC_CODE,	{ 0x37,	    0x27     } },	/*  40 [0x28]	 7    */
    124  1.1  tsutsui 	{ KC_CODE,	{ 0x38,	    0x28     } },	/*  41 [0x29]	 8    */
    125  1.1  tsutsui 	{ KC_CODE,	{ 0x39,	    0x29     } },	/*  42 [0x2A]	 9    */
    126  1.1  tsutsui 	{ KC_CODE,	{ 0x30,	    0x30     } },	/*  43 [0x2B]	 0    */
    127  1.1  tsutsui 	{ KC_CODE,	{ 0x2D,	    0x3D     } },	/*  44 [0x2C]	 -    */
    128  1.1  tsutsui 	{ KC_CODE,	{ 0x5E,	    0x7E     } },	/*  45 [0x2D]	 ^    */
    129  1.1  tsutsui 	{ KC_CODE,	{ 0x5C,	    0x7C     } },	/*  46 [0x2E]	 \    */
    130  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  47 [0x2F]	      */
    131  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  48 [0x30]	      */
    132  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  49 [0x31]	      */
    133  1.1  tsutsui 	{ KC_CODE,	{ 0x71,	    0x51     } },	/*  50 [0x32]	 q    */
    134  1.1  tsutsui 	{ KC_CODE,	{ 0x77,	    0x57     } },	/*  51 [0x33]	 w    */
    135  1.1  tsutsui 	{ KC_CODE,	{ 0x65,	    0x45     } },	/*  52 [0x34]	 e    */
    136  1.1  tsutsui 	{ KC_CODE,	{ 0x72,	    0x52     } },	/*  53 [0x35]	 r    */
    137  1.1  tsutsui 	{ KC_CODE,	{ 0x74,	    0x54     } },	/*  54 [0x36]	 t    */
    138  1.1  tsutsui 	{ KC_CODE,	{ 0x79,	    0x59     } },	/*  55 [0x37]	 y    */
    139  1.1  tsutsui 	{ KC_CODE,	{ 0x75,	    0x55     } },	/*  56 [0x38]	 u    */
    140  1.1  tsutsui 	{ KC_CODE,	{ 0x69,	    0x49     } },	/*  57 [0x39]	 i    */
    141  1.1  tsutsui 	{ KC_CODE,	{ 0x6F,	    0x4F     } },	/*  58 [0x3A]	 o    */
    142  1.1  tsutsui 	{ KC_CODE,	{ 0x70,	    0x50     } },	/*  59 [0x3B]	 p    */
    143  1.1  tsutsui 	{ KC_CODE,	{ 0x40,	    0x60     } },	/*  60 [0x3C]	 @    */
    144  1.1  tsutsui 	{ KC_CODE,	{ 0x5B,	    0x7B     } },	/*  61 [0x3D]	 [    */
    145  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  62 [0x3E]	      */
    146  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  63 [0x3F]	      */
    147  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  64 [0x40]	      */
    148  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  65 [0x41]	      */
    149  1.1  tsutsui 	{ KC_CODE,	{ 0x61,	    0x41     } },	/*  66 [0x42]	 a    */
    150  1.1  tsutsui 	{ KC_CODE,	{ 0x73,	    0x53     } },	/*  67 [0x43]	 s    */
    151  1.1  tsutsui 	{ KC_CODE,	{ 0x64,	    0x44     } },	/*  68 [0x44]	 d    */
    152  1.1  tsutsui 	{ KC_CODE,	{ 0x66,	    0x46     } },	/*  69 [0x45]	 f    */
    153  1.1  tsutsui 	{ KC_CODE,	{ 0x67,	    0x47     } },	/*  70 [0x46]	 g    */
    154  1.1  tsutsui 	{ KC_CODE,	{ 0x68,	    0x48     } },	/*  71 [0x47]	 h    */
    155  1.1  tsutsui 	{ KC_CODE,	{ 0x6A,	    0x4A     } },	/*  72 [0x48]	 j    */
    156  1.1  tsutsui 	{ KC_CODE,	{ 0x6B,	    0x4B     } },	/*  73 [0x49]	 k    */
    157  1.1  tsutsui 	{ KC_CODE,	{ 0x6C,	    0x4C     } },	/*  74 [0x4A]	 l    */
    158  1.1  tsutsui 	{ KC_CODE,	{ 0x3B,	    0x2B     } },	/*  75 [0x4B]	 ;    */
    159  1.1  tsutsui 	{ KC_CODE,	{ 0x3A,	    0x2A     } },	/*  76 [0x4C]	 :    */
    160  1.1  tsutsui 	{ KC_CODE,	{ 0x5D,	    0x7D     } },	/*  77 [0x4D]	 ]    */
    161  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  78 [0x4E]	      */
    162  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  79 [0x4F]	      */
    163  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  80 [0x50]	      */
    164  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  81 [0x51]	      */
    165  1.1  tsutsui 	{ KC_CODE,	{ 0x7A,	    0x5A     } },	/*  82 [0x52]	 z    */
    166  1.1  tsutsui 	{ KC_CODE,	{ 0x78,	    0x58     } },	/*  83 [0x53]	 x    */
    167  1.1  tsutsui 	{ KC_CODE,	{ 0x63,	    0x43     } },	/*  84 [0x54]	 c    */
    168  1.1  tsutsui 	{ KC_CODE,	{ 0x76,	    0x56     } },	/*  85 [0x55]	 v    */
    169  1.1  tsutsui 	{ KC_CODE,	{ 0x62,	    0x42     } },	/*  86 [0x56]	 b    */
    170  1.1  tsutsui 	{ KC_CODE,	{ 0x6E,	    0x4E     } },	/*  87 [0x57]	 n    */
    171  1.1  tsutsui 	{ KC_CODE,	{ 0x6D,	    0x4D     } },	/*  88 [0x58]	 m    */
    172  1.1  tsutsui 	{ KC_CODE,	{ 0x2C,	    0x3C     } },	/*  89 [0x59]	 ,    */
    173  1.1  tsutsui 	{ KC_CODE,	{ 0x2E,	    0x3E     } },	/*  90 [0x5A]	 .    */
    174  1.1  tsutsui 	{ KC_CODE,	{ 0x2F,	    0x3F     } },	/*  91 [0x5B]	 /    */
    175  1.1  tsutsui 	{ KC_CODE,	{ 0x5F,	    0x5F     } },	/*  92 [0x5C]	 _    */
    176  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  93 [0x5D]	      */
    177  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  94 [0x5E]	      */
    178  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  95 [0x5F]	      */
    179  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  96 [0x60]	      */
    180  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  97 [0x61]	      */
    181  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  98 [0x62]	      */
    182  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/*  99 [0x63]	      */
    183  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 100 [0x64]	      */
    184  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 101 [0x65]	      */
    185  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 102 [0x66]	      */
    186  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 103 [0x67]	      */
    187  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 104 [0x68]	      */
    188  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 105 [0x69]	      */
    189  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 106 [0x6A]	      */
    190  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 107 [0x6B]	      */
    191  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 108 [0x6C]	      */
    192  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 109 [0x6D]	      */
    193  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 110 [0x6E]	      */
    194  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 111 [0x6F]	      */
    195  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 112 [0x70]	      */
    196  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 113 [0x71]	      */
    197  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 114 [0x72]	      */
    198  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 115 [0x73]	      */
    199  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 116 [0x74]	      */
    200  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 117 [0x75]	      */
    201  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 118 [0x76]	      */
    202  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 119 [0x77]	      */
    203  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 120 [0x78]	      */
    204  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 121 [0x79]	      */
    205  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 122 [0x7A]	      */
    206  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 123 [0x7B]	      */
    207  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 124 [0x7C]	      */
    208  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 125 [0x7D]	      */
    209  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 126 [0x7E]	      */
    210  1.1  tsutsui 	{ KC_IGNORE,	{ 0,	    0        } },	/* 127 [0x7F]	      */
    211  1.1  tsutsui };
    212  1.1  tsutsui 
    213  1.1  tsutsui int	shift_flag = 0;
    214  1.1  tsutsui int	ctrl_flag  = 0;
    215  1.1  tsutsui int	meta_flag  = 0;
    216  1.5  tsutsui int	mouse_flag  = 0;
    217  1.1  tsutsui 
    218  1.1  tsutsui int
    219  1.3  tsutsui kbd_decode(uint8_t code)
    220  1.1  tsutsui {
    221  1.1  tsutsui 	unsigned int c, updown = 0;
    222  1.1  tsutsui 
    223  1.5  tsutsui 	/* ignore mouse data */
    224  1.5  tsutsui 	if (mouse_flag != 0) {
    225  1.5  tsutsui 		mouse_flag--;
    226  1.5  tsutsui 		return KC_IGNORE;
    227  1.5  tsutsui 	}
    228  1.5  tsutsui 	if ((code & 0xf8) == 0x80) {
    229  1.5  tsutsui 		mouse_flag = 2;
    230  1.5  tsutsui 		return KC_IGNORE;
    231  1.5  tsutsui 	}
    232  1.5  tsutsui 
    233  1.1  tsutsui 	if (code & 0x80)
    234  1.1  tsutsui 		updown = 1;
    235  1.1  tsutsui 
    236  1.1  tsutsui 	code &= 0x7F;
    237  1.1  tsutsui 
    238  1.1  tsutsui 	c = kbd_keymap[code].km_type;
    239  1.1  tsutsui 
    240  1.1  tsutsui 	if (c == KC_IGNORE)
    241  1.2  tsutsui 		return KC_IGNORE;
    242  1.1  tsutsui 
    243  1.1  tsutsui 	if ((c == KC_CODE) && updown)
    244  1.2  tsutsui 		return KC_IGNORE;
    245  1.1  tsutsui 
    246  1.1  tsutsui 	if (c == KC_SHIFT) {
    247  1.2  tsutsui 		switch (kbd_keymap[code].km_code[0]) {
    248  1.1  tsutsui 
    249  1.1  tsutsui 		case KS_SHIFT:
    250  1.1  tsutsui 			shift_flag = 1 - updown;
    251  1.1  tsutsui 			break;
    252  1.1  tsutsui 
    253  1.1  tsutsui 		case KS_CTRL:
    254  1.1  tsutsui 			ctrl_flag  = 1 - updown;
    255  1.1  tsutsui 			break;
    256  1.1  tsutsui 
    257  1.1  tsutsui 		case KS_META:
    258  1.1  tsutsui 			meta_flag  = 1 - updown;
    259  1.1  tsutsui 			break;
    260  1.1  tsutsui 		}
    261  1.1  tsutsui 
    262  1.2  tsutsui 		return KC_IGNORE;
    263  1.1  tsutsui 	}
    264  1.1  tsutsui 
    265  1.1  tsutsui 	if (shift_flag)
    266  1.1  tsutsui 		c = kbd_keymap[code].km_code[1];
    267  1.1  tsutsui 	else
    268  1.1  tsutsui 		c = kbd_keymap[code].km_code[0];
    269  1.1  tsutsui 
    270  1.1  tsutsui 	if (meta_flag)
    271  1.1  tsutsui 		c |= 0x80;
    272  1.1  tsutsui 
    273  1.1  tsutsui 	if (ctrl_flag)
    274  1.1  tsutsui 		c &= 0x1F;
    275  1.1  tsutsui 
    276  1.2  tsutsui 	return c;
    277  1.1  tsutsui }
    278