Exemplo n.º 1
0
 private static void refreshGlobalKeys(keyObj pressedKey, KeyCode code)
 {
     if (pressedKey.isDown())
     {
         foreach (globalRegisterdCallback call in registerdGlobalKeys)
         {
             call.Invoke(pressedKey.text, code);
         }
     }
 }
Exemplo n.º 2
0
        public static void setPressed(int id, bool press)
        {
            keyObj  matchedKeys = getKeyByID(id);
            KeyCode KeyCode     = getKeyNameByID(id);

            if (matchedKeys != null)
            {
                if (press)
                {
                    // press list
                    if (!pressedKeys.Contains(KeyCode))
                    {
                        pressedKeys.Add(KeyCode);
                    }

                    // down
                    if (matchedKeys.isPres)
                    {
                        matchedKeys.waitForChange = true;
                    }
                    else
                    {
                        matchedKeys.waitForChange = false;
                    }
                    matchedKeys.isPres = true;
                }
                else
                {
                    // press list
                    if (pressedKeys.Contains(KeyCode))
                    {
                        pressedKeys.Remove(KeyCode);
                    }

                    // up
                    if (matchedKeys.isPres)
                    {
                        matchedKeys.waitForChange = false;
                    }
                    else
                    {
                        // if is already up
                        matchedKeys.waitForChange = true;
                    }
                    matchedKeys.isPres = false;
                }
            }
        }
Exemplo n.º 3
0
        public static void refreshCallbacks(int keyID, inputTypes inputType)
        {
            KeyCode            key  = getKeyNameByID(keyID);
            List <keyRegister> keys = getAllRegisterdByKey(key);

            keycodes.refreshGlobalKeys(keycodes.keys[key], key);
            if (keys.Count > 0)
            {
                foreach (keyRegister rKey in keys)
                {
                    if (rKey.getKeyInputType() != inputTypes.pressed)
                    {
                        // single event
                        keyObj keyobj = keycodes.keys[key];
                        if (rKey.getKeyInputType() == inputTypes.up || rKey.getKeyInputType() == inputTypes.repeatedUp)
                        {
                            if (keyobj.isUp())
                            {
                                rKey.Invoke();
                            }
                        }
                        else
                        {
                            if (keyobj.isDown())
                            {
                                rKey.Invoke();
                            }
                        }
                    }
                    else
                    {
                        // is pressed
                        if (inputType == inputTypes.down)
                        {
                            rKey.Invoke();
                        }
                    }
                }
                cleanListOf(key, inputType);
            }
            if (inputType == inputTypes.up)
            {
                reopenMultipleCallbacks(key);
            }
            // last
            refreshMultipleCallbacks();
        }