Commit 65d562ee authored by Gerard Gascón's avatar Gerard Gascón
Browse files

feat: added preprocessor directive for platform dependant compilation

parent 1e6f8c0b
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -8,13 +8,23 @@
        <RootNamespace>SwitchSlidePresenter</RootNamespace>
    </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>
      <PackageReference Include="JoyCon.NET" Version="1.0.1" />
      <PackageReference Include="WiimoteLib.NetCore" Version="1.0.0" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Win32Api\Win32Api.csproj" />
      <ProjectReference Include="..\Win32Api\Win32Api.csproj" Condition="$([MSBuild]::IsOSPlatform('Windows'))"/>
    </ItemGroup>

</Project>
+13 −0
Original line number Diff line number Diff line
#if OS_LINUX
namespace SwitchSlidePresenter.InputSender;

public class LinuxInputSender : IInputSender {
	public void NextSlide() {

	}

	public void PreviousSlide() {

	}
}
#endif
 No newline at end of file
+13 −0
Original line number Diff line number Diff line
#if OS_MAC
namespace SwitchSlidePresenter.InputSender;

public class MacInputSender : IInputSender {
	public void NextSlide() {

	}

	public void PreviousSlide() {

	}
}
#endif
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
using System.Runtime.InteropServices;
#if OS_WINDOWS
using System.Runtime.InteropServices;
using Win32Api;

namespace SwitchSlidePresenter.InputSender;
@@ -45,3 +46,4 @@ public class WindowsInputSender : IInputSender {
		Win32Api.Win32Api.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(Input)));
	}
}
#endif
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
@@ -4,7 +4,14 @@ namespace SwitchSlidePresenter;

public class SlideSwitcher : IDisposable {
	private readonly IGamepadReader? _reader;

#if OS_WINDOWS
	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) {
		_reader = reader;