I've seen some examples of using Windows.Gaming.Input in C++ console apps but is there a way to access it in a non-UWP C# project as well?
Thanks,
I've seen some examples of using Windows.Gaming.Input in C++ console apps but is there a way to access it in a non-UWP C# project as well?
Thanks,
I've managed to do this by doing the following:
*.csproj
file in a text editor, e.g. notepad.<TargetPlatformVersion>10.0</TargetPlatformVersion>
to the *.csproj
file. You can put it after the <TargetFrameworkVersion/>
entry.<TargetPlatform>
and <TargetFramework>
.System.Runtime.WindowsRuntime
reference (I used v4.7.0, newest stable version at the time) with nuget, or manually browse for the DLL file on your system.Windows.Gaming
reference.*.cs
files, you'll want to use the reference with using Windows.Gaming.Input;
. If the reference is not found, try including it outside the namespace. Or you can also try using global::Windows.Gaming.Input;
instead.c# <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net7.0-windows</TargetFramework> <TargetPlatformVersion>10.0</TargetPlatformVersion> <Nullable>enable</Nullable> <UseWindowsForms>true</UseWindowsForms> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" /> </ItemGroup> </Project>
P.S: Formatting didn't go well –
Burgoo <TargetFramework>
and <TargetPlatform>
. Updated answer, thanks. –
Oscine <ItemGroup> <Reference Include="Windows.Gaming" /> <Reference Include="WindowsBase" /> </ItemGroup>
–
Oscine but is there a way to access it in C# with UWP as well?
Sure, you could access Windows.Gaming.Input
with C# within UWP platform. For example,
var controllers = RawGameController.RawGameControllers;
foreach (var item in controllers)
{
var name = item.DisplayName;
}
Unfortunately, there is not c# project could be referred, if you do want to c# project, please feel free post your requirement with Windows Feed Backhub app.
© 2022 - 2024 — McMap. All rights reserved.