Beispiel #1
0
bool WorldInput::update(sf::Event event) {
    switch (event.type) {
        case sf::Event::KeyPressed:
            return keyInput(event);
        default:
            return false;
    }
}
Beispiel #2
0
// main
void main(){
	char chkey = keyInput();
	printf("%c\n", chkey);

	// 맨 처음 값만 잘나오고, 다음 값은 쓰레기 값이 나온다
	int* parr = LocalArray();
	for (int i = 0; i < 5; i++){
		printf("%d\n", parr[i]);
	}

} // main()
   void  HGEInput::pollKeyInput(hgeInputEvent &ki)
   {
       if (ki.type != INPUT_KEYDOWN 
           && ki.type != INPUT_KEYUP )
       {
            return ;
       }
       
       if (ki.type == INPUT_KEYDOWN)
       {
           Key keyObj = convertToKey(ki.key, ki.chr);
 
           KeyInput keyInput(keyObj, KeyInput::Pressed);
 
           keyInput.setNumericPad(isNumericPad(ki.key));
 
           keyInput.setShiftPressed(ki.flags & HGEINP_SHIFT);
           keyInput.setAltPressed(ki.flags & HGEINP_ALT);
           keyInput.setControlPressed(ki.flags & HGEINP_CTRL);
       
           mKeyInputQueue.push(keyInput);
       }
 
       if (ki.type == INPUT_KEYUP)
       {
           Key keyObj = convertToKey(ki.key, ki.chr);
 
           KeyInput keyInput(keyObj, KeyInput::Released);
 
           keyInput.setNumericPad(isNumericPad(ki.key));
 
           keyInput.setShiftPressed(ki.flags & HGEINP_SHIFT);
           keyInput.setAltPressed(ki.flags & HGEINP_ALT);
           keyInput.setControlPressed(ki.flags & HGEINP_CTRL);
       
           mKeyInputQueue.push(keyInput);
       }
   }
Beispiel #4
0
void lua::utils::dumpTable(TraversalInfo input)
{
    bool tableIsNotEmpty = false;
    input.output << '{';

    const int top = lua_gettop(input.L);

    const int tableIndex = input.index;

    TraversalInfo keyInput(input);
    keyInput.index = top + 1;
    keyInput.level += 1;
    keyInput.indent = true;

    TraversalInfo valueInput(input);
    valueInput.index = top + 2;
    valueInput.level += 1;
    valueInput.indent = false;

    // first 'dummy' key
    lua_pushnil(input.L);

    // table is in the stack at 'tableIndex'
    while (lua_next(input.L, tableIndex) != 0)
    {
        tableIsNotEmpty = true;
        input.output << '\n';

        printType(keyInput);
        input.output << " => ";
        printType(valueInput);

        // removes 'value' but keeps 'key' for next iteration
        lua_pop(input.L, 1);
    }
    if (tableIsNotEmpty)
    {
        input.output << '\n';
        if (input.indent)
        {
            helper::indent(input.level, input.output);
        }
    }
    input.output << '}';
}
    void OpenLayerInput::pollKeyInput()
    {
        int unicode, scancode;

        if (keyboard_needs_poll())
        {
            poll_keyboard();
        }

        while (keypressed())
        {
            unicode = ureadkey(&scancode);
            Key keyObj = convertToKey(scancode, unicode);

            KeyInput keyInput(keyObj, KeyInput::Pressed);

            keyInput.setNumericPad(isNumericPad(scancode));
            keyInput.setShiftPressed(key_shifts & KB_SHIFT_FLAG);
            keyInput.setAltPressed(key_shifts & KB_ALT_FLAG);
            keyInput.setControlPressed(key_shifts & KB_CTRL_FLAG);
#ifdef KB_COMMAND_FLAG
            keyInput.setMetaPressed(key_shifts & (KB_COMMAND_FLAG |
                                                  KB_LWIN_FLAG |
                                                  KB_RWIN_FLAG));
#else
            keyInput.setMetaPressed(key_shifts & (KB_LWIN_FLAG |
                                                  KB_RWIN_FLAG));
#endif


            mKeyQueue.push(keyInput);

            mPressedKeys[scancode] = keyInput;
        }

        if (key[KEY_ALT] && mPressedKeys.find(KEY_ALT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_ALT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_ALT] = keyInput;
        }

        if (key[KEY_ALTGR] && mPressedKeys.find(KEY_ALTGR) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_ALTGR, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_ALTGR] = keyInput;
        }

        if (key[KEY_LSHIFT] && mPressedKeys.find(KEY_LSHIFT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_LSHIFT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_LSHIFT] = keyInput;
        }
    
        if (key[KEY_RSHIFT] && mPressedKeys.find(KEY_RSHIFT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_RSHIFT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_RSHIFT] = keyInput;
        }
		
        if (key[KEY_LCONTROL] && mPressedKeys.find(KEY_LCONTROL) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_LCONTROL, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_LCONTROL] = keyInput;
        }

        if (key[KEY_RCONTROL] && mPressedKeys.find(KEY_RCONTROL) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_RCONTROL, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_RCONTROL] = keyInput;
        }

        // Check for released keys
        std::map<int, KeyInput>::iterator iter, tempIter;
        for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); )
        {
            if (!key[iter->first])
            {
                KeyInput keyInput(iter->second.getKey(), KeyInput::Released);
                keyInput.setNumericPad(iter->second.isNumericPad());
                keyInput.setShiftPressed(iter->second.isShiftPressed());
                keyInput.setAltPressed(iter->second.isAltPressed());
                keyInput.setControlPressed(iter->second.isControlPressed());

                mKeyQueue.push(keyInput);

                tempIter = iter;
                iter++;
                mPressedKeys.erase(tempIter);
            }
            else
            {
                iter++;
            }
        }
    }