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 <SDL_thread.h>
18 #include <windows.h>
19 #include <mmsystem.h>
20 
21 namespace openmsx {
22 
23 class EventDistributor;
24 class Scheduler;
25 class PluggingController;
26 
27 class MidiInWindows : public MidiInDevice, private Runnable, 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  virtual ~MidiInWindows();
39 
40  // Pluggable
41  virtual void plugHelper(Connector& connector, EmuTime::param time);
42  virtual void unplugHelper(EmuTime::param time);
43  virtual const std::string& getName() const;
44  virtual string_ref getDescription() const;
45 
46  // MidiInDevice
47  virtual void signal(EmuTime::param time);
48 
49  template<typename Archive>
50  void serialize(Archive& ar, unsigned version);
51 
52 private:
53  // Runnable
54  virtual void run();
55 
56  // EventListener
57  virtual int signalEvent(const std::shared_ptr<const Event>& event);
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  unsigned 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
const EmuTime & param
Definition: EmuTime.hh:20
const string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:363
void serialize(Archive &ar, T &t, unsigned version)