Ejemplo n.º 1
0
        private bool updateStickHandlers(KeymapOutConfig outConfig, double value)
        {
            foreach (IOutputHandler handler in outputHandlers)
            {
                IStickHandler stickHandler = handler as IStickHandler;
                if (stickHandler != null)
                {
                    foreach (KeymapOutput output in outConfig.Stack)
                    {
                        if (output.Continous)
                        {
                            double newValue = value;
                            //Make sure the value is not above 1
                            newValue = newValue > 1 ? 1 : newValue;
                            //Set value to 0 if it's within deadzone
                            newValue = newValue <= outConfig.Deadzone ? 0 : (newValue - outConfig.Deadzone) / (1 - outConfig.Deadzone);

                            //Add the scaling from the config
                            newValue = newValue * outConfig.Scale;
                            if (stickHandler.setValue(output.Key.ToLower(), newValue))
                            {
                                break; // we will break for the first accepting handler, for each output key
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void SetKeymap(Keymap keymap)
        {
            if (this.keymap == null || this.keymap.Equals(keymap))
            {
                this.config = new Dictionary <string, KeymapOutConfig>();

                foreach (KeymapInput input in KeymapDatabase.Current.getAvailableInputs())
                {
                    KeymapOutConfig outConfig = keymap.getConfigFor((int)id, input.Key);
                    if (outConfig != null)
                    {
                        this.config.Add(input.Key, outConfig);
                    }
                }

                KeymapOutConfig pointerConfig;
                if (this.config.TryGetValue("Pointer", out pointerConfig) && this.OnConfigChanged != null)
                {
                    this.OnConfigChanged(new WiiKeyMapConfigChangedEvent(keymap.getName(), keymap.getFilename(), pointerConfig.Stack.First().Key));
                }
            }
        }
Ejemplo n.º 3
0
        private bool updateStickHandlers(KeymapOutConfig outConfig, double value)
        {
            foreach (IOutputHandler handler in outputHandlers)
            {
                IStickHandler stickHandler = handler as IStickHandler;
                if (stickHandler != null)
                {
                    foreach(KeymapOutput output in outConfig.Stack)
                    {
                        if (output.Continous)
                        {
                            double newValue = value;
                            //Make sure the value is not above 1
                            newValue = newValue > 1 ? 1 : newValue;
                            //Set value to 0 if it's within deadzone
                            newValue = newValue <= outConfig.Deadzone ? 0 : (newValue - outConfig.Deadzone) / (1 - outConfig.Deadzone);

                            //Add the scaling from the config
                            newValue = newValue * outConfig.Scale;
                            if (stickHandler.setValue(output.Key.ToLower(), newValue))
                            {
                                break; // we will break for the first accepting handler, for each output key
                            }
                        }
                    }
                }
            }
            return false;
        }