Example #1
0
        private void Target_OnFeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
        {
            byte[] data = { 0x20, e.SmallMotor, e.LargeMotor };

            Task.Run(() => {
                lock (_VibrationTimer)
                {
                    if (!_Device.IsOpen)
                    {
                        return;
                    }

                    _Device.WriteFeatureData(data);
                }

                var timeout = e.SmallMotor > 0 || e.LargeMotor > 0 ? 3000 : Timeout.Infinite;
                _VibrationTimer.Change(timeout, Timeout.Infinite);
            });

            if (LedNumber != e.LedNumber)
            {
                LedNumber = e.LedNumber;
                // TODO raise event here
            }
        }
Example #2
0
 private void OnFeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     if (_feedbackCallback == null)
     {
         return;
     }
     _feedbackCallback(e.LargeMotor, e.SmallMotor, e.LedNumber);
 }
Example #3
0
 private void FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     InvokeFeedbackEvent(new XboxFeedbackEventArgs
     {
         Small     = (double)e.SmallMotor / byte.MaxValue,
         Large     = (double)e.LargeMotor / byte.MaxValue,
         LedNumber = e.LedNumber,
     });
 }
Example #4
0
        public void ReceiveRumble(object sender, Xbox360FeedbackReceivedEventArgs e)
        {
            SetRumble(lowFreq, _highFreq, e.LargeMotor / (float)255, rumblePeriod);

            if (other != null)
            {
                other.SetRumble(lowFreq, _highFreq, e.LargeMotor / (float)255, rumblePeriod);
            }
        }
        public void SetVibration(MapTo userIndex, byte largeMotor, byte smallMotor, byte ledNumber)
        {
            var client = ViGEmClient.Current;

            if (client == null)
            {
                return;
            }
            var e = new Xbox360FeedbackReceivedEventArgs(largeMotor, smallMotor, ledNumber);

            ViGEmClient.Current.Feedbacks[(int)userIndex - 1] = e;
        }
Example #6
0
        private void TargetOnFeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
        {
            byte[] data = { 0x20, e.SmallMotor, e.LargeMotor };

            Task.Run(() =>
            {
                if (_Device.IsOpen)
                {
                    _Device.WriteFeatureData(data);
                }
            });
        }
 private void Controller_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     lock (FeedbackLock)
     {
         var controller = (Xbox360Controller)sender;
         for (int i = 0; i < 4; i++)
         {
             if (ViGEmClient.Current.Targets[i] == controller)
             {
                 // Add force feedback value for processing.
                 ViGEmClient.Current.Feedbacks[i] = e;
                 break;
             }
         }
     }
 }
Example #8
0
        private void Target_OnFeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
        {
            byte[] data = { 0x20, e.SmallMotor, e.LargeMotor };

            Task.Run(() =>
            {
                if (_Device.IsOpen)
                {
                    _Device.WriteFeatureData(data);
                }
            });

            if (LedNumber != e.LedNumber)
            {
                LedNumber = e.LedNumber;
                // TODO raise event here
            }
        }
Example #9
0
 private void Target360_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     byte[] vibReport = { 0x05, e.LargeMotor, e.LargeMotor, e.SmallMotor, e.SmallMotor };
     _stream.Write(vibReport);
 }
Example #10
0
 private void FeedbackReceivedRcv(object _sender, Xbox360FeedbackReceivedEventArgs e)
 {
     FeedbackReceived(e);
 }
Example #11
0
 private void Controller_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     SetVibration(e.SmallMotor, e.LargeMotor);
 }
Example #12
0
 private void Controller_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     // Set whether or not the value increased
     RumbleChanged   = _VibrationMotor > 0;
     _VibrationMotor = e.LargeMotor;
 }
 private void MyController_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
 }
Example #14
0
 private void Target360_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     vibrate(e.LargeMotor, e.SmallMotor);
 }
Example #15
0
 private void Target360_FeedbackReceived(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
 }
Example #16
0
        private void connectClientToPort(object sender, Xbox360FeedbackReceivedEventArgs eventArgs)
        {
            Xbox360Controller newController = (Xbox360Controller)sender;

            newController.FeedbackReceived -= connectClientToPort;

            Console.WriteLine(eventArgs);
            Console.WriteLine(eventArgs.LedNumber);

            // ledNumber returns 0 for player 1, 1 for player 2, 2 for player 3, 3 for player 4
            // but on other computers, ledNumber returns 1 for player 1, 2 for player 2 and so on
            // When the first controller connects (thus when portCalculator isn't defined yet),
            // if the LedNumber is 0, portCalculator = 1
            // else, it's 0
            if (Globals.portCalculator == null)
            {
                if (eventArgs.LedNumber == 0)
                {
                    Globals.portCalculator = 1;
                }
                else
                {
                    Globals.portCalculator = 0;
                }
            }

            int port = eventArgs.LedNumber + (int)Globals.portCalculator;

            if (port > 4)
            {
                newController.Disconnect();
                Send("Disconnect:4 controllers already connected!");
                return;
            }



            Application.Current.Dispatcher.Invoke(() =>
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                Label statusLabel;
                Button disconnectButton;

                switch (port)
                {
                case 1:
                    statusLabel      = mainWindow.lblController1Connected;
                    disconnectButton = mainWindow.btnController1Disconnect;
                    break;

                case 2:
                    statusLabel      = mainWindow.lblController2Connected;
                    disconnectButton = mainWindow.btnController2Disconnect;
                    break;

                case 3:
                    statusLabel      = mainWindow.lblController3Connected;
                    disconnectButton = mainWindow.btnController3Disconnect;
                    break;

                case 4:
                    statusLabel      = mainWindow.lblController4Connected;
                    disconnectButton = mainWindow.btnController4Disconnect;
                    break;

                default:
                    return;
                }

                Globals.wssv.AddWebSocketService("/x360_port" + port, () => new X360(newController, port, statusLabel, disconnectButton));
                // Example: Connected:x360_port1
                Send("Connected:x360_port" + port);
            });
        }
Example #17
0
 protected void FeedbackEventHandler(object sender, Xbox360FeedbackReceivedEventArgs e)
 {
     SubscribeFeedback(e);
 }