openMSX
MidiInWindows.hh
Go to the documentation of this file.
1 #ifndef MIDIINWINDOWS_HH
2 #define MIDIINWINDOWS_HH
3 
4 #if defined(_WIN32)
5 
6 #ifndef WIN32_LEAN_AND_MEAN
7 #define WIN32_LEAN_AND_MEAN
8 #endif
9 
10 #include "openmsx.hh"
11 #include "MidiInDevice.hh"
12 #include "Thread.hh"
13 #include "EventListener.hh"
14 #include "Semaphore.hh"
15 #include "serialize_meta.hh"
16 #include "circular_buffer.hh"
17 #include <windows.h>
18 #include <mmsystem.h>
19 
20 namespace openmsx {
21 
22 class EventDistributor;
23 class Scheduler;
24 class PluggingController;
25 
26 class MidiInWindows final : public MidiInDevice, private Runnable
27  , private EventListener
28 {
29 public:
32  static void registerAll(EventDistributor& eventDistributor,
33  Scheduler& scheduler,
34  PluggingController& controller);
35 
36  MidiInWindows(EventDistributor& eventDistributor, Scheduler& scheduler,
37  unsigned num);
38  ~MidiInWindows();
39 
40  // Pluggable
41  void plugHelper(Connector& connector, EmuTime::param time) override;
42  void unplugHelper(EmuTime::param time) override;
43  const std::string& getName() const override;
44  string_ref getDescription() const override;
45 
46  // MidiInDevice
47  void signal(EmuTime::param time) override;
48 
49  template<typename Archive>
50  void serialize(Archive& ar, unsigned version);
51 
52 private:
53  // Runnable
54  void run() override;
55 
56  // EventListener
57  int signalEvent(const std::shared_ptr<const Event>& event) override;
58 
59  void procShortMsg(long unsigned param);
60  void procLongMsg(LPMIDIHDR p);
61 
62  EventDistributor& eventDistributor;
63  Scheduler& scheduler;
64  Thread thread;
65  unsigned devidx;
66  DWORD thrdid;
67  cb_queue<byte> queue;
68  Semaphore lock; // to protect queue
69  std::string name;
70  std::string desc;
71 };
72 
73 } // namespace openmsx
74 
75 #endif // defined(_WIN32)
76 #endif // MIDIINWINDOWS_HH
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:7
const EmuTime & param
Definition: EmuTime.hh:20
const string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:373
void serialize(Archive &ar, T &t, unsigned version)