Exemplo n.º 1
0
  bool GboxInstance::HandleKeyboard(const pp::KeyboardInputEvent& event) {
    uint32_t key = event.GetKeyCode();
    uint32_t type = event.GetType();
    uint32_t mods = 0; // event.GetModifiers();

    theLog.info("+Input Keyboard: ty:%d mods:%d key:%d/%c (sca:%d)", 
        type, mods, key, key, m_key_shift);

    if (type == 9) return false; // not sure what this is for

    if (key == 16) { // shift
      if (type == 7) m_key_shift = true;
      if (type == 8) m_key_shift = false;
      return true;
    }
    if (key == 17) { // ctrl
      if (type == 7) m_key_ctrl = true;
      if (type == 8) m_key_ctrl = false;
      return true;
    }
    if (key == 18) { // alt
      if (type == 7) m_key_alt = true;
      if (type == 8) m_key_alt = false;
      return true;
    }
    if (key == 91) { // left apple
      if (type == 7) m_key_left_apple = true;
      if (type == 8) m_key_left_apple = false;
      return true;
    }
    if (key == 93) { // right apple
      if (type == 7) m_key_right_apple = true;
      if (type == 8) m_key_right_apple = false;
      return true;
    }

    if (type == 7) m_down_sca = sca(); // shift-ctrl-alt on only keydown matters

    const char *dc = key < 223 ? display_codes[key] : "";
    const char *cc = key < 223 ? control_codes[key] : "";
    const char *co = key < 223 ? codes[key] : "";

    theLog.info("%d/ dc: '%s'  cc: '%s'  co: '%s'", key, dc, cc, co);

    if (type == 8) {
      if (strlen(co)) {
        Key(key, m_down_sca, dc, cc, co);
        return true;
      }
    }
    if (key == 8 || key == 9 || key == 13 || key == 27 || key == 37 || key == 38) {
      return true;
    }

    //if (type != 7)
    //  theLog.info("+Input Keyboard: et:%d key:%d/%c (unhandled)", type, key, key);

    return false;
  }
Exemplo n.º 2
0
	void NACLWindow::process_key_event( const pp::KeyboardInputEvent& ev )
	{
		uint8 code = uint8(ev.GetKeyCode());
		switch( ev.GetType() )
		{
		case PP_INPUTEVENT_TYPE_KEYDOWN:
			m_keyboard.keys[code] = true;
			listeners().broadcast(WindowEvent::KeyDown(code));
			break;
		case PP_INPUTEVENT_TYPE_KEYUP:
			m_keyboard.keys[code] = false;
			listeners().broadcast(WindowEvent::KeyUp(code));
			break;
		}
	}
Exemplo n.º 3
0
bool eUSPInstance::SpecialKeyDown(const pp::KeyboardInputEvent event)
{
	int key = event.GetKeyCode();
	enum { K_F12 = 123 };
	if(key == K_F12)
	{
		Handler()->OnAction(A_RESET);
		return true;
	}
	else if(key == 'F' && event.GetModifiers()&PP_INPUTEVENT_MODIFIER_CONTROLKEY)
	{
		full_screen.SetFullscreen(!full_screen.IsFullscreen());
		return true;
	}
	return false;
}