1
0
Fork 0

Rework ListMidi so it can be more easily added to more backends.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3836
This commit is contained in:
Peter Veenstra 2013-10-18 11:55:02 +00:00
parent 3701512a16
commit ffb8cec4d6
3 changed files with 16 additions and 41 deletions

View file

@ -25,6 +25,7 @@
#include "SDL.h"
#include "dosbox.h"
#include "midi.h"
#include "cross.h"
#include "support.h"
#include "setup.h"
@ -33,7 +34,6 @@
#include "hardware.h"
#include "timer.h"
#define SYSEX_SIZE 1024
#define RAWBUF 1024
Bit8u MIDI_evt_len[256] = {
@ -59,23 +59,11 @@ Bit8u MIDI_evt_len[256] = {
0,2,3,2, 0,0,1,0, 1,0,1,1, 1,0,1,0 // 0xf0
};
class MidiHandler;
MidiHandler * handler_list = 0;
MidiHandler * handler_list=0;
class MidiHandler {
public:
MidiHandler() {
next=handler_list;
handler_list=this;
};
virtual bool Open(const char * /*conf*/) { return true; };
virtual void Close(void) {};
virtual void PlayMsg(Bit8u * /*msg*/) {};
virtual void PlaySysex(Bit8u * /*sysex*/,Bitu /*len*/) {};
virtual const char * GetName(void) { return "none"; };
virtual ~MidiHandler() { };
MidiHandler * next;
MidiHandler::MidiHandler(){
next = handler_list;
handler_list = this;
};
MidiHandler Midi_none;
@ -103,21 +91,7 @@ MidiHandler Midi_none;
#endif
static struct {
Bitu status;
Bitu cmd_len;
Bitu cmd_pos;
Bit8u cmd_buf[8];
Bit8u rt_buf[8];
struct {
Bit8u buf[SYSEX_SIZE];
Bitu used;
Bitu delay;
Bit32u start;
} sysex;
bool available;
MidiHandler * handler;
} midi;
DB_Midi midi;
void MIDI_RawOutByte(Bit8u data) {
if (midi.sysex.start) {

View file

@ -87,6 +87,14 @@ public:
return;
}
}
void ListAll(Program* base) {
unsigned int total = midiOutGetNumDevs();
for(unsigned int i = 0;i < total;i++) {
MIDIOUTCAPS mididev;
midiOutGetDevCaps(i, &mididev, sizeof(MIDIOUTCAPS));
base->WriteOut("%2d\t \"%s\"\n",i,mididev.szPname);
}
}
};
MidiHandler_win32 Midi_win32;

View file

@ -47,6 +47,7 @@
#include "mapper.h"
#include "hardware.h"
#include "programs.h"
#include "midi.h"
#define MIXER_SSIZE 4
#define MIXER_SHIFT 14
@ -577,15 +578,7 @@ private:
}
void ListMidi(){
#if defined (WIN32)
unsigned int total = midiOutGetNumDevs();
for(unsigned int i=0;i<total;i++) {
MIDIOUTCAPS mididev;
midiOutGetDevCaps(i, &mididev, sizeof(MIDIOUTCAPS));
WriteOut("%2d\t \"%s\"\n",i,mididev.szPname);
}
#endif
return;
if(midi.handler) midi.handler->ListAll(this);
};
};