ZoriaRPG icon

ZScript Keyboard Handler

ZoriaRPG | PRO | 06/26/18 07:31:05 AM UTC | 0 ⭐ | 648 👁️ | Never ⏰ | []
C++ |

1.66 KB

|

None

|

0 👍

/

0 👎

int key_repeat = 0;
void DoKey(int buffer)
{
    int keymap[KEY_MAX]; int tempchar; int modofiers[9];
    while(Game->TypingMode)
    {
        
        if ( key_repeat > 0 )
        {
            --key_repeat;
            continue;
        }
        memset(modifiers,0); //clear this iteration
        for ( int q = 0; q < KEY_MAX; ++q )
        {
            if ( Input->ReadKey[q] ) tempchar = keymap[q];
            key_repeat = KEY_REPEAT_DUR;
            
            if ( tempchar !IsModifier() )
                break;
            else 
            {
                switch(tempkey)
                {
                    case KEY_LSHIFT:
                    {
                        modifiers[LSHIFT] = 1; break; 
                    }
                    case KEY_RSHIFT:
                    {
                        modifiers[RSHIFT] = 1; break; 
                    }
                    case KEY_LCTL:
                    {
                        modifiers[LCTL] = 1; break; 
                    }
                    case KEY_RCTL:
                    {
                        modifiers[RCTL] = 1; break; 
                    }
                    case KEY_LALT:
                    {
                        modifiers[LALT] = 1; break; 
                    }
                    case KEY_RALT:
                    {
                        modifiers[RALT] = 1; break; 
                    }
                    case KEY_APPLE:
                    {
                        modifiers[APPLE] = 1; break; 
                    }
                    case KEY_OPT:
                    {
                        modifiers[OPT] = 1; break; 
                    }
                    case KEY_WIN:
                    {
                        modifiers[WIN] = 1; break; 
                    }
                }
            } //Don't break or continue here!
                        
        }
        
        //actions to do with tempkey
        
        //forward to KeyProcess(tempchar, buffer)!
        
        //chars
        
            //modified
        
            //not modified
        
        //special
            //backspace
            //function and other
        
        //Exit Typing Mode
        if ( tempchar == KEY_ESC ) Game->TypingMode = false;
        
        
        Waitframe();
}
 
void KeypressProcess(int chr, int buffer)
{
    //actions to do with tempkey
        
        //chars
        
            //modified
        
            //not modified
        
        //special
            //backspace
            //function and other
    
}

Comments