Example #1
0
        private void SetThumbStickAxis(XboxThumbAxis axis, Side side)
        {
            int factor = 200;
            var x      = axis.X * factor;
            var y      = axis.Y * factor;

            if (x > short.MaxValue)
            {
                x = short.MaxValue - 1;
            }
            if (x < short.MinValue)
            {
                x = short.MinValue + 1;
            }
            if (y > short.MaxValue)
            {
                y = short.MaxValue - 1;
            }
            if (y < short.MinValue)
            {
                y = short.MinValue + 1;
            }

            Report.SetAxis(side == Side.LEFT ? Xbox360Axes.LeftThumbX : Xbox360Axes.RightThumbX, (short)(x * -1));
            Report.SetAxis(side == Side.LEFT ? Xbox360Axes.LeftThumbY : Xbox360Axes.RightThumbY, (short)y);
            X360Controller.SendReport(Report);
        }
Example #2
0
        public override async Task DepressXboxButton(IAsyncStreamReader <XboxButton> buttonStream, IServerStreamWriter <Response> responseStream, ServerCallContext context)
        {
            while (await buttonStream.MoveNext())
            {
                var button = buttonStream.Current;

                Report.SetButtonState((Xbox360Buttons)button.Id, false);
                X360Controller.SendReport(Report);

                Response reply = new Response {
                    Received = true
                };
                await responseStream.WriteAsync(reply);
            }
        }
Example #3
0
        public override async Task XboxRightTrigger(IAsyncStreamReader <XboxTrigger> triggerStream, IServerStreamWriter <Response> responseStream, ServerCallContext context)
        {
            while (await triggerStream.MoveNext())
            {
                var trigger = triggerStream.Current;

                Report.SetAxis(Xbox360Axes.RightTrigger, (short)trigger.Pressure);
                X360Controller.SendReport(Report);

                Response reply = new Response {
                    Received = true
                };
                await responseStream.WriteAsync(reply);
            }
        }
Example #4
0
        public override async Task PressXboxButton(IAsyncStreamReader <XboxButton> buttonStream, IServerStreamWriter <Response> responseStream, ServerCallContext context)
        {
            while (await buttonStream.MoveNext())
            {
                var button = buttonStream.Current;
                if (button.Id == 0x9001 && !X360Controller.IsConneced) // Init
                {
                    X360Controller.Connect();
                }

                Report.SetButtonState((Xbox360Buttons)button.Id, true);
                X360Controller.SendReport(Report);

                Response reply = new Response {
                    Received = true
                };
                await responseStream.WriteAsync(reply);
            }
        }