(Wiiuse) Add HAVE_WIIUSE_RUMBLE and HAVE_WIIUSE_SPEAKER defines

This commit is contained in:
twinaphex 2013-01-07 05:03:50 +01:00
parent 05333fcc0a
commit a67c247ebc
5 changed files with 32 additions and 3 deletions

View File

@ -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

View File

@ -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)) {

View File

@ -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));

View File

@ -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)
{

View File

@ -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<<chan);
break;
@ -1028,6 +1036,7 @@ s32 WPAD_ScanPads()
return WPAD_ReadPending(WPAD_CHAN_ALL, NULL);
}
#ifdef HAVE_WIIUSE_RUMBLE
s32 WPAD_Rumble(s32 chan, int status)
{
int i;
@ -1055,6 +1064,7 @@ s32 WPAD_Rumble(s32 chan, int status)
_CPU_ISR_Restore(level);
return WPAD_ERR_NONE;
}
#endif
s32 WPAD_SetIdleThresholds(s32 chan, s32 btns, s32 ir, s32 accel, s32 js, s32 wb, s32 mp)
{
@ -1088,6 +1098,7 @@ s32 WPAD_SetIdleThresholds(s32 chan, s32 btns, s32 ir, s32 accel, s32 js, s32 wb
return WPAD_ERR_NONE;
}
#ifdef HAVE_WIIUSE_SPEAKER
s32 WPAD_ControlSpeaker(s32 chan,s32 enable)
{
int i;
@ -1142,12 +1153,11 @@ s32 WPAD_IsSpeakerEnabled(s32 chan)
_CPU_ISR_Restore(level);
return ret;
}
#endif
s32 WPAD_SendStreamData(s32 chan,void *buf,u32 len)
{
u32 level;
struct timespec tb;
wiimote *wm = NULL;
if(chan<WPAD_CHAN_0 || chan>=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)
{