コード例 #1
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;
}
コード例 #2
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;
}
コード例 #3
0
ファイル: keyb.c プロジェクト: yeqingyan/tos_tos
unsigned int get_keyboard() {
  int keyboard_count;
  unsigned int keyboard_addr = 0;
  UsbCheckForChange();
  keyboard_count = KeyboardCount();
  assert(keyboard_count > 0);

  keyboard_addr = KeyboardGetAddress(0);
  assert(keyboard_addr != 0);
  return keyboard_addr;
}
コード例 #4
0
ファイル: KeyboardManager.cpp プロジェクト: GhostLyrics/sweb
KeyboardManager::KeyboardManager() :
    keyboard_buffer_(256), extended_scancode(0), keyboard_status_(0), usb_kbd_addr_(0), current_key_(0)
{
  UsbInitialise();
  for (uint32 i = 0; i < 32; ++i)
  {
    if (Devices[i] != 0 && ((struct HidDevice*)(Devices[i]->DriverData))->Header.DeviceDriver == DeviceDriverHid)
    {
      KeyboardAttach(Devices[i],0);
    }
  }
  usb_kbd_addr_ = KeyboardGetAddress(0);
}