コード例 #1
0
ファイル: KeyboardManager.cpp プロジェクト: GhostLyrics/sweb
void KeyboardManager::serviceIRQ( void )
{
  KeyboardPoll(usb_kbd_addr_);
  uint8 scancode = KeyboardGetKeyDown(usb_kbd_addr_,0);
  if (scancode > 0x80 || scancode == 0)
  {
    current_key_ = 0;
    return;
  }

  struct KeyboardModifiers km = KeyboardGetModifiers(usb_kbd_addr_);
  uint8 key = 0;
  if (scancode <= 0x40 && (km.LeftShift || km.RightShift))
    key = E0_KEYS[scancode];
  else // numpad not yet implemented
    key = STANDARD_KEYMAP[scancode];

  if (key != current_key_)
  {
    if(main_console)
    {
      keyboard_buffer_.put( key ); // put it inside the buffer
      main_console->addJob();
    }
  }

  current_key_ = key;
}
コード例 #2
0
ファイル: keyboard.c プロジェクト: kjetilos/baking-pi
int KeyboardUpdate()
{
	do
	{
		if (KeyboardAddress == 0) 
		{
			UsbCheckForChange();
			if (KeyboardCount() == 0) 
			{
				KeyboardAddress = 0;
				return 0;
			}
		
			KeyboardAddress = KeyboardGetAddress(0);
			if (KeyboardAddress == 0)
			{
				return 0;
			}
		}
		int i;
		for (i=0; i<6; i++) 
		{
			KeyDown[i] = KeyboardGetKeyDown(KeyboardAddress, i);
		}
	} while (KeyboardPoll(KeyboardAddress) != 0);
	return KeyboardAddress;
}
コード例 #3
0
ファイル: keyb.c プロジェクト: yeqingyan/tos_tos
/*
 * keyboard_update
 * Based on
 * http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html
 *
 * 1.  Retrieve a stored keyboard address (initially 0).
 * 2.  If this is not 0, go to 9.
 * 3.  Call UsbCheckForChange to detect new keyboards.
 * 4.  Call KeyboardCount to detect how many keyboards are present.
 * 5.  If this is 0 store the address as 0 and return; we can't do anything with
 * no keyboard.
 * 6.  Call KeyboardGetAddress with parameter 0 to get the first keyboard's
 * address.
 * 7.  Store this address.
 * 8.  If this is 0, return; there is some problem.
 * 9.  Call KeyboardGetKeyDown 6 times to get each key currently down and store
 * them
 * 10. Call KeyboardPoll
 * 11. If the result is non-zero go to 3. There is some problem (such as
 * disconnected keyboard).
 */
void keyboard_update() {
  int keyboard_count;
  int i;

  do {
    if (keyboard_address == 0) {
      UsbCheckForChange();
      keyboard_count = KeyboardCount();
      kprintf("Got %d keyboard\n", keyboard_count);
      if (keyboard_count == 0) {
        keyboard_address = 0;
        kprintf("No keyboard found\n", keyboard_count);
        return;
      }

      keyboard_address = KeyboardGetAddress(0);
      if (keyboard_address == 0) {
        kprintf("Error! Keyboard address is %d\n", keyboard_address);
        return;
      }
    }
    // Call KeyboardGetKeyDown 6 times to get each key currently down and store
    // them
    for (i = 0; i < 6; i += 1) {
      old_keys[i] = KeyboardGetKeyDown(keyboard_address, i);
    }
  } while (KeyboardPoll(keyboard_address) != 0);
  return;
}