void SilverbackInput::pushKeyEvent(int key, int rawchar, bool down) {
	gcn::KeyInput i;

	//Console_Printf("Got input: %d %d %s\n", key, rawchar, down ? "down" : "up");

	if(rawchar || key < 200) {
		if(rawchar > 32 && rawchar < 127)
			i.setKey(gcn::Key(rawchar));
#ifndef _WIN32
		else if(rawchar>=127 || (rawchar == key && key <= 32))
			i.setKey(convertKey(key));
		else if(key > 32 && key < 127)
			i.setKey(gcn::Key(key));
#else
		else i.setKey(convertKey(key));
#endif

		i.setType(down ? gcn::KeyInput::PRESSED : gcn::KeyInput::RELEASED);
		i.setShiftPressed(Input_IsKeyDown(KEY_SHIFT));
		i.setControlPressed(Input_IsKeyDown(KEY_CTRL));
		i.setAltPressed(Input_IsKeyDown(KEY_ALT));
		i.setNumericPad(key >= KEY_KEYPAD_0 && key <= KEY_KEYPAD_ENTER);

		mKeyInputQueue.push(i);
	} else if ((key >= KEY_MOUSEFIRSTBUTTON && key <= KEY_MOUSELASTBUTTON) || key == KEY_XBUTTON1 || key == KEY_XBUTTON2) {
		pushMouseEvent(key, down);
	}
}
Esempio n. 2
0
void RenderWindow::handleEvent(sf::Event& event)
{
    actionMap.pushEvent(event);
    if(actionMap.isActive("QUIT"))
        this->close();

    actionMap.invokeCallbacks(callbackSystem, this);

    CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
    sf::Vector2i mousep = sf::Mouse::getPosition(*this);
    if(event.type == sf::Event::MouseLeft)
        context.injectMouseLeaves();
    context.injectMousePosition(mousep.x, mousep.y);
    if(event.type == sf::Event::MouseButtonPressed)
        context.injectMouseButtonDown(CEGUI::MouseButton(event.mouseButton.button));
    if(event.type == sf::Event::MouseButtonReleased)
        context.injectMouseButtonUp(CEGUI::MouseButton(event.mouseButton.button));
    if(event.type == sf::Event::KeyPressed)
        context.injectKeyDown(convertKey(event.key.code));
    if(event.type == sf::Event::KeyReleased)
        context.injectKeyUp(convertKey(event.key.code));
    if(event.type == sf::Event::TextEntered)
        context.injectChar(event.text.unicode);
    if(event.type == sf::Event::MouseWheelMoved)
        context.injectMouseWheelChange(event.mouseWheel.delta);
    float elapsedTime = elapsedclock->restart().asSeconds();
    CEGUI::System::getSingleton().injectTimePulse(elapsedTime);
    context.injectTimePulse(elapsedTime);
    actionMap.clearEvents();
}
Esempio n. 3
0
QStringList MDConfAgent::listDirs(const QString &key) const
{
    QStringList children;
    gint length = 0;
    QByteArray k = convertKey(priv->prefix + key);
    //qDebug() << "MDConfItem::listDirs" << k;

    gchar **dirs = dconf_client_list(priv->client, k.data(), &length);
    GError *error = NULL;

    for (gint x = 0; x < length; x++) {
      const gchar *dir = g_strdup_printf ("%s%s", k.data(), dirs[x]);
      if (dconf_is_dir(dir, &error)) {
        // We have to mimic how gconf was behaving.
        // so we need to chop off trailing slashes.
        // dconf will also barf if it gets a "path" with 2 slashes.
        QString d = convertKey(dir);
        g_free ((gpointer)dir);
        //qDebug() << "have dir:" << d;
        if (d.endsWith("/")) {
          d.chop(1);
        }
        children.append(d);
      }
    }

    g_strfreev(dirs);

    return children;
}
Esempio n. 4
0
void MDConfAgent::watchKey(const QString &key, const QVariant &def)
{
    if (!priv->values.contains(key)) {
        if (!key.endsWith("/")) {
            priv->values[key] = MDConf::read(priv->client, convertKey(priv->prefix + key));
            if (priv->values[key].isNull() && !def.isNull()) {
                priv->values[key] = def;
            }
            Q_EMIT valueChanged(key);
        }
        MDConf::watch(priv->client, convertKey(priv->prefix + key));
    }
}
Esempio n. 5
0
bool llm::InputListener::keyPressed(const OIS::KeyEvent &e){
	std::cout << "keyPressed" << std::endl;
	llm::Application* app = llm::Application::getInstance();
	if(app->inGame()) {
		switch(e.key) {
			case OIS::KC_ESCAPE:
				llm::Application::getInstance()->pause();
				break;
			case OIS::KC_R:
				llm::Application::getInstance()->game()->activeMagnetism();
				break;
			case OIS::KC_F:
				llm::Application::getInstance()->game()->player()->switchPole();
			case OIS::KC_A:
				llm::Application::getInstance()->game()->player()->direction(L);
				break;
			case OIS::KC_D:
				llm::Application::getInstance()->game()->player()->direction(R);
				break;
			case OIS::KC_Q:
				if( app->game()->cubeSelected() != -1 )
					app->game()->level()->cubes()[app->game()->cubeSelected()]->rotateLeft();
				break;
			case OIS::KC_E:
				if( app->game()->cubeSelected() != -1 )
					app->game()->level()->cubes()[app->game()->cubeSelected()]->rotateRight();
				break;
		}
	} else {
		CEGUI::System &sys = CEGUI::System::getSingleton();
	    sys.injectKeyDown(convertKey(e));
	}
    return m_bContinue;
}
Esempio n. 6
0
void MDConfAgent::update_value(const QString &key)
{
    QString privKey = key;
    privKey = privKey.remove(0, priv->prefix.length());
    priv->values[privKey] = MDConf::read(priv->client, convertKey(key));
    Q_EMIT valueChanged(privKey);
}
Esempio n. 7
0
void MDConfAgent::setValue(const QString &key, const QVariant &val)
{
    if (priv->values.contains(key)) {
        priv->values[key] = val;
    }
    MDConf::write(priv->client, convertKey(priv->prefix + key), val);
}
Esempio n. 8
0
void MDConfAgent::unsetValue(const QString &key)
{
    if (priv->values.contains(key)) {
        priv->values[key] = QVariant();
    }
    MDConf::clear(priv->client, convertKey(priv->prefix + key));
}
Esempio n. 9
0
void MDConfAgent::unwatchKey(const QString &key)
{
    if (priv->values.contains(key)) {
        priv->values.remove(key);
        MDConf::unwatch(priv->client, convertKey(priv->prefix + key));
    }
}
Esempio n. 10
0
void GAE_InputSystem_getEvent(GAE_Event_t* const event, void* userData) {
	GAE_InputSystem_t* system = (GAE_InputSystem_t*)userData;
	SDL_Event* sdlEvent = (SDL_Event*)GAE_Map_begin(event->params);

	if (GAE_EVENT_KEYBOARD == event->type) {
		switch(sdlEvent->type) {
			case SDL_KEYUP:
				system->keyboard->keys[convertKey(sdlEvent->key.keysym.sym)] = GAE_FALSE;
			break;
			case SDL_KEYDOWN:
				system->keyboard->keys[convertKey(sdlEvent->key.keysym.sym)] = GAE_TRUE;
			break;
			default:
			break;
		}
	}
}
Esempio n. 11
0
QVariant MDConfAgent::value(const QString &key) const
{
    if (priv->values.contains(key)) {
        return priv->values[key];
    }
    else {
        return MDConf::read(priv->client, convertKey(priv->prefix + key));
    }
}
Esempio n. 12
0
MDConfAgent::~MDConfAgent()
{
    g_signal_handler_disconnect(priv->client, priv->handler);
    foreach (const QString &key, priv->values.keys()) {
        QByteArray k = convertKey(priv->prefix + key);
        dconf_client_unwatch_fast(priv->client, k.data());
    }
    g_object_unref(priv->client);
    delete priv;
}
Esempio n. 13
0
static void GLFWCALL keyboardInput(int key, int state)
{
	if (key == GLFW_KEY_RCTRL && state == GLFW_PRESS)
	{
		mouselocked = !mouselocked;
		if (mouselocked)
			glfwDisable(GLFW_MOUSE_CURSOR);
		else
			glfwEnable(GLFW_MOUSE_CURSOR);
	}
	graphics.injectKeyboard(convertKey(key), state);
}
Esempio n. 14
0
// *Date params will be deleted by this function
closure* telaRelatorio(closure* cl, char* beginDate, char* endDate)
{
	relatorio_t* relatorio;
	int isFinished = FALSE, refresh = TRUE; 
	char buf[MAXBUF];	
	const char* evId = (const char*)cl->param;
	point center = getScreenCenter(); 	
	memset (buf,'\0',sizeof(buf));
	snprintf(buf,MAXBUF,"Gerando relatório...");
	WRITE_AT(buf,center.x-10,center.y*2-1);
	CHECK(NULL!=evId);
	CHECK(SUCCESS==initAmbiente());
	CHECK(SUCCESS==get_relatorio(beginDate,endDate,evId,&relatorio));
	CHECK(NULL!=relatorio);	
	while (!isFinished) {
		char szKey;
		long lOSEvent = wait_event();
		if (refresh /*if there's no check it will keep rewriting constantly*/) {
			clrscr ();	
			show_bmp(LOGO_FILENAME);
			WRITE_AT_CENTERED("Relatorio",center.x,center.y-3);
			snprintf(buf,MAXBUF,"Inicio: %s\0",relatorio->begin_date);		
			WRITE_AT(buf,center.x-10,center.y);
			snprintf(buf,MAXBUF,"Fim:    %s\0",relatorio->end_date);		
			WRITE_AT(buf,center.x-10,center.y+1);
			snprintf(buf,MAXBUF,"Valor:  %s\0",valor_withCurrency(relatorio->value));
			WRITE_AT(buf,center.x-10,center.y+2);
			WRITE_AT("1> Imprimir",center.x-10,center.y+4);
			WRITE_AT("#> Tela Anterior",center.x-10,center.y+5);
			refresh = FALSE;
		} 
		if (lOSEvent & EVT_KBD) {
			if (read(g_conHandle, &szKey, 1) > 0) {
				szKey = convertKey (szKey);	
				if (KEY_HASH == szKey || KEY_BACK == szKey || KEY_ESC == szKey) {
					isFinished = TRUE;
				} else if (szKey == KEY_1) {
					char msg[MAX_BUFF_SIZE];
					if(relatorio_hasError(relatorio, msg, MAX_BUFF_SIZE)) {
						clrscr();
						write_multilineCentered(msg);
						SVC_WAIT(2000);
						refresh = TRUE;
					} else {
						CHECK(SUCCESS==print_relatorio(relatorio));
					}
				}
			}
		}
	}
	delete_relatorio(relatorio);
	return popClosure(cl);
}
Esempio n. 15
0
QVariantMap MDConfAgent::listItems(const QString &key) const
{

    QVariantMap children;
    gint length = 0;
    QByteArray k = convertKey(priv->prefix + key);
    //qDebug() << "MDConfItem::listItems" << k;

    gchar **items = dconf_client_list(priv->client, k.data(), &length);
    GError *error = NULL;

    for (gint x = 0; x < length; x++) {
      const gchar *item = g_strdup_printf ("%s%s", k.data(), items[x]);
      if (dconf_is_key(item, &error)) {
        // We have to mimic how gconf was behaving.
        // so we need to chop off trailing slashes.
        // dconf will also barf if it gets a "path" with 2 slashes.
        QString child = convertKey(item);
        QVariant val;
        GVariant *v = dconf_client_read(priv->client, item);
        if (!v) {
            qWarning() << "MGConfItem Failed to read" << child;
        }
        else {
            val = MDConf::convertValue(v);
            children[child] = val;

            //qDebug() << "have item:" << child;

            g_variant_unref(v);
        }
        g_free ((gpointer)item);
      }
    }

    g_strfreev(items);

    return children;
}
Esempio n. 16
0
/**
**  Get the hot key from a string
*/
int GetHotKey(const std::string &text)
{
	int hotkey = 0;
	size_t pos = 0;

	if (text.length() > 1) {
		hotkey = convertKey(text.c_str());
	} else if (text.length() == 1) {
		GetUTF8(text, pos, hotkey);
	}

	return hotkey;
}
Esempio n. 17
0
File: menus.c Progetto: bzero/POSApp
closure* showMenu2(MenuItem_t* items, int numItems, closure* cl)
{
	closure* next_cl = NULL;
	int isFinished = FALSE; 
	bool multipage, firstpage, lastpage;
	CHECK(NULL!=cl);
	firstpage = cl->page==0;
	multipage = (numItems > PAGE_ITEMS);
	lastpage = (cl->page+1)*PAGE_ITEMS >= numItems;
	CHECK(SUCCESS==printMenu2(items,numItems,multipage,lastpage,cl->page));
	while (!isFinished) {
		char szKey;
		long lOSEvent = wait_event();
		if (lOSEvent & EVT_KBD) {
			if (read(g_conHandle, &szKey, 1) > 0) {
				int i;
				const MenuItem_t* curr = items;
				szKey = convertKey (szKey);	
				if (KEY_HASH == szKey || KEY_BACK == szKey) {
					if (multipage && !firstpage) {
						cl->page--;
						next_cl = cl;
						isFinished = TRUE;
					} else {
						next_cl = popClosure(cl);
						isFinished = TRUE;
					}
				} else if (szKey == KEY_STAR) {
					if (multipage && !lastpage) {
						cl->page++;
						next_cl = cl;
						isFinished = TRUE;
					}
				} else {
					for (i=0; i<numItems; i++) {
						if (curr->key == szKey) {
							CHECK(NULL!=(curr->func));
							next_cl = pushClosure(cl, curr->func, curr->param);
							isFinished = TRUE;
							break;
						}
						curr++;
					}
				}
			}
		}
	}
	return next_cl;
}
Esempio n. 18
0
/**
**  Get the hot key from a string
*/
int GetHotKey(const std::string &text)
{
	int hotkey = 0;
	int utf8;
	size_t pos = 0;

	while (GetUTF8(text, pos, utf8)) {
		if (utf8 == '~') {
			if (pos >= text.size()) {
				break;
			}
			if (text[pos] == '<') {
				++pos;
				size_t endpos = pos;
				while (endpos < text.size()) {
					if (text[endpos] == '~') {
						break;
					}
					++endpos;
				}
				std::string key = text.substr(pos, endpos - pos);
				hotkey = convertKey(key.c_str());
				break;
			}
			if (text[pos] == '!') {
				++pos;
				if (pos >= text.size()) {
					break;
				}
				GetUTF8(text, pos, utf8);
				hotkey = utf8;
				break;
			}
		}
	}

	return hotkey;
}
Esempio n. 19
0
File: menus.c Progetto: bzero/POSApp
closure* showMenuWithTimeout(const MenuItem_t* items, int numItems, closure* cl, long msecs, char defKey)
{
	closure* next_cl = NULL;
	int isFinished = FALSE; 
	CHECK(NULL!=cl);
	CHECK(SUCCESS==printMenu(items, numItems));
	while (!isFinished) {
		char szKey = 0;
		long lOSEvent;		
		if (msecs > 0) {
			CHECK(0<=set_timer(msecs, EVT_TIMER));
		}
		lOSEvent = wait_event();
		if (lOSEvent & EVT_KBD || lOSEvent & EVT_TIMER) {	
			if (lOSEvent & EVT_TIMER) {
				szKey = defKey;
			}	
			if (0!=szKey || read(g_conHandle, &szKey, 1) > 0) {
				int i;
				const MenuItem_t* curr = items;
				szKey = convertKey (szKey);				
				for (i=0; i<numItems; i++) {
					if (curr->key == szKey) {
						CHECK(NULL!=(curr->func));
						next_cl = pushClosure(cl, curr->func, NULL);
						isFinished = TRUE;
						break;
					}
					curr++;
				}
			}
			CHECK(SUCCESS==printMenu(items,numItems));
		} 	
	}
	return next_cl;
}
OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event)
{
	OSStatus err = eventNotHandledErr;
	GHOST_IWindow *window = m_windowManager->getActiveWindow();
	UInt32 kind = ::GetEventKind(event);
	UInt32 modifiers;
	UInt32 rawCode;
	GHOST_TKey key;
	unsigned char ascii;

	/* Can happen, very rarely - seems to only be when command-H makes
	 * the window go away and we still get an HKey up. 
	 */
	if (!window) {
		//::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
		//key = convertKey(rawCode);
		return err;
	}
	
	err = noErr;
	switch (kind) {
		case kEventRawKeyDown: 
		case kEventRawKeyRepeat: 
		case kEventRawKeyUp: 
			::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
			::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii);
	
			key = convertKey(rawCode);
			ascii = convertRomanToLatin(ascii);
			
			//		if (key!=GHOST_kKeyUnknown) {
			GHOST_TEventType type;
			if (kind == kEventRawKeyDown) {
				type = GHOST_kEventKeyDown;
			}
			else if (kind == kEventRawKeyRepeat) {
				type = GHOST_kEventKeyDown;      /* XXX, fixme */
			}
			else {
				type = GHOST_kEventKeyUp;
			}
			pushEvent(new GHOST_EventKey(getMilliSeconds(), type, window, key, ascii, NULL) );
//			}
			break;
	
		case kEventRawKeyModifiersChanged: 
			/* ugh */
			::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
			if ((modifiers & shiftKey) != (m_modifierMask & shiftKey)) {
				pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
			}
			if ((modifiers & controlKey) != (m_modifierMask & controlKey)) {
				pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) );
			}
			if ((modifiers & optionKey) != (m_modifierMask & optionKey)) {
				pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
			}
			if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) {
				pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
			}
			
			m_modifierMask = modifiers;
			break;
			
		default:
			err = eventNotHandledErr;
			break;
	}
	
	return err;
}
Esempio n. 21
0
bool KexiCSVExportWizard::readBoolEntry(const char *key, bool defaultValue)
{
    return m_importExportGroup.readEntry(convertKey(key, m_options.mode), defaultValue);
}
Esempio n. 22
0
QString KexiCSVExportWizard::readEntry(const char *key, const QString& defaultValue)
{
    return m_importExportGroup.readEntry(convertKey(key, m_options.mode), defaultValue);
}
Esempio n. 23
0
void KexiCSVExportWizard::writeEntry(const char *key, bool value)
{
    m_importExportGroup.writeEntry(convertKey(key, m_options.mode), value);
}
Esempio n. 24
0
void KexiCSVExportWizard::deleteEntry(const char *key)
{
    m_importExportGroup.deleteEntry(convertKey(key, m_options.mode));
}
const std::string& AndroidKeyboard::getAsString(KeyCode kc)
{
        char buf[2] = { (char)convertKey(0, kc).key, 0 };
	mGetString.assign(&buf[0],2);
	return mGetString;
}
Esempio n. 26
0
void MainWindow::keyPressEvent(QKeyEvent* evt)
{
//    qDebug() << "MainWindow::keyPressEvent()";
    currentKeyChanged()(convertKey(evt));
}