Esempio n. 1
0
/**
 * Sends a scancode to the keyboard.
 *
 * @returns COM status code
 * @param scancode The scancode to send
 */
STDMETHODIMP Keyboard::PutScancode(LONG scancode)
{
    com::SafeArray<LONG> scancodes(1);
    scancodes[0] = scancode;
    return PutScancodes(ComSafeArrayAsInParam(scancodes), NULL);
}
static unsigned char kbd_read_input(void)
{
   int i, j, k, l;
   unsigned char prev;
   static unsigned char count = 0;

   static unsigned char oldcodes[KBD_ROWS][KBD_COLUMNS]={{0,0,0,0,0,0,0,0},
                                                         {0,0,0,0,0,0,0,0},
                                                         {0,0,0,0,0,0,0,0},
                                                         {0,0,0,0,0,0,0,0},
                                                         {0,0,0,0,0,0,0,0}};
   unsigned char inputcode[KBD_ROWS][KBD_COLUMNS];

   memset(inputcode, 0, sizeof(unsigned char) * (KBD_ROWS * KBD_COLUMNS));
   scancodes(inputcode);

   for(i = 0; i < KBD_COLUMNS; i++)
   {
      for(j = 0; j < KBD_ROWS; j++)
      {
//         if(oldcodes[j][i] == 0xe0)
//            oldcodes[j][i] =
         if(oldcodes[j][i] != inputcode[j][i])
         {
            // Value of the key before entering this function
            prev = oldcodes[j][i];

            // KEYUP
            if(inputcode[j][i] == 0 && oldcodes[j][i] != 0 && !(oldcodes[j][i] & KBD_KEYUP))
            {
               oldcodes[j][i] |= KBD_KEYUP;

               if(mode_ena == KBD_UP_ON)
                  mode_ena = KBD_UP_OFF;
               if(prev == KBD_MODESCAN)
                  if(mode_ena == KBD_DOWN_HOLD)
                     mode_ena = KBD_UP_OFF;
                  else if(mode_ena == KBD_DOWN)
                     mode_ena = KBD_UP_ON;
               if(mode_ena == KBD_DOWN)
                  mode_ena = KBD_DOWN_HOLD;
            }
            // RESET KEYUP
            else if(oldcodes[j][i] & KBD_KEYUP)
               oldcodes[j][i] = 0;
            // KEY DOWN
            else
            {
               oldcodes[j][i] = inputcode[j][i];

               // Parse out mode modifiers before the keyboard interpreter can touch them
  	       if(inputcode[j][i] == KBD_MODESCAN)
               {
                  if(!mode_ena)
                     mode_ena = KBD_DOWN;
                  continue;
               }
               if(inputcode[j][i] == KBD_NUMCURSCAN)
               {
                  numcur_ena = numcur_ena?0:1;
                  continue;
               }
            }
            //printk("Modified: (%#x,%#x), ipv:%#x, To: (%#.2x), From: (%#.2x), Flags:%d,%d,%d\r\n", j, i, inputcode[j][i], oldcodes[j][i], prev, mode_ena, shift_ena, numcur_ena);
            return oldcodes[j][i];
         }
      }
   }

   return (unsigned char)(KBD_NO_DATA);
}