您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ translateKey函数代码示例

51自学网 2021-06-03 08:57:10
  C++
这篇教程C++ translateKey函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中translateKey函数的典型用法代码示例。如果您正苦于以下问题:C++ translateKey函数的具体用法?C++ translateKey怎么用?C++ translateKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了translateKey函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _

void OptionKey::Render(){    WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);    mFont->SetColor(getColor(WGuiColor::TEXT));    JRenderer * renderer = JRenderer::GetInstance();    if (LOCAL_KEY_NONE == from)    {        string msg = _("New binding...");        mFont->DrawString(msg, (SCREEN_WIDTH - mFont->GetStringWidth(msg.c_str())) / 2, y + 2);    }    else    {        const KeyRep& rep = translateKey(from);        if (rep.second)            renderer->RenderQuad(rep.second, x + 4, y + 3, 0, 16.0f / rep.second->mHeight, 16.0f / rep.second->mHeight);        else            mFont->DrawString(rep.first, x + 4, y + 3, JGETEXT_LEFT);        const KeyRep& rep2 = translateKey(to);        if (rep2.second)        {            float ratio = 16.0f / rep2.second->mHeight;            renderer->RenderQuad(rep2.second, x + width - (ratio * rep2.second->mWidth) - 2, y + 3, 0, ratio, ratio);        }        else            mFont->DrawString(rep2.first, width - 4, y + 3, JGETEXT_RIGHT);    }}
开发者ID:Esplin,项目名称:wagic,代码行数:28,


示例2: cKey

void ConfigurationMapper::enumerate(const std::string& key, Keys& range) const{	std::string cKey(key);	if (!cKey.empty()) cKey += '.';	std::string::size_type keyLen = cKey.length();	if (keyLen < _toPrefix.length())	{		if (_toPrefix.compare(0, keyLen, cKey) == 0)		{			std::string::size_type pos = _toPrefix.find_first_of('.', keyLen);			poco_assert_dbg(pos != std::string::npos);			range.push_back(_toPrefix.substr(keyLen, pos - keyLen));		}	}	else	{		std::string translatedKey;		if (cKey == _toPrefix)		{			translatedKey = _fromPrefix;			if (!translatedKey.empty())				translatedKey.resize(translatedKey.length() - 1);		}		else translatedKey = translateKey(key);		_pConfig->enumerate(translatedKey, range);	}}
开发者ID:beneon,项目名称:MITK,代码行数:27,


示例3: switch

LONG WINAPI QuackWin::MainWndProc(HWND n_hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {	switch (uMsg) {	case WM_DESTROY:		PostQuitMessage(0);		break;	case WM_CREATE:	{									LPCREATESTRUCT cs = reinterpret_cast<LPCREATESTRUCT>(lParam);									void * lpCreateParam = cs->lpCreateParams;									QuackWin *win = reinterpret_cast<QuackWin *>(lpCreateParam);									assert(win == this);									return DefWindowProc(hWnd, uMsg, wParam, lParam);	}	case WM_CHAR:	case WM_KEYDOWN:	case WM_SYSCHAR:	case WM_UNICHAR:	case WM_SYSKEYDOWN:	{											const char key = translateKey(wParam, lParam);											if (key == 0)												break;											input->HandleKeyPress(key);											break;	}	}	return DefWindowProc(hWnd, uMsg, wParam, lParam);}
开发者ID:orbv,项目名称:Quack,代码行数:29,


示例4: getKeyFromBuffer

int16 Util::checkKey() {	Common::KeyState key;	getKeyFromBuffer(key);	return translateKey(key);}
开发者ID:tramboi,项目名称:scummvm-test,代码行数:7,


示例5: translateKey

BOOL LLKeyboardWin32::translateExtendedKey(const U16 os_key, const MASK mask, KEY *translated_key){	if(mNumpadDistinct == ND_NUMLOCK_ON)	{		std::map<U16, KEY>::iterator iter = mTranslateNumpadMap.find(os_key);		if (iter != mTranslateNumpadMap.end())		{			*translated_key = iter->second;			return TRUE;		}	}	BOOL success = translateKey(os_key, translated_key);	if(mNumpadDistinct != ND_NEVER) {		if(!success) return success;		if(mask & MASK_EXTENDED) 		{			// this is where we'd create new keycodes for extended keys			// the set of extended keys includes the 'normal' arrow keys and 			// the pgup/dn/insert/home/end/delete cluster above the arrow keys			// see http://windowssdk.msdn.microsoft.com/en-us/library/ms646280.aspx			// only process the return key if numlock is off			if(((mNumpadDistinct == ND_NUMLOCK_OFF && 				 !(GetKeyState(VK_NUMLOCK) & 1)) 				 || mNumpadDistinct == ND_NUMLOCK_ON) &&					*translated_key == KEY_RETURN) {					*translated_key = KEY_PAD_RETURN;			}		}		else 		{			// the non-extended keys, those are in the numpad			switch (*translated_key) 			{				case KEY_LEFT:					*translated_key = KEY_PAD_LEFT; break;				case KEY_RIGHT: 					*translated_key = KEY_PAD_RIGHT; break;				case KEY_UP: 					*translated_key = KEY_PAD_UP; break;				case KEY_DOWN:					*translated_key = KEY_PAD_DOWN; break;				case KEY_HOME:					*translated_key = KEY_PAD_HOME; break;				case KEY_END:					*translated_key = KEY_PAD_END; break;				case KEY_PAGE_UP:					*translated_key = KEY_PAD_PGUP; break;				case KEY_PAGE_DOWN:					*translated_key = KEY_PAD_PGDN; break;				case KEY_INSERT:					*translated_key = KEY_PAD_INS; break;				case KEY_DELETE:					*translated_key = KEY_PAD_DEL; break;			}		}	}	return success;}
开发者ID:Xara,项目名称:Opensource-V2-SL-Viewer,代码行数:60,


示例6: if

void eLircInputDevice::handleCode(long arg){	const lircEvent* event = (const lircEvent*)arg;	int code, flags;	if (event->repeat == true) {		flags = eRCKey::flagRepeat;	} else if (event->release == true) {		flags = eRCKey::flagBreak;	} else {		flags = eRCKey::flagMake;	}	code = translateKey(event->name);	eDebug("LIRC name=%s code=%d flags=%d", event->name, code, flags);	input->keyPressed(eRCKey(this, code, flags));	if (flags == eRCKey::flagMake) {		flags = eRCKey::flagBreak;		eDebug("LIRC name=%s code=%d flags=%d", event->name, code, flags);		input->keyPressed(eRCKey(this, code, flags));		flags = eRCKey::flagMake;	}}
开发者ID:Leatherface75,项目名称:enigma2pc,代码行数:25,


示例7: SDL_PumpEvents

//// ISDL12KeyboardInputDevice::gatherEvents//// Pumps the SDL Event queue and retrieves any mouse events and puts them into// this instance's event queue.//void ISDL12KeyboardInputDevice::gatherEvents(){	if (!active())		return;	// Force SDL to gather events from input devices. This is called	// implicitly from SDL_PollEvent but since we're using SDL_PeepEvents to	// process only mouse events, SDL_PumpEvents is necessary.	SDL_PumpEvents();	// Retrieve chunks of up to 1024 events from SDL	int num_events = 0;	const int max_events = 1024;	SDL_Event sdl_events[max_events];	bool quit_event = false;	while ((num_events = SDL_PeepEvents(sdl_events, max_events, SDL_GETEVENT, SDL_KEYEVENTMASK)))	{		for (int i = 0; i < num_events; i++)		{			const SDL_Event& sdl_ev = sdl_events[i];			assert(sdl_ev.type == SDL_KEYDOWN || sdl_ev.type == SDL_KEYUP);			if (sdl_ev.key.keysym.sym == SDLK_F4 && sdl_ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))			{				// HeX9109: Alt+F4 for cheats! Thanks Spleen				// [SL] Don't handle it here but make sure we indicate there was an ALT+F4 event.				quit_event = true;			}			else if (sdl_ev.key.keysym.sym == SDLK_TAB && sdl_ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))			{				// do nothing - the event is dropped			}			else			{				// Normal game keyboard event - insert it into our internal queue				event_t ev;				ev.type = (sdl_ev.type == SDL_KEYDOWN) ? ev_keydown : ev_keyup;				ev.data1 = translateKey(sdl_ev.key.keysym.sym);				ev.data2 = ev.data3 = translateKeyText(sdl_ev.key.keysym.sym, sdl_ev.key.keysym.mod);								if (ev.data1)					mEvents.push(ev);			}		}	}	// Translate the ALT+F4 key combo event into a SDL_QUIT event and push	// it back into SDL's event queue so that it can be handled elsewhere.	if (quit_event)	{		SDL_Event sdl_ev;		sdl_ev.type = SDL_QUIT;		SDL_PushEvent(&sdl_ev);	}}
开发者ID:davidsgalbraith,项目名称:odamex,代码行数:63,


示例8: translateKey

bool Util::checkKey(int16 &key) {	Common::KeyState keyS;	if (!getKeyFromBuffer(keyS))		return false;	key = translateKey(keyS);	return true;}
开发者ID:tramboi,项目名称:scummvm-test,代码行数:10,


示例9: translateKey

void WebWindow::onKeyUp(CEGUI::KeyEventArgs& e){    UINT vk = translateKey(e.scancode);    if (vk)    {        e.handled = d_webView->keyUp(vk, 0, false);    }    CEGUI::Window::onKeyUp(e);}
开发者ID:DaneTheory,项目名称:wke,代码行数:10,


示例10: translateKey

void eSDLInputDevice::handleCode(long arg){	const SDL_KeyboardEvent *event = (const SDL_KeyboardEvent *)arg;	const SDL_keysym *key = &event->keysym;	int km = input->getKeyboardMode();	int code, flags;	if (event->type == SDL_KEYDOWN) {		m_unicode = key->unicode;		flags = eRCKey::flagMake;	} else {		flags = eRCKey::flagBreak;	}	if (km == eRCInput::kmNone) {		code = translateKey(key->sym);	} else {		eDebug("unicode=%04x scancode=%02x", m_unicode, key->scancode);		if (m_unicode & 0xff80) {			eDebug("SDL: skipping unicode character");			return;		}		code = m_unicode & ~0xff80;		// unicode not set...!? use key symbol		if (code == 0) {			// keysym is ascii			if (key->sym >= 128) {				eDebug("SDL: cannot emulate ASCII");				return;			}			eDebug("SDL: emulate ASCII");			code = key->sym;		}		if (km == eRCInput::kmAscii) {			// skip ESC c or ESC '[' c			if (m_escape) {				if (code != '[')					m_escape = false;				return;			}			if (code == SDLK_ESCAPE)				m_escape = true;			if ((code < SDLK_SPACE) ||			    (code == 0x7e) ||	// really?			    (code == SDLK_DELETE))				return;		}		flags |= eRCKey::flagAscii;	}	eDebug("SDL code=%d flags=%d", code, flags);	input->keyPressed(eRCKey(this, code, flags));}
开发者ID:BananaSamurai,项目名称:Enigma2,代码行数:55,


示例11: while

int16 Util::getKey() {	Common::KeyState key;	while (!getKeyFromBuffer(key)) {		processInput();		if (keyBufferEmpty())			g_system->delayMillis(10 / _vm->_global->_speedFactor);	}	return translateKey(key);}
开发者ID:tramboi,项目名称:scummvm-test,代码行数:11,


示例12: getWindow

void GfxGLWindowGLUT::keyboardCB( unsigned char key, int x, int y ){    GfxGLWindowGLUT& window = getWindow();    KeyID keyId = translateKey( key );    ModBitfield mods = getModifiers();    // FIXME: what does GLUT's key CB correspond to? keydown, or     // key press?    //window.keyDownReceived( keyId, mods );    window.keyPressed( keyId, mods );    window.handleMiscEvents();}
开发者ID:jeske,项目名称:freecoth,代码行数:13,


示例13: SimpleMenu

void OptionKey::KeyPressed(LocalKeySym key){    from = key;    g->UngrabKeyboard(this);    grabbed = false;    btnMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 0, this, Fonts::MENU_FONT, 80, 10);    for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i)    {        const KeyRep& rep = translateKey(btnList[i]);        btnMenu->Add(i, rep.first.c_str());    }}
开发者ID:Esplin,项目名称:wagic,代码行数:13,


示例14: translateKey

BOOL LLKeyboardMacOSX::translateNumpadKey( const U16 os_key, KEY *translated_key ){	if(mNumpadDistinct == ND_NUMLOCK_ON)	{		std::map<U16, KEY>::iterator iter= mTranslateNumpadMap.find(os_key);		if(iter != mTranslateNumpadMap.end())		{			*translated_key = iter->second;			return TRUE;		}	}	return translateKey(os_key, translated_key);}
开发者ID:IamusNavarathna,项目名称:SingularityViewer,代码行数:13,


示例15: translateKey

void SdlContext::processKeyboardEvent( SDL_KeyboardEvent& event ){    if(event.type != SDL_KEYDOWN)        return;        unsigned int key= translateKey(event.keysym.sym);    if(key == 0)        return;        int x, y;    SDL_GetMouseState(&x, &y);        //~ printf("widgets: scan 0x%x '%c' key %c %d, key name %s/n", event.keysym.scancode, event.keysym.scancode, event.keysym.sym, translateKey(event.keysym.sym), SDL_GetKeyName(event.keysym.sym));    UIContext::keyboard(key, x, y);}
开发者ID:Amxx,项目名称:MobileReality,代码行数:15,


示例16: Q_UNUSED

void QWaylandInputDevice::inputHandleKey(void *data,					 struct wl_input_device *input_device,					 uint32_t time, uint32_t key, uint32_t state){#ifndef QT_NO_WAYLAND_XKB    Q_UNUSED(input_device);    QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;    QWaylandWindow *window = inputDevice->mKeyboardFocus;    uint32_t code, sym, level;    Qt::KeyboardModifiers modifiers;    QEvent::Type type;    char s[2];    if (window == NULL) {	/* We destroyed the keyboard focus surface, but the server	 * didn't get the message yet. */	return;    }    code = key + inputDevice->mXkb->min_key_code;    level = 0;    if (inputDevice->mModifiers & Qt::ShiftModifier &&	XkbKeyGroupWidth(inputDevice->mXkb, code, 0) > 1)	level = 1;    sym = XkbKeySymEntry(inputDevice->mXkb, code, level, 0);    modifiers = translateModifiers(inputDevice->mXkb->map->modmap[code]);    if (state) {	inputDevice->mModifiers |= modifiers;	type = QEvent::KeyPress;    } else {	inputDevice->mModifiers &= ~modifiers;	type = QEvent::KeyRelease;    }    sym = translateKey(sym, s, sizeof s);    if (window) {        QWindowSystemInterface::handleKeyEvent(window->widget(),                                               time, type, sym,                                               inputDevice->mModifiers,                                               QString::fromLatin1(s));    }#endif}
开发者ID:Suneal,项目名称:qt,代码行数:48,


示例17: SP_PollEvents

void SP_PollEvents(void) {	SDL_Event event;	while(SDL_PollEvent(&event)) {		if (event.type == SDL_QUIT) {			pleaseExit = true;		} else if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) {			boolean down = event.type == SDL_KEYDOWN;			if (down && event.key.keysym.sym == SDLK_m) { // override mouse grabbing				toggleMouseGrab();			}			int idKey = translateKey(event.key.keysym.sym);			if (idKey != 0) {				SPI_InputKey(idKey, down);			}			char c=0;			if ((event.key.keysym.unicode&0xFF80) == 0) {				c = event.key.keysym.unicode&0x7F;			}			if (down && c != 0) {				SPI_InputASCII(c);			}		} else if (event.type == SDL_MOUSEMOTION) {			SPI_InputMouseMotion(event.motion.xrel,event.motion.yrel);		} else if (event.type == SDL_MOUSEBUTTONDOWN) {			if (event.button.button == SDL_BUTTON_LEFT) {				SPI_InputKey(but_Mouse1, 1);			} else if (event.button.button == SDL_BUTTON_RIGHT) {				SPI_InputKey(but_Mouse2, 1);			} else if (event.button.button == SDL_BUTTON_MIDDLE) {				SPI_InputKey(but_Mouse3, 1);			}		} else if (event.type == SDL_MOUSEBUTTONUP) {			if (event.button.button == SDL_BUTTON_LEFT) {				SPI_InputKey(but_Mouse1, 0);			} else if (event.button.button == SDL_BUTTON_RIGHT) {				SPI_InputKey(but_Mouse2, 0);			} else if (event.button.button == SDL_BUTTON_MIDDLE) {				SPI_InputKey(but_Mouse3, 0);			}		} else if (event.type == SDL_VIDEORESIZE) {			SDL_ResizeEvent *resize = (SDL_ResizeEvent*)&event;			SPG_SetWindowSize(resize->w, resize->h);		}	}}
开发者ID:NotStiller,项目名称:Catacomb3D,代码行数:46,


示例18: translateKey

/** /brief The GUI's key press event handler. * *  This function should be called from the SDL event loop. It takes a keyboard event *  as an argument, translates it to PUI syntax and passes it to the *  PUI-internal keyboard function. If there's no active widget which could *  use the key event the function will return false, giving the caller *  the opportunity to use the event for other purposes. *  /param key A key symbol generated by an SDL keyboard event. *  /return true if PUI was able to handle the event */bool CGUIMain::keyDownEventHandler(SDL_keysym& key){  int tkey;  bool ret;  tkey = translateKey(key);  ret = puKeyboard(tkey, PU_DOWN);    // ESC key handling  // note: translateKey() does not affect the ESC keysym,  // so it is safe to test the SDL key value here  if (!ret && (tkey == SDLK_ESCAPE))  {    if (isVisible())    {      CRRCDialog* top = CRRCDialog::getToplevel();      if (top != NULL)      {        if (top->hasCancelButton())        {          //std::cout << "Invoking CANCEL for toplevel dialog" << std::endl;          top->setValue(CRRC_DIALOG_CANCEL);          top->invokeCallback();        }      }      else      {        //std::cout << "No active dialog, hiding GUI" << std::endl;        hide();      }    }    else    {      reveal();    }    ret = true;  }  return ret;}
开发者ID:mayrit,项目名称:crrcsim,代码行数:50,


示例19: flushCompressedMouse

voidServerProxy::keyUp(){	// get mouse up to date	flushCompressedMouse();	// parse	UInt16 id, mask, button;	ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button);	LOG((CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button));	// translate	KeyID id2             = translateKey(static_cast<KeyID>(id));	KeyModifierMask mask2 = translateModifierMask(								static_cast<KeyModifierMask>(mask));	if (id2   != static_cast<KeyID>(id) ||		mask2 != static_cast<KeyModifierMask>(mask))		LOG((CLOG_DEBUG1 "key up translated to id=0x%08x, mask=0x%04x", id2, mask2));	// forward	m_client->keyUp(id2, mask2, button);}
开发者ID:TotoxLAncien,项目名称:synergy,代码行数:22,


示例20: windowProc

// Window callback function (handles window events)//static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,                                   WPARAM wParam, LPARAM lParam){    _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0);    switch (uMsg)    {        case WM_NCCREATE:        {            CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;            SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);            break;        }        case WM_SETFOCUS:        {            if (window->cursorMode != GLFW_CURSOR_NORMAL)                _glfwPlatformApplyCursorMode(window);            if (window->monitor && window->autoIconify)                enterFullscreenMode(window);            _glfwInputWindowFocus(window, GL_TRUE);            return 0;        }        case WM_KILLFOCUS:        {            if (window->cursorMode != GLFW_CURSOR_NORMAL)                restoreCursor(window);            if (window->monitor && window->autoIconify)            {                _glfwPlatformIconifyWindow(window);                leaveFullscreenMode(window);            }            _glfwInputWindowFocus(window, GL_FALSE);            return 0;        }        case WM_SYSCOMMAND:        {            switch (wParam & 0xfff0)            {                case SC_SCREENSAVE:                case SC_MONITORPOWER:                {                    if (window->monitor)                    {                        // We are running in full screen mode, so disallow                        // screen saver and screen blanking                        return 0;                    }                    else                        break;                }                // User trying to access application menu using ALT?                case SC_KEYMENU:                    return 0;            }            break;        }        case WM_CLOSE:        {            _glfwInputWindowCloseRequest(window);            return 0;        }        case WM_KEYDOWN:        case WM_SYSKEYDOWN:        {            const int scancode = (lParam >> 16) & 0x1ff;            const int key = translateKey(wParam, lParam);            if (key == _GLFW_KEY_INVALID)                break;            _glfwInputKey(window, key, scancode, GLFW_PRESS, getKeyMods());            break;        }        case WM_CHAR:        {            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);            return 0;        }        case WM_SYSCHAR:        {            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_FALSE);            return 0;        }        case WM_UNICHAR:        {            // This message is not sent by Windows, but is sent by some//.........这里部分代码省略.........
开发者ID:RubenMagallanes,项目名称:comp308sheepSim,代码行数:101,


示例21: processEvent

static void processEvent(XEvent *event){    _GLFWwindow* window;    switch (event->type)    {	case KeyPress:	{	    // A keyboard key was pressed	    window = findWindow(event->xkey.window);	    if (window == NULL)		return;	    _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_PRESS);	    _glfwInputChar(window, translateChar(&event->xkey));	    break;	}	case KeyRelease:	{	    // A keyboard key was released	    window = findWindow(event->xkey.window);	    if (window == NULL)		return;	    // Do not report key releases for key repeats. For key repeats we	    // will get KeyRelease/KeyPress pairs with similar or identical	    // time stamps. User selected key repeat filtering is handled in	    // _glfwInputKey/_glfwInputChar.	    if (XEventsQueued(_glfwLibrary.X11.display, QueuedAfterReading))	    {		XEvent nextEvent;		XPeekEvent(_glfwLibrary.X11.display, &nextEvent);		if (nextEvent.type == KeyPress &&		    nextEvent.xkey.window == event->xkey.window &&		    nextEvent.xkey.keycode == event->xkey.keycode)		{		    // This last check is a hack to work around key repeats		    // leaking through due to some sort of time drift		    // Toshiyuki Takahashi can press a button 16 times per		    // second so it's fairly safe to assume that no human is		    // pressing the key 50 times per second (value is ms)		    if ((nextEvent.xkey.time - event->xkey.time) < 20)		    {			// Do not report anything for this event			break;		    }		}	    }	    _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_RELEASE);	    break;	}	case ButtonPress:	{	    // A mouse button was pressed or a scrolling event occurred	    window = findWindow(event->xbutton.window);	    if (window == NULL)		return;	    if (event->xbutton.button == Button1)		_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);	    else if (event->xbutton.button == Button2)		_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);	    else if (event->xbutton.button == Button3)		_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);	    // XFree86 3.3.2 and later translates mouse wheel up/down into	    // mouse button 4 & 5 presses	    else if (event->xbutton.button == Button4)		_glfwInputScroll(window, 0.0, 1.0);	    else if (event->xbutton.button == Button5)		_glfwInputScroll(window, 0.0, -1.0);	    else if (event->xbutton.button == Button6)		_glfwInputScroll(window, -1.0, 0.0);	    else if (event->xbutton.button == Button7)		_glfwInputScroll(window, 1.0, 0.0);	    break;	}	case ButtonRelease:	{	    // A mouse button was released	    window = findWindow(event->xbutton.window);	    if (window == NULL)		return;	    if (event->xbutton.button == Button1)	    {		_glfwInputMouseClick(window,				     GLFW_MOUSE_BUTTON_LEFT,				     GLFW_RELEASE);	    }	    else if (event->xbutton.button == Button2)	    {		_glfwInputMouseClick(window,//.........这里部分代码省略.........
开发者ID:Ape,项目名称:DCPUToolchain,代码行数:101,


示例22: processEvent

// Process the specified X event//static void processEvent(XEvent *event){    _GLFWwindow* window = NULL;    if (event->type != GenericEvent)    {        window = _glfwFindWindowByHandle(event->xany.window);        if (window == NULL)        {            // This is either an event for a destroyed GLFW window or an event            // of a type not currently supported by GLFW            return;        }    }    switch (event->type)    {        case KeyPress:        {            _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_PRESS);            if (!(event->xkey.state & ControlMask) &&                !(event->xkey.state & Mod1Mask /*Alt*/))            {            _glfwInputChar(window, translateChar(&event->xkey));            }            break;        }        case KeyRelease:        {            _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_RELEASE);            break;        }        case ButtonPress:        {            if (event->xbutton.button == Button1)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);            else if (event->xbutton.button == Button2)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);            else if (event->xbutton.button == Button3)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);            // Modern X provides scroll events as mouse button presses            else if (event->xbutton.button == Button4)                _glfwInputScroll(window, 0.0, 1.0);            else if (event->xbutton.button == Button5)                _glfwInputScroll(window, 0.0, -1.0);            else if (event->xbutton.button == Button6)                _glfwInputScroll(window, -1.0, 0.0);            else if (event->xbutton.button == Button7)                _glfwInputScroll(window, 1.0, 0.0);            break;        }        case ButtonRelease:        {            if (event->xbutton.button == Button1)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_LEFT,                                     GLFW_RELEASE);            }            else if (event->xbutton.button == Button2)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_MIDDLE,                                     GLFW_RELEASE);            }            else if (event->xbutton.button == Button3)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_RIGHT,                                     GLFW_RELEASE);            }            break;        }        case EnterNotify:        {            if (window->cursorMode == GLFW_CURSOR_HIDDEN)                hideCursor(window);            _glfwInputCursorEnter(window, GL_TRUE);            break;        }        case LeaveNotify:        {            if (window->cursorMode == GLFW_CURSOR_HIDDEN)                showCursor(window);            _glfwInputCursorEnter(window, GL_FALSE);            break;        }//.........这里部分代码省略.........
开发者ID:NathanSweet,项目名称:glfw,代码行数:101,


示例23: processEvent

// Process the specified X event//static void processEvent(XEvent *event){    _GLFWwindow* window = NULL;    if (event->type != GenericEvent)    {        window = _glfwFindWindowByHandle(event->xany.window);        if (window == NULL)        {            // This is an event for a window that has already been destroyed            return;        }    }    switch (event->type)    {        case KeyPress:        {            const int key = translateKey(event->xkey.keycode);            const int mods = translateState(event->xkey.state);            const int character = translateChar(&event->xkey);            _glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);            if (character != -1)                _glfwInputChar(window, character);            break;        }        case KeyRelease:        {            const int key = translateKey(event->xkey.keycode);            const int mods = translateState(event->xkey.state);            _glfwInputKey(window, key, event->xkey.keycode, GLFW_RELEASE, mods);            break;        }        case ButtonPress:        {            const int mods = translateState(event->xbutton.state);            if (event->xbutton.button == Button1)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);            else if (event->xbutton.button == Button2)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);            else if (event->xbutton.button == Button3)                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);            // Modern X provides scroll events as mouse button presses            else if (event->xbutton.button == Button4)                _glfwInputScroll(window, 0.0, 1.0);            else if (event->xbutton.button == Button5)                _glfwInputScroll(window, 0.0, -1.0);            else if (event->xbutton.button == Button6)                _glfwInputScroll(window, -1.0, 0.0);            else if (event->xbutton.button == Button7)                _glfwInputScroll(window, 1.0, 0.0);            else            {                // Additional buttons after 7 are treated as regular buttons                // We subtract 4 to fill the gap left by scroll input above                _glfwInputMouseClick(window,                                     event->xbutton.button - 4,                                     GLFW_PRESS,                                     mods);            }            break;        }        case ButtonRelease:        {            const int mods = translateState(event->xbutton.state);            if (event->xbutton.button == Button1)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_LEFT,                                     GLFW_RELEASE,                                     mods);            }            else if (event->xbutton.button == Button2)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_MIDDLE,                                     GLFW_RELEASE,                                     mods);            }            else if (event->xbutton.button == Button3)            {                _glfwInputMouseClick(window,                                     GLFW_MOUSE_BUTTON_RIGHT,                                     GLFW_RELEASE,                                     mods);            }//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:lfant,代码行数:101,


示例24: TRACEOUT

bool MMSInputLISThread::translateEvent(struct input_event *linux_evt, MMSInputEvent *inputevent) {	static int x = -1, y = -1;	static int px = 0, py = 0;	static int pressed = 0xff;	TRACEOUT("MMSINPUT", "EVENT TYPE = %d, CODE = %d, VALUE = %d", linux_evt->type, linux_evt->code, linux_evt->value);	if(linux_evt->type == EV_ABS) {		if(this->device.touch.swapXY) {			if(linux_evt->code == ABS_X) { linux_evt->code = ABS_Y; }			else if(linux_evt->code == ABS_Y) { linux_evt->code = ABS_X; }		}		switch(linux_evt->code) {			case ABS_X:				x = linux_evt->value - this->device.touch.rect.x;				if(this->device.touch.swapX) {					x = this->device.touch.rect.w - x;				}				x*= this->device.touch.xFactor;				TRACEOUT("MMSINPUT", "EVENT TYPE = EV_ABS, CODE = ABS_X, X = %d, XF = %f", x, this->device.touch.xFactor);				break;			case ABS_Y:				y = linux_evt->value - this->device.touch.rect.y;				if(this->device.touch.swapY) {					y = this->device.touch.rect.h - y;				}				y*= this->device.touch.yFactor;				TRACEOUT("MMSINPUT", "EVENT TYPE = EV_ABS, CODE = ABS_Y, Y = %d, YF = %f", y, this->device.touch.yFactor);				break;			case ABS_PRESSURE:				/*				 * if the touch driver doesn't send BTN_xxx events, use				 * ABS_PRESSURE as indicator for pressed/released				 */				TRACEOUT("MMSINPUT", "EVENT TYPE = EV_ABS, CODE = ABS_PRESSURE, VALUE = %d", linux_evt->value);				if(!this->device.touch.haveBtnEvents) {					pressed = (linux_evt->value ? 1 : 0);				}				break;			default:				break;		}	} else if(linux_evt->type == EV_KEY) {		switch(linux_evt->code) {			case BTN_LEFT:			case BTN_TOUCH:				pressed = (linux_evt->value ? 1 : 0);				break;			default:				inputevent->key = translateKey(linux_evt->code);				if (inputevent->key == MMSKEY_UNKNOWN)					return false;				inputevent->type = linux_evt->value ? MMSINPUTEVENTTYPE_KEYPRESS : MMSINPUTEVENTTYPE_KEYRELEASE;				TRACEOUT("MMSINPUT", "KEY %s %d", (pressed ? "PRESS" : "RELEASE"), inputevent->key);				return true;				break;		}	} else if(linux_evt->type == EV_SYN) {		if(pressed != 0xff) {			inputevent->type = (pressed ? MMSINPUTEVENTTYPE_BUTTONPRESS : MMSINPUTEVENTTYPE_BUTTONRELEASE);			if (pressed) {				px = x;				py = y;				if (x<0 || y<0) {					// x or y coordinate not set, ignore the PRESS event					x = -1;					y = -1;					return false;				}				inputevent->posx = x;				inputevent->posy = y;				x = -1;				y = -1;			}			else {				if (x<0 || y<0) {					// x or y coordinate not set, check pressed coordinate					x = -1;					y = -1;					if (px<0 || py<0) {						// px or py coordinate not set, ignore the RELEASE event						return false;					}					else {						inputevent->posx = px;						inputevent->posy = py;					}				}//.........这里部分代码省略.........
开发者ID:RomTok,项目名称:disco-light,代码行数:101,



注:本文中的translateKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ translate_text函数代码示例
C++ translateChar函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。