Speaker functionaliteit verbeterd. Commentaar toegevoegd bij mogelijke verbeterpunten.

This commit is contained in:
2011-07-24 13:41:02 +00:00
parent 3852163f6e
commit f9bafb6fb9
6 changed files with 13 additions and 12 deletions

View File

@@ -56,14 +56,13 @@ void wiiuse_speaker_volume(struct wiimote_t* wm, double vol) {
}
void wiiuse_speaker_config(struct wiimote_t* wm) {
byte cfg[7] = {wm->speaker.format, 0x00, 0x00, wm->speaker.rate, wm->speaker.vol, 0x00, 0x00};
byte cfg[7] = {0x00, wm->speaker.format, 15, 25, wm->speaker.vol, 0x00, 0x00};
wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 7);
}
void wiiuse_speaker_data(struct wiimote_t* wm, byte* data) {
/* Todo: add data length dynamically */
//byte buf[21];
//WIIUSE_DEBUG("data length %d", sizeof(buf) / sizeof(byte));
//memcpy(buf, data, 21);
wiiuse_send(wm, WM_CMD_STREAM_DATA, data, 21);
void wiiuse_speaker_data(struct wiimote_t* wm, byte* data, int len) {
byte buf[21] = {0x00};
buf[0] = len << 3;
memcpy(buf + 1, data, len);
wiiuse_send(wm, WM_CMD_STREAM_DATA, buf, 21);
}

View File

@@ -1,5 +1,7 @@
#include "wiiuse.h"
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define WIIMOTE_GET_RUMBLE(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE) ? 0x01 : 0x00)
#define WIIMOTE_GET_SPEAKER_MAX_VOLUME(wm) (wm->speaker.format == 0x00 ? 0x40 : 0xff)

View File

@@ -665,7 +665,7 @@ WIIUSE_EXPORT extern void wiiuse_speaker_format(struct wiimote_t* wm, byte forma
WIIUSE_EXPORT extern void wiiuse_speaker_volume(struct wiimote_t* wm, double vol);
WIIUSE_EXPORT extern void wiiuse_speaker_rate(struct wiimote_t* wm, double freq);
WIIUSE_EXPORT extern void wiiuse_speaker_config(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_data(struct wiimote_t* wm, byte* data);
WIIUSE_EXPORT extern void wiiuse_speaker_data(struct wiimote_t* wm, byte* data, int len);
#ifdef __cplusplus
}