コード例 #1
0
        internal unsafe JoystickState(IJoystick joystick, MemoryPool <byte> pool)
        {
            Name        = joystick.Name;
            Index       = joystick.Index;
            IsConnected = joystick.IsConnected;
            var srcAxes    = joystick.Axes;
            var srcButtons = joystick.Buttons;
            var srcHats    = joystick.Hats;

            _axes    = pool.Rent((_axisCount = srcAxes.Count) * sizeof(Axis));
            _buttons = pool.Rent((_buttonCount = srcButtons.Count) * sizeof(Button));
            _hats    = pool.Rent((_hatCount = srcHats.Count) * sizeof(Hat));
            var dstAxes    = GetAxes();
            var dstButtons = GetButtons();
            var dstHats    = GetHats();

            for (var i = 0; i < _axisCount; i++)
            {
                dstAxes[i] = srcAxes[i];
            }

            for (var i = 0; i < _buttonCount; i++)
            {
                dstButtons[i] = srcButtons[i];
            }

            for (var i = 0; i < _hatCount; i++)
            {
                dstHats[i] = srcHats[i];
            }

            Deadzone = joystick.Deadzone;
        }
コード例 #2
0
        private void FillJoystickInfo(int index, Label label)
        {
            IJoystick j = InputLib.Input.Joysticks[index];

            StringBuilder b = new StringBuilder();

            b.Append("Joystick ");
            b.AppendLine(index.ToString());
            b.AppendLine(j.Name);
            b.Append("Axis Count: ");
            b.AppendLine(j.AxisCount.ToString());

            for (int i = 0; i < j.AxisCount; i++)
            {
                b.Append("Axis ");
                b.Append(i.ToString());
                b.Append(": ");
                b.Append(j.AxisState(i));
                b.AppendLine();
            }

            b.AppendLine();

            b.Append("X: ");
            b.AppendLine(j.AxisState(0).ToString(CultureInfo.CurrentCulture));
            b.Append("Y: ");
            b.AppendLine(j.AxisState(1).ToString(CultureInfo.CurrentCulture));
            b.AppendLine();

            b.Append("Buttons: ");

            bool comma = false;

            for (int i = 0; i < j.ButtonCount; i++)
            {
                if (j.ButtonState(i))
                {
                    if (comma)
                    {
                        b.Append(",");
                    }
                    b.Append(i.ToString());
                    comma = true;
                }
            }

            b.AppendLine();
            b.Append("Hats:");

            for (int i = 0; i < j.HatCount; i++)
            {
                b.Append("    ");
                b.Append(i.ToString());
                b.Append(": ");
                b.Append(j.HatState(i));
                b.AppendLine();
            }

            label.Text = b.ToString();
        }
コード例 #3
0
 public JoystickStateListener(IJoystick js, PacketBuilder pb, JoystickStateStore holder)
 {
     this.joystick = js;
     this.handle = js.WaitHandle;
     this.packetBuilder = pb;
     this.holder = holder;
 }
コード例 #4
0
        public JoystickGamepad(IJoystick joystick)
        {
            this.joystick_ = joystick;

            // TODO: Consistent way to get analog sticks?
            var axes = joystick.Axes;

            this.analogSticks_[AnalogStickType.PRIMARY] =
                new AxesAsAnalogStick {
                Horizontal = axes[0], Vertical = axes[1]
            };
            this.analogSticks_[AnalogStickType.SECONDARY] =
                new AxesAsAnalogStick {
                Horizontal = axes[3], Vertical = axes[4]
            };
            this.AnalogSticks = this.analogSticks_.Values.ToImmutableArray();

            // TODO: Consistent way to get buttons?
            var buttons = joystick.Buttons;

            this.faceButtons_[FaceButtonType.PRIMARY]   = buttons[4];
            this.faceButtons_[FaceButtonType.SECONDARY] = buttons[5];
            this.faceButtons_[FaceButtonType.START]     = buttons[8];
            this.faceButtons_[FaceButtonType.SELECT]    = buttons[7];
            this.Buttons = this.faceButtons_.Values.ToImmutableArray();
        }
コード例 #5
0
ファイル: JoystickState.cs プロジェクト: storm32600/Silk.NET
        internal unsafe JoystickState(IJoystick joystick)
        {
            Name        = joystick.Name;
            Index       = joystick.Index;
            IsConnected = joystick.IsConnected;
            var axes    = joystick.Axes;
            var buttons = joystick.Buttons;
            var hats    = joystick.Hats;

            _axes    = (Axis *)Marshal.AllocHGlobal((_axisCount = axes.Count) * sizeof(Axis));
            _buttons = (Button *)Marshal.AllocHGlobal((_buttonCount = buttons.Count) * sizeof(Button));
            _hats    = (Hat *)Marshal.AllocHGlobal((_hatCount = hats.Count) * sizeof(Hat));
            for (var i = 0; i < _axisCount; i++)
            {
                _axes[i] = axes[i];
            }

            for (var i = 0; i < _buttonCount; i++)
            {
                _buttons[i] = buttons[i];
            }

            for (var i = 0; i < _hatCount; i++)
            {
                _hats[i] = hats[i];
            }

            Deadzone = joystick.Deadzone;
        }
コード例 #6
0
        /// <summary>
        /// Inicializace joysticku/gamepadu
        /// </summary>
        private void inicializeJoystick()
        {
            controllView.showControlMessage(MessageTypeEnum.progress, "Probíhá inicializace ovládacího zařízení.");
            JoystickBridge joystickBridge = new JoystickBridge();

            joystick = joystickBridge.getJoystick();
            joystick.onOff(false);
            joystick.subscribeDirectMoveStickObserver(joystickDirectMoveChanged);
            joystick.subscribeMoveStickObserver(joystickMoveChanged);
            joystick.subscribeButtonMoveUpObserver(joystickButtonMoveUpChanged);
            joystick.subscribeButtonMoveDownObserver(joystickButtonMoveDownChanged);
            joystick.subscribeButtonNarrowObserver(joystickButtonNarrowChanged);
            joystick.subscribeButtonWidenObserver(joystickButtonWidenChanged);
            joystick.subscribeButtonDefaultPositionObserver(joystickButtonDefaultPositionChanged);
            joystick.subscribeButtonRotateLeftObserver(joystickButtonRotateLeftChanged);
            joystick.subscribeButtonRotateRightObserver(joystickButtonRotateRightChanged);
            joystick.subscribeButtonStopObserver(joystickButtonStopChanged);
            joystick.subscribeButtonTiltBackObserver(joystickButtonTiltBackChanged);
            joystick.subscribeButtonTiltFrontObserver(joystickButtonTiltFrontChanged);
            joystick.subscribeButtonTiltLeftObserver(joystickButtonTiltLeftChanged);
            joystick.subscribeButtonTiltRightObserver(joystickButtonTiltRightChanged);
            joystick.subscribeFrontNarrowObserver(joysticFrontNarrowChanged);
            joystick.subscribeBackNarrowObserver(joystickBackNarrowChanged);
            joystick.subscribeErrorObserver(refindJoystick);
            if (!joystickBridge.success)
            {
                gamePadChecker.Enabled = true;
                controllView.showControlMessage(MessageTypeEnum.error, joystickBridge.message);
            }
            else
            {
                controllView.showControlMessage(MessageTypeEnum.success, joystickBridge.message);
            }
        }
コード例 #7
0
 public static IJoystick GetMainController(IntPtr windowHandle)
 {
     if (JoystickFactory.mainController != null)
         return mainController;
     else
         return JoystickFactory.mainController = new Joystick(
             windowHandle,getJoystickIndex(Constants.LogitechExtreme3DProGuid),
             JoystickType.MainController);
 }
コード例 #8
0
 public static IJoystick GetManipulatorRight(IntPtr windowHandle)
 {
     if (JoystickFactory.manipulatorRight != null)
         return manipulatorRight;
     else
         return JoystickFactory.manipulatorRight = new Joystick(
             windowHandle,getJoystickIndex(Constants.Logitechextreme3DProManipulatorGuid),
             JoystickType.ManipulatorRight);
 }
コード例 #9
0
        public JoystickPedal(IJoystick joystick)
        {
            left   = new ButtonMonitor(() => joystick.Button8, "Left", OnPropertyChange, () => LeftUp, () => LeftDown);
            center = new ButtonMonitor(() => joystick.Button7 || joystick.Button9, "Center", OnPropertyChange,
                                       () => CenterUp, () => CenterDown);
            right = new ButtonMonitor(() => joystick.Button10, "Right", OnPropertyChange, () => RightUp, () => RightDown);

            joystick.StateChanged += left.StateChanged;
            joystick.StateChanged += center.StateChanged;
            joystick.StateChanged += right.StateChanged;
        }
コード例 #10
0
ファイル: Snake.cs プロジェクト: pvrobays/sensehat-snake
 public Snake(IJoystick joystick, ISnakeRenderer snakeRenderer)
 {
     _random        = new Random();
     _joystick      = joystick;
     _snakeRenderer = snakeRenderer;
     _isRunning     = false;
     snake          = new CircularQueue <Point>();
     snake.EnqueueWithoutDequeue(new Point(3, 3));
     direction   = new Vector2(1, 0);
     ateLastTime = false;
     food        = GenerateNewFoodPosition();
 }
コード例 #11
0
ファイル: HOTASQueue.cs プロジェクト: joekolodz/SierraHOTAS
        public void Listen(IJoystick joystick, Dictionary <int, ObservableCollection <IHotasBaseMap> > modeProfiles, Dictionary <int, ModeActivationItem> modeProfileActivationButtons)
        {
            Joystick      = joystick;
            _modeProfiles = modeProfiles;
            _modeProfileActivationButtons = modeProfileActivationButtons;

            if (_modeProfiles.Count > 0)
            {
                _buttonMap = _modeProfiles[1];
            }

            _jitterDetectionDictionary = new Dictionary <int, JitterDetection>();

            _actionJobs = new BlockingCollection <ActionJobItem>();

            _isStopRequested = false;
            Task.Factory.StartNew(ListenLoop, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(DequeueLoop, TaskCreationOptions.LongRunning);
        }
コード例 #12
0
        // Initialize Objects and add notify events
        private FlightModel()
        {
            netClient       = new FlightNetClient();
            fileIterator    = new FlightDataIterator();
            dataParser      = new XMLParser();
            dataAnalyzer    = new DataAnalyzer();
            libLoader       = new LibraryLoader();
            anomalyAnalyzer = new AnomalyAnalyzer(libLoader);
            selectedPlot    = new MonitorGraph(dataAnalyzer, fileIterator);
            correlatedPlot  = new MonitorGraph(dataAnalyzer, fileIterator);
            anomalyPlot     = new AnomalyGraph(dataAnalyzer, fileIterator, anomalyAnalyzer);
            simPlayer       = new FlightSimPlayer(netClient, fileIterator);
            joystick        = new FlightJoystick(fileIterator, dataAnalyzer);
            dashboard       = new FlightDashboard(fileIterator, dataAnalyzer);

            // add notify events
            simPlayer.PropertyChanged += PropertyChangedFunction;
            joystick.PropertyChanged  += PropertyChangedFunction;
            dashboard.PropertyChanged += PropertyChangedFunction;
        }
コード例 #13
0
    public bool Connect(string name, IJoystick joystick)
    {
        if (joystick == null)
            return false;

#if UNITY_IPHONE
		{
			MOGAAdapter adapter = new MOGAAdapter(name, joystick);
			
			jc.SetAdapter(adapter);
		}
#else
        {
            XBox360Adapter adapter = new XBox360Adapter(name, joystick);

            jc.SetAdapter(adapter);
        }
#endif

        return true;
    }
コード例 #14
0
 public JoystickViewModel(IJoystick stick)
 {
     Stick = stick;
     Stick.StateChanged += (s, e) => OnPropertyChanged(nameof(Stick));
 }
コード例 #15
0
 private void initializePilotJoystick()
 {
     coPilotRightJoystick = new JoystickMock();
 }
コード例 #16
0
 private void OnLostConnectionToDevice(object sender, EventArgs e)
 {
     Joystick     = null;
     Capabilities = null;
     LostConnectionToDevice?.Invoke(sender, new LostConnectionToDeviceEventArgs(this));
 }
コード例 #17
0
 public PacketBuilder(IJoystick joystick)
 {
     this.joystick = joystick;
 }
コード例 #18
0
        private static DeviceViewModel CreateDeviceViewMode(out IHOTASQueue hotasQueue, out IHOTASDevice hotasDevice, out IJoystick subJoystick)
        {
            var subFileSystem         = Substitute.For <IFileSystem>();
            var subDispatchFactory    = Substitute.For <DispatcherFactory>();
            var subDirectInputFactory = Substitute.For <DirectInputFactory>();
            var subMediaPlayerFactory = Substitute.For <MediaPlayerFactory>();
            var subJoystickFactory    = Substitute.For <JoystickFactory>();

            var hotasQueueFactory  = new HOTASQueueFactory(Substitute.For <IKeyboard>());
            var hotasDeviceFactory = new HOTASDeviceFactory();

            var deviceId    = Guid.NewGuid();
            var productId   = Guid.NewGuid();
            var directInput = subDirectInputFactory.CreateDirectInput();

            subJoystick = subJoystickFactory.CreateJoystick(directInput, deviceId);
            subJoystick.Capabilities.Returns(new Capabilities());

            hotasQueue  = hotasQueueFactory.CreateHOTASQueue();
            hotasDevice = hotasDeviceFactory.CreateHOTASDevice(directInput, subJoystickFactory, productId, deviceId, "test", hotasQueue);
            hotasDevice.Capabilities = new Capabilities()
            {
                AxeCount = 0, ButtonCount = 2
            };

            var deviceVm = new DeviceViewModel(subDispatchFactory.CreateDispatcher(), subFileSystem, subMediaPlayerFactory, hotasDevice);

            return(deviceVm);
        }
コード例 #19
0
    public XBox360Adapter(string name, IJoystick js)
    {
        controller = name;

        mIJoystick = js;
    }
コード例 #20
0
 public MainPacketBuilder(IJoystick joystick)
     : base(joystick)
 {
     this.joystick = joystick;
 }
コード例 #21
0
ファイル: Controller.cs プロジェクト: Brzobohaty/Robot
 /// <summary>
 /// Inicializace joysticku/gamepadu
 /// </summary>
 private void inicializeJoystick()
 {
     controllView.showControlMessage(MessageTypeEnum.progress, "Probíhá inicializace ovládacího zařízení.");
     JoystickBridge joystickBridge = new JoystickBridge();
     joystick = joystickBridge.getJoystick();
     joystick.onOff(false);
     joystick.subscribeDirectMoveStickObserver(joystickDirectMoveChanged);
     joystick.subscribeMoveStickObserver(joystickMoveChanged);
     joystick.subscribeButtonMoveUpObserver(joystickButtonMoveUpChanged);
     joystick.subscribeButtonMoveDownObserver(joystickButtonMoveDownChanged);
     joystick.subscribeButtonNarrowObserver(joystickButtonNarrowChanged);
     joystick.subscribeButtonWidenObserver(joystickButtonWidenChanged);
     joystick.subscribeButtonDefaultPositionObserver(joystickButtonDefaultPositionChanged);
     joystick.subscribeButtonRotateLeftObserver(joystickButtonRotateLeftChanged);
     joystick.subscribeButtonRotateRightObserver(joystickButtonRotateRightChanged);
     joystick.subscribeButtonStopObserver(joystickButtonStopChanged);
     joystick.subscribeButtonTiltBackObserver(joystickButtonTiltBackChanged);
     joystick.subscribeButtonTiltFrontObserver(joystickButtonTiltFrontChanged);
     joystick.subscribeButtonTiltLeftObserver(joystickButtonTiltLeftChanged);
     joystick.subscribeButtonTiltRightObserver(joystickButtonTiltRightChanged);
     joystick.subscribeFrontNarrowObserver(joysticFrontNarrowChanged);
     joystick.subscribeBackNarrowObserver(joystickBackNarrowChanged);
     joystick.subscribeErrorObserver(refindJoystick);
     if (!joystickBridge.success)
     {
         gamePadChecker.Enabled = true;
         controllView.showControlMessage(MessageTypeEnum.error, joystickBridge.message);
     }
     else
     {
         controllView.showControlMessage(MessageTypeEnum.success, joystickBridge.message);
     }
 }
コード例 #22
0
 public static JoystickState CaptureState(this IJoystick obj) => new JoystickState(obj);
コード例 #23
0
    public MOGAAdapter(string name, IJoystick js)
    {
        controller = name;

        mIJoystick = js;
    }
コード例 #24
0
        //public void ReAcquireJoystick()
        //{
        //    Joystick?.Unacquire();
        //    Joystick?.Dispose();
        //    AcquireJoystick();
        //}

        private void AcquireJoystick()
        {
            Joystick            = _joystickFactory.CreateJoystick(_directInput, DeviceId);
            Joystick.BufferSize = 4096;
            Joystick.Acquire();
        }
コード例 #25
0
 private void initializePilotJoystick()
 {
     WaitHandle handle = new AutoResetEvent(false);
     coPilotRightJoystick = JoystickFactory.GetManipulatorRight(pilotView.Handle);
     coPilotRightJoystick.Acquire(handle);
 }
コード例 #26
0
 private static void JoystickOnButtonDown(IJoystick arg1, Button arg2)
 {
     Console.WriteLine($"J{arg1.Index}> {arg2.Name} down.");
 }
コード例 #27
0
 private static void JoystickOnHatMoved(IJoystick arg1, Hat arg2)
 {
     Console.WriteLine($"J{arg1.Index}> {arg2.Index} hat moved: {arg2.Position}");
 }
コード例 #28
0
 private static void JoystickOnAxisMoved(IJoystick arg1, Axis arg2)
 {
     Console.WriteLine($"J{arg1.Index}> {arg2.Index} axis moved: {arg2.Position}");
 }
コード例 #29
0
ファイル: Program.cs プロジェクト: fossabot/Silk.NET
 private static void JoystickOnHatMoved(IJoystick arg1, Hat arg2)
 {
     Console.WriteLine("J" + arg1.Index + "> " + arg2.Index + " hat moved: " + arg2.Position);
 }
コード例 #30
0
ファイル: Program.cs プロジェクト: fossabot/Silk.NET
 private static void JoystickOnAxisMoved(IJoystick arg1, Axis arg2)
 {
     Console.WriteLine("J" + arg1.Index + "> " + arg2.Index + " axis moved: " + arg2.Position);
 }
コード例 #31
0
ファイル: Program.cs プロジェクト: fossabot/Silk.NET
 private static void JoystickOnButtonDown(IJoystick arg1, Button arg2)
 {
     Console.WriteLine("J" + arg1.Index + "> " + arg2.Name + " down.");
 }
コード例 #32
0
 private void initializeCoPilotRightJoystick()
 {
     WaitHandle handle = new AutoResetEvent(false);
     pilotJoystick = JoystickFactory.GetMainController(pilotView.Handle);
     pilotJoystick.Acquire(handle);
 }
コード例 #33
0
 public ManipulatorRightPacketBuilder(IJoystick joystick)
     : base(joystick)
 {
     this.joystick = joystick;
 }