Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using SharpDX.DirectInput;
- namespace UPJoystick
- {
- static class Program
- {
- /// <summary>
- /// Główny punkt wejścia dla aplikacji.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- MainWindow mainWindow = new MainWindow(GetJoystick());
- Application.Run(mainWindow);
- }
- static Joystick GetJoystick()
- {
- DirectInput directInput = new DirectInput();
- List<Guid> joysticksList = new List<Guid>();
- List<DeviceType> types = new List<DeviceType>();
- Guid joystickGuid = Guid.Empty;
- foreach (DeviceInstance device in directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices))
- {
- types.Add(device.Type);
- joysticksList.Add(device.InstanceGuid);
- }
- //jakis wybor trzeba zrobic
- if(joysticksList.Any())
- {
- joystickGuid = joysticksList.ElementAt(0);
- }
- Joystick joystick = null;
- if (joystickGuid != Guid.Empty)
- {
- joystick = new Joystick(directInput, joystickGuid);
- }
- return joystick;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement