Exemplo n.º 1
0
void VRPNButtonInputDevice::Update() {
	if(InputDevice){
		{
			FScopeLock ScopeLock(&CritSect);
			InputDevice->mainloop();
		}
		while(KeyPressStack.Num() > 0)
		{
			KeyEventPair ButtonEvent = KeyPressStack.Pop(/*bAllowShrinking=*/false);
			// process the button presses
			const FKey* Key = ButtonMap.Find(ButtonEvent.Button);
			if(Key == nullptr)
			{
				UE_LOG(LogVRPNInputDevice, Warning, TEXT("Could not find button with id %i."), ButtonEvent.Button);
				return;
			}


			if(ButtonEvent.State == 1)
			{
				FKeyEvent KeyEvent(*Key, FSlateApplication::Get().GetModifierKeys(), 0, 0, 0, 0);
				FSlateApplication::Get().ProcessKeyDownEvent(KeyEvent);
			}
			else
			{
				FKeyEvent KeyEvent(*Key, FSlateApplication::Get().GetModifierKeys(), 0, 0, 0, 0);
				FSlateApplication::Get().ProcessKeyUpEvent(KeyEvent);
			}
		}
	}
}
Exemplo n.º 2
0
	LRESULT Win32Window::wndProc(UINT msg, WPARAM wParam, LPARAM lParam) {
		if(msg == WM_CLOSE) {
			PostQuitMessage(0);
		}

		switch(msg) {
		case WM_SIZE:
			onResize(ResizeEvent(LOWORD(lParam), HIWORD(lParam)));
			break;

		case WM_KEYDOWN:
			onKeyDown(KeyEvent(wParam));
			break;

		case WM_KEYUP:
			onKeyUp(KeyEvent(wParam));
			break;

		case WM_MOUSEMOVE:
			POINTS pt = MAKEPOINTS(lParam);
			break;
		}

		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
Exemplo n.º 3
0
void MInputTask::VFrame( const float fDelta )
{
	while( SDL_PollEvent(&m_Event) ) {
		if( m_Event.type == SDL_QUIT ) Engine::GetInstance()->TaskManager()->EarlyAbort();
		else if( m_Event.type == SDL_KEYDOWN ) KeyEvent(m_Event.key.keysym.sym,true);
		else if( m_Event.type == SDL_KEYUP ) KeyEvent(m_Event.key.keysym.sym,false);
	}
}
Exemplo n.º 4
0
/*
 * Translates a Linux input event into a DirectFB input event.
 */
bool CLinuxInputDevice::TranslateEvent(const struct input_event& levt,
    XBMC_Event& devt)
{
  switch (levt.type)
  {
  case EV_KEY:
    return KeyEvent(levt, devt);

  case EV_REL:
    if (m_bSkipNonKeyEvents)
    {
      CLog::Log(LOGINFO, "read a relative event which will be ignored (device name %s) (file name %s)", m_deviceName, m_fileName.c_str());
      return false;
    }

    return RelEvent(levt, devt);

  case EV_ABS:
    if (m_bSkipNonKeyEvents)
    {
      CLog::Log(LOGINFO, "read an absolute event which will be ignored (device name %s) (file name %s)", m_deviceName, m_fileName.c_str());
      return false;
    }

    return AbsEvent(levt, devt);

  default:
    ;
  }

  return false;
}
KeyEvent MImKeyBinding::toKeyEventImpl(QKeyEvent::Type eventType,
                                    Qt::KeyboardModifiers modifiers,
                                    const QString &labelText) const
{
    Qt::Key key = Qt::Key_unknown;
    KeyEvent::SpecialKey specialKey = KeyEvent::NotSpecial;
    QString text(labelText);

    switch (keyAction) {
    case ActionShift:
        key = Qt::Key_Shift;
        break;
    case ActionSpace:
        key = Qt::Key_Space;
        text = " ";
        break;
    case ActionBackspace:
        key = Qt::Key_Backspace;
        text = "\b";
        break;
    case ActionReturn:
        key = Qt::Key_Return;
        text = "\r";
        break;
    case ActionTab:
        key = Qt::Key_Tab;
        text = "\t";
        break;
    case ActionCycle:
        specialKey = KeyEvent::CycleSet;
        text = cycleSet;
        break;
    case ActionLayoutMenu:
        specialKey = KeyEvent::LayoutMenu;
        break;
    case ActionSym:
        specialKey = KeyEvent::Sym;
        break;
    case ActionPlusMinusToggle:
        specialKey = KeyEvent::ChangeSign;
        break;
    case ActionDecimalSeparator:
    case ActionInsert:
        if (!text.isEmpty()) {
            key = static_cast<Qt::Key>(QKeySequence(text)[0]);
        }

        break;
    case ActionCommit:
        specialKey = KeyEvent::Commit;
        break;
    case ActionSwitch:
        specialKey = KeyEvent::Switch;
        break;
    case NumActions:
        Q_ASSERT(false);
    }

    return KeyEvent(text, eventType, key, specialKey, modifiers);
}
void Sence::Run()
{							
	KeyEvent();	
	Process();			
	Render();
							
}
Exemplo n.º 7
0
	void specialUp(int key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), getSpecialKey(key)));
		}
	}
Exemplo n.º 8
0
	void keyboardUp(unsigned char key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), GLUT_TO_KEYEVENT_KEYS[key]));
		}
	}
Exemplo n.º 9
0
void WinInputManager::Run(UINT const & msg, WPARAM wParam, LPARAM lParam)
{
    if (m_listenerList.empty())
        return;

    eKeyCodes KeyIndex;
    wchar_t buffer[1];
    BYTE lpKeyState[256];

    CursorEvent();
    switch (msg)
    {
    case WM_KEYDOWN:
        KeyIndex = static_cast<eKeyCodes>(wParam);
        GetKeyboardState(lpKeyState);
        ToUnicode(wParam, HIWORD(lParam) & 0xFF, lpKeyState, buffer, 1, 0);
        KeyEvent(KeyIndex, buffer[0], true);
        break;
    case WM_KEYUP:
        KeyIndex = static_cast<eKeyCodes>(wParam);
        GetKeyboardState(lpKeyState);
        ToUnicode(wParam, HIWORD(lParam) & 0xFF, lpKeyState, buffer, 1, 0);
        KeyEvent(KeyIndex, buffer[0], false);
        break;
    case WM_LBUTTONDOWN:
        MouseEvent(MOUSE_LEFT, true);
        break;
    case WM_LBUTTONUP:
        MouseEvent(MOUSE_LEFT, false);
        break;
    case WM_RBUTTONDOWN:
        MouseEvent(MOUSE_RIGHT, true);
        break;
    case WM_RBUTTONUP:
        MouseEvent(MOUSE_RIGHT, false);
        break;
    case WM_MBUTTONDOWN:
        MouseEvent(MOUSE_MIDDLE, true);
        break;
    case WM_MBUTTONUP:
        MouseEvent(MOUSE_MIDDLE, false);
        break;
    case WM_MOUSEWHEEL:
        MouseWheelEvent((short)GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA);
        break;
    }
}
Exemplo n.º 10
0
Action::Action(String const &label, QObject *target, char const *slot)
    : _event(KeyEvent("")), _label(label), _target(target), _slot(slot)
{
    if(target && slot)
    {
        connect(this, SIGNAL(triggered()), target, slot);
    }
}
Exemplo n.º 11
0
void Window::PulseReceived( Pulse *pulse )
{
    Rect oldFrame;
    uint32 d1,d2,d3,d4,d5,d6;
    d1 = (*pulse)[0];
    d2 = (*pulse)[1];
    d3 = (*pulse)[2];
    d4 = (*pulse)[3];
    d5 = (*pulse)[4];
    d6 = (*pulse)[5];



    switch (d1)
    {
    case PULSE:
        if ( smk_getpid() != pulse->source_pid ) break; // Ignore the daemons.
        Pulsed();
        break;

    case FOCUS:
        m_focus = (d2 == 1);
        Focus( m_focus );
        break;

    case MOUSE_DOWN:
    case MOUSE_UP:
    case MOUSE_MOVED:
        MouseEvent( d1, d2, d3, d4 );
        break;

    case KEY_DOWN:
    case KEY_UP:
        KeyEvent( d1, d2, d3, d4 );
        break;

    case DRAW:
        Draw( Rect(d2,d3,d4,d5) );
        Sync();
        break;

    case MOVE:
        oldFrame = m_frame;
        m_frame.left   += d2;
        m_frame.right  += d2;
        m_frame.top    += d3;
        m_frame.bottom += d3;
        WindowMoved( Frame() );
        break;

    default:
        Looper::PulseReceived( pulse );
        break;
    }
}
Exemplo n.º 12
0
//-----------------------------------------------------------------------
void Window::eventKey(const KEYS KeyCode, const wchar_t ch, bool press)
{
	for ( auto it = m_msgHandlers.begin(); it != m_msgHandlers.end(); ++it )
	{
		if ( !(*it) )
			continue;
		// кнопка нажата
		if ( press == true )
		{
			if ( (*it)->OnKeyDown(KeyEvent(ch, KeyCode, false)) == true )
				return;
		}
		// кнопка отпущена
		else
		{
			if ( (*it)->OnKeyUp(KeyEvent(ch, KeyCode, false)) == true )
				return;
		}
	}
}
Exemplo n.º 13
0
//---------------------------------------------------------------------------
void __fastcall TFileEdit::FormPaint(TObject *Sender)
{
    if( m_InitFirst ) {
        m_InitFirst = FALSE;
        const short _tt[]= {
            VK_CONTROL, VK_END, VK_END|0x8000, VK_CONTROL|0x8000,
            0
        };
        KeyEvent(_tt);
        AdjustTop();
    }
}
Exemplo n.º 14
0
LineEditor::LineEditor(XConsole * console)
:cx_( 0 ),
 inOverwriteMode_( false ),
 advancedEditing_( false ),
 lastChar_( 0 ),
 historyShown_( -1 ),
 keyRepeat_(KeyEvent(), FLT_MAX),
 time_( 0 ),
 console_(console)
{
	lineLength_ = console_->visibleWidth();
}
Exemplo n.º 15
0
void g2Controller::__KeyEvent(unsigned char key, bool IsSpecial)
{
    // Ignore if not visible
    if(!GetVisibility())
        return;
    
    // Update key event
    KeyEvent(key, IsSpecial);
    
    // Update all children
    for(ChildObjectsIt Child = ChildObjects.begin(); Child != ChildObjects.end(); Child++)
        (*Child)->__KeyEvent(key, IsSpecial);
}
Exemplo n.º 16
0
static void textbox(char **textlines)
{
	int items = 0, i;
	int height, width;
	rect R;
	rect tR;
	int cx, cy;
	char *msg1 = "Click or press any key to continue";

	for (items = width = 0; textlines[items]; items++)
		width = max(width, StringWidth(textlines[items]) + 16);
	width = max(width, StringWidth(msg1) + 16);
	Centers(&sR, &cx, &cy);


	height = FontHeight * (items + 1) + 16;

	R.Xmin = cx - width / 2;
	R.Xmax = R.Xmin + width - 1;
	R.Ymin = cy - height / 2;
	R.Ymax = R.Ymin + height - 1;
	framelines(&R);
	BasicCenteredBox(&tR, width, height, DARKGRAY, textlines[0], WHITE);

	TextAlign(alignLeft, alignTop);
	for (i = 1; i < items; i++)
	{
		MoveTo(tR.Xmin + 4, tR.Ymin + 8 + FontHeight * i);
		PenColor(WHITE);
		BackColor(DARKGRAY);
		DrawString(textlines[i]);
	}

	MoveTo(cx, tR.Ymin + 8 + FontHeight * i + 4);
	TextAlign(alignCenter, alignTop);
	DrawString(msg1);


	while (1)
	{
		event e;

		KeyEvent(true, &e);

		if (e.ASCII || e.ScanCode || (e.State & 0x700))
			break;
	}
	WaitForNothing();
	PopRect(&i);
	framelines(&R);
}
Exemplo n.º 17
0
/*
 * Translates a Linux input event into a DirectFB input event.
 */
bool CLinuxInputDevice::TranslateEvent(const struct input_event& levt,
    XBMC_Event& devt)
{
  if (m_devicePreferredId == LI_DEVICE_MULTITOUCH)
  {
    switch (levt.type)
    {
    case EV_ABS:
      return mtAbsEvent(levt);

    case EV_SYN:
      return mtSynEvent(levt);

    default:
      // Ignore legacy (key) events
      return false;
    }
  }

  switch (levt.type)
  {
  case EV_KEY:
    return KeyEvent(levt, devt);

  case EV_REL:
    if (m_bSkipNonKeyEvents)
    {
      CLog::Log(LOGINFO, "read a relative event which will be ignored (device name %s) (file name %s)", m_deviceName, m_fileName.c_str());
      return false;
    }

    return RelEvent(levt, devt);

  case EV_ABS:
    if (m_bSkipNonKeyEvents)
    {
      CLog::Log(LOGINFO, "read an absolute event which will be ignored (device name %s) (file name %s)", m_deviceName, m_fileName.c_str());
      return false;
    }

    return AbsEvent(levt, devt);

  default:
    ;
  }

  return false;
}
Exemplo n.º 18
0
void g2Controller::__KeyEvent(unsigned char key, bool IsSpecial)
{
    // Ignore if not visible
    if(!GetVisibility())
        return;
    
    // Update key event
    KeyEvent(key, IsSpecial);
    
    // Update all children
    int QueueSize = (int)ChildObjects.size();
    for(int i = 0; i < QueueSize; i++)
    {
        // Get child
        g2Controller* Child = ChildObjects.front();
        ChildObjects.pop();
        
        // Update child key event
        Child->__KeyEvent(key, IsSpecial);
        
        // Put back
        ChildObjects.push(Child);
    }
}
Exemplo n.º 19
0
void InputSystem::bindAction(const char* key, int t, void (*callback)()) {
	key_callbacks[key] = KeyEvent(key, t, callback);
}
Exemplo n.º 20
0
void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp ){
	bool added = g_keyEvents.insert( KeyEvents::value_type( name, KeyEvent( GlobalShortcuts_insert( name, accelerator ), keyDown, keyUp ) ) ).second;
	ASSERT_MESSAGE( added, "command already registered: " << makeQuoted( name ) );
}
Exemplo n.º 21
0
/**
 *	This method processes key down events
 */
LineEditor::ProcessState LineEditor::processKeyEvent(
	KeyEvent event, std::string& resultString )
{
	#define EMPTY_STR(str) \
		(str.empty() || str.find_first_not_of(32) == std::string::npos)

	const KeyEvent::Key eventKey = event.key();

	bool isResultSet = false;
	bool isHandled = false;

	if (event.isKeyDown())
	{
		char keyChar = event.character();

		isHandled = this->processAdvanceEditKeys( event );
		if (!isHandled)
		{
			isHandled = true;
			switch (eventKey)
			{
			case KeyEvent::KEY_RETURN:
			case KeyEvent::KEY_JOY8:	// 'A' key
				if (!event.isAltDown())
				{
					resultString = editString_;
					isResultSet = true;
					editString_ = "";
					cx_ = 0;
					lastChar_ = 0;
				}
				else
				{
					isHandled = false;
				}
				break;

			case KeyEvent::KEY_DELETE:
				if ( cx_ < (int)editString_.length( ) )
					deleteChar( cx_ );
				break;

			case KeyEvent::KEY_BACKSPACE:
			case KeyEvent::KEY_JOY14:	// left trigger
				if ( cx_ )
				{
					cx_--;
					deleteChar( cx_ );
				}
				break;

			case KeyEvent::KEY_INSERT:
				inOverwriteMode_ = !inOverwriteMode_;
				break;

			case KeyEvent::KEY_LEFTARROW:
			case KeyEvent::KEY_JOY2:	// dpad left
				if ( cx_ > 0 )
					cx_--;
				break;

			case KeyEvent::KEY_RIGHTARROW:
			case KeyEvent::KEY_JOY3:	// dpad right
				if ( cx_ < (int)editString_.length() )
					cx_++;
				break;

			case KeyEvent::KEY_UPARROW:
			case KeyEvent::KEY_JOY0:	// dpad up
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = 1;
					}
					else 
					{
						if (!EMPTY_STR(editString_))
						{
							history_[historyShown_] = editString_;
						}
						++historyShown_;
					}
					showHistory();
				}
				break;

			case KeyEvent::KEY_DOWNARROW:
			case KeyEvent::KEY_JOY1:	// dpad down
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = history_.size() - 1;
					}
					else 
					{
						if (!EMPTY_STR(editString_))
						{
							history_[historyShown_] = editString_;
						}
						--historyShown_;
					}
					showHistory();
				}
				break;

			case KeyEvent::KEY_HOME:
				cx_ = 0;
				break;

			case KeyEvent::KEY_END:
				cx_ = editString_.length();
				break;

			// joystick space
			case KeyEvent::KEY_JOY15:
				keyChar = ' ';
				isHandled = false;
				break;

			default:
				isHandled = false;
				break;
			}
		}

		if (!isHandled && keyChar != 0)
		{
			isHandled = true;

			cx_ += this->insertChar( cx_, keyChar );

			lastChar_ = 0;
		}
		else if (event.isCtrlDown())
		{
			if (event.isKeyDown() && eventKey == KeyEvent::KEY_U)
			{
				int assignmentLocation = editString_.find_last_of( "=" );

				if (assignmentLocation > 0)
				{
					editString_ = editString_.substr( 0, assignmentLocation + 1 );
					cx_ = min( cx_, (int)editString_.length() );

					isHandled = true;
				}
			}
		}

		// if key is relevant (i.e. was handled) and 
		// it isn't the RETURN key, insert it into 
		// list of currently pressed-down keys
		if (isHandled && !isResultSet && this->keyRepeat_.first.key() != eventKey )
		{
			this->keyRepeat_.first  = event;
			this->keyRepeat_.second = this->time_ + KEY_REPEAT_START_SEC;
		}
		if( this->keyRepeat_.first.modifiers() != event.modifiers() )
		{
			this->keyRepeat_.first = KeyEvent( keyRepeat_.first.type(), 
				keyRepeat_.first.key(), event.modifiers() );
		}
	}
	else
	{
		// this is a key-up event. 
		// Stop key from repeating
		if (eventKey == this->keyRepeat_.first.key() ||
			event.isCtrlDown() || event.isAltDown() )
		{
			this->keyRepeat_.first = KeyEvent();
			this->keyRepeat_.second = FLT_MAX;
			this->time_ = 0;
		}
		else if( this->keyRepeat_.first.modifiers() != event.modifiers() )
		{
			this->keyRepeat_.first = KeyEvent( keyRepeat_.first.type(), 
				keyRepeat_.first.key(), event.modifiers() );
		}
	}

	// these are key up and key downs
	if (!isHandled) switch (eventKey)
	{
		// any joystick button or quantized direction 
		// change and we go and update our joystick state
		case KeyEvent::KEY_JOYALPUSH:
		case KeyEvent::KEY_JOYARPUSH:
		case KeyEvent::KEY_JOYALUP:
		case KeyEvent::KEY_JOYALDOWN:
		case KeyEvent::KEY_JOYALLEFT:
		case KeyEvent::KEY_JOYALRIGHT:
		case KeyEvent::KEY_JOYARUP:
		case KeyEvent::KEY_JOYARDOWN:
		case KeyEvent::KEY_JOYARLEFT:
		case KeyEvent::KEY_JOYARRIGHT:
			this->processJoystickStates(
				InputDevices::joystick().stickDirection( 1 ),
				InputDevices::joystick().stickDirection( 0 ),
				InputDevices::isKeyDown( KeyEvent::KEY_JOYARPUSH ),
				InputDevices::isKeyDown( KeyEvent::KEY_JOYALPUSH ) );
			isHandled = true;
			break;
	}

	// end of line, request processing
	if (isResultSet)
	{
		if (!EMPTY_STR(resultString))
		{
			if (history_.size() > 0 && historyShown_ != -1)
			{
				history_[ 0 ] = resultString;
			}
			else
			{
				history_.insert( history_.begin(), resultString );
			}
		}
		else
		{
			if (history_.size() > 0 && EMPTY_STR(history_[ 0 ]))
			{
				history_.erase(history_.begin());
			}
		}
		// clamp history 
		if (history_.size() > MAX_HISTORY_ENTRIES)
		{
			history_.erase( history_.end()-1 );
		}
		historyShown_ = -1;
		return RESULT_SET;
	}

	if (isHandled)
	{
		return PROCESSED;
	}

	return NOT_HANDLED;
}
Exemplo n.º 22
0
int _jGetString(char *dest, char *start, int maxlen, GS_TYPE type)
{
	/*
	 * Returns 1 if OK; 0 if rejected or quit.
	 */

	int y;
	event e;
	int i;
	int startx;
   int key;

   curpos = 0;
	HideCursor();
	startx = QueryX();
	y = QueryY();

	lrects = malloc(maxlen * sizeof(rect));
	for (i = 0; i < maxlen; i++)
	{
		rect R;

		R.Xmin = startx + i * StringWidthX;
		R.Xmax = R.Xmin + StringWidthX - 1;
		R.Ymax = y;
		R.Ymin = R.Ymax - FontHeight + 1;
		lrects[i] = R;
	}


	tbuf = malloc(maxlen + 1);
	memset(tbuf, ' ', maxlen);
	tbuf[maxlen] = 0;

	i = 0;
	if (start)
	{
		for (i = 0; i < maxlen && start[i]; i++)
			tbuf[i] = start[i];
	}
	curpos = min(i, maxlen - 1);



	TextAlign(alignLeft, alignBottom);

	DrawString(tbuf);

	/* Now highlight somebody */
	InvertRect(&lrects[curpos]);


	while (1)
	{
      key = 0;

		KeyEvent(true, &e);
      if (e.ASCII && e.ASCII != 0xe0)
         key = e.ASCII;
      else if (e.ScanCode != 0xff)
         key = e.ScanCode << 8;

      



		if (key)
		{
			if (key == 0x0d || key == 0x1b)
				break;

			if (key == 0x08)	/* backspace */
            backspace(maxlen);
         else if (key == 0x15)      /* control U */
         {
            while(curpos)
               backspace(maxlen);
         }
			else
			{
				int acceptable = 0;

				if (type == GS_ANYTHING)
					acceptable = isprint(key);
				else if (type == GS_INTEGER)
					acceptable = isdigit(key) || key == '-';
				else if (type == GS_UNSIGNED)
					acceptable = isdigit(key);
				else if (type == GS_FLOAT)
					acceptable = isdigit(key) || key == '.' || key == '-' || key == 'E' || key == 'e';

				if (acceptable)
				{
					InvertRect(&lrects[curpos]);
					MoveTo(lrects[curpos].Xmin, lrects[curpos].Ymax);
					DrawChar(key);
					tbuf[curpos] = key;

					if (curpos < maxlen - 1)
						curpos++;

					InvertRect(&lrects[curpos]);
				}
			}

		}
		else
		{
			int button = (e.State & 0x700) >> 8;

			if (button == swRight)
			{
				key = 0x1b;
				break;
			}
		}
	}
	if (key != 0x1b)
		strcpy(dest, tbuf);

	ShowCursor();
	free(lrects);
	free(tbuf);
	return (key != 0x1b);
}
Exemplo n.º 23
0
void GameView::handle_keyboard_event(QKeyEvent* event, KeyEventType type) {
    if (type == KEY_PRESS_EVENT) {
        std::string text = event->text().toStdString();
        //std::cout << text << std::endl;
        _game.handle_text_event(text);
    }
    
    Key key = KEY_NONE;
    
    switch (event->key()) {
        case Qt::Key_Space: key = KEY_SPACE; break;
            
        case Qt::Key_0: key = KEY_0; break;
        case Qt::Key_1: key = KEY_1; break;
        case Qt::Key_2: key = KEY_2; break;
        case Qt::Key_3: key = KEY_3; break;
        case Qt::Key_4: key = KEY_4; break;
        case Qt::Key_5: key = KEY_5; break;
        case Qt::Key_6: key = KEY_6; break;
        case Qt::Key_7: key = KEY_7; break;
        case Qt::Key_8: key = KEY_8; break;
        case Qt::Key_9: key = KEY_9; break;
            
        case Qt::Key_A: key = KEY_A; break;
        case Qt::Key_B: key = KEY_B; break;
        case Qt::Key_C: key = KEY_C; break;
        case Qt::Key_D: key = KEY_D; break;
        case Qt::Key_E: key = KEY_E; break;
        case Qt::Key_F: key = KEY_F; break;
        case Qt::Key_G: key = KEY_G; break;
        case Qt::Key_H: key = KEY_H; break;
        case Qt::Key_I: key = KEY_I; break;
        case Qt::Key_J: key = KEY_J; break;
        case Qt::Key_K: key = KEY_K; break;
        case Qt::Key_L: key = KEY_L; break;
        case Qt::Key_M: key = KEY_M; break;
        case Qt::Key_N: key = KEY_N; break;
        case Qt::Key_O: key = KEY_O; break;
        case Qt::Key_P: key = KEY_P; break;
        case Qt::Key_Q: key = KEY_Q; break;
        case Qt::Key_R: key = KEY_R; break;
        case Qt::Key_S: key = KEY_S; break;
        case Qt::Key_T: key = KEY_T; break;
        case Qt::Key_U: key = KEY_U; break;
        case Qt::Key_V: key = KEY_V; break;
        case Qt::Key_W: key = KEY_W; break;
        case Qt::Key_X: key = KEY_X; break;
        case Qt::Key_Y: key = KEY_Y; break;
        case Qt::Key_Z: key = KEY_Z; break;
            
        case Qt::Key_Up: key = KEY_ARROW_UP; break;
        case Qt::Key_Down: key = KEY_ARROW_DOWN; break;
        case Qt::Key_Left: key = KEY_ARROW_LEFT; break;
        case Qt::Key_Right: key = KEY_ARROW_RIGHT; break;
            
        case Qt::Key_Backspace: key = KEY_BACKSPACE; break;
        case Qt::Key_Return: case Qt::Key_Enter: key = KEY_RETURN; break;
        case Qt::Key_Escape: key = KEY_ESCAPE; break;
            
        default: QGLWidget::keyPressEvent(event); break;
    }
    
    if (key != KEY_NONE) {
        _game.handle_keyboard_event(KeyEvent(key, type));
    }
}
Exemplo n.º 24
0
BOOL
consoleGetKey (
    PKBDKEY        Key,
     BOOL           fWait
    )
/*++

Routine Description:

    Gets the next key from  the input buffer.

Arguments:

    Key     -	Supplies a pointer to a key structure
    fWait   -	Supplies a flag:
		if TRUE, the function blocks until a key is ready.
		if FALSE, the function returns immediately.

Return Value:

    TRUE if keystroke read, FALSE otherwise.

--*/
{

    PINPUT_RECORD   pEvent;

    do {
	pEvent = NextEvent( ADVANCE, fWait );

	if (pEvent) {

	    switch ( EVENT_TYPE(pEvent) ) {

	    case KEY_EVENT:
		if (KeyEvent(PKEY_EVT(pEvent), Key)) {
		    return TRUE;
		}
		break;

	    case MOUSE_EVENT:
		MouseEvent(PMOUSE_EVT(pEvent));
		break;

	    case WINDOW_BUFFER_SIZE_EVENT:
		WindowEvent(PWINDOW_EVT(pEvent));
		break;

            case MENU_EVENT:
                MenuEvent(PMENU_EVT(pEvent));
            break;

            case FOCUS_EVENT:
                if (FocusEvent(PFOCUS_EVT(pEvent), Key)) {
		    return TRUE;
		}
            break;

	    default:
		break;
	    }
	}
    } while (fWait);

    return FALSE;
}
Exemplo n.º 25
0
	KeyEvent Input::makeKey (EventImpl x) {
		SDL_Event *ev = reinterpret_cast<SDL_Event*>(x);
		return KeyEvent(ms_,
			ev->key.keysym.sym,
			ev->key.state == SDL_PRESSED );
	}
Exemplo n.º 26
0
bool EmitKeyDownEventForKey(FKey key, int32 user, bool repeat)
{
	FKeyEvent KeyEvent(key, FSlateApplication::Get().GetModifierKeys(), user, repeat, 0, 0);
	return FSlateApplication::Get().ProcessKeyDownEvent(KeyEvent);
}
Exemplo n.º 27
0
void OpenGLWindow::keyReleaseEvent(QKeyEvent * e)
{
	KeyEvent(e, GLFW_RELEASE);
}
Exemplo n.º 28
0
void OpenGLWindow::keyPressEvent(QKeyEvent * e)
{
	KeyEvent(e, GLFW_PRESS);
}
Exemplo n.º 29
0
bool ControllerScriptingInterface::isKeyCaptured(QKeyEvent* event) const {
    return isKeyCaptured(KeyEvent(*event));
}
Exemplo n.º 30
0
void henon_tweaker(void)
{
	int i;
	char chosen_file[128];
	rect R;
	rect tR;
	int last_time;
	int keyword;
	int current_item;
	int centerx, centery;
	int height, width;
	int row;
	static int lefters[] = {
		1, 2, 0,
		4, 3,
		5,
		12, 6, 7, 8, 9, 10, 11,
		15, 13, 14
	};

	static int righters[] = {
		1, 2, 0,
		4, 3,
		5,
		7, 8, 9, 10, 11, 12, 6,
		14, 15, 13
	};

	static int uppers[] = {
		13, 14, 15,
		0, 2,
		3,
		5, 5, 5, 5, 5, 5, 5,
		6, 8, 11
	};

	static int downers[] = {
		3, 3, 4,
		5, 5,
		8,
		13, 13, 13, 14, 14, 15, 15,
		0, 1, 2
	};

	our_flocktype = flocktype;
	our_tracetype = tracetype;
	henon_slider.value = fha;


	height = 2 + FontHeight + 8 +
		2 * (3 * FontHeight / 2) +
		slider_height(&henon_slider) + 4
		+ 2 * FontHeight + 4;

	width = 2 * sR.Xmax / 3;

	HideCursor();
	PushCursorPosition();
	BasicCenteredBox(&tR, width, height, LIGHTGRAY, "Hnon Tweaks", BLACK);
	Centers(&tR, &centerx, &centery);
	PushMouseRectLimit(&tR);
	items = 0;

	R.Xmin = tR.Xmin + 4 + StringWidth("Flock Size: ") + 4;
	R.Xmax = tR.Xmax - 4;
	R.Ymin = row = tR.Ymin + FontHeight + 8;
	R.Ymax = R.Ymin + FontHeight + 4;
	JString("Flock size: ", R.Xmin - 2, R.Ymin + 2, BLACK, LIGHTGRAY, alignRight, alignTop);
	CreateRadioPanel(&R, SML, flocktypeR, 3, our_flocktype);
	for (i = 0; i < 3; i++)
		bR[items++] = &flocktypeR[i];


	OffsetRect(&R, 0, 3 * FontHeight / 2);
	R.Xmin = centerx;
	row = R.Ymin;
	JString("Trace Type: ", R.Xmin - 2, R.Ymin + 2, BLACK, LIGHTGRAY, alignRight, alignTop);
	CreateRadioPanel(&R, PL, tracetypeR, 2, our_tracetype);
	for (i = 0; i < 2; i++)
		bR[items++] = &tracetypeR[i];

	row += 3 * FontHeight / 2;
	create_slider(&henon_slider, &tR, 4, row - tR.Ymin);
	bR[items++] = &henon_slider.bR;
	bR[items++] = &henon_slider.TB.nR;
	for (i = 0; i < 6; i++)
		bR[items++] = &henon_slider.zR[i];

	if (!fancyflag)
	{
		R = henon_slider.tR;
		InsetRect(&R, 1, 1);
		GrayOut(&R);
	}

	row = henon_slider.tR.Ymax + FontHeight;
	R.Xmin = tR.Xmin + 4;
	R.Xmax = tR.Xmax - 4;
	R.Ymin = row;
	R.Ymax = row + FontHeight + 4;

	CreateRadioPanel(&R, standard_button_texts, doitR, 3, -1);
	for (i = 0; i < 3; i++)
		bR[items++] = &doitR[i];

	current_item = items - 1;
	push(current_item, true);
	move_to_corner(bR[current_item]);

	ShowCursor();
	while (1)
	{
		event e;
		int n = KeyEvent(false, &e);
		int button = (e.State & 0x700) >> 8;
		int X = e.CursorX;
		int Y = e.CursorY;
		int last_item = current_item;
		slider *current_slider = NULL;

		if (fancyflag && XYInRect(X, Y, &henon_slider.tR))
			current_slider = &henon_slider;
		keyword = 0;
		if (n)
			last_time = e.Time;
		else
		{
			if (e.Time - last_time > 5)
			{
				if (button)
					n = 1;
				else
					last_time = e.Time;
			}
		}
		if (n)
		{
			keyword = ShiftArrows(&e);
			if (button == swRight)
				keyword = 0x1b;

			if (!keyword)
			{
				if (e.ASCII && e.ASCII != 0xe0)
					keyword = e.ASCII;
				else
					keyword = e.ScanCode << 8;
			}
			if (button == swLeft)
			{
				keyword = 0x0d;
				if (current_slider)
				{
					if (XYInRect(X, Y, &current_slider->bR))
					{
						PushMouseRectLimit(&current_slider->sR);
						while (button == swLeft)
						{
							reposition_slider_X(current_slider, X, false);
							KeyEvent(false, &e);
							button = (e.State & 0x700) >> 8;
							X = e.CursorX;
							Y = e.CursorY;
						}
						PopMouseRect();
						keyword = 0;
					}
					else if (XYInRect(X, Y, &current_slider->sR))
					{
						reposition_slider_X(current_slider, X, false);
						keyword = 0;
					}
				}
			}