This commit is contained in:
2011-02-01 18:50:35 +00:00
parent d0b37da24d
commit a4facdae7a
9 changed files with 88 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
copy ..\wiiuse.h ..\..\WiiUseJ\ copy ..\wiiuse.h ..\..\WiiUseJ\
copy ..\speaker.h ..\..\WiiUseJ\ copy ..\speaker.h ..\..\WiiUseJ\
copy Release\wiiuse.lib ..\..\WiiUseJ\lib\ copy Release\wiiuse.lib ..\..\WiiUseJ\lib\
copy Release\wiiuse.dll ..\..\..\java\main\native\ copy Release\wiiuse.dll ..\..\..\java\native\

Binary file not shown.

63
c/wiiuse/speaker.c Normal file
View File

@@ -0,0 +1,63 @@
#include <stdio.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "speaker.h"
void wiiuse_speaker_enable(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm) | WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED;
wiiuse_send(wm, WM_CMD_SPEAKER_ENABLE, &buf, 1);
}
void wiiuse_speaker_disable(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm);
wiiuse_send(wm, WM_CMD_SPEAKER_ENABLE, &buf, 1);
}
void wiiuse_speaker_mute(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm) | WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE;
wiiuse_send(wm, WM_CMD_SPEAKER_MUTE, &buf , 1);
}
void wiiuse_speaker_unmute(struct wiimote_t* wm) {
byte buf = WIIMOTE_GET_RUMBLE(wm);
wiiuse_send(wm, WM_CMD_SPEAKER_MUTE, &buf, 1);
}
void wiiuse_speaker_config(struct wiimote_t* wm, unsigned short freq, byte vol) {
if (freq > 0x0000) {
cfg[2] = freq & 0x00ff;
cfg[3] = (freq & 0xff00) >> 8;
}
printf("speaker 0x%02x%02x\n", cfg[2], cfg[3]);
fflush(stdout);
if (vol > 0x00) {
cfg[4] = vol;
}
wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 9);
}
void wiiuse_speaker_data(struct wiimote_t* wm, byte* data) {
byte buf[21];
buf[0] = sizeof(data) << 3;
memcpy(buf + 1, data, 20);
wiiuse_send(wm, WM_CMD_STREAM_DATA, buf, 21);
}
void wiiuse_speaker_activate(struct wiimote_t* wm) {
wiiuse_speaker_enable(wm);
wiiuse_speaker_unmute(wm);
wiiuse_speaker_config(wm, 0x00, 0x00);
}
void wiiuse_speaker_deactivate(struct wiimote_t* wm) {
wiiuse_speaker_mute(wm);
wiiuse_speaker_disable(wm);
}
void wiiuse_speaker_frequency(struct wiimote_t* wm, unsigned short freq) {
wiiuse_speaker_config(wm, freq, 0x00);
}
void wiiuse_speaker_volume(struct wiimote_t* wm, byte vol) {
wiiuse_speaker_config(wm, 0x0000, vol);
}

23
c/wiiuse/speaker.h Normal file
View File

@@ -0,0 +1,23 @@
#include "wiiuse.h"
#define WIIMOTE_GET_RUMBLE(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE) ? 0x01 : 0x00)
#define WM_CMD_SPEAKER_ENABLE 0x14
#define WM_CMD_STREAM_DATA 0x18
#define WM_CMD_SPEAKER_MUTE 0x19
#define WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE 0x04
#define WM_REG_SPEAKER 0x04a20001
static byte cfg[9] = {0x00, 0x00, 0x00, 0xdd, 0x40, 0x00, 0x00, 0x01, 0x01};
WIIUSE_EXPORT extern void wiiuse_speaker_enable(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_disable(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_mute(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_unmute(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_activate(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_deactivate(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_speaker_volume(struct wiimote_t* wm, byte vol);
WIIUSE_EXPORT extern void wiiuse_speaker_frequency(struct wiimote_t* wm, unsigned short freq);
WIIUSE_EXPORT extern void wiiuse_speaker_data(struct wiimote_t* wm, byte* data);

Binary file not shown.

Binary file not shown.

View File

@@ -1,2 +1 @@
copy Release\WiiUseJ.dll ..\..\..\java\main\native\ copy Release\WiiUseJ.dll ..\..\..\java\native\
pause

BIN
java/native/WiiUseJ.dll Normal file

Binary file not shown.

BIN
java/native/wiiuse.dll Normal file

Binary file not shown.