Ejemplo n.º 1
0
        private void JoyPadListener()
        {
            while (IsConnected)
            {
                try
                {
                    Joy.Poll();
                    var datas = Joy.GetBufferedData();
                    foreach (var state in datas)
                    {
                        // Console.WriteLine(state);
                        // create model for the input
                        GamePadInputModel Model = new GamePadInputModel {
                            InputName   = state.Offset.ToString(),
                            Timestamp   = state.Timestamp,
                            Value       = state.Value,
                            InputNumber = state.RawOffset
                        };

                        // callback
                        callback.JoyStickInput(Model);
                    }
                }
                catch
                {
                    IsConnected = false;
                    Joy.Unacquire();
                }
            }
        }
Ejemplo n.º 2
0
        private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            // Switch case for keys
            switch (e.Key)
            {
            case System.Windows.Input.Key.A:
                GamePadInputModel M = new GamePadInputModel
                {
                    InputName   = "X",
                    InputNumber = 0,
                    Timestamp   = 0,
                    Value       = 32767
                };
                BlueToothHandler.JoyStickInput(M);
                break;

            case System.Windows.Input.Key.D:
                GamePadInputModel MM = new GamePadInputModel
                {
                    InputName   = "X",
                    InputNumber = 0,
                    Timestamp   = 0,
                    Value       = 32767
                };
                BlueToothHandler.JoyStickInput(MM);
                break;

            case System.Windows.Input.Key.W:
                GamePadInputModel MMM = new GamePadInputModel
                {
                    InputName   = "RotationZ",
                    InputNumber = 20,
                    Timestamp   = 0,
                    Value       = 32767
                };
                BlueToothHandler.JoyStickInput(MMM);
                break;

            case System.Windows.Input.Key.S:
                GamePadInputModel MMMM = new GamePadInputModel
                {
                    InputName   = "RotationZ",
                    InputNumber = 20,
                    Timestamp   = 0,
                    Value       = 32767
                };
                BlueToothHandler.JoyStickInput(MMMM);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        public void JoyStickInput(GamePadInputModel input)
        {
            if (input.Value < 0)
            {
                input.Value = 1;                  // remove the negative number from the D-Pad
            }
            // write the info to the GUI somehow
            Callback.SetPadControlText(input.ToString());

            if (IsConnected)
            {
                // get model
                BTInputModel Model = new BTInputModel {
                    Value = Convert.ToUInt16(input.Value),
                    Key   = Convert.ToByte(input.InputNumber)
                };
                // message type
                MessageTypeEnum msgType = MessageTypeEnum.BTInput;

                // send UART message
                SendBytes(msgType, Model);
            }
        }
Ejemplo n.º 4
0
 public void JoyStickInput(GamePadInputModel input)
 {
 }