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_BINARY 2
#define CONFIG_SELECTION 3
#define CONFIG_MIDI 4
typedef struct device_config_selection_t
{

View file

@ -201,6 +201,7 @@ void initpc()
keyboard_init();
mouse_init();
joystick_init();
midi_init();
loadconfig(NULL);
pclog("Config loaded\n");
@ -278,6 +279,9 @@ void resetpchard()
device_close_all();
device_init();
midi_close();
midi_init();
timer_reset();
sound_reset();
mem_resize();
@ -463,6 +467,7 @@ void closepc()
dumpregs();
closevideo();
device_close_all();
midi_close();
}
/*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 =
{
"Sound Blaster v1.0",
@ -685,7 +698,8 @@ device_t sb_16_device =
NULL,
sb_speed_changed,
NULL,
sb_add_status_info
sb_add_status_info,
sb_16_config
};
device_t sb_awe32_device =
{
@ -696,5 +710,6 @@ device_t sb_awe32_device =
sb_awe32_available,
sb_speed_changed,
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);
int val_int;
char *val_string;
int num;
char s[80];
switch (config->type)
{
@ -53,6 +55,21 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
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++;
}
@ -100,6 +117,17 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
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++;
}
@ -142,6 +170,13 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
break;
case CONFIG_MIDI:
c = SendMessage(h, CB_GETCURSEL, 0, 0);
config_set_int(NULL, config->name, c);
id += 2;
break;
}
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->x = 10;
dlg->y = 10;
dlg->cx = 150;
dlg->cx = 220;
dlg->cy = 70;
data = (uint16_t *)(dlg + 1);
@ -218,13 +253,14 @@ void deviceconfig_open(HWND hwnd, device_t *device)
break;
case CONFIG_SELECTION:
case CONFIG_MIDI:
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 70;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;

View file

@ -15,13 +15,19 @@ void midi_init()
MIDIOUTCAPS ocaps;
MMRESULT hr;
midi_id=0;
midi_id = config_get_int(NULL, "midi", 0);
hr = midiOutOpen(&midi_out_device, midi_id, 0,
0, CALLBACK_NULL);
if (hr != MMSYSERR_NOERROR) {
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);
@ -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 uint32_t midi_command;
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 1};

View file

@ -465,10 +465,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
get_registry_key_map();
ghwnd=hwnd;
midi_init();
atexit(midi_close);
initpc();
vid_apis[0][vid_api].init(ghwnd);