static void PrintPOV(Xbox360Service s, int id) { POV pov = POV.POV_NONE; if (!s.GetDpad(id, ref pov)) { pov = POV.POV_NONE; } Console.WriteLine("{0}", povNameMap[pov]); }
public MainWindow() { InitializeComponent(); logger = Logger.GetInstance(); handler = new PacketHandler(); lastHeartbeatReceived = DateTime.MinValue; receivedDriveModeAck = false; xboxService = new Xbox360Service(); bool xbox_init_ok = xboxService.Initialize(); if (!xbox_init_ok) { logger.Write(LoggerLevel.Warning, "Failed to initialize the Xbox360Service. Joysticks are inoperable for this session."); } packetSocket = new UdpClient(PKT_PORT); packetSocket.BeginReceive(PacketReceiveCallback, null); imgListener = new TcpListener(IPAddress.Any, IMG_PORT); imgListener.Start(); imgListenerThread = new Thread(ImageListenerThread); imgListenerThread.SetApartmentState(ApartmentState.STA); imgListenerThread.Start(); queryHeartbeatTimer = new System.Timers.Timer(QUERY_HEARTBEAT_INTERVAL); queryHeartbeatTimer.Elapsed += new ElapsedEventHandler(QueryHeartbeatEvent); queryHeartbeatTimer.Enabled = true; isConnected = false; windowClosing = false; currentDriveMode = DriveMode.Direct; connectionThread = new Thread(ConnectingWorker); joystickReadThread = new Thread(ReadJoystickValues); joystickReadThread.IsBackground = true; joystickReadThread.Start(); qualitySlider.Value = 15; // default dispSlider.Value = -1; vibSlider.Value = -1; }
static void PrintButtons(Xbox360Service s, int id) { bool[] buttons = new bool[11]; if (!s.GetButtons(id, ref buttons)) { for (int i = 0; i < 11; i++) { buttons[i] = false; } } for (int i = 0; i < 11; i++) { Console.Write("{0} {1} ", i, buttons[i]); } Console.WriteLine(); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("usage: JoystickLibraryTester.exe <number_joysticks>"); return; } int num_joysticks; if (!int.TryParse(args[0], out num_joysticks)) { Console.WriteLine("Please enter a valid number of joysticks (> 0)."); return; } //Extreme3DProService s = new Extreme3DProService(num_joysticks); Xbox360Service s = new Xbox360Service(num_joysticks); if (!s.Initialize()) { Console.WriteLine("Failed to initialize!"); return; } if (!s.Start()) { Console.WriteLine("Failed to start!"); return; } Console.WriteLine("Waiting for a joystick to be plugged in..."); while (s.GetConnectedJoysticksCount() < 1) ; Console.WriteLine("Found one - starting main loop."); while (true) { foreach (int i in s.GetJoystickIDs()) { Console.Write("[{0}] ", i); PrintAbsoluteAxes(s, i); //PrintButtons(s, i); //PrintPOV(s, i); } } }
static void PrintAbsoluteAxes(Xbox360Service s, int id) { int lx = 0, ly = 0, rx = 0, ry = 0; if (!s.GetLeftX(id, ref lx)) { lx = 0; } if (!s.GetLeftY(id, ref ly)) { ly = 0; } if (!s.GetRightX(id, ref rx)) { rx = 0; } if (!s.GetRightY(id, ref ry)) { ry = 0; } Console.WriteLine("LX: {0} | LY: {1} | RX: {2} | RY: {3}", lx, ly, rx, ry); }
static void Main(string[] args) { Extreme3DProService es = new Extreme3DProService(); Xbox360Service xs = new Xbox360Service(); if (!xs.Initialize()) { Console.WriteLine("Failed to initialize Xbox!"); return; } if (!es.Initialize()) { Console.WriteLine("Failed to initialize Logitech!"); return; } Console.WriteLine("Waiting for a joystick to be plugged in..."); while (es.GetNumberConnected() < 1) { ; } Console.WriteLine("Found one - starting main loop."); while (true) { foreach (int i in es.GetIDs()) { Console.Write("[{0}] ", i); PrintAbsoluteAxes(es, i); //PrintButtons(s, i); //PrintPOV(s, i); } } }
static void PrintPOV(Xbox360Service s, int id) { POV pov = POV.POV_NONE; if (!s.GetDpad(id, ref pov)) pov = POV.POV_NONE; Console.WriteLine("{0}", povNameMap[pov]); }
static void PrintButtons(Xbox360Service s, int id) { bool[] buttons = new bool[11]; if (!s.GetButtons(id, ref buttons)) for (int i = 0; i < 11; i++) buttons[i] = false; for (int i = 0; i < 11; i++) Console.Write("{0} {1} ", i, buttons[i]); Console.WriteLine(); }
static void PrintAbsoluteAxes(Xbox360Service s, int id) { int lx = 0, ly = 0, rx = 0, ry = 0; if (!s.GetLeftX(id, ref lx)) lx = 0; if (!s.GetLeftY(id, ref ly)) ly = 0; if (!s.GetRightX(id, ref rx)) rx = 0; if (!s.GetRightY(id, ref ry)) ry = 0; Console.WriteLine("LX: {0} | LY: {1} | RX: {2} | RY: {3}", lx, ly, rx, ry); }