Skip to content

Commit f394a34

Browse files
committedJul 23, 2016
Added missing input implementation for Pro Pinball.
1 parent 31c0a79 commit f394a34

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed
 
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reactive;
5+
using System.Reactive.Linq;
6+
using System.Reactive.Subjects;
7+
using System.Runtime.InteropServices;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows.Media.Imaging;
11+
using NLog;
12+
13+
namespace LibDmd.Input.ProPinball
14+
{
15+
16+
public class ProPinballSlave : IFrameSource
17+
{
18+
const int FrameSize = 128 * 32;
19+
20+
public string Name { get; } = "Pro Pinball";
21+
22+
public IObservable<Unit> OnResume => _onResume;
23+
public IObservable<Unit> OnPause => _onPause;
24+
25+
private readonly ISubject<Unit> _onResume = new Subject<Unit>();
26+
private readonly ISubject<Unit> _onPause = new Subject<Unit>();
27+
28+
private readonly ISubject<BitmapSource> _frames = new Subject<BitmapSource>();
29+
private ProPinballBridge.ProPinballDmd _bridge;
30+
31+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
32+
33+
/// <summary>
34+
/// Starts sending frames.
35+
/// </summary>
36+
private void StartCapturing()
37+
{
38+
_bridge = new ProPinballBridge.ProPinballDmd();
39+
40+
Logger.Info("DMD status: {0}", _bridge.Status);
41+
if (_bridge.Status != 0) {
42+
unsafe {
43+
Logger.Error("Error: {0}", new string(_bridge.Error));
44+
}
45+
} else {
46+
Logger.Info("Subscribing to Pro Pinball's message queue...");
47+
unsafe {
48+
_bridge.GetFrames(frame => {
49+
Console.WriteLine("Got frame!");
50+
var f = new byte[FrameSize];
51+
Marshal.Copy((IntPtr)frame, f, 0, FrameSize);
52+
});
53+
}
54+
}
55+
}
56+
57+
public IObservable<BitmapSource> GetFrames()
58+
{
59+
StartCapturing();
60+
return _frames;
61+
}
62+
63+
}
64+
}

‎ProPinballSlave/ProPinballSlave.vcxproj

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
<Text Include="ReadMe.txt" />
138138
</ItemGroup>
139139
<ItemGroup>
140-
<ClInclude Include="..\packages\boost.1.60.0.0\lib\native\include\boost\interprocess\ipc\message_queue.hpp" />
141140
<ClInclude Include="resource.h" />
142141
<ClInclude Include="stdafx.h" />
143142
</ItemGroup>

‎ProPinballSlave/ProPinballSlave.vcxproj.filters

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
<ClInclude Include="resource.h">
2525
<Filter>Header Files</Filter>
2626
</ClInclude>
27-
<ClInclude Include="..\packages\boost.1.60.0.0\lib\native\include\boost\interprocess\ipc\message_queue.hpp">
28-
<Filter>Header Files</Filter>
29-
</ClInclude>
3027
</ItemGroup>
3128
<ItemGroup>
3229
<ResourceCompile Include="app.rc">

0 commit comments

Comments
 (0)
Please sign in to comment.