7

Been looking for the Windows.Gaming.Input namespace but am having a hard time. What should I be referencing to get access to this? MSDN was literally no help in the matter. https://msdn.microsoft.com/en-us/library/windows/apps/windows.gaming.input.aspx

Worth noting that I have already included WindowsBase and System.Windows thinking they may be in there. No luck.

Also tried:

  • c# UWP app
  • c++ DirectX UWP app

Neither would resolve the namespace.

Wobbles
  • 3,033
  • 1
  • 25
  • 51
  • 1
    Are you building a UWP app? From what I've found googling, seems that namespace is limited to those applications (http://answers.flyppdevportal.com/MVC/Post/Thread/11b24053-99bf-4ec1-b958-ba8608e14e48?category=csharpgeneral) – sous2817 Apr 18 '16 at 13:16
  • @sous2817 Ive tried creating a blank UWP and tried including it there aswell hoping that I could trace it back to a DLL and build a wrapper for it for my usses, but even in the UWP app it says the `Gaming` namespace does not exist in `Windows`... – Wobbles Apr 18 '16 at 13:21
  • In the linked thread, there is also the same problem with referencing. However, since you are not using UWP, some one is suggestion http://sharpdx.org/ in the same thread. – Christian Gollhardt Apr 18 '16 at 13:24
  • I also think I remember reading that the Windows.Gaming.Input namespace is for C++ only. – sous2817 Apr 18 '16 at 13:26
  • @ChristianGollhardt SharpDX (and other DirectX wrappers) have not yet caught up to the newer versions of DirectX that expose new methods and properties for their newer hardware (XB One controllers). This is why im trying to wrap it myself and get access to stuff such as the impulse triggers on XB Ones controllers. – Wobbles Apr 18 '16 at 13:26
  • @sous2817 thats why I figured Id write a wrapper, but still cannot find it in the namespace. – Wobbles Apr 18 '16 at 13:27
  • Just tried creating a c++ DirectX UWP app and still could not resolve Windows.Gaming... – Wobbles Apr 18 '16 at 13:31
  • Maybe you are able to extract more information here: https://msdn.microsoft.com/en-us/library/windows/apps/mt282476.aspx. Accroding to a comment [here](http://stackoverflow.com/a/31979643/2441442) it seems to be part of the UWP SDK. This questions seems to be a good example for the upcomming documentation feature on SO... – Christian Gollhardt Apr 18 '16 at 13:39
  • 1
    What version of VS are you using (as well as UWP version, etc)? I'm using Visual Studio 2015 Update 2 with the various UWP options installed (1.3.1). Creating a new C# UWP project targeting Windows 10 I have access to Windows.Gaming. – sous2817 Apr 18 '16 at 14:04
  • I was using update 1, just installed update 2, will check and see if that was it. – Wobbles Apr 19 '16 at 14:31
  • Turns out that was the issue, only seems to work in update 2, wish that was documented somewhere, could have saved myself a whole bunch of headache. But its all for not apparently anyway as I cannot find a way to reference any library I write in UWP that supports the gamepad in my .NET application... Anybody know how I can do so? – Wobbles Apr 19 '16 at 15:32

1 Answers1

2

Windows.Gaming.Input is a UWP namespace, in order to use it you need to create a UWP app. From your question (you have included WindowsBase and System.Windows) it seems that you've created a WPF app, which is not the case.

You can create a UWP project with New -> Project -> Visual C# -> Windows -> Universal for a C# project and Other Languages -> Visual C++ -> Windows -> Universal for a C++ project.

After that it should work just fine.

enter image description here

Eldar Dordzhiev
  • 5,105
  • 2
  • 22
  • 26
  • 1
    You can do this without creating a new UWP project: https://stackoverflow.com/a/69123772/883015 – Joe DF Sep 09 '21 at 19:30