From a67c247ebc869118575aa4ead7c78ad6500bb39f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 7 Jan 2013 05:03:50 +0100 Subject: [PATCH] (Wiiuse) Add HAVE_WIIUSE_RUMBLE and HAVE_WIIUSE_SPEAKER defines --- console/griffin/griffin.c | 2 ++ wii/wiiuse/events.c | 6 ++++++ wii/wiiuse/io_wii.c | 2 ++ wii/wiiuse/wiiuse.c | 4 ++++ wii/wiiuse/wpad.c | 21 ++++++++++++++++++--- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 17ad14123f..d6ee7f233b 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -236,7 +236,9 @@ INPUT #include "../../wii/wiiuse/ir.c" #include "../../wii/wiiuse/motion_plus.c" #include "../../wii/wiiuse/nunchuk.c" +#ifdef HAVE_WIIUSE_SPEAKER #include "../../wii/wiiuse/speaker.c" +#endif #include "../../wii/wiiuse/wiiuse.c" #include "../../wii/wiiuse/wpad.c" #endif diff --git a/wii/wiiuse/events.c b/wii/wiiuse/events.c index 94671c6956..fa60c61550 100644 --- a/wii/wiiuse/events.c +++ b/wii/wiiuse/events.c @@ -101,7 +101,9 @@ static void event_status(struct wiimote_t *wm,ubyte *msg) { int ir = 0; int attachment = 0; +#ifdef HAVE_WIIUSE_SPEAKER int speaker = 0; +#endif //int led[4]= {0}; struct cmd_blk_t *cmd = wm->cmd_head; @@ -114,7 +116,9 @@ static void event_status(struct wiimote_t *wm,ubyte *msg) //if(msg[2]&WM_CTRL_STATUS_BYTE1_LED_4) led[3] = 1; if((msg[2]&WM_CTRL_STATUS_BYTE1_ATTACHMENT)==WM_CTRL_STATUS_BYTE1_ATTACHMENT) attachment = 1; +#ifdef HAVE_WIIUSE_SPEAKER if((msg[2]&WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED)==WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED) speaker = 1; +#endif if((msg[2]&WM_CTRL_STATUS_BYTE1_IR_ENABLED)==WM_CTRL_STATUS_BYTE1_IR_ENABLED) ir = 1; wm->battery_level = msg[5]; @@ -127,6 +131,7 @@ static void event_status(struct wiimote_t *wm,ubyte *msg) if(ir && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_IR)) WIIMOTE_ENABLE_STATE(wm,WIIMOTE_STATE_IR); else if(!ir && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_IR)) WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR); +#ifdef HAVE_WIIUSE_SPEAKER if(!speaker && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_SPEAKER_INIT)) { WIIMOTE_DISABLE_STATE(wm,WIIMOTE_STATE_SPEAKER_INIT); wiiuse_set_speaker(wm,1); @@ -134,6 +139,7 @@ static void event_status(struct wiimote_t *wm,ubyte *msg) } if(speaker && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_SPEAKER)) WIIMOTE_ENABLE_STATE(wm,WIIMOTE_STATE_SPEAKER); else if(!speaker && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_SPEAKER)) WIIMOTE_DISABLE_STATE(wm,WIIMOTE_STATE_SPEAKER); +#endif if(attachment) { if(!WIIMOTE_IS_SET(wm,WIIMOTE_STATE_EXP) && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_EXP_FAILED) && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_EXP_HANDSHAKE)) { diff --git a/wii/wiiuse/io_wii.c b/wii/wiiuse/io_wii.c index 63a693395f..0dc459b167 100644 --- a/wii/wiiuse/io_wii.c +++ b/wii/wiiuse/io_wii.c @@ -40,7 +40,9 @@ static s32 __wiiuse_disconnected(void *arg,struct bte_pcb *pcb,u8 err) //printf("wiimote disconnected\n"); WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_IR|WIIMOTE_STATE_IR_INIT)); +#ifdef HAVE_WIIUSE_SPEAKER WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_SPEAKER|WIIMOTE_STATE_SPEAKER_INIT)); +#endif WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_EXP|WIIMOTE_STATE_EXP_HANDSHAKE|WIIMOTE_STATE_EXP_FAILED)); WIIMOTE_DISABLE_STATE(wm,(WIIMOTE_STATE_CONNECTED|WIIMOTE_STATE_HANDSHAKE|WIIMOTE_STATE_HANDSHAKE_COMPLETE)); diff --git a/wii/wiiuse/wiiuse.c b/wii/wiiuse/wiiuse.c index 659b3892f7..efadacdf95 100644 --- a/wii/wiiuse/wiiuse.c +++ b/wii/wiiuse/wiiuse.c @@ -24,7 +24,9 @@ void wiiuse_send_next_command(struct wiimote_t *wm) if(cmd->state!=CMD_READY) return; cmd->state = CMD_SENT; +#ifdef HAVE_WIIUSE_RUMBLE if(WIIMOTE_IS_SET(wm,WIIMOTE_STATE_RUMBLE)) cmd->data[1] |= 0x01; +#endif //WIIUSE_DEBUG("Sending command: %02x %02x", cmd->data[0], cmd->data[1]); wiiuse_io_write(wm,cmd->data,cmd->len); @@ -162,6 +164,7 @@ void wiiuse_motion_sensing(struct wiimote_t* wm, int status) * * @param wm Pointer to a wiimote_t structure. */ +#ifdef HAVE_WIIUSE_RUMBLE void wiiuse_toggle_rumble(struct wiimote_t* wm) { if (!wm) return; @@ -184,6 +187,7 @@ void wiiuse_rumble(struct wiimote_t* wm, int status) else if(!status && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_RUMBLE)) return; wiiuse_toggle_rumble(wm); } +#endif void wiiuse_set_leds(struct wiimote_t *wm,int leds,cmd_blk_cb cb) { diff --git a/wii/wiiuse/wpad.c b/wii/wiiuse/wpad.c index b017af6689..08b42b5f8d 100644 --- a/wii/wiiuse/wpad.c +++ b/wii/wiiuse/wpad.c @@ -41,7 +41,11 @@ distribution. #include "lwp_threads.inl" #include "conf.h" #include "ir.h" + +#ifdef HAVE_WIIUSE_SPEAKER #include "speaker.h" +#endif + #include "dynamics.h" #include "wiiuse_internal.h" #include "wiiuse/wpad.h" @@ -151,6 +155,7 @@ static void __wpad_timeouthandler(syswd_t alarm,void *cbarg) __lwp_thread_dispatchunnest(); } +#ifdef HAVE_WIIUSE_SPEAKER static void __wpad_sounddata_alarmhandler(syswd_t alarm,void *cbarg) { u8 *snd_data; @@ -174,6 +179,7 @@ static void __wpad_sounddata_alarmhandler(syswd_t alarm,void *cbarg) wpdcb->sound_off += MAX_STREAMDATA_LEN; wiiuse_write_streamdata(wm,(snd_data+snd_off),MAX_STREAMDATA_LEN,NULL); } +#endif static void __wpad_setfmt(s32 chan) { @@ -526,7 +532,9 @@ static void __wpad_eventCB(struct wiimote_t *wm,s32 event) wiiuse_set_ir_position(wm,(CONF_GetSensorBarPosition()^1)); wiiuse_set_ir_sensitivity(wm,CONF_GetIRSensitivity()); wiiuse_set_leds(wm,(WIIMOTE_LED_1<<(chan%WPAD_BALANCE_BOARD)),NULL); +#ifdef HAVE_WIIUSE_SPEAKER wiiuse_set_speaker(wm,wpdcb->speaker_enabled); +#endif __wpad_setfmt(chan); __wpads_active |= (0x01<=WPAD_MAX_WIIMOTES) return WPAD_ERR_BAD_CHANNEL; @@ -1157,7 +1167,9 @@ s32 WPAD_SendStreamData(s32 chan,void *buf,u32 len) return WPAD_ERR_NOT_READY; } - wm = __wpads[chan]; +#ifdef HAVE_WIIUSE_SPEAKER + struct timespec tb; + wiimote *wm = __wpads[chan]; if(wm!=NULL && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_CONNECTED)) { if(WIIMOTE_IS_SET(wm,WIIMOTE_STATE_HANDSHAKE_COMPLETE) && WIIMOTE_IS_SET(wm,WIIMOTE_STATE_SPEAKER)) { @@ -1170,11 +1182,13 @@ s32 WPAD_SendStreamData(s32 chan,void *buf,u32 len) SYS_SetPeriodicAlarm(__wpdcb[chan].sound_alarm,&tb,&tb,__wpad_sounddata_alarmhandler, &__wpdcb[chan]); } } +#endif _CPU_ISR_Restore(level); return WPAD_ERR_NONE; } +#ifdef HAVE_WIIUSE_SPEAKER void WPAD_EncodeData(WPADEncStatus *info,u32 flag,const s16 *pcmSamples,s32 numSamples,u8 *encData) { int n; @@ -1192,6 +1206,7 @@ void WPAD_EncodeData(WPADEncStatus *info,u32 flag,const s16 *pcmSamples,s32 numS samples += 2; } } +#endif WPADData *WPAD_Data(int chan) {