コード例 #1
0
        private void Start()
        {
            _handler.Commands.Subscribe(c =>
            {
                switch (c.Command)
                {
                case MessageCommandNames.LoadMidiNoteToMotionMap:
                    LoadMidiNoteToMotionMap(c.Content);
                    break;

                case MessageCommandNames.RequireMidiNoteOnMessage:
                    _redirectNoteOnMessageToIpc = c.ToBoolean();
                    break;
                }
            });

            _midiInputObserver.NoteOn.Subscribe(noteNumber =>
            {
                if (_redirectNoteOnMessageToIpc)
                {
                    _sender?.SendCommand(MessageFactory.Instance.MidiNoteOn(noteNumber));
                }

                if (UseMidiInput &&
                    _cooldownCount <= 0 &&
                    _noteNumberToMotionMap.ContainsKey(noteNumber))
                {
                    RequestExecuteWordToMotionItem?.Invoke(_noteNumberToMotionMap[noteNumber]);
                    _cooldownCount = cooldownTime;
                }
            });
        }
コード例 #2
0
        public void Initialize(
            IMessageReceiver receiver, IMessageSender sender,
            RawInputChecker rawInputChecker,
            XInputGamePad gamepadListener,
            MidiInputObserver midiObserver
            )
        {
            _keyboard     = new KeyboardToWordToMotion(rawInputChecker);
            _midi         = new MidiToWordToMotion(receiver, sender, midiObserver);
            _gamepad      = new GamepadToWordToMotion(gamepadListener);
            _wordAnalyzer = new WordAnalyzer();

            _keyboard.RequestExecuteWordToMotionItem += v =>
            {
                if (UseKeyboardInput && _coolDownCount <= 0)
                {
                    _coolDownCount = cooldownTime;
                    RequestExecuteWordToMotionItem?.Invoke(v);
                }
            };

            _midi.RequestExecuteWordToMotionItem += v =>
            {
                if (UseMidiInput && _coolDownCount <= 0)
                {
                    _coolDownCount = cooldownTime;
                    RequestExecuteWordToMotionItem?.Invoke(v);
                }
            };

            _gamepad.RequestExecuteWordToMotionItem += v =>
            {
                if (UseGamepadInput && _coolDownCount <= 0)
                {
                    _coolDownCount = cooldownTime;
                    RequestExecuteWordToMotionItem?.Invoke(v);
                }
            };

            _wordAnalyzer.WordDetected += word =>
            {
                if (UseKeyboardWordTypingForWordToMotion)
                {
                    _coolDownCount = cooldownTime;
                    RequestExecuteWord?.Invoke(word);
                }
            };

            rawInputChecker.PressedRawKeys.Subscribe(keyName =>
            {
                if (UseKeyboardWordTypingForWordToMotion)
                {
                    _count = forgetTime;
                    _wordAnalyzer.Add(KeyName2Char(keyName));
                }
            });
        }
コード例 #3
0
 public GamepadToWordToMotion(XInputGamePad gamepadInput)
 {
     _gamepadObserve = gamepadInput.ButtonUpDown.Subscribe(data =>
     {
         if (data.IsPressed && _gamePadKeyToItemIndex.ContainsKey(data.Key))
         {
             RequestExecuteWordToMotionItem?.Invoke(_gamePadKeyToItemIndex[data.Key]);
         }
     });
 }
コード例 #4
0
 public KeyboardToWordToMotion(RawInputChecker rawInputChecker)
 {
     _inputObserver = rawInputChecker.PressedRawKeys.Subscribe(keyName =>
     {
         //NOTE: D0-D8とNumPad系のキーはサニタイズ対象じゃないので、そのまま受け取っても大丈夫
         if (_keyToItemIndex.ContainsKey(keyName))
         {
             RequestExecuteWordToMotionItem?.Invoke(_keyToItemIndex[keyName]);
         }
     });
 }
コード例 #5
0
 private void Start()
 {
     _gamepadInput.ButtonUpDown.Subscribe(data =>
     {
         if (UseGamepadInput &&
             data.IsPressed &&
             _cooldownCount <= 0 &&
             _gamePadKeyToItemIndex.ContainsKey(data.Key))
         {
             RequestExecuteWordToMotionItem?.Invoke(
                 _gamePadKeyToItemIndex[data.Key]
                 );
             _cooldownCount = cooldownTime;
         }
     });
 }
コード例 #6
0
        private void Start()
        {
            _rawInputChecker.PressedKeys.Subscribe(keyName =>
            {
                if (!UseKeyboardInput || _cooldownCount > 0)
                {
                    return;
                }

                //NOTE: D0-D8とNumPad系のキーはサニタイズ対象じゃないので、そのまま受け取っても大丈夫
                if (_keyToItemIndex.ContainsKey(keyName))
                {
                    RequestExecuteWordToMotionItem?.Invoke(_keyToItemIndex[keyName]);
                    _cooldownCount = cooldownTime;
                }
            });
        }
コード例 #7
0
        public MidiToWordToMotion(IMessageReceiver receiver, IMessageSender sender, MidiInputObserver midiObserver)
        {
            receiver.AssignCommandHandler(
                VmmCommands.LoadMidiNoteToMotionMap,
                c => LoadMidiNoteToMotionMap(c.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.RequireMidiNoteOnMessage,
                c => _redirectNoteOnMessageToIpc = c.ToBoolean()
                );

            _midiObserver = midiObserver.NoteOn.Subscribe(noteNumber =>
            {
                if (_redirectNoteOnMessageToIpc)
                {
                    sender.SendCommand(MessageFactory.Instance.MidiNoteOn(noteNumber));
                }

                if (_noteNumberToMotionMap.ContainsKey(noteNumber))
                {
                    RequestExecuteWordToMotionItem?.Invoke(_noteNumberToMotionMap[noteNumber]);
                }
            });
        }