Exemplo n.º 1
0
// adds the most recent key press to the key_queue
void getKeyPress(void){		
	int row;
	int col;
	int key;							
	row = getRow();									// get the row of current key being pressed
	col = getCol(row); 								// get the col of current key being pressed		
	key = keyMap(row,col);							// will hold the key value to be added to queue
	pushKey(key); 									// push key onto queue		
}
Exemplo n.º 2
0
    void LuaModule::pushJsonScalarValue(const Json::Value &key,
                                        const Json::Value &val, lua_State * stack) {
        if (val.isObject() || val.isArray()) {
            throw std::runtime_error("Not a scalar value");
        }

        if (key.isString()) {
            pushKey(key, stack);
        }
        pushValue(val, stack);
        if (key.isNumeric()) {
            lua_rawseti(stack, -2, key.asInt() + 1);
        } else if (key.isString()) {
            lua_settable(stack, -3);
        }
    }
Exemplo n.º 3
0
    void LuaModule::pushJsonToArbStack(const Json::Value &json, lua_State * stack) {
        std::list<Json::ValueConstIterator> path;
        path.push_back(json.begin());
        lua_newtable(stack);
        while (!path.empty()) {
            std::flush(std::cout);
            size_t depth = path.size();
            if ((depth == 1 && path.back() == json.end())) {
                path.pop_back();
                break;
            }

            if (depth > 1) {
                const Json::ValueConstIterator &pointedArray = *(--(--(path.end())));
                if (path.back() == pointedArray->end()) {
                    if (pointedArray.key().isString()) {
                        lua_settable(stack, -3);
                    } else if (pointedArray.key().isIntegral()) {
                        // CHANGE
                        lua_rawseti(stack, -2, pointedArray.key().asInt() + 1);
                    } else {
                        throw std::runtime_error("Failed to get array index type");
                    }
                    path.pop_back();
                    path.back()++;
                    continue;
                }
            }

            if (path.back()->isArray() || path.back()->isObject()) {
                //printKey(path);
                const Json::Value &array = *path.back();
                if (path.back().key().isString()) {
                    pushKey(path.back().key(), stack);
                }
                lua_newtable(stack);
                path.push_back(array.begin());
                continue;
            } else {
                //printKeyValue(path);
                pushJsonScalarValue(path.back().key(), *path.back(), stack);
                path.back()++;
                continue;
            }
        }
    }
Exemplo n.º 4
0
bool KeyController::handleEvent(Event *evt)
{
	bool retVal=true;

	if (evt->Type==MM_MOUSEMOVE || evt->Type==MM_LBUTTONDOWN)	// Keine MouseEvents durchlassen!
	{
		retVal=false;
		evt->Type=MM_NO_EVENT;
	}
	if (evt->Type==HEX_MOUSE_CHANGE)
	{
		evt->Type=MM_MOUSEMOVE;
		evt->lData=(iMouseY<<16) + iMouseX;
		evt->wData=0;
	}

	if (evt->Type==MM_KEYDOWN)
	{
		if (evt->wData==iUp)
			pushKey(0);
		if (evt->wData==iDown)
			pushKey(1);
		if (evt->wData==iLeft)
			pushKey(2);
		if (evt->wData==iRight)
			pushKey(3);
		if (evt->wData==iFire)
		{
			evt->Type=MM_LBUTTONDOWN;
			evt->lData=(iMouseY<<16) + iMouseX;
			evt->wData=0;
		}
		evt=processKeyMove(evt);
	}

	if (evt->Type==MM_KEYUP)
	{
		if (evt->wData==iUp)
		{
			evt->Type=MM_MOUSEMOVE;
			releaseKey(0);
		}
		if (evt->wData==iDown)
		{
			evt->Type=MM_MOUSEMOVE;
			releaseKey(1);
		}
		if (evt->wData==iLeft)
		{
			evt->Type=MM_MOUSEMOVE;
			releaseKey(2);
		}
		if (evt->wData==iRight)
		{
			evt->Type=MM_MOUSEMOVE;
			releaseKey(3);
		}
		if (evt->wData==iFire)
		{
			evt->Type=MM_LBUTTONUP;
		}
		if (evt->Type==MM_MOUSEMOVE || evt->Type==MM_LBUTTONUP)
		{
			evt->lData=(iMouseY<<16) + iMouseX;
			evt->wData=0;
		}
	}


	return retVal;
}