From b030bf671d4d40ba1fd32c38603999d113b4f6d4 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 10 May 2019 21:51:09 -0700 Subject: *: drop vestigial cruft breaking win32 builds Just some unused schismtracker junk, there really shouldn't be any SDL dependency at all but I haven't gone through and exhaustively cleared all that out. --- src/Makefile.am | 12 -- src/include/event.h | 46 ------ src/include/osdefs.h | 24 ---- src/sys/macosx/macosx-sdlmain.m | 1 - src/sys/macosx/osdefs.c | 25 ---- src/sys/win32/midi-win32mm.c | 311 ---------------------------------------- src/sys/win32/osdefs.c | 175 ---------------------- src/sys/win32/volume-win32mm.c | 91 ------------ 8 files changed, 685 deletions(-) delete mode 100644 src/include/event.h delete mode 100644 src/sys/win32/midi-win32mm.c delete mode 100644 src/sys/win32/volume-win32mm.c diff --git a/src/Makefile.am b/src/Makefile.am index 7da07f1..e892c20 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,6 @@ noinst_HEADERS = \ include/cmixer.h \ include/disko.h \ include/dmoz.h \ - include/event.h \ include/fmopl.h \ include/fmt.h \ include/fmt-types.h \ @@ -37,23 +36,12 @@ if USE_WIN32 files_win32 = \ sys/win32/osdefs.c \ sys/win32/slurp-win32.c \ - sys/win32/volume-win32mm.c \ - sys/win32/midi-win32mm.c \ sys/win32/filetype.c \ sys/win32/localtime_r.c cflags_win32=-I$(srcdir)/sys/win32 lib_win32=-lwinmm endif -if HAVE_WINDRES - -## --use-temp-file is needed to work around stupid bugs -WRCFLAGS = --use-temp-file -I. -I$(srcdir) $(cflags_version) $(wrcflags_version) -.rc.$(OBJEXT): - $(WINDRES) $(WRCFLAGS) -i $< -o $@ -files_windres=sys/win32/schismres.rc -sys/win32/schismres.$(OBJEXT): icons/schismres.ico config.h Makefile.am -endif HAVE_WINDRES if USE_WII files_wii=sys/wii/isfs.c sys/wii/osdefs.c diff --git a/src/include/event.h b/src/include/event.h deleted file mode 100644 index 2bdcdc8..0000000 --- a/src/include/event.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Schism Tracker - a cross-platform Impulse Tracker clone - * copyright (c) 2003-2005 Storlek - * copyright (c) 2005-2008 Mrs. Brisby - * copyright (c) 2009 Storlek & Mrs. Brisby - * copyright (c) 2010-2012 Storlek - * URL: http://schismtracker.org/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef _schismevent_h -#define _schismevent_h - -#include "sdlmain.h" - -#define SCHISM_EVENT_UPDATE_IPMIDI SDL_USEREVENT+0 -#define SCHISM_EVENT_MIDI SDL_USEREVENT+1 -#define SCHISM_EVENT_PLAYBACK SDL_USEREVENT+2 -#define SCHISM_EVENT_NATIVE SDL_USEREVENT+3 -#define SCHISM_EVENT_PASTE SDL_USEREVENT+4 - -#define SCHISM_EVENT_MIDI_NOTE 1 -#define SCHISM_EVENT_MIDI_CONTROLLER 2 -#define SCHISM_EVENT_MIDI_PROGRAM 3 -#define SCHISM_EVENT_MIDI_AFTERTOUCH 4 -#define SCHISM_EVENT_MIDI_PITCHBEND 5 -#define SCHISM_EVENT_MIDI_TICK 6 -#define SCHISM_EVENT_MIDI_SYSEX 7 -#define SCHISM_EVENT_MIDI_SYSTEM 8 - -#define SCHISM_EVENT_NATIVE_OPEN 1 -#define SCHISM_EVENT_NATIVE_SCRIPT 16 - -#endif diff --git a/src/include/osdefs.h b/src/include/osdefs.h index 25e92f4..39eb9e3 100644 --- a/src/include/osdefs.h +++ b/src/include/osdefs.h @@ -28,7 +28,6 @@ and possibly other files as well. Only one osdefs.c should be in use at a time. #define OSDEFS_H #include "headers.h" -#include "event.h" // This is defined in osdefs.c but not used anywhere. // Currently, its only purpose is to prevent erroneous linking of multiple osdefs.o files in the same build. @@ -91,13 +90,11 @@ Leave this *undefined* if no implementation exists. */ // Implementations for the above, and more. -int macosx_sdlevent(SDL_Event *event); // patch up osx scancodes for printscreen et al; numlock hack? int macosx_ibook_fnswitch(int setting); void wii_sysinit(int *pargc, char ***pargv); // set up filesystem void wii_sysexit(void); // close filesystem void wii_sdlinit(void); // set up wiimote -int wii_sdlevent(SDL_Event *event); // add unicode values; wiimote hack to allow simple playback void x11_screensaver_deactivate(void); unsigned int xv_yuvlayout(void); @@ -106,27 +103,6 @@ void win32_sysinit(int *pargc, char ***pargv); void win32_get_modkey(int *m); void win32_filecreated_callback(const char *filename); -// migrated from xkb.c -#if defined(HAVE_X11_XKBLIB_H) -# define USE_XKB 1 -#endif - -#if defined(USE_XKB) || defined(WIN32) || defined(MACOSX) -int key_scancode_lookup(int k, int def); -#else -#define key_scancode_lookup(k, def) def -#endif - -#if defined(USE_X11) || defined(WIN32) || defined(MACOSX) -unsigned int key_repeat_delay(void); -unsigned int key_repeat_rate(void); -#else -# include "sdlmain.h" // blecch -# define key_repeat_delay() SDL_DEFAULT_REPEAT_DELAY -# define key_repeat_rate() SDL_DEFAULT_REPEAT_INTERVAL -#endif - - // Mixer interfaces void volume_setup(void); diff --git a/src/sys/macosx/macosx-sdlmain.m b/src/sys/macosx/macosx-sdlmain.m index df7f440..33b065e 100644 --- a/src/sys/macosx/macosx-sdlmain.m +++ b/src/sys/macosx/macosx-sdlmain.m @@ -40,7 +40,6 @@ pruned up some here :) -mrsb extern char *initial_song; #include /* necessary here */ -#include "event.h" #include "osdefs.h" #define Cursor AppleCursor diff --git a/src/sys/macosx/osdefs.c b/src/sys/macosx/osdefs.c index 57fd832..8a07e36 100644 --- a/src/sys/macosx/osdefs.c +++ b/src/sys/macosx/osdefs.c @@ -23,32 +23,7 @@ #include "headers.h" #include "osdefs.h" -#include "event.h" #include "song.h" const char *osname = "macosx"; - -int macosx_sdlevent(SDL_Event *event) -{ - if (event->type == SDL_KEYDOWN || event->type == SDL_KEYUP) { - if (event->key.keysym.sym == 0) { - switch (event->key.keysym.scancode) { - case 106: // mac F16 key - event->key.keysym.sym = SDLK_PRINT; - event->key.keysym.mod = KMOD_CTRL; - return 1; - case 234: // XXX what key is this? - if (event->type == SDL_KEYDOWN) - song_set_current_order(song_get_current_order() - 1); - return 0; - case 233: // XXX what key is this? - if (event->type == SDL_KEYUP) - song_set_current_order(song_get_current_order() + 1); - return 0; - }; - } - } - return 1; -} - diff --git a/src/sys/win32/midi-win32mm.c b/src/sys/win32/midi-win32mm.c deleted file mode 100644 index 1c1f27e..0000000 --- a/src/sys/win32/midi-win32mm.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Schism Tracker - a cross-platform Impulse Tracker clone - * copyright (c) 2003-2005 Storlek - * copyright (c) 2005-2008 Mrs. Brisby - * copyright (c) 2009 Storlek & Mrs. Brisby - * copyright (c) 2010-2012 Storlek - * URL: http://schismtracker.org/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "headers.h" -#include "sdlmain.h" - -#include "log.h" -#include "midi.h" - -#include "util.h" - -#include -#include -#include - -#ifndef WIN32 -# error You have no winmm. Why are you trying to build this file? -#endif - - -struct win32mm_midi { - DWORD id; - - HMIDIOUT out; - HMIDIIN in; - - MIDIINCAPS icp; - MIDIOUTCAPS ocp; - - MIDIHDR hh; - LPMIDIHDR obuf; - unsigned char sysx[1024]; -}; -static unsigned int mm_period = 0; -static unsigned int last_known_in_port = 0; -static unsigned int last_known_out_port = 0; - -static void _win32mm_sysex(LPMIDIHDR *q, const unsigned char *d, unsigned int len) -{ - char *z; - LPMIDIHDR m; - - if (!d) len=0; - z = mem_alloc(sizeof(MIDIHDR) + len); - m = (LPMIDIHDR)z; - - memset(m, 0, sizeof(MIDIHDR)); - if (len) memcpy(z + sizeof(MIDIHDR), d, len); - - m->lpData = (z+sizeof(MIDIHDR)); - m->dwBufferLength = len; - m->lpNext = *q; - m->dwOffset = 0; - (*q) = (m); -} -static void _win32mm_send(struct midi_port *p, const unsigned char *data, - unsigned int len, UNUSED unsigned int delay) -{ - struct win32mm_midi *m; - DWORD q; - - if (len == 0) return; - - m = p->userdata; - if (len <= 4) { - q = data[0]; - if (len > 1) q |= (data[1] << 8); - if (len > 2) q |= (data[2] << 16); - if (len > 3) q |= (data[3] << 24); /* eh... */ - (void)midiOutShortMsg(m->out, q); - } else { - /* SysEX */ - _win32mm_sysex(&m->obuf, data, len); - if (midiOutPrepareHeader(m->out, m->obuf, sizeof(MIDIHDR)) == MMSYSERR_NOERROR) { - (void)midiOutLongMsg(m->out, m->obuf, sizeof(MIDIHDR)); - } - } -} - - - - -struct curry { - struct midi_port *p; - unsigned char *d; - unsigned int len; -}; - - -static CALLBACK void _win32mm_xp_output(UNUSED UINT uTimerID, - UNUSED UINT uMsg, - DWORD_PTR dwUser, - UNUSED DWORD_PTR dw1, - UNUSED DWORD_PTR dw2) -{ - struct curry *c; - c = (struct curry *)dwUser; - _win32mm_send(c->p, c->d, c->len, 0); - free(c); -} -static void _win32mm_send_xp(struct midi_port *p, const unsigned char *buf, - unsigned int len, unsigned int delay) -{ - /* version for windows XP */ - struct curry *c; - - if (!delay) _win32mm_send(p,buf,len,0); - if (len == 0) return; - - c = mem_alloc(sizeof(struct curry) + len); - c->p = p; - c->d = ((unsigned char*)c)+sizeof(struct curry); - c->len = len; - timeSetEvent(delay, mm_period, _win32mm_xp_output, (DWORD_PTR)c, - TIME_ONESHOT | TIME_CALLBACK_FUNCTION); -} - -static CALLBACK void _win32mm_inputcb(UNUSED HMIDIIN in, UINT wmsg, DWORD_PTR inst, - DWORD_PTR param1, DWORD_PTR param2) -{ - struct midi_port *p = (struct midi_port *)inst; - struct win32mm_midi *m; - unsigned char c[4]; - - switch (wmsg) { - case MIM_OPEN: - SDL_Delay(0); /* eh? */ - case MIM_CLOSE: - break; - case MIM_DATA: - c[0] = param1 & 255; - c[1] = (param1 >> 8) & 255; - c[2] = (param1 >> 16) & 255; - midi_received_cb(p, c, 3); - break; - case MIM_LONGDATA: - { - MIDIHDR* hdr = (MIDIHDR*) param1; - if (hdr->dwBytesRecorded > 0) - { - /* long data */ - m = p->userdata; - midi_received_cb(p, (unsigned char *) m->hh.lpData, m->hh.dwBytesRecorded); - //TODO: The event for the midi sysex (midi-core.c SCHISM_EVENT_MIDI_SYSEX) should - // call us back so that we can add the buffer back with midiInAddBuffer(). - } - break; - } - } -} - - -static int _win32mm_start(struct midi_port *p) -{ - struct win32mm_midi *m; - UINT id; - WORD r; - - m = p->userdata; - id = m->id; - if (p->io == MIDI_INPUT) { - m->in = NULL; - r = midiInOpen(&m->in, - (UINT_PTR)id, - (DWORD_PTR)_win32mm_inputcb, - (DWORD_PTR)p, - CALLBACK_FUNCTION); - if (r != MMSYSERR_NOERROR) return 0; - memset(&m->hh, 0, sizeof(m->hh)); - m->hh.lpData = (LPSTR)m->sysx; - m->hh.dwBufferLength = sizeof(m->sysx); - m->hh.dwFlags = 0; - r = midiInPrepareHeader(m->in, &m->hh, sizeof(MIDIHDR)); - if (r != MMSYSERR_NOERROR) return 0; - r = midiInAddBuffer(m->in, &m->hh, sizeof(MIDIHDR)); - if (r != MMSYSERR_NOERROR) return 0; - if (midiInStart(m->in) != MMSYSERR_NOERROR) return 0; - - } - if (p->io & MIDI_OUTPUT) { - m->out = NULL; - if (midiOutOpen(&m->out, - (UINT_PTR)id, - 0, 0, - CALLBACK_NULL) != MMSYSERR_NOERROR) return 0; - } - return 1; -} -static int _win32mm_stop(struct midi_port *p) -{ - struct win32mm_midi *m; - LPMIDIHDR ptr; - - m = p->userdata; - if (p->io & MIDI_INPUT) { - /* portmidi appears to (essentially) ignore the error codes - for these guys */ - (void)midiInStop(m->in); - (void)midiInReset(m->in); - (void)midiInUnprepareHeader(m->in,&m->hh,sizeof(m->hh)); - (void)midiInClose(m->in); - } - if (p->io & MIDI_OUTPUT) { - (void)midiOutReset(m->out); - (void)midiOutClose(m->out); - /* free output chain */ - ptr = m->obuf; - while (ptr) { - m->obuf = m->obuf->lpNext; - (void)free(m->obuf); - ptr = m->obuf; - } - } - return 1; -} - - -static void _win32mm_poll(struct midi_provider *p) -{ - struct win32mm_midi *data; - - UINT i; - UINT mmin, mmout; - WORD r; - - mmin = midiInGetNumDevs(); - for (i = last_known_in_port; i < mmin; i++) { - data = mem_alloc(sizeof(struct win32mm_midi)); - memset(data,0,sizeof(struct win32mm_midi)); - r = midiInGetDevCaps(i, (LPMIDIINCAPS)&data->icp, - sizeof(MIDIINCAPS)); - if (r != MMSYSERR_NOERROR) { - free(data); - continue; - } - data->id = i; - midi_port_register(p, MIDI_INPUT, data->icp.szPname, data, 1); - } - last_known_in_port = mmin; - - mmout = midiOutGetNumDevs(); - for (i = last_known_out_port; i < mmout; i++) { - data = mem_alloc(sizeof(struct win32mm_midi)); - memset(data,0,sizeof(struct win32mm_midi)); - r = midiOutGetDevCaps(i, (LPMIDIOUTCAPS)&data->ocp, - sizeof(MIDIOUTCAPS)); - if (r != MMSYSERR_NOERROR) { - if (data) free(data); - continue; - } - data->id = i; - midi_port_register(p, MIDI_OUTPUT, data->ocp.szPname, data, 1); - } - last_known_out_port = mmout; -} - -int win32mm_midi_setup(void) -{ - static struct midi_driver driver; - - TIMECAPS caps; - - memset(&driver, 0, sizeof(driver)); - - driver.flags = 0; - driver.poll = _win32mm_poll; - driver.thread = NULL; - driver.enable = _win32mm_start; - driver.disable = _win32mm_stop; - - { - if (timeGetDevCaps(&caps, sizeof(caps)) == 0) { - mm_period = caps.wPeriodMin; - if (timeBeginPeriod(mm_period) == 0) { - driver.send = _win32mm_send_xp; - driver.flags |= MIDI_PORT_CAN_SCHEDULE; - } else { - driver.send = _win32mm_send; - log_appendf(4, "Cannot install WINMM timer (midi output will skip)"); - } - } else { - driver.send = _win32mm_send; - log_appendf(4, "Cannot get WINMM timer capabilities (midi output will skip)"); - } - } - - if (!midi_provider_register("Win32MM", &driver)) return 0; - - return 1; -} - diff --git a/src/sys/win32/osdefs.c b/src/sys/win32/osdefs.c index 0beccbf..1b039a1 100644 --- a/src/sys/win32/osdefs.c +++ b/src/sys/win32/osdefs.c @@ -21,178 +21,3 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Predominantly this file is keyboard crap, but we also get the network configured here */ - -#include "headers.h" -#include "sdlmain.h" -#include "it.h" -#include "osdefs.h" - -#include -#include - -/* eek... */ -void win32_get_modkey(int *mk) -{ - BYTE ks[256]; - if (GetKeyboardState(ks) == 0) return; - - if (ks[VK_CAPITAL] & 128) { - status.flags |= CAPS_PRESSED; - } else { - status.flags &= ~CAPS_PRESSED; - } - - (*mk) = ((*mk) & ~(KMOD_NUM|KMOD_CAPS)) - | ((ks[VK_NUMLOCK]&1) ? KMOD_NUM : 0) - | ((ks[VK_CAPITAL]&1) ? KMOD_CAPS : 0); -} - -/* more windows key stuff... */ -unsigned int key_repeat_rate(void) -{ - DWORD spd; - if (!SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &spd, 0)) return 0; - if (!spd) return 1; - return spd; -} -unsigned int key_repeat_delay(void) -{ - int delay; - - if (!SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &delay, 0)) return 0; - switch (delay) { - case 0: return 250; - case 1: return 500; - case 2: return 750; - }; - return 1000; -} - -static HKL default_keymap; -static HKL us_keymap; - -static void win32_setup_keymap(void) -{ - default_keymap = GetKeyboardLayout(0); - us_keymap = LoadKeyboardLayout("00000409", KLF_ACTIVATE|KLF_REPLACELANG|KLF_NOTELLSHELL); - ActivateKeyboardLayout(default_keymap,0); -} - -int key_scancode_lookup(int k, int def) -{ -#ifndef VK_0 -#define VK_0 '0' -#define VK_1 '1' -#define VK_2 '2' -#define VK_3 '3' -#define VK_4 '4' -#define VK_5 '5' -#define VK_6 '6' -#define VK_7 '7' -#define VK_8 '8' -#define VK_9 '9' -#define VK_A 'A' -#define VK_B 'B' -#define VK_C 'C' -#define VK_D 'D' -#define VK_E 'E' -#define VK_F 'F' -#define VK_G 'G' -#define VK_H 'H' -#define VK_I 'I' -#define VK_J 'J' -#define VK_K 'K' -#define VK_L 'L' -#define VK_M 'M' -#define VK_N 'N' -#define VK_O 'O' -#define VK_P 'P' -#define VK_Q 'Q' -#define VK_R 'R' -#define VK_S 'S' -#define VK_T 'T' -#define VK_U 'U' -#define VK_V 'V' -#define VK_W 'W' -#define VK_X 'X' -#define VK_Y 'Y' -#define VK_Z 'Z' -#endif /* VK_0 */ - -/* These keys haven't been defined, but were experimentally determined */ -#define VK_SEMICOLON 0xBA -#define VK_EQUALS 0xBB -#define VK_COMMA 0xBC -#define VK_MINUS 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_GRAVE 0xC0 -#define VK_LBRACKET 0xDB -#define VK_BACKSLASH 0xDC -#define VK_RBRACKET 0xDD -#define VK_APOSTROPHE 0xDE -#define VK_BACKTICK 0xDF -#define VK_OEM_102 0xE2 - switch (MapVirtualKeyEx(k, 1 /* MAPVK_VSC_TO_VK */, us_keymap)) { - case VK_0: return SDLK_0; - case VK_1: return SDLK_1; - case VK_2: return SDLK_2; - case VK_3: return SDLK_3; - case VK_4: return SDLK_4; - case VK_5: return SDLK_5; - case VK_6: return SDLK_6; - case VK_7: return SDLK_7; - case VK_8: return SDLK_8; - case VK_9: return SDLK_9; - case VK_A: return SDLK_a; - case VK_B: return SDLK_b; - case VK_C: return SDLK_c; - case VK_D: return SDLK_d; - case VK_E: return SDLK_e; - case VK_F: return SDLK_f; - case VK_G: return SDLK_g; - case VK_H: return SDLK_h; - case VK_I: return SDLK_i; - case VK_J: return SDLK_j; - case VK_K: return SDLK_k; - case VK_L: return SDLK_l; - case VK_M: return SDLK_m; - case VK_N: return SDLK_n; - case VK_O: return SDLK_o; - case VK_P: return SDLK_p; - case VK_Q: return SDLK_q; - case VK_R: return SDLK_r; - case VK_S: return SDLK_s; - case VK_T: return SDLK_t; - case VK_U: return SDLK_u; - case VK_V: return SDLK_v; - case VK_W: return SDLK_w; - case VK_X: return SDLK_x; - case VK_Y: return SDLK_y; - case VK_Z: return SDLK_z; - case VK_SEMICOLON: return SDLK_SEMICOLON; - case VK_GRAVE: return SDLK_BACKQUOTE; - case VK_APOSTROPHE: return SDLK_QUOTE; - case VK_BACKTICK: return SDLK_BACKQUOTE; - case VK_BACKSLASH: return SDLK_BACKSLASH; - case VK_LBRACKET: return SDLK_LEFTBRACKET; - case VK_RBRACKET: return SDLK_RIGHTBRACKET; - }; - return def; -} - - -void win32_sysinit(UNUSED int *pargc, UNUSED char ***pargv) -{ - static WSADATA ignored; - - win32_setup_keymap(); - - memset(&ignored, 0, sizeof(ignored)); - if (WSAStartup(0x202, &ignored) == SOCKET_ERROR) { - WSACleanup(); /* ? */ - status.flags |= NO_NETWORK; - } -} - diff --git a/src/sys/win32/volume-win32mm.c b/src/sys/win32/volume-win32mm.c deleted file mode 100644 index e3d966c..0000000 --- a/src/sys/win32/volume-win32mm.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Schism Tracker - a cross-platform Impulse Tracker clone - * copyright (c) 2003-2005 Storlek - * copyright (c) 2005-2008 Mrs. Brisby - * copyright (c) 2009 Storlek & Mrs. Brisby - * copyright (c) 2010-2012 Storlek - * URL: http://schismtracker.org/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "headers.h" - -#include "util.h" -#include "osdefs.h" - -#ifndef WIN32 -# error Why do you want to build this if you do not intend to use it? -#endif - -#include -#include - -/* Note: [Gargaj] - - WinMM DOES support max volumes up to 65535, but the scroller is - so goddamn slow and it only supports 3 digits anyway, that - it doesn't make any sense to keep the precision. -*/ - -int win32mm_volume_get_max(void) -{ - return 0xFF; -} - -static HWAVEOUT open_mixer(void) -{ - HWAVEOUT hwo=NULL; - WAVEFORMATEX pwfx; -#if 0 - pwfx.wFormatTag = WAVE_FORMAT_UNKNOWN; - pwfx.nChannels = 0; - pwfx.nSamplesPerSec = 0; - pwfx.wBitsPerSample = 0; - pwfx.nBlockAlign = 0; - pwfx.nAvgBytesPerSec = 0; - pwfx.cbSize = 0; -#else - pwfx.wFormatTag = WAVE_FORMAT_PCM; - pwfx.nChannels = 1; - pwfx.nSamplesPerSec = 44100; - pwfx.wBitsPerSample = 8; - pwfx.nBlockAlign = 4; - pwfx.nAvgBytesPerSec = 44100*1*1; - pwfx.cbSize = 0; -#endif - if (waveOutOpen(&hwo, WAVE_MAPPER, &pwfx, 0, 0, CALLBACK_NULL)!=MMSYSERR_NOERROR) - return NULL; - return hwo; -} - -void win32mm_volume_read(int *left, int *right) -{ - DWORD vol; - - *left = *right = 0; - - waveOutGetVolume(NULL,&vol); - - *left = (vol & 0xFFFF) >> 8; - *right = (vol >> 16) >> 8; -} - -void win32mm_volume_write(int left, int right) -{ - DWORD vol = ((left & 0xFF)<<8) | ((right & 0xFF)<<(16+8)); - - waveOutSetVolume(NULL,vol); -} -- cgit v1.2.3