Windows MIDI out device now selectable.

This commit is contained in:
TomW 2015-08-23 20:59:15 +01:00
commit 25286c8f0b
6 changed files with 83 additions and 11 deletions

View file

@ -2,6 +2,7 @@
#define CONFIG_INT 1 #define CONFIG_INT 1
#define CONFIG_BINARY 2 #define CONFIG_BINARY 2
#define CONFIG_SELECTION 3 #define CONFIG_SELECTION 3
#define CONFIG_MIDI 4
typedef struct device_config_selection_t typedef struct device_config_selection_t
{ {

View file

@ -201,6 +201,7 @@ void initpc()
keyboard_init(); keyboard_init();
mouse_init(); mouse_init();
joystick_init(); joystick_init();
midi_init();
loadconfig(NULL); loadconfig(NULL);
pclog("Config loaded\n"); pclog("Config loaded\n");
@ -278,6 +279,9 @@ void resetpchard()
device_close_all(); device_close_all();
device_init(); device_init();
midi_close();
midi_init();
timer_reset(); timer_reset();
sound_reset(); sound_reset();
mem_resize(); mem_resize();
@ -463,6 +467,7 @@ void closepc()
dumpregs(); dumpregs();
closevideo(); closevideo();
device_close_all(); device_close_all();
midi_close();
} }
/*int main() /*int main()

View file

@ -616,6 +616,19 @@ static device_config_t sb_pro_config[] =
} }
}; };
static device_config_t sb_16_config[] =
{
{
.name = "midi",
.description = "MIDI out device",
.type = CONFIG_MIDI,
.default_int = 0
},
{
.type = -1
}
};
device_t sb_1_device = device_t sb_1_device =
{ {
"Sound Blaster v1.0", "Sound Blaster v1.0",
@ -685,7 +698,8 @@ device_t sb_16_device =
NULL, NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
sb_add_status_info sb_add_status_info,
sb_16_config
}; };
device_t sb_awe32_device = device_t sb_awe32_device =
{ {
@ -696,5 +710,6 @@ device_t sb_awe32_device =
sb_awe32_available, sb_awe32_available,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
sb_add_status_info sb_add_status_info,
sb_16_config
}; };

View file

@ -27,6 +27,8 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
HWND h = GetDlgItem(hdlg, id); HWND h = GetDlgItem(hdlg, id);
int val_int; int val_int;
char *val_string; char *val_string;
int num;
char s[80];
switch (config->type) switch (config->type)
{ {
@ -53,6 +55,21 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2; id += 2;
break; break;
case CONFIG_MIDI:
val_int = config_get_int(NULL, config->name, config->default_int);
num = midi_get_num_devs();
for (c = 0; c < num; c++)
{
midi_get_dev_name(c, s);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
if (val_int == c)
SendMessage(h, CB_SETCURSEL, c, 0);
}
id += 2;
break;
} }
config++; config++;
} }
@ -100,6 +117,17 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2; id += 2;
break; break;
case CONFIG_MIDI:
val_int = config_get_int(NULL, config->name, config->default_int);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (val_int != c)
changed = 1;
id += 2;
break;
} }
config++; config++;
} }
@ -142,6 +170,13 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2; id += 2;
break; break;
case CONFIG_MIDI:
c = SendMessage(h, CB_GETCURSEL, 0, 0);
config_set_int(NULL, config->name, c);
id += 2;
break;
} }
config++; config++;
} }
@ -177,7 +212,7 @@ void deviceconfig_open(HWND hwnd, device_t *device)
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
dlg->x = 10; dlg->x = 10;
dlg->y = 10; dlg->y = 10;
dlg->cx = 150; dlg->cx = 220;
dlg->cy = 70; dlg->cy = 70;
data = (uint16_t *)(dlg + 1); data = (uint16_t *)(dlg + 1);
@ -218,13 +253,14 @@ void deviceconfig_open(HWND hwnd, device_t *device)
break; break;
case CONFIG_SELECTION: case CONFIG_SELECTION:
case CONFIG_MIDI:
/*Combo box*/ /*Combo box*/
item = (DLGITEMTEMPLATE *)data; item = (DLGITEMTEMPLATE *)data;
item->x = 70; item->x = 70;
item->y = y; item->y = y;
item->id = id++; item->id = id++;
item->cx = 70; item->cx = 140;
item->cy = 150; item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL; item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;

View file

@ -15,13 +15,19 @@ void midi_init()
MIDIOUTCAPS ocaps; MIDIOUTCAPS ocaps;
MMRESULT hr; MMRESULT hr;
midi_id=0; midi_id = config_get_int(NULL, "midi", 0);
hr = midiOutOpen(&midi_out_device, midi_id, 0, hr = midiOutOpen(&midi_out_device, midi_id, 0,
0, CALLBACK_NULL); 0, CALLBACK_NULL);
if (hr != MMSYSERR_NOERROR) { if (hr != MMSYSERR_NOERROR) {
printf("midiOutOpen error - %08X\n",hr); printf("midiOutOpen error - %08X\n",hr);
return; midi_id = 0;
hr = midiOutOpen(&midi_out_device, midi_id, 0,
0, CALLBACK_NULL);
if (hr != MMSYSERR_NOERROR) {
printf("midiOutOpen error - %08X\n",hr);
return;
}
} }
midiOutReset(midi_out_device); midiOutReset(midi_out_device);
@ -37,6 +43,18 @@ void midi_close()
} }
} }
int midi_get_num_devs()
{
return midiOutGetNumDevs();
}
void midi_get_dev_name(int num, char *s)
{
MIDIOUTCAPS caps;
midiOutGetDevCaps(num, &caps, sizeof(caps));
strcpy(s, caps.szPname);
}
static int midi_pos, midi_len; static int midi_pos, midi_len;
static uint32_t midi_command; static uint32_t midi_command;
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1}; static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1};

View file

@ -466,9 +466,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
ghwnd=hwnd; ghwnd=hwnd;
midi_init();
atexit(midi_close);
initpc(); initpc();
vid_apis[0][vid_api].init(ghwnd); vid_apis[0][vid_api].init(ghwnd);