|
|
| version 1.1, 2003/10/25 21:28:14 | version 1.3, 2003/10/30 19:39:52 |
|---|---|
| Line 15 | Line 15 |
| #include "sound.h" | #include "sound.h" |
| #include "fmboard.h" | #include "fmboard.h" |
| #include "dialogutils.h" | #include "dialogutils.h" |
| #include "hid.h" | |
| #include "soundopt.h" | |
| #define getControlValue(a) GetControl32BitValue(getControlRefByID(a,0,soundWin)) | #define getControlValue(a,b) GetControl32BitValue(getControlRefByID(a,b,soundWin)) |
| #define setControlValue(a,b) SetControl32BitValue(getControlRefByID(a,0,soundWin),b) | #define setControlValue(a,b,c) SetControl32BitValue(getControlRefByID(a,b,soundWin),c) |
| #define getMenuValue (getControlValue(cmd.commandID,0)-1) | |
| #define kMaxNumTabs 6 | #define kMaxNumTabs 6 |
| enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; |
| static OSStatus setupJoyConfig (OSType type); | |
| static void initJoyPad(void); | |
| static IBNibRef nibRef; | |
| static WindowRef soundWin; | static WindowRef soundWin; |
| static UInt16 lastPaneSelected = 1; // static, to keep track of it long term (in a more complex application | static WindowRef joyWin; |
| static UInt16 lastPaneSelected = 1; // static, to keep track of it long term (in a more complex application | |
| // you might store this in a data structure in the window refCon) | // you might store this in a data structure in the window refCon) |
| static void setFieldValue(UInt32 type) { | |
| ControlRef conRef; | |
| Str255 title; | |
| SInt32 value; | |
| value = getControlValue(type); | |
| NumToString(value, title); | |
| conRef = getControlRefByID(type, 1, soundWin); | |
| SetControlData(conRef, kControlNoPart, kControlStaticTextTextTag, *title, title+1); | |
| Draw1Control(conRef); | |
| } | |
| static BYTE snd26 = 0; | static BYTE snd26 = 0; |
| static BYTE snd86 = 0; | static BYTE snd86 = 0; |
| static BYTE spb = 0; | static BYTE spb = 0; |
| static BYTE spbvrc = 0; | static BYTE spbvrc = 0; |
| static void set26jmp(BYTE value, BYTE bit) { | BYTE* cfg[5] = {&np2cfg.vol_fm, &np2cfg.vol_ssg, &np2cfg.vol_adpcm, &np2cfg.vol_pcm, &np2cfg.vol_rhythm}; |
| if ((snd26 ^ value) & bit) { | //-----init |
| snd26 &= ~bit; | static void initMixer(BYTE *data) { |
| snd26 |= value; | short j; |
| } | for (j=0;j<5;j++) { |
| setControlValue('vMix', j, *(data+j)); | |
| } | |
| } | |
| static void init14(BYTE *data) { | |
| short i; | |
| for (i=0;i<6;i++) { | |
| setControlValue('vMix', i+10, *(data+i)); | |
| } | |
| } | |
| static void set26s(BYTE chip, OSType io, OSType inturrupt, OSType rom) { | |
| BYTE para; | |
| static short paranum[4] = {0, 3, 1, 2}; | |
| setControlValue(io, 0, ((chip >> 4) & 1)+1); | |
| setControlValue(inturrupt, 0, paranum[(chip >> 6) & 3]+1); | |
| para = chip & 7; | |
| if (para > 4) { | |
| para = 4; | |
| } | |
| setControlValue(rom, 0, para+1); | |
| } | |
| static void set86s(void) { | |
| setControlValue('86io', 0, ((~snd86) & 1)+1); | |
| static short paranum[4] = {0, 1, 3, 2}; | |
| setControlValue('86in', 0, paranum[(snd86 >> 2) & 3]+1); | |
| setControlValue('86id', 0, (((~snd86) >> 5) & 7)+1); | |
| setControlValue('86it', 0, (snd86 & 0x10)?1:0); | |
| setControlValue('86rm', 0, (snd86 & 0x02)?1:0); | |
| } | |
| static void setSPB(void) { | |
| set26s(spb, 'spio', 'spin', 'sprm'); | |
| setControlValue('spvl', 0, (spbvrc & 1)?1:0); | |
| setControlValue('spvr', 0, (spbvrc & 2)?1:0); | |
| } | } |
| static void initSoundWindow(void) { | static void initSoundWindow(void) { |
| setControlValue('vFM ', np2cfg.vol_fm); | BYTE data[5]; |
| setFieldValue('vFM '); | short i; |
| setControlValue('vPSG', np2cfg.vol_ssg); | for (i=0;i<5;i++) { |
| setFieldValue('vPSG'); | data[i] = *(cfg[i]); |
| setControlValue('vADP', np2cfg.vol_adpcm); | } |
| setFieldValue('vADP'); | initMixer(data); |
| setControlValue('vPCM', np2cfg.vol_pcm); | init14(np2cfg.vol14); |
| setFieldValue('vPCM'); | |
| setControlValue('vRtm', np2cfg.vol_rhythm); | |
| setFieldValue('vRtm'); | |
| setControlValue('vLft', np2cfg.vol14[0]); | |
| setFieldValue('vLft'); | |
| setControlValue('vRit', np2cfg.vol14[1]); | |
| setFieldValue('vRit'); | |
| setControlValue('vf2 ', np2cfg.vol14[2]); | |
| setFieldValue('vf2 '); | |
| setControlValue('vf4 ', np2cfg.vol14[3]); | |
| setFieldValue('vf4 '); | |
| setControlValue('vf8 ', np2cfg.vol14[4]); | |
| setFieldValue('vf8 '); | |
| setControlValue('vf16', np2cfg.vol14[5]); | |
| setFieldValue('vf16'); | |
| snd26 = np2cfg.snd26opt; | snd26 = np2cfg.snd26opt; |
| { | uncheckAllPopupMenuItems('26io', 2, soundWin); |
| BYTE para; | uncheckAllPopupMenuItems('26in', 4, soundWin); |
| static short paranum[4] = {0, 3, 1, 2}; | uncheckAllPopupMenuItems('26rm', 5, soundWin); |
| setControlValue('26io', ((snd26 >> 4) & 1)+1); | set26s(snd26, '26io', '26in', '26rm'); |
| setControlValue('26in', paranum[(snd26 >> 6) & 3]+1); | |
| para = snd26 & 7; | |
| if (para > 4) { | |
| para = 4; | |
| } | |
| setControlValue('26rm', para+1); | |
| } | |
| snd86 = np2cfg.snd86opt; | snd86 = np2cfg.snd86opt; |
| { | uncheckAllPopupMenuItems('86io', 2, soundWin); |
| setControlValue('86io', ((~snd86) & 1)+1); | uncheckAllPopupMenuItems('86in', 4, soundWin); |
| static short paranum[4] = {0, 1, 3, 2}; | uncheckAllPopupMenuItems('86id', 8, soundWin); |
| setControlValue('86in', paranum[(snd86 >> 2) & 3]+1); | set86s(); |
| setControlValue('86id', (((~snd86) >> 5) & 7)+1); | |
| SetControl32BitValue(getControlRefByID('86in',1,soundWin),(snd86 & 0x10)?1:0); | |
| SetControl32BitValue(getControlRefByID('86rm',1,soundWin),(snd86 & 0x02)?1:0); | |
| } | |
| spb = np2cfg.spbopt; | spb = np2cfg.spbopt; |
| spbvrc = np2cfg.spb_vrc; // ver0.30 | |
| uncheckAllPopupMenuItems('spio', 2, soundWin); | |
| uncheckAllPopupMenuItems('spin', 4, soundWin); | |
| uncheckAllPopupMenuItems('sprm', 5, soundWin); | |
| setSPB(); | |
| setControlValue('splv', 0, np2cfg.spb_vrl); | |
| setControlValue('sprv', 0, np2cfg.spb_x); | |
| initJoyPad(); | |
| } | |
| //-----change | |
| static BYTE getsnd26int(OSType board) { | |
| switch (getControlValue(board, 0)) | |
| { | { |
| BYTE para; | case 1: |
| static short paranum[4] = {0, 3, 1, 2}; | return(0x00); |
| setControlValue('spio', ((spb >> 4) & 1)+1); | |
| setControlValue('spin', paranum[(spb >> 6) & 3]+1); | case 2: |
| para = spb & 7; | return(0x80); |
| if (para > 4) { | |
| para = 4; | case 4: |
| return(0x40); | |
| } | |
| return(0xc0); | |
| } | |
| static BYTE getsnd86int(void) { | |
| switch (getControlValue('86in', 0)) | |
| { | |
| case 1: | |
| return(0x00); | |
| case 2: | |
| return(0x04); | |
| case 4: | |
| return(0x08); | |
| } | |
| return(0x0c); | |
| } | |
| static BYTE getspbVRch(void) { | |
| BYTE ret = 0; | |
| if (getControlValue('spvl', 0)) { | |
| ret++; | |
| } | |
| if (getControlValue('spvr', 0)) { | |
| ret += 2; | |
| } | |
| return(ret); | |
| } | |
| static void changeSoundOpt(void) { | |
| SINT32 val; | |
| UInt8 update; | |
| int renewal; | |
| short i,j; | |
| renewal = 0; | |
| for (j=0;j<5;j++) { | |
| val = getControlValue('vMix', j); | |
| if (val != *cfg[j]) { | |
| *cfg[j] = val; | |
| renewal = 1; | |
| } | } |
| setControlValue('sprm', para+1); | |
| spbvrc = np2cfg.spb_vrc; // ver0.30 | |
| setControlValue('spvl',(spbvrc & 1)?1:0); | |
| setControlValue('spvr',(spbvrc & 2)?1:0); | |
| setControlValue('splv',np2cfg.spb_vrl); | |
| setControlValue('sprv',np2cfg.spb_x); | |
| } | } |
| spbvrc = np2cfg.spb_vrc; // ver0.30 | if (renewal) { |
| sysmng_update(SYS_UPDATECFG); | |
| } | |
| opngen_setvol(np2cfg.vol_fm); | |
| psggen_setvol(np2cfg.vol_ssg); | |
| rhythm_setvol(np2cfg.vol_rhythm); | |
| rhythm_update(&rhythm); | |
| adpcm_setvol(np2cfg.vol_adpcm); | |
| adpcm_update(&adpcm); | |
| pcm86gen_setvol(np2cfg.vol_pcm); | |
| pcm86gen_update(); | |
| renewal = 0; | |
| for (i=0;i<6;i++) { | |
| val = getControlValue('vMix',i+10); | |
| if (val != np2cfg.vol14[i]) { | |
| np2cfg.vol14[i] = val; | |
| renewal = 1; | |
| } | |
| } | |
| if (renewal) { | |
| sysmng_update(SYS_UPDATECFG); | |
| tms3631_setvol(np2cfg.vol14); | |
| } | |
| if (np2cfg.snd26opt != snd26) { | |
| np2cfg.snd26opt = snd26; | |
| sysmng_update(SYS_UPDATECFG); | |
| } | |
| if (np2cfg.snd86opt != snd86) { | |
| np2cfg.snd86opt = snd86; | |
| sysmng_update(SYS_UPDATECFG); | |
| } | |
| update = 0; | |
| if (np2cfg.spbopt != spb) { | |
| np2cfg.spbopt = spb; | |
| update |= SYS_UPDATECFG; | |
| } | |
| if (np2cfg.spb_vrc != spbvrc) { | |
| np2cfg.spb_vrc = spbvrc; | |
| update |= SYS_UPDATECFG; | |
| } | |
| val = getControlValue('splv', 0); | |
| if (np2cfg.spb_vrl != val) { | |
| np2cfg.spb_vrl = val; | |
| update |= SYS_UPDATECFG; | |
| } | |
| opngen_setVR(np2cfg.spb_vrc, np2cfg.spb_vrl); | |
| val = getControlValue('sprv', 0); | |
| if (np2cfg.spb_x != val) { | |
| np2cfg.spb_x = val; | |
| update |= SYS_UPDATECFG; | |
| } | |
| sysmng_update(update); | |
| changeJoyPadSetup(); | |
| } | } |
| static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { |
| OSStatus err = eventNotHandledErr; | OSStatus err = eventNotHandledErr; |
| HICommand cmd; | HICommand cmd; |
| SINT32 val; | BYTE defaultmix[5] = {64, 64, 64, 64, 64}; |
| UInt8 value[6]; | BYTE b; |
| UInt8 b; | |
| UInt8 update; | |
| int renewal; | |
| if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { |
| GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); |
| switch (cmd.commandID) | switch (cmd.commandID) |
| { | { |
| case 'vFM ': | case 'vDEF': |
| case 'vPSG': | initMixer(defaultmix); |
| case 'vADP': | |
| case 'vPCM': | |
| case 'vRtm': | |
| case 'vLft': | |
| case 'vRit': | |
| case 'vf2 ': | |
| case 'vf4 ': | |
| case 'vf8 ': | |
| case 'vf16': | |
| setFieldValue(cmd.commandID); | |
| break; | break; |
| case '26io': | case '26io': |
| set26jmp(getControlValue('26io'), 0x10); | setjmper(&snd26, (getMenuValue == 1)?0x10:0x00, 0x10); |
| break; | break; |
| case kHICommandOK: | case '26in': |
| renewal = 0; | setjmper(&snd26, getsnd26int(cmd.commandID), 0xc0); |
| val = getControlValue('vFM '); | break; |
| if (val != np2cfg.vol_fm) { | |
| np2cfg.vol_fm = val; | case '26rm': |
| renewal = 1; | setjmper(&snd26, getMenuValue, 0x07); |
| } | break; |
| val = getControlValue('vPSG'); | |
| if (val != np2cfg.vol_ssg) { | |
| np2cfg.vol_ssg = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vADP'); | |
| if (val != np2cfg.vol_adpcm) { | |
| np2cfg.vol_adpcm = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vPCM'); | |
| if (val != np2cfg.vol_pcm) { | |
| np2cfg.vol_pcm = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vRtm'); | |
| if (val != np2cfg.vol_rhythm) { | |
| np2cfg.vol_rhythm = val; | |
| renewal = 1; | |
| } | |
| if (renewal) { | |
| sysmng_update(SYS_UPDATECFG); | |
| } | |
| opngen_setvol(np2cfg.vol_fm); | |
| psggen_setvol(np2cfg.vol_ssg); | |
| rhythm_setvol(np2cfg.vol_rhythm); | |
| rhythm_update(&rhythm); | |
| adpcm_setvol(np2cfg.vol_adpcm); | |
| adpcm_update(&adpcm); | |
| pcm86gen_setvol(np2cfg.vol_pcm); | |
| pcm86gen_update(); | |
| renewal = 0; | |
| val = getControlValue('vLft'); | |
| if (val != np2cfg.vol14[0]) { | |
| np2cfg.vol14[0] = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vRit'); | |
| if (val != np2cfg.vol14[1]) { | |
| np2cfg.vol14[1] = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vf2 '); | |
| if (val != np2cfg.vol14[2]) { | |
| np2cfg.vol14[2] = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vf4 '); | |
| if (val != np2cfg.vol14[3]) { | |
| np2cfg.vol14[3] = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vf8 '); | |
| if (val != np2cfg.vol14[4]) { | |
| np2cfg.vol14[4] = val; | |
| renewal = 1; | |
| } | |
| val = getControlValue('vf16'); | |
| if (val != np2cfg.vol14[5]) { | |
| np2cfg.vol14[5] = val; | |
| renewal = 1; | |
| } | |
| if (renewal) { | |
| sysmng_update(SYS_UPDATECFG); | |
| tms3631_setvol(np2cfg.vol14); | |
| } | |
| if (np2cfg.snd26opt != snd26) { | case '26DF': |
| np2cfg.snd26opt = snd26; | snd26 = 0xd1; |
| sysmng_update(SYS_UPDATECFG); | set26s(snd26, '26io', '26in', '26rm'); |
| } | break; |
| if (np2cfg.snd86opt != snd86) { | |
| np2cfg.snd86opt = snd86; | |
| sysmng_update(SYS_UPDATECFG); | |
| } | |
| update = 0; | case '86io': |
| if (np2cfg.spbopt != spb) { | setjmper(&snd86, (getMenuValue == 0)?0x01:0x00, 0x01); |
| np2cfg.spbopt = spb; | break; |
| update |= SYS_UPDATECFG; | |
| } | case '86it': |
| if (np2cfg.spb_vrc != spbvrc) { | setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x10:0x00, 0x10); |
| np2cfg.spb_vrc = spbvrc; | break; |
| update |= SYS_UPDATECFG; | |
| } | case '86in': |
| val = getControlValue('spvl'); | setjmper(&snd86, getsnd86int(), 0x0c); |
| if (np2cfg.spb_vrl != val) { | break; |
| np2cfg.spb_vrl = val; | |
| update |= SYS_UPDATECFG; | case '86id': |
| } | setjmper(&snd86, (~getMenuValue & 7) << 5, 0xe0); |
| opngen_setVR(np2cfg.spb_vrc, np2cfg.spb_vrl); | break; |
| val = getControlValue('sprv'); | |
| if (np2cfg.spb_x != val) { | case '86rm': |
| np2cfg.spb_x = val; | setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x02:0x00, 0x02); |
| update |= SYS_UPDATECFG; | break; |
| } | |
| sysmng_update(update); | case '86DF': |
| snd86 = 0x7f; | |
| set86s(); | |
| break; | |
| case 'spio': | |
| setjmper(&spb, (getMenuValue == 1)?0x10:0x00, 0x10); | |
| break; | |
| case 'spin': | |
| setjmper(&spb, getsnd26int(cmd.commandID), 0xc0); | |
| break; | |
| case 'sprm': | |
| setjmper(&spb, getMenuValue, 0x07); | |
| break; | |
| case 'spvl': | |
| case 'spvr': | |
| b = getspbVRch(); | |
| if ((spbvrc ^ b) & 3) { | |
| spbvrc = b; | |
| } | |
| break; | |
| case 'spDF': | |
| spb = 0xd1; | |
| spbvrc = 0; | |
| setSPB(); | |
| break; | |
| case kHICommandOK: | |
| changeSoundOpt(); | |
| endLoop(soundWin); | endLoop(soundWin); |
| err=noErr; | err=noErr; |
| break; | break; |
| case kHICommandCancel: | case kHICommandCancel: |
| revertTemporal(); | |
| endLoop(soundWin); | endLoop(soundWin); |
| err=noErr; | err=noErr; |
| break; | break; |
| case JOYPAD_UP: | |
| case JOYPAD_DOWN: | |
| case JOYPAD_LEFT: | |
| case JOYPAD_RIGHT: | |
| case JOYPAD_ABUTTON: | |
| case JOYPAD_BBUTTON: | |
| err=setupJoyConfig(cmd.commandID); | |
| break; | |
| default: | |
| break; | |
| } | } |
| } | } |
| Line 275 static pascal OSStatus cfWinproc(EventHa | Line 344 static pascal OSStatus cfWinproc(EventHa |
| return err; | return err; |
| } | } |
| static pascal OSStatus sliderEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | |
| { | |
| return( changeSlider((ControlRef)inUserData, soundWin, 0) ); | |
| } | |
| static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) |
| { | { |
| WindowRef theWindow = (WindowRef)inUserData; // get the windowRef, passed around as userData | WindowRef theWindow = (WindowRef)inUserData; // get the windowRef, passed around as userData |
| Line 288 static pascal OSStatus PrefsTabEventHand | Line 362 static pascal OSStatus PrefsTabEventHand |
| static void makeNibWindow (IBNibRef nibRef) { | static void makeNibWindow (IBNibRef nibRef) { |
| OSStatus err; | OSStatus err; |
| short i,j,l; | |
| EventHandlerRef ref; | |
| ControlRef targetCon[11]; | |
| err = CreateWindowFromNib(nibRef, CFSTR("SoundDialog"), &soundWin); | err = CreateWindowFromNib(nibRef, CFSTR("SoundDialog"), &soundWin); |
| if (err == noErr) { | if (err == noErr) { |
| initSoundWindow(); | initSoundWindow(); |
| SetInitialTabState(soundWin, lastPaneSelected, kMaxNumTabs); | SetInitialTabState(soundWin, lastPaneSelected, kMaxNumTabs); |
| EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; | EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; |
| InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,soundWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, soundWin, NULL ); | InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,soundWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, soundWin, NULL ); |
| EventTypeSpec sliderControlEvents[] ={ | |
| { kEventClassControl, kEventControlDraw }, | |
| { kEventClassControl, kEventControlValueFieldChanged } | |
| }; | |
| for (i=0;i<5;i++) { | |
| targetCon[i] = getControlRefByID('vMix',i,soundWin); | |
| } | |
| for (j=0;j<6;j++) { | |
| targetCon[j+5] = getControlRefByID('vMix',10+j,soundWin); | |
| } | |
| for (l=0;l<11;l++) { | |
| InstallControlEventHandler( targetCon[l], sliderEventHandlerProc , GetEventTypeCount(sliderControlEvents), sliderControlEvents, (void *)targetCon[l], NULL ); | |
| } | |
| EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; | EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; |
| EventHandlerRef ref; | |
| InstallWindowEventHandler (soundWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)soundWin, &ref); | InstallWindowEventHandler (soundWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)soundWin, &ref); |
| ShowSheetWindow(soundWin, hWndMain); | ShowSheetWindow(soundWin, hWndMain); |
| Line 307 static void makeNibWindow (IBNibRef nibR | Line 400 static void makeNibWindow (IBNibRef nibR |
| void initSoundOpt( void ) { | void initSoundOpt( void ) { |
| OSStatus err; | OSStatus err; |
| IBNibRef nibRef; | |
| err = CreateNibReference(CFSTR("np2"), &nibRef); | err = CreateNibReference(CFSTR("np2"), &nibRef); |
| if (err ==noErr ) { | if (err ==noErr ) { |
| Line 319 void initSoundOpt( void ) { | Line 411 void initSoundOpt( void ) { |
| } | } |
| } | } |
| //--------JoyPad | |
| static pascal OSStatus joyWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | |
| OSStatus err = eventNotHandledErr; | |
| HICommand cmd; | |
| if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { | |
| GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | |
| switch (cmd.commandID) | |
| { | |
| case 'notJ': | |
| HideSheetWindow(joyWin); | |
| DisposeWindow(joyWin); | |
| err = noErr; | |
| break; | |
| default: | |
| break; | |
| } | |
| } | |
| return err; | |
| } | |
| static void setTitle(OSType type, char* elementName) { | |
| Str255 str; | |
| mkstr255(str, elementName); | |
| SetControlTitle(getControlRefByID(type, 0, soundWin), str); | |
| } | |
| static OSStatus setupJoyConfig (OSType type) { | |
| OSStatus err = noErr; | |
| char elementName[256] = "----"; | |
| err = CreateWindowFromNib(nibRef, CFSTR("InputWindow"), &joyWin); | |
| if (err == noErr) { | |
| EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess } }; | |
| EventHandlerRef ref; | |
| InstallWindowEventHandler (joyWin, NewEventHandlerUPP(joyWinproc), 1, list, (void *)joyWin, &ref); | |
| ShowSheetWindow(joyWin, soundWin); | |
| if (setJoypad(type, elementName)) { | |
| setTitle(type, elementName); | |
| } | |
| HideSheetWindow(joyWin); | |
| DisposeWindow(joyWin); | |
| } | |
| return(err); | |
| } | |
| static void setName (OSType type) { | |
| char elementName[256] = "----"; | |
| if (getJoypadName(type, elementName)) { | |
| if (elementName) { | |
| setTitle(type, elementName); | |
| } | |
| } | |
| } | |
| static void initJoyPad(void) { | |
| setName(JOYPAD_UP); | |
| setName(JOYPAD_DOWN); | |
| setName(JOYPAD_LEFT); | |
| setName(JOYPAD_RIGHT); | |
| setName(JOYPAD_ABUTTON); | |
| setName(JOYPAD_BBUTTON); | |
| initTemporal(); | |
| } |