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 : public MidiInDevice, private Runnable, private EventListener
27 {
28 public:
31  static void registerAll(EventDistributor& eventDistributor,
32  Scheduler& scheduler,
33  PluggingController& controller);
34 
35  MidiInWindows(EventDistributor& eventDistributor, Scheduler& scheduler,
36  unsigned num);
37  virtual ~MidiInWindows();
38 
39  // Pluggable
40  virtual void plugHelper(Connector& connector, EmuTime::param time);
41  virtual void unplugHelper(EmuTime::param time);
42  virtual const std::string& getName() const;
43  virtual string_ref getDescription() const;
44 
45  // MidiInDevice
46  virtual void signal(EmuTime::param time);
47 
48  template<typename Archive>
49  void serialize(Archive& ar, unsigned version);
50 
51 private:
52  // Runnable
53  virtual void run();
54 
55  // EventListener
56  virtual int signalEvent(const std::shared_ptr<const Event>& event);
57 
58  void procShortMsg(long unsigned param);
59  void procLongMsg(LPMIDIHDR p);
60 
61  EventDistributor& eventDistributor;
62  Scheduler& scheduler;
63  Thread thread;
64  unsigned devidx;
65  DWORD thrdid;
66  cb_queue<byte> queue;
67  Semaphore lock; // to protect queue
68  std::string name;
69  std::string desc;
70 };
71 
72 } // namespace openmsx
73 
74 #endif // defined(_WIN32)
75 #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
const EmuTime & param
Definition: EmuTime.hh:20
eventDistributor(eventDistributor_)
const string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:363
void serialize(Archive &ar, T &t, unsigned version)
thread(this)