コード例 #1
0
 void Awake()
 {
     if (instance != this || instance == null)
     {
         instance = this;
     }
 }
コード例 #2
0
    private void TryRegisterPlayer(int controllerID)
    {
        if (ControllerMapping.HasMapping(controllerID))
        {
            return;
        }

        ControllerMapping.BeaverType nextFreeType = ControllerMapping.GetNextAvailableType();
        int currentPlayers = ControllerMapping.NumberOfRegisteredPlayers;

        ControllerMapping.SetMapping(controllerID, nextFreeType);

        Chain.AddChain();

        for (int i = 0; i < ControllerMapping.NumberOfRegisteredPlayers; i++)
        {
            AudioSources[i].Stop();
            AudioSources[i].Play();
        }

        if (ControllerMapping.NumberOfRegisteredPlayers >= MinAmountOfPlayers)
        {
            EnableStart();
        }
    }
コード例 #3
0
    public Sprite ReturnCorrectButtonSprite(PlayerActions playerAction)
    {
        _currentController = getCurrentController();
        if (playerAction == PlayerActions.Dashing)
        {
            return(_currentController.DashButton);
        }
        else if (playerAction == PlayerActions.Jumping)
        {
            return(_currentController.JumpButton);
        }
        else if (playerAction == PlayerActions.FiringGun)
        {
            return(_currentController.FireButton);
        }
        else if (playerAction == PlayerActions.Interact)
        {
            return(_currentController.InteractButton);
        }
        else if (playerAction == PlayerActions.SwitchCompanion)
        {
            return(_currentController.SwitchCompanion);
        }

        return(_currentController.JumpButton);
    }
コード例 #4
0
 public MappingSelectionArgs(GenericController controller, ControllerType target, Skin previewSkin, ControllerMapping mapping)
 {
     Controller  = controller;
     Target      = target;
     PreviewSkin = previewSkin;
     Mapping     = mapping;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: arosecra/ffxi-companion
        public static void addButtonToAltTabCommand(StateControllerMapping scm,
                                                    FFXICompanion.Settings.Button controllerButton,
                                                    Settings.Action buttonAction)
        {
            ControllerMapping cm = new ControllerMapping();

            cm.button        = new ControllerButton(controllerButton, buttonAction);
            cm.altTabCommand = new AltTabCommand();
            scm.controllerMappings.Add(cm);
        }
コード例 #6
0
        private void UpdateUI()
        {
            GenericController controller = null;
            ControllerType    target     = ControllerType.Unknown;
            Skin skin = null;
            ControllerMapping mapping = null;

            if (lbControllerSource.SelectedItem is GenericController g)
            {
                controller = g;
                if (lbTargetControllerType.SelectedItem is ControllerType tgt)
                {
                    target = tgt;
                    if (lbSkins.SelectedItem is Skin s)
                    {
                        skin = s;
                    }
                }
            }
            // mappings can be deleted without selecting in step 1-3 first
            if (lbMappings.SelectedItem is ControllerMapping m)
            {
                mapping = m;
            }

            lblStep1.Font             = new Font(lblStep1.Font, controller == null ? FontStyle.Bold : FontStyle.Regular);
            lblPickController.Visible = controller == null;

            lblStep2.Font = new Font(lblStep2.Font, controller != null && target == ControllerType.Unknown ? FontStyle.Bold : FontStyle.Regular);
            lbTargetControllerType.Enabled = controller != null;
            lblPickTarget.Visible          = controller != null && target == ControllerType.Unknown;

            lblStep3.Font       = new Font(lblStep3.Font, target != ControllerType.Unknown && skin == null ? FontStyle.Bold : FontStyle.Regular);
            lbSkins.Enabled     = target != ControllerType.Unknown;
            lblPickSkin.Visible = target != ControllerType.Unknown && skin == null;

            lblStep4.Font          = new Font(lblStep4.Font, skin != null && mapping == null ? FontStyle.Bold : FontStyle.Regular);
            lblPickMapping.Visible = btnAddMapping.Enabled = skin != null;

            bool applies = mapping?.AppliesTo(controller) ?? false;

            btnClone.Enabled         = mapping != null;
            btnRemoveMapping.Enabled = mapping != null && !mapping.IsBuiltIn;
            btnContinue.Enabled      = applies && !mapping.IsBuiltIn;

            if (applies && mapping.IsBuiltIn)
            {
                lblMappingBuiltIn.Visible = true;
            }
            else
            {
                lblMappingIncompatible.Visible = mapping != null && !applies;
            }
        }
コード例 #7
0
    public ControllerMapping GetMappingForGuid(string guid)
    {
        if (guid == null)
        {
            return(null);
        }

        ControllerMapping mapping = null;

        controllerMappings.TryGetValue(guid, out mapping);
        return(mapping);
    }
コード例 #8
0
ファイル: A_Button.cs プロジェクト: CGowdy/SCD-Prototype
        public A_Button(ControllerMapping controllerMapping) : base()
        {
            //TODO: Will want to allow multiple presets at some point
            Preset preset = controllerMapping.presets.First <Preset>();

            base.groupID = preset.groupSourceBindings.FirstOrDefault().GetKeyValueByValue(STEAM_DIAMOND_BUTTON_TEXT).GetKey();

            base.group = controllerMapping.groups.Where(x => x.GetKeyValueByKey("id").GetValue().Equals(groupID)).FirstOrDefault();

            base.keyValue = base.group.bindings.Where(x => x.GetKeyValueByKey(STEAM_A_BUTTON_TEXT) != null).FirstOrDefault().GetKeyValueByKey(STEAM_A_BUTTON_TEXT);

            base.action = base.keyValue.GetValue();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: arosecra/ffxi-companion
        public static void addButtonToKeyPressMapping(StateControllerMapping scm,
                                                      FFXICompanion.Settings.Button controllerButton,
                                                      Settings.Action buttonAction,
                                                      Settings.Key key,
                                                      Settings.Action keyPress1)
        {
            ControllerMapping cm = new ControllerMapping();

            cm.button            = new ControllerButton(controllerButton, buttonAction);
            cm.keyPressesCommand = new KeyPressesCommand();
            cm.keyPressesCommand.keyPresses.Add(new KeyPress(key, keyPress1));
            scm.controllerMappings.Add(cm);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: arosecra/ffxi-companion
        public static void addButtonToOneKeyPressAndReleaseMapping(StateControllerMapping scm,
                                                                   FFXICompanion.Settings.Button controllerButton,
                                                                   Settings.Action buttonAction,
                                                                   Settings.Key key)
        {
            ControllerMapping cm = new ControllerMapping();

            cm.button            = new ControllerButton(controllerButton, buttonAction);
            cm.keyPressesCommand = new KeyPressesCommand();
            cm.keyPressesCommand.keyPresses.Add(new KeyPress(key, Settings.Action.PRESSED));
            cm.keyPressesCommand.keyPresses.Add(new KeyPress(key, Settings.Action.RELEASED));
            scm.controllerMappings.Add(cm);
        }
コード例 #11
0
    public void AddController(ControllerMapping mapping, string type = "")
    {
        var controllerViewObj = GameObject.Instantiate(this.controllerViewItemPrefab, this.controllerView, false);
        var customController  = controllerViewObj.AddComponent <CustomController>();

        customController.SetMapping(mapping);

        var controllerViewItem = controllerViewObj.GetComponent <ControllerViewItem>();

        if (controllerViewItem != null)
        {
            controllerViewItem.typeText.text = type;
        }
    }
コード例 #12
0
    private void Awake()
    {
        if (Application.isEditor)
        {
            if (!ControllerMapping.HasMapping(0))
            {
                for (int i = 0; i < numberOfPlayers; i++)
                {
                    ControllerMapping.SetMapping(i, (ControllerMapping.BeaverType)i);
                }
            }
        }

        Destroy(this);
    }
コード例 #13
0
    public void SetMapping(ControllerMapping mapping)
    {
        if (this.initialized)
        {
            throw new InvalidOperationException("Cannot set mapping multiple times");
        }

        this.controllerView = this.GetComponent <ControllerViewItem>();
        Debug.Assert(this.controllerView != null);

        this.buttons      = mapping.Buttons.ToDictionary(b => b, b => this.controllerView.AddToggleInput(b.label));
        this.analogSticks = mapping.Sticks.ToDictionary(s => s, s => this.controllerView.AddAnalogKnob(s.label));

        this.initialized = true;
    }
コード例 #14
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ControllerComponentObject> controllerComponents = new List <ControllerComponentObject>();
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                desktopVDFFileLoc = ofd.FileName;
            }
            VDFParser parser = new VDFParser();
            ParentKey parent = parser.Parse(new StreamReader(File.Open(desktopVDFFileLoc, FileMode.Open)));


            controllerMapping = new ControllerMapping();
            controllerMapping.ParseParentKey(parent);
        }
コード例 #15
0
    public static void UpdateAutoControls()    //Called in main.cs every frame
    {
        if (Time.time > (controllerCheckDelay + controllerCheckTimeSet))
        {
            controllerCheckTimeSet = Time.time;

            string[] strs = Input.GetJoystickNames();
            for (int i = 0; i < strs.Length; i++)
            {
                if (currentControllerMapping != ControllerMapping.Xbox360 && strs[i].Contains("360"))
                {
                    Debug.Log("Switching to Auto-Xbox360");
                    currentControllerMapping = ControllerMapping.Xbox360;
                }
            }
        }
    }
コード例 #16
0
    private void Start()
    {
        //Grab Player Count From PlayerMapping
        PlayerCount = ControllerMapping.NumberOfRegisteredPlayers;

        //Spawn n Players and give them the correct input mapping
        for (int i = 0; i < PlayerCount; i++)
        {
            int controllerID;
            if (ControllerMapping.TryGetID((ControllerMapping.BeaverType)i, out controllerID))
            {
                SpawnPlayer(i, controllerID);
            }
            else if (Application.isEditor)
            {
                SpawnPlayer(i, i);
            }
        }
    }
コード例 #17
0
ファイル: X_Button.cs プロジェクト: CGowdy/SCD-Prototype
        public X_Button(ControllerMapping controllerMapping)
        {
            //TODO: Will want to allow multiple presets at some point
            Preset preset = controllerMapping.presets.First <Preset>();

            foreach (KeyValue keyvalue in preset.groupSourceBindings.First <GroupSourceBinding>().keyValues)
            {
                if (keyvalue.GetValue().Equals(STEAM_DIAMOND_BUTTON_TEXT))
                {
                    groupID = keyvalue.GetKey();
                    break;
                }
            }

            foreach (Group group in controllerMapping.groups)
            {
                KeyValue kv;
                if ((kv = group.FindBinding(STEAM_X_BUTTON_TEXT)) != null)
                {
                    action = kv.GetValue();
                }
            }
        }
コード例 #18
0
    private void Parse(string elementIdentifierCsv)
    {
        controllerMappings.Clear();

        List <string>        lines          = new List <string>(elementIdentifierCsv.Split('\n'));
        IEnumerator <string> lineEnumerator = lines.GetEnumerator();

        // Skip the version line
        lineEnumerator.MoveNext();
        // Skip the column name header line
        lineEnumerator.MoveNext();

        while (lineEnumerator.MoveNext())
        {
            string[] row            = lineEnumerator.Current.Split(',');
            string   controllerName = row[1].Replace("\"", "");
            string   controllerGuid = row[2].Replace("\"", "");
            string   elementId      = row[3].Replace("\"", "");
            string   elementName    = row[4].Replace("\"", "");
            string   type           = row[5].Replace("\"", "");

            ControllerMapping controllerMapping;
            if (!controllerMappings.TryGetValue(controllerGuid, out controllerMapping))
            {
                controllerMapping = new ControllerMapping();
                controllerMapping.controllerName = controllerName;
                controllerMappings.Add(controllerGuid, controllerMapping);
            }

            ElementIdentifier elementIdentifier = new ElementIdentifier();
            elementIdentifier.name = elementName;
            elementIdentifier.type = (ElementIdentifierType)int.Parse(type);

            controllerMapping.elementIdToNameMap.Add(int.Parse(elementId), elementIdentifier);
        }
    }
コード例 #19
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                VDFParser parser = new VDFParser();
                ParentKey parent = parser.Parse(new StreamReader(File.Open(desktopVDFFileLoc, FileMode.Open)));
                controllerMapping = new ControllerMapping();
                controllerMapping.ParseParentKey(parent);

                a = new A_Button(controllerMapping);
                b = new B_Button(controllerMapping);
                x = new X_Button(controllerMapping);
                y = new Y_Button(controllerMapping);
                lbl_A_Button.Text = a.action;
                lbl_B_Button.Text = b.action;
                lbl_X_Button.Text = x.action;
                lbl_Y_Button.Text = y.action;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not read file");
                Console.WriteLine(ex.Message);
            }
        }
コード例 #20
0
        public void Initialize(OpenTK.GameWindow window)
        {
            game = window;

            int numKeys         = (int)OpenTK.Input.Key.LastKey;
            int numMouseButtons = (int)OpenTK.Input.MouseButton.LastButton;

            prevKeysDown = new bool[numKeys];
            curKeysDown  = new bool[numKeys];
            for (int i = 0; i < numKeys; ++i)
            {
                prevKeysDown[i] = curKeysDown[i] = false;
            }

            prevMouseDown = new bool[numMouseButtons];
            curMouseDown  = new bool[numMouseButtons];
            for (int i = 0; i < numMouseButtons; ++i)
            {
                prevMouseDown[i] = curMouseDown[i] = false;
            }

            numJoysticks = game.Joysticks.Count;
            joyMapping   = new ControllerMapping[numJoysticks];
            prevJoyDown  = new ControllerState[numJoysticks];
            curJoyDown   = new ControllerState[numJoysticks];
            joyDeadZone  = new float[numJoysticks];
            for (int i = 0; i < numJoysticks; ++i)
            {
                joyMapping[i]  = new ControllerMapping();
                prevJoyDown[i] = new ControllerState();
                curJoyDown[i]  = new ControllerState();
                joyDeadZone[i] = 0.25f;
            }

            isInitialized = true;
        }
コード例 #21
0
 /* Constructor/s */
 public HeroesControllerHelper(ControllerMapping controllerMapping, HeroesController *heroesController)
 {
     ControllerMapping            = controllerMapping;
     _controllerMappingDictionary = ControllerMappingDictionaryFactory.GetDictionary(controllerMapping);
     HeroesController             = heroesController;
 }
コード例 #22
0
 public void setCurrentController(ControllerType type)
 {
     _currentController = _listControllerMappings.Where(x => x.controllerType == type).SingleOrDefault();
 }
コード例 #23
0
        public void Initialize(OpenTK.GameWindow window)
        {
            game = window;

            int numKeys = (int)OpenTK.Input.Key.LastKey;
            int numMouseButtons = (int)OpenTK.Input.MouseButton.LastButton;

            prevKeysDown = new bool[numKeys];
            curKeysDown = new bool[numKeys];
            for (int i = 0; i < numKeys; ++i) {
                prevKeysDown[i] = curKeysDown[i] = false;
            }

            prevMouseDown = new bool[numMouseButtons];
            curMouseDown = new bool[numMouseButtons];
            for (int i = 0; i < numMouseButtons; ++i) {
                prevMouseDown[i] = curMouseDown[i] = false;
            }

            numJoysticks = game.Joysticks.Count;
            joyMapping = new ControllerMapping[numJoysticks];
            prevJoyDown = new ControllerState[numJoysticks];
            curJoyDown = new ControllerState[numJoysticks];
            joyDeadZone = new float[numJoysticks];
            for (int i = 0; i < numJoysticks; ++i) {
                joyMapping[i] = new ControllerMapping();
                prevJoyDown[i] = new ControllerState();
                curJoyDown[i] = new ControllerState();
                joyDeadZone[i] = 0.25f;
            }

            isInitialized = true;
        }
コード例 #24
0
        public ControllerMapperEditor(GenericController realController, ControllerType target, Skin skin, ControllerMapping mapping) : this()
        {
            System.Diagnostics.Debug.Assert(mapping.AppliesTo(realController));
            System.Diagnostics.Debug.Assert(skin.Controllers.Contains(target));

            _realController = realController;
            _skin           = skin = Skin.Clone(skin);   // do not let main skin be affected
            _mapping        = mapping;

            IController iController = realController.RequiresPolling ? new PollingController(realController, 1000 / 16) : (IController)realController;

            iController.StateUpdated += OnControllerStateUpdate;
            gamepadViewer.StartTesting(iController);
            skinPreview.Skin  = skin;
            _mappedController = new MappedController(mapping, iController);

            // determine number of buttons/axes on controller and number of buttons/axes in skin
            var state = realController.GetState();
            int numControllerButtons = state.Buttons.Count;
            int numControllerAxes    = state.Axes.Count;

            skin.GetNumberOfElements(out int numSkinButtons, out int numSkinAxes);

            List <ControllerMapping.Button> sourceButtons = new List <ControllerMapping.Button>();
            List <ControllerMapping.Axis>   sourceAxes    = new List <ControllerMapping.Axis>();

            // ensure mapping contains entries for all buttons and axes on controller
            for (int i = 0; i < numControllerButtons; i++)
            {
                if (_mapping.ButtonMaps.All(b => b.Source != (ControllerMapping.Button)i))
                {
                    _mapping.ButtonMaps.Add(new ControllerMapping.ButtonMap {
                        Source = (ControllerMapping.Button)i,
                        Target = ControllerMapping.Button.Unmapped,
                    });
                }
                sourceButtons.Add((ControllerMapping.Button)i);
            }
            for (int i = 0; i < numControllerAxes; i++)
            {
                if (_mapping.AxisMaps.All(b => b.Source != (ControllerMapping.Axis)i))
                {
                    // default 1:1 map
                    _mapping.AxisMaps.Add(new ControllerMapping.AxisMap {
                        Source    = (ControllerMapping.Axis)i,
                        Target    = (ControllerMapping.Axis)i,
                        IsTrigger = realController.IsAxisTrigger(i)
                    });
                }
                sourceAxes.Add((ControllerMapping.Axis)i);
            }
            // remove invalid entries
            _mapping.ButtonMaps.RemoveAll(b => (int)b.Source >= numControllerButtons || (int)b.Target >= numSkinButtons);
            _mapping.AxisMaps.RemoveAll(a => (int)a.Source >= numControllerAxes || (int)a.Target >= numSkinAxes);
            // make sure they appear in logical order
            _mapping.ButtonMaps.Sort((self, other) => self.Source.CompareTo(other.Source));
            _mapping.AxisMaps.Sort((self, other) => self.Source.CompareTo(other.Source));

            dgvcSourceButton.DataSource     = sourceButtons;
            cbButtonToAxisSource.DataSource = sourceButtons;
            cbAxisToButtonTarget.DataSource = sourceButtons;

            dgvcSourceAxis.DataSource       = sourceAxes;
            cbAxisToButtonSource.DataSource = sourceAxes;
            cbButtonToAxisTarget.DataSource = sourceAxes;

            List <ControllerMapping.Button> targetButtons = new List <ControllerMapping.Button> {
                ControllerMapping.Button.Unmapped
            };

            for (int i = 0; i < numSkinButtons; i++)
            {
                targetButtons.Add((ControllerMapping.Button)i);
            }

            List <ControllerMapping.Axis> targetAxes = new List <ControllerMapping.Axis> {
                ControllerMapping.Axis.Unmapped
            };

            for (int i = 0; i < numSkinAxes; i++)
            {
                targetAxes.Add((ControllerMapping.Axis)i);
            }



            // enable dataGridViews only if there are actual elements in both controller and axis
            if (numSkinButtons > 0 && numControllerButtons > 0)
            {
                dgvcTargetButton.DataSource = targetButtons;
                bsButtons.DataSource        = new BindingList <ControllerMapping.ButtonMap>(_mapping.ButtonMaps);
                dgvButtons.DataSource       = bsButtons;
            }
            else
            {
                tpButtons.Visible = dgvButtons.Visible = lblButtons.Visible = false;
            }

            tpAxesToButtons.Visible = numControllerAxes > 0;
            tpButtonsToAxes.Visible = numControllerButtons > 0;

            bsAxesToButtons.DataSource = new BindingList <ControllerMapping.AxisToButtonMap>(_mapping.AxisToButtonMaps);
            bsButtonsToAxes.DataSource = new BindingList <ControllerMapping.ButtonToAxisMap>(_mapping.ButtonToAxisMaps);

            if (numSkinAxes > 0 && numControllerAxes > 0)
            {
                dgvcTargetAxis.DataSource = targetAxes;
                bsAxes.DataSource         = new BindingList <ControllerMapping.AxisMap>(_mapping.AxisMaps);
                dgvAxes.DataSource        = bsAxes;
            }
            else
            {
                tpAxes.Visible          = false;
                tpAxesToButtons.Visible = false;
            }
        }
コード例 #25
0
 private void SendMidiCommand(int inChannel, int inValue, int inStatus, int inControl, ControllerMapping mapping)
 {
     if ((string.IsNullOrWhiteSpace(mapping.MidiOutCmdDown) == false) && inValue > 0)
     {
         midiDevice.SendMsg(inChannel, inValue, inStatus, inControl, mapping.MidiOutCmdDown);
     }
     else if ((string.IsNullOrWhiteSpace(mapping.MidiOutCmdUp) == false) && inValue <= 0)
     {
         midiDevice.SendMsg(inChannel, inValue, inStatus, inControl, mapping.MidiOutCmdUp);
     }
     else if ((string.IsNullOrWhiteSpace(mapping.MidiOutCmdSetValue) == false))
     {
         midiDevice.SendMsg(inChannel, inValue, inStatus, inControl, mapping.MidiOutCmdSetValue);
     }
 }
コード例 #26
0
        void OnMidiInput(MidiDevice Device, int DeviceIdx, int ControlId, int Data, int Status, int Event, int Channel)
        {
            // Following opening the midi controller most controllers will immediatly send current status of any knobs and sliders
            // We are not interested in these messages when in setup. The Only way to ignore them is to introduce a delay following the open command.
            if (DateTime.Now < ignoreMidiMessagesUntil)
            {
                return;
            }

            this.InvokeIfRequired(p =>
            {
                if (tabControl.SelectedTab == debugTab)
                {
                    _diagList.Add(new MidiDiagItem {
                        Device = DeviceIdx.ToString("X2"), ControlId = ControlId.ToString("X2"), Data = Data.ToString("X2"), Status = Status.ToString("X2"), Voice = ((MidiEvent)Event).ToString().Replace("_", " "), Channel = (Channel + 1).ToString("X2")
                    });
                    if (_diagList.Count > 100)
                    {
                        _diagList.RemoveAt(0);
                    }
                    midiDiagDataGrid.CurrentCell = midiDiagDataGrid.Rows[_diagList.Count - 1].Cells[0];
                }

                if (tabControl.SelectedTab == commandsTabPage)
                {
                    tabControl.SelectedTab = mappedControlsTab;
                    if (mappedCommandsGridView.SelectedRows.Count == 1)
                    {
                        var row          = mappedCommandsGridView.SelectedRows[0];
                        int cmdIdx       = mappedCommandsGridView.Columns["cmdIdDataGridViewTextBoxColumn"].Index;
                        CatCmdToUse      = (CatCmd)row.Cells[cmdIdx].Value;
                        int ctIdx        = mappedCommandsGridView.Columns["controlTypeDataGridViewTextBoxColumn"].Index;
                        ControlTypeToUse = (ControlType)row.Cells[ctIdx].Value;
                    }
                }

                if (tabControl.SelectedTab == mappedControlsTab)
                {
                    ControllerMapping mapping = DB.GetMapping(DeviceName, ControlId);
                    if (AddingControl && AddingControlId != ControlId)
                    {
                        MappingDone();
                    }
                    if (mapping == null)
                    {
                        mapping = new ControllerMapping {
                            MidiControlId = ControlId, MaxValue = int.MinValue, MinValue = int.MaxValue, MidiControlType = ControlTypeToUse, MidiControlName = ""
                        };
                        mapping.CatCmd      = CatCmdDb.Get(CatCmd.None);
                        DataRowView newView = (DataRowView)controllerMappingBindingSource1.AddNew();
                        DB.PopulateRow(newView.Row, mapping);
                        DB.AddRow(DeviceName, newView.Row);
                        newView.Row.AcceptChanges();
                        mapControlToCommandGrid.Refresh();
                        DB.SaveChanges(DeviceName);
                        AddingControl   = true;
                        AddingControlId = ControlId;
                    }

                    int Idx = controllerMappingBindingSource1.Find("MidiControlId", mapping.MidiControlId);
                    controllerMappingBindingSource1.Position = Idx;
                    ShowMapInCtrl2CmdDialog(ControlId, Data);
                    ValidateDialogInput();
                    SendMidiCommand(Channel, Data, Status, ControlId, mapping);
                }
            });
        }
コード例 #27
0
 private void Awake()
 {
     player   = GetComponent <Player>();
     keyBinds = ControllerMapping.GetKeyBinds(player.ID);
 }
コード例 #28
0
ファイル: KeyMapper.cs プロジェクト: arosecra/ffxi-companion
        private void handleCommand(ControllerMapping mapping)
        {
            if (mapping.keyPressesCommand != null)
            {
                handleKeyPressesCommand(mapping.keyPressesCommand);
            }
            else if (mapping.altTabCommand != null)
            {
                //List<Process> polProcesses = new List<Process>();
                //foreach (Process process in Process.GetProcesses())
                // {
                //    if(process.ProcessName == "pol") {
                //       polProcesses.Add(process);
                //    }
                //}
                //IntPtr s = polProcesses[0].MainWindowHandle;
                //Console.WriteLine(polProcesses[0].MainWindowTitle);

                //WinApi.User32.User32Methods.ShowWindow(s, WinApi.User32.ShowWindowCommands.SW_SHOWMINIMIZED  );
                //WinApi.User32.User32Methods.ShowWindow(s, WinApi.User32.ShowWindowCommands.SW_SHOWNORMAL  );

                // IntPtr activeWindow = WinApi.User32.User32Methods.GetForegroundWindow();
                // int currentIndex = -1;
                // for(int i = 0; i < polProcesses.Count; i++) {
                //     Process p = polProcesses[i];
                //     if(p.Handle == activeWindow) {
                //         currentIndex = i;
                //     }
                // }
                // currentIndex++;
                // Console.WriteLine(currentIndex);
                // currentIndex %= polProcesses.Count;
                // Console.WriteLine(currentIndex);

                // // IntPtr s = process.MainWindowHandle;
                // // SetForegroundWindow(s);
                // // WinApi.User32.User32Methods.BringWindowToTop(polProcesses[currentIndex].Handle);
                // IntPtr newActiveWindow = polProcesses[currentIndex].Handle;

                // if (newActiveWindow != activeWindow) {
                //     uint thread1 = WinApi.User32.User32Methods.GetWindowThreadProcessId(activeWindow, IntPtr.Zero);
                //     uint thread2 = WinApi.Kernel32.Kernel32Methods.GetCurrentThreadId();

                //     if (thread1 != thread2)
                //     {
                //         bool attachThread = WinApi.User32.User32Methods.AttachThreadInput(thread1, thread2, true);
                //         bool bringToTop = WinApi.User32.User32Methods.BringWindowToTop(newActiveWindow);
                //         if (WinApi.User32.User32Methods.IsIconic(newActiveWindow))
                //         {
                //             bool showWindow = WinApi.User32.User32Methods.ShowWindow(newActiveWindow, WinApi.User32.ShowWindowCommands.SW_SHOWNORMAL);
                //         }
                //         else
                //         {
                //             bool showWindow = WinApi.User32.User32Methods.ShowWindow(newActiveWindow, WinApi.User32.ShowWindowCommands.SW_SHOW);
                //         }
                //         attachThread = WinApi.User32.User32Methods.AttachThreadInput(thread1, thread2, false);
                //     }
                //     else
                //     {
                //         WinApi.User32.User32Methods.SetForegroundWindow(newActiveWindow);
                //     }
                //     if (WinApi.User32.User32Methods.IsIconic(newActiveWindow))
                //     {
                //         WinApi.User32.User32Methods.ShowWindow(newActiveWindow, WinApi.User32.ShowWindowCommands.SW_SHOWNORMAL);
                //     }
                //     else
                //     {
                //         WinApi.User32.User32Methods.ShowWindow(newActiveWindow, WinApi.User32.ShowWindowCommands.SW_SHOW);
                //     }
                // }
            }
        }