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; }
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(); }
public JoystickStateListener(IJoystick js, PacketBuilder pb, JoystickStateStore holder) { this.joystick = js; this.handle = js.WaitHandle; this.packetBuilder = pb; this.holder = holder; }
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(); }
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; }
/// <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); } }
public static IJoystick GetMainController(IntPtr windowHandle) { if (JoystickFactory.mainController != null) return mainController; else return JoystickFactory.mainController = new Joystick( windowHandle,getJoystickIndex(Constants.LogitechExtreme3DProGuid), JoystickType.MainController); }
public static IJoystick GetManipulatorRight(IntPtr windowHandle) { if (JoystickFactory.manipulatorRight != null) return manipulatorRight; else return JoystickFactory.manipulatorRight = new Joystick( windowHandle,getJoystickIndex(Constants.Logitechextreme3DProManipulatorGuid), JoystickType.ManipulatorRight); }
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; }
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(); }
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); }
// 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; }
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; }
public JoystickViewModel(IJoystick stick) { Stick = stick; Stick.StateChanged += (s, e) => OnPropertyChanged(nameof(Stick)); }
private void initializePilotJoystick() { coPilotRightJoystick = new JoystickMock(); }
private void OnLostConnectionToDevice(object sender, EventArgs e) { Joystick = null; Capabilities = null; LostConnectionToDevice?.Invoke(sender, new LostConnectionToDeviceEventArgs(this)); }
public PacketBuilder(IJoystick joystick) { this.joystick = joystick; }
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); }
public XBox360Adapter(string name, IJoystick js) { controller = name; mIJoystick = js; }
public MainPacketBuilder(IJoystick joystick) : base(joystick) { this.joystick = joystick; }
public static JoystickState CaptureState(this IJoystick obj) => new JoystickState(obj);
public MOGAAdapter(string name, IJoystick js) { controller = name; mIJoystick = js; }
//public void ReAcquireJoystick() //{ // Joystick?.Unacquire(); // Joystick?.Dispose(); // AcquireJoystick(); //} private void AcquireJoystick() { Joystick = _joystickFactory.CreateJoystick(_directInput, DeviceId); Joystick.BufferSize = 4096; Joystick.Acquire(); }
private void initializePilotJoystick() { WaitHandle handle = new AutoResetEvent(false); coPilotRightJoystick = JoystickFactory.GetManipulatorRight(pilotView.Handle); coPilotRightJoystick.Acquire(handle); }
private static void JoystickOnButtonDown(IJoystick arg1, Button arg2) { Console.WriteLine($"J{arg1.Index}> {arg2.Name} down."); }
private static void JoystickOnHatMoved(IJoystick arg1, Hat arg2) { Console.WriteLine($"J{arg1.Index}> {arg2.Index} hat moved: {arg2.Position}"); }
private static void JoystickOnAxisMoved(IJoystick arg1, Axis arg2) { Console.WriteLine($"J{arg1.Index}> {arg2.Index} axis moved: {arg2.Position}"); }
private static void JoystickOnHatMoved(IJoystick arg1, Hat arg2) { Console.WriteLine("J" + arg1.Index + "> " + arg2.Index + " hat moved: " + arg2.Position); }
private static void JoystickOnAxisMoved(IJoystick arg1, Axis arg2) { Console.WriteLine("J" + arg1.Index + "> " + arg2.Index + " axis moved: " + arg2.Position); }
private static void JoystickOnButtonDown(IJoystick arg1, Button arg2) { Console.WriteLine("J" + arg1.Index + "> " + arg2.Name + " down."); }
private void initializeCoPilotRightJoystick() { WaitHandle handle = new AutoResetEvent(false); pilotJoystick = JoystickFactory.GetMainController(pilotView.Handle); pilotJoystick.Acquire(handle); }
public ManipulatorRightPacketBuilder(IJoystick joystick) : base(joystick) { this.joystick = joystick; }