feat: added preprocessor directive for platform dependant compilation
This commit is contained in:
parent
1e6f8c0b9f
commit
65d562ee74
5 changed files with 48 additions and 3 deletions
|
@ -8,13 +8,23 @@
|
||||||
<RootNamespace>SwitchSlidePresenter</RootNamespace>
|
<RootNamespace>SwitchSlidePresenter</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
|
||||||
|
<DefineConstants>OS_WINDOWS</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
|
||||||
|
<DefineConstants>OS_LINUX</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
|
||||||
|
<DefineConstants>OS_MAC</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JoyCon.NET" Version="1.0.1" />
|
<PackageReference Include="JoyCon.NET" Version="1.0.1" />
|
||||||
<PackageReference Include="WiimoteLib.NetCore" Version="1.0.0" />
|
<PackageReference Include="WiimoteLib.NetCore" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Win32Api\Win32Api.csproj" />
|
<ProjectReference Include="..\Win32Api\Win32Api.csproj" Condition="$([MSBuild]::IsOSPlatform('Windows'))"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
13
SlidePresenter/InputSender/LinuxInputSender.cs
Normal file
13
SlidePresenter/InputSender/LinuxInputSender.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#if OS_LINUX
|
||||||
|
namespace SwitchSlidePresenter.InputSender;
|
||||||
|
|
||||||
|
public class LinuxInputSender : IInputSender {
|
||||||
|
public void NextSlide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PreviousSlide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
13
SlidePresenter/InputSender/MacInputSender.cs
Normal file
13
SlidePresenter/InputSender/MacInputSender.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#if OS_MAC
|
||||||
|
namespace SwitchSlidePresenter.InputSender;
|
||||||
|
|
||||||
|
public class MacInputSender : IInputSender {
|
||||||
|
public void NextSlide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PreviousSlide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Runtime.InteropServices;
|
#if OS_WINDOWS
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using Win32Api;
|
using Win32Api;
|
||||||
|
|
||||||
namespace SwitchSlidePresenter.InputSender;
|
namespace SwitchSlidePresenter.InputSender;
|
||||||
|
@ -45,3 +46,4 @@ public class WindowsInputSender : IInputSender {
|
||||||
Win32Api.Win32Api.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(Input)));
|
Win32Api.Win32Api.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(Input)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -4,7 +4,14 @@ namespace SwitchSlidePresenter;
|
||||||
|
|
||||||
public class SlideSwitcher : IDisposable {
|
public class SlideSwitcher : IDisposable {
|
||||||
private readonly IGamepadReader? _reader;
|
private readonly IGamepadReader? _reader;
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
private readonly IInputSender _inputSender = new WindowsInputSender();
|
private readonly IInputSender _inputSender = new WindowsInputSender();
|
||||||
|
#elif OS_MAC
|
||||||
|
private readonly IInputSender _inputSender = new MacInputSender();
|
||||||
|
#elif OS_LINUX
|
||||||
|
private readonly IInputSender _inputSender = new LinuxInputSender();
|
||||||
|
#endif
|
||||||
|
|
||||||
public SlideSwitcher(IGamepadReader? reader) {
|
public SlideSwitcher(IGamepadReader? reader) {
|
||||||
_reader = reader;
|
_reader = reader;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue