From 5953907f867d0fdecd83fda2aa31813041d9a514 Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 19 Jan 2015 19:04:59 +0100 Subject: [PATCH] Allowed Mac and Linux to use GamePad. Added Name param to GamePad. Added Xbox 360 Wireless Joystick linux config to GamePadCongifurationDatabase. --- Source/OpenTK/Input/GamePad.cs | 13 +++++++++++++ Source/OpenTK/Input/GamePadConfigurationDatabase.cs | 1 + Source/OpenTK/Platform/Linux/LinuxFactory.cs | 5 +++++ Source/OpenTK/Platform/MacOS/MacOSFactory.cs | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/Source/OpenTK/Input/GamePad.cs b/Source/OpenTK/Input/GamePad.cs index 7578eb23..907ec8c9 100644 --- a/Source/OpenTK/Input/GamePad.cs +++ b/Source/OpenTK/Input/GamePad.cs @@ -92,5 +92,18 @@ namespace OpenTK.Input { return driver.SetVibration(index, left, right); } + + /// + /// Gets the name of this + /// + /// + /// Returns the name of the gamepad if the gamepad is connected. + /// Otherwise returns an empty string. + /// + /// A zero-based device index for the GamePad device to affect + public static string GetName(int index) + { + return driver.GetName(index); + } } } diff --git a/Source/OpenTK/Input/GamePadConfigurationDatabase.cs b/Source/OpenTK/Input/GamePadConfigurationDatabase.cs index 098435b9..cbd503de 100644 --- a/Source/OpenTK/Input/GamePadConfigurationDatabase.cs +++ b/Source/OpenTK/Input/GamePadConfigurationDatabase.cs @@ -116,6 +116,7 @@ namespace OpenTK.Input Add("030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,"); Add("030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,"); Add("030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,"); + Add("000000006258786f2033363020576972,X360 Wireless Controller,a:b0,b:b1,back:b8,dpdown:b16,dpleft:b13,dpright:b14,dpup:b15,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,"); // Android Add("4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,"); diff --git a/Source/OpenTK/Platform/Linux/LinuxFactory.cs b/Source/OpenTK/Platform/Linux/LinuxFactory.cs index 21132c13..37d108a2 100644 --- a/Source/OpenTK/Platform/Linux/LinuxFactory.cs +++ b/Source/OpenTK/Platform/Linux/LinuxFactory.cs @@ -242,6 +242,11 @@ namespace OpenTK.Platform.Linux } } + public override OpenTK.Input.IGamePadDriver CreateGamePadDriver() + { + return new MappedGamePadDriver(); + } + #endregion } } diff --git a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs index 9a40ffa3..dde24600 100644 --- a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs +++ b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs @@ -95,6 +95,11 @@ namespace OpenTK.Platform.MacOS { return InputDriver.JoystickDriver; } + + public override OpenTK.Input.IGamePadDriver CreateGamePadDriver() + { + return new MappedGamePadDriver(); + } #endregion