//In this function you will be able to add a key with a inputcallback to the dictionary.
 public static void AddToDict(KeyCode key, InputCallback value)
 {
     if (!_inputs.ContainsKey(key))
     {
         _inputs.Add(key, value);
     }
 }
Exemple #2
0
 public DatepickerWindow(string windowTitle, string labelText,
                         InputCallback inputCallback)
 {
     InitializeComponent();
     this.inputCallback = inputCallback;
     Owner = Application.Current.MainWindow;
     Title = windowTitle;
     InputLabel.Content = labelText;
 }
Exemple #3
0
 public static void RegisterInputCallback(int callbackID, InputCallback callback)
 {
     if (!InputCallbackDatabase.ContainsKey(callbackID))
     {
         InputCallbackDatabase.Add(callbackID, callback);
     }
     else
     {
         throw new CallbackAlreadyRegisteredException("The Input Callback of Type" + callbackID + "is already registered.");
     }
 }
Exemple #4
0
 public InputWindow(string windowTitle, string labelText, string defaultText,
                    InputCallback inputCallback, bool allowWhitespaceOnSave = true)
 {
     InitializeComponent();
     this.inputCallback         = inputCallback;
     this.allowWhitespaceOnSave = allowWhitespaceOnSave;
     Owner = Application.Current.MainWindow;
     Title = windowTitle;
     InputLabel.Content = labelText;
     InputBox.Text      = defaultText;
     InputBox.Focus();
     InputBox.CaretIndex = InputBox.Text.Length;
 }
 public static void RegisterInputEvent(Type target, InputCallback callback, PriorityType priority = PriorityType.UI)
 {
     if (Instance != null)
     {
         if (Instance._typeToInputListenerDict.ContainsKey(target))
         {
             Instance._typeToInputListenerDict.Remove(target);
             Instance._typeToPriorityDict.Remove(target);
         }
         Instance._typeToInputListenerDict.Add(target, new InputListener()
         {
             Callback = callback
         });
         Instance._typeToPriorityDict.Add(target, priority);
     }
 }
    public static void RegisterSelectEvent(GameObject target, InputCallback callback)
    {
        if (Instance != null)
        {
            if (Instance._objectToSelectListenerDict.ContainsKey(target))
            {
                Instance._objectToSelectListenerDict.Remove(target);
            }

            Instance._objectToSelectListenerDict.Add(target, new InputListener()
            {
                Callback = callback
            });

            Instance._isFreshRegisterInfo = true;
        }
    }
 public static void RegisterInputEvent(GameObject target, InputCallback callback, PriorityType priority = PriorityType.UI)
 {
     if (Instance != null)
     {
         if (Instance._objectToInputListenerDict.ContainsKey(target))
         {
             Instance._objectToInputListenerDict.Remove(target);
             Instance._objectToPriorityDict.Remove(target);
         }
         Instance._objectToInputListenerDict.Add(target, new InputListener()
         {
             Callback = callback
         });
         Instance._objectToPriorityDict.Add(target, priority);
         Instance._isFreshRegisterInfo = true;
     }
 }
Exemple #8
0
        // We want to be able to serialize callbacks with an int id. This is a hacky way that lets us do that
        // with reflection without having to explicitly register each one.
        public static void Initialize()
        {
            Type type = typeof(Callbacks);

            foreach (MethodInfo mi in type.GetMethods())
            {
                // Identify ones that match the callbacks
                InputCallback temp = null;
                try
                {
                    temp = (InputCallback)Delegate.CreateDelegate(typeof(InputCallback), mi);
                }
                catch (Exception)
                {
                }
                if (temp != null)
                {
                    idToCallbacks[mi.Name.CRC32Hash()] = temp;
                }
            }
        }
    private static Dictionary <KeyCode, InputCallback> _inputs = new Dictionary <KeyCode, InputCallback>();  //This variable saves all keycodes together with a inputcallback, the inputcallback is explained in another class.

    //Every frame we will check if the inputs dictionary has 1 or more indexes, if so we will loop through all possible keycodes to check
    //if the input dictionary contains this keycode. If this is the case check for all three sorts of key press if the input callback has a function.
    //Then call this method.
    private void FixedUpdate()
    {
        if (_inputs.Count == 0)
        {
            return;
        }

        foreach (KeyCode kc in System.Enum.GetValues(typeof(KeyCode)))
        {
            if (_inputs.ContainsKey(kc))
            {
                InputCallback icb = _inputs [kc];
                if (Input.GetKeyDown(kc))
                {
                    if (icb.KeyDown != null)
                    {
                        icb.KeyDown();
                    }
                }

                if (Input.GetKeyUp(kc))
                {
                    if (icb.KeyUp != null)
                    {
                        icb.KeyUp();
                    }
                }

                if (Input.GetKey(kc))
                {
                    if (icb.KeyPressed != null)
                    {
                        icb.KeyPressed();
                    }
                }
            }
        }
    }
Exemple #10
0
    void FixedUpdate()
    {
        InputCallback ic = new InputCallback();

        ic.KeyDown = Jump;

        KeyboardInput.AddToDict(KeyCode.Space, ic);

        //jump animation handling
        if (!_isGrounded && !_playerDamage.IsDamaged)
        {
            float currentY = transform.position.y;
            if (currentY - _lastY > 0)
            {
                _animHandler.AnimState = Constants.PLAYERRISE;
            }
            else if (currentY - _lastY < 0)
            {
                _animHandler.AnimState = Constants.PLAYERFALL;
            }
            _lastY = currentY;
        }
    }
 public AttachmentEditWindow(string windowTitle, string defaultTitle,
                             string defaultLink, InputCallback inputCallback,
                             AttachmentEditWindowType type)
 {
     InitializeComponent();
     this.inputCallback = inputCallback;
     this.type          = type;
     Owner = Application.Current.MainWindow;
     Title = windowTitle;
     if (type == AttachmentEditWindowType.File)
     {
         LinkLabel.Content = "Datei:";
     }
     else
     {
         LinkLabel.Content     = "URL:";
         FileButton.Visibility = Visibility.Collapsed;
         LinkBox.Width         = TitleBox.Width;
     }
     TitleBox.Text = defaultTitle;
     LinkBox.Text  = defaultLink;
     TitleBox.Focus();
     TitleBox.CaretIndex = TitleBox.Text.Length;
 }
Exemple #12
0
 public abstract void sameboy_setinputcallback(IntPtr core, InputCallback callback);
Exemple #13
0
 public abstract void TI83_SetInputCallback(IntPtr context, InputCallback callback);
Exemple #14
0
    /// Public Methods

    /// <summary>
    /// Registers a callback method to be called whenever a key is pressed.
    /// Called regardless of modifier
    /// </summary>
    /// <param name="keyPress">What key should trigger the callback</param>
    /// <param name="callback">Callback method</param>
    public void M_RegisterInputCallbackPressed(KeyCode keyPress, InputMethod callback)
    {
        InputCallback newCb = new InputCallback(callback, KeyModifier.Any);

        this.m_inputPressedCallbacks.AddToList(keyPress, newCb);
    }
 public static void Register <TElement, TArgs>(InputCallback <TElement, TArgs> handler) where TElement : IInputElement where TArgs : InputEventArgs
 {
     InputMappers.Add(typeof(TArgs), (element, args) => handler((TElement)element, (TArgs)args));
 }
Exemple #16
0
    /// <summary>
    /// Registers a callback method to be called whenever a key is released and
    /// when the specified modifier is held down (including only when no modifier
    /// is held down)
    /// </summary>
    /// <param name="keyPress">What key should trigger the callback</param>
    /// <param name="modifier">Callback method</param>
    /// <param name="callback">What modifier should be held down to trigger callback</param>
    public void M_RegisterInputCallbackReleased(KeyCode keyPress, KeyModifier modifier, InputMethod callback)
    {
        InputCallback newCb = new InputCallback(callback, modifier);

        this.m_inputUpCallbacks.AddToList(keyPress, newCb);
    }
Exemple #17
0
 public void SetM64PInputCallbacks(InputCallback inputCallback, RumbleCallback rumbleCallback)
 {
     InpSetInputCallback(InpInputCallback = inputCallback);
     _ = InpSetRumbleCallback(m64pRumbleCallback = rumbleCallback);
 }
Exemple #18
0
 public static extern void libmeteor_setkeycallback(InputCallback callback);
Exemple #19
0
    /// <summary>
    /// Registers a callback method to be called whenever a key is held down and
    /// when the specified modifier is held down (including only when no modifier
    /// is held down)
    /// </summary>
    /// <param name="keyPress">What key should trigger the callback</param>
    /// <param name="modifier">Callback method</param>
    /// <param name="callback">What modifier should be held down to trigger callback</param>
    public void M_RegisterInputCallbackDown(KeyCode keyPress, KeyModifier modifier, InputMethod callback)
    {
        InputCallback newCb = new InputCallback(callback, modifier);

        m_inputDownCallbacks.AddToList(keyPress, newCb);
    }
Exemple #20
0
 public static extern void sameboy_setinputcallback(IntPtr core, InputCallback callback);
Exemple #21
0
 public void SetM64PInputCallback(InputCallback inputCallback)
 {
     InpInputCallback = inputCallback;
     InpSetInputCallback(InpInputCallback);
 }
 public static extern void libyabause_setinputcallback(InputCallback cb);
Exemple #23
0
 public abstract void BizSetInputCallback(IntPtr ctx, InputCallback cb);
		public void SetM64PInputCallback(InputCallback inputCallback)
		{
			InpInputCallback = inputCallback;
			InpSetInputCallback(InpInputCallback);
		}
Exemple #25
0
		public static extern void libmeteor_setkeycallback(InputCallback callback);
Exemple #26
0
    private void Awake()
    {
        Instance = this;

        Clear();

        InputListenerManager.RegisterInputEvent(Button_LeftMove.gameObject, new InputCallback()
        {
            PressCallBack = () =>
            {
                CurrentButtonState = InputButtonState.Left;
            },
            CancelCallBack = (o) =>
            {
                if (CurrentButtonState == InputButtonState.Left)
                {
                    CurrentButtonState = InputButtonState.None;
                }
            }
        }, InputListenerManager.PriorityType.UITigger);

        InputListenerManager.RegisterInputEvent(Button_RightMove.gameObject, new InputCallback()
        {
            PressCallBack = () =>
            {
                CurrentButtonState = InputButtonState.Right;
            },
            CancelCallBack = (o) =>
            {
                if (CurrentButtonState == InputButtonState.Right)
                {
                    CurrentButtonState = InputButtonState.None;
                }
            }
        }, InputListenerManager.PriorityType.UITigger);


        InputListenerManager.RegisterInputEvent(Button_Confire.gameObject, new InputCallback()
        {
            ClickCallBack = () =>
            {
                if (CharacterControl.Instance != null)
                {
                    CharacterControl.Instance.OnConfire();
                }
            }
        }, InputListenerManager.PriorityType.UITigger);


        var input = new InputCallback()
        {
            ClickCallBack = () =>
            {
                if (IsShow)
                {
                    NovelsManager.Instance.IsAcceptConfirm = true;
                }
            }
        };


        InputListenerManager.RegisterInputEvent(typeof(UIConfirmBlock), input, InputListenerManager.PriorityType.UI);
    }
Exemple #27
0
		public static extern void libyabause_setinputcallback(InputCallback cb);