Project settings gecorrigeerd en basis voor wiimote speaker functionaliteit toegevoegd.

This commit is contained in:
2011-07-23 13:57:30 +00:00
parent 8ec09d9c86
commit bd8c575826
19 changed files with 260 additions and 202 deletions

View File

@@ -6,6 +6,7 @@
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574"> <cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" moduleId="org.eclipse.cdt.core.settings" name="Debug"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<macros> <macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiuse"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/> <stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros> </macros>
<externalSettings> <externalSettings>
@@ -23,24 +24,26 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="wiiuse" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug" postbuildStep="./copy.bat"> <configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1116435574." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.540248766" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.540248766" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.763602244" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.763602244" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
<builder buildPath="${workspace_loc:/Wiiuse/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1458906080" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> <builder buildPath="${workspace_loc:/Wiiuse/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1458906080" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.1226602461" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug"> <tool command="as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.1226602461" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.131768531" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> <inputType id="cdt.managedbuild.tool.gnu.assembler.input.131768531" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1802027" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1802027" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1760584596" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug"> <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1760584596" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.655662583" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.655662583" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.277209318" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.277209318" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.203394821" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.203394821" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
</option> </option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.993291047" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <option id="gnu.c.compiler.option.preprocessor.def.symbols.993291047" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WIIUSE_COMPILE_LIB"/> <listOptionValue builtIn="false" value="WIIUSE_COMPILE_LIB"/>
<listOptionValue builtIn="false" value="WITH_WIIUSE_DEBUG"/>
</option> </option>
<option id="gnu.c.compiler.option.misc.other.650784187" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2123798748" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2123798748" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.2136680964" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug"> <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.2136680964" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
@@ -50,10 +53,13 @@
<listOptionValue builtIn="false" value="Ws2_32"/> <listOptionValue builtIn="false" value="Ws2_32"/>
<listOptionValue builtIn="false" value="Setupapi"/> <listOptionValue builtIn="false" value="Setupapi"/>
</option> </option>
<option id="gnu.c.link.option.ldflags.1119328813" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="gnu.c.link.option.implname.339020882" name="Import Library name (-Wl,--out-implib=)" superClass="gnu.c.link.option.implname" value="${target}.lib" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.119816846" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.119816846" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType> </inputType>
<outputType id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.output.556110947" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.output"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1884243654" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug"> <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1884243654" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug">
<option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1243107261" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1243107261" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
@@ -820,6 +826,10 @@
</cconfiguration> </cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339"> <cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" moduleId="org.eclipse.cdt.core.settings" name="Release"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" moduleId="org.eclipse.cdt.core.settings" name="Release">
<macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiusegrapje"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros>
<externalSettings> <externalSettings>
<externalSetting> <externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Wiiuse"/> <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Wiiuse"/>
@@ -835,7 +845,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="wiiuse" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release" postbuildStep="./copy.bat" prebuildStep=""> <configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release" postbuildStep="./copy.bat" prebuildStep="">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.1074641339." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.1012515545" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.1012515545" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.834409978" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.834409978" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
@@ -847,7 +857,7 @@
<outputType id="cdt.managedbuild.tool.gnu.archiver.output.1238104425" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.archiver.output"/> <outputType id="cdt.managedbuild.tool.gnu.archiver.output.1238104425" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.archiver.output"/>
</tool> </tool>
<tool command="gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.982483224" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release"> <tool command="gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.982483224" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.508635058" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.508635058" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.so.release.option.debugging.level.818549324" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> <option id="gnu.c.compiler.mingw.so.release.option.debugging.level.818549324" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.489733690" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.489733690" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
@@ -865,6 +875,8 @@
<listOptionValue builtIn="false" value="Ws2_32"/> <listOptionValue builtIn="false" value="Ws2_32"/>
<listOptionValue builtIn="false" value="Setupapi"/> <listOptionValue builtIn="false" value="Setupapi"/>
</option> </option>
<option id="gnu.c.link.option.ldflags.1077843674" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="gnu.c.link.option.implname.1912270887" name="Import Library name (-Wl,--out-implib=)" superClass="gnu.c.link.option.implname" value="${target}.lib" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1240500014" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1240500014" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>

View File

@@ -1,4 +1,4 @@
#Wed Jul 20 20:10:42 CEST 2011 #Wed Jul 20 23:54:48 CEST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/delimiter=; environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.so.debug.1116435574/CPATH/operation=remove

View File

@@ -1,4 +1,3 @@
copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h
copy ..\src\speaker.h ..\..\WiiuseJ\src\speaker.h copy wiiuse.lib ..\..\WiiuseJ\lib\wiiuse.lib
copy wiiuse.dll ..\..\WiiuseJ\lib\wiiuse.dll
copy wiiuse.dll ..\..\Mimis\wiiuse.dll copy wiiuse.dll ..\..\Mimis\wiiuse.dll

View File

@@ -1,4 +1,3 @@
copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h copy ..\src\wiiuse.h ..\..\WiiuseJ\src\wiiuse.h
copy ..\src\speaker.h ..\..\WiiuseJ\src\speaker.h copy wiiuse.lib ..\..\WiiuseJ\lib\wiiuse.lib
copy wiiuse.dll ..\..\WiiuseJ\lib\wiiuse.dll
copy wiiuse.dll ..\..\Mimis\wiiuse.dll copy wiiuse.dll ..\..\Mimis\wiiuse.dll

View File

@@ -39,8 +39,6 @@
#define WIIMOTE_PI 3.14159265f #define WIIMOTE_PI 3.14159265f
//#define WITH_WIIUSE_DEBUG
/* Error output macros */ /* Error output macros */
#define WIIUSE_ERROR(fmt, ...) //fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__) #define WIIUSE_ERROR(fmt, ...) //fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__)
@@ -57,6 +55,7 @@
int i = strlen(file) - 1; \ int i = strlen(file) - 1; \
for (; i && (file[i] != '\\'); --i); \ for (; i && (file[i] != '\\'); --i); \
fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \ fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
fflush(stderr); \
} while (0) } while (0)
#else #else
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__) #define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)

View File

@@ -480,10 +480,11 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
#ifdef WITH_WIIUSE_DEBUG #ifdef WITH_WIIUSE_DEBUG
{ {
int i = 0; int i = 0;
printf("Read: "); fprintf(stderr, "[DEBUG] Read: ");
for (; i < req->size - req->wait; ++i) for (; i < req->size - req->wait; ++i)
printf("%x ", req->buf[i]); fprintf(stderr, "%x ", req->buf[i]);
printf("\n"); fprintf(stderr, "\n");
fflush(stderr);
} }
#endif #endif

View File

@@ -24,30 +24,17 @@ void wiiuse_speaker_unmute(struct wiimote_t* wm) {
wiiuse_send(wm, WM_CMD_SPEAKER_MUTE, &buf, 1); 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) { void wiiuse_speaker_activate(struct wiimote_t* wm) {
wiiuse_speaker_enable(wm); wiiuse_speaker_enable(wm);
wiiuse_speaker_mute(wm);
byte buf = 0x01;
wiiuse_write_data(wm, WM_REG_SPEAKER + 8, &buf, 1);
buf = 0x08;
wiiuse_write_data(wm, WM_REG_SPEAKER, &buf, 1);
wiiuse_speaker_config(wm);
buf = 0x01;
wiiuse_write_data(wm, WM_REG_SPEAKER + 7, &buf, 1);
wiiuse_speaker_unmute(wm); wiiuse_speaker_unmute(wm);
wiiuse_speaker_config(wm, 0x00, 0x00);
} }
void wiiuse_speaker_deactivate(struct wiimote_t* wm) { void wiiuse_speaker_deactivate(struct wiimote_t* wm) {
@@ -55,10 +42,28 @@ void wiiuse_speaker_deactivate(struct wiimote_t* wm) {
wiiuse_speaker_disable(wm); wiiuse_speaker_disable(wm);
} }
void wiiuse_speaker_frequency(struct wiimote_t* wm, unsigned short freq) { void wiiuse_speaker_format(struct wiimote_t* wm, byte format) {
wiiuse_speaker_config(wm, freq, 0x00); wm->speaker.format = format;
} }
void wiiuse_speaker_volume(struct wiimote_t* wm, byte vol) { void wiiuse_speaker_rate(struct wiimote_t* wm, double rate) {
wiiuse_speaker_config(wm, 0x0000, vol); // Check: pcm_sample_rate = 12000000 / rate_value adpcm_sample_rate = 6000000 / rate_value
wm->speaker.rate = 48000 / rate;
}
void wiiuse_speaker_volume(struct wiimote_t* wm, double vol) {
wm->speaker.vol = vol * WIIMOTE_GET_SPEAKER_MAX_VOLUME(wm);
}
void wiiuse_speaker_config(struct wiimote_t* wm) {
byte cfg[7] = {wm->speaker.format, 0x00, 0x00, wm->speaker.rate, 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);
} }

View File

@@ -1,6 +1,7 @@
#include "wiiuse.h" #include "wiiuse.h"
#define WIIMOTE_GET_RUMBLE(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE) ? 0x01 : 0x00) #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)
#define WM_CMD_SPEAKER_ENABLE 0x14 #define WM_CMD_SPEAKER_ENABLE 0x14
#define WM_CMD_STREAM_DATA 0x18 #define WM_CMD_STREAM_DATA 0x18
@@ -8,16 +9,4 @@
#define WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE 0x04 #define WM_CTRL_STATUS_BYTE1_SPEAKER_MUTE 0x04
#define WM_REG_SPEAKER 0x04a20001 #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);

View File

@@ -538,10 +538,11 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte
#ifdef WITH_WIIUSE_DEBUG #ifdef WITH_WIIUSE_DEBUG
{ {
int i = 0; int i = 0;
printf("Write data is: "); fprintf(stderr, "[DEBUG} Write data is: ");
for (; i < len; ++i) for (; i < len; ++i)
printf("%x ", data[i]); fprintf(stderr, "%x ", data[i]);
printf("\n"); fprintf(stderr, "\n");
fflush(stderr);
} }
#endif #endif
@@ -607,14 +608,15 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
#ifdef WITH_WIIUSE_DEBUG #ifdef WITH_WIIUSE_DEBUG
{ {
int x = 2; int x = 2;
printf("[DEBUG] (id %i) SEND: (%x) %.2x ", wm->unid, buf[0], buf[1]); fprintf(stderr, "[DEBUG] (id %i) SEND: (%x) %.2x ", wm->unid, buf[0], buf[1]);
#ifndef WIN32 #ifndef WIN32
for (; x < len+2; ++x) for (; x < len+2; ++x)
#else #else
for (; x < len+1; ++x) for (; x < len+1; ++x)
#endif #endif
printf("%.2x ", buf[x]); fprintf(stderr, "%.2x ", buf[x]);
printf("\n"); fprintf(stderr, "\n");
fflush(stderr);
} }
#endif #endif

View File

@@ -371,6 +371,16 @@ typedef struct ir_t {
} ir_t; } ir_t;
/**
* @struct speaker_t
*/
typedef struct speaker_t {
byte format;
byte vol;
byte rate;
} speaker_t;
/** /**
* @struct joystick_t * @struct joystick_t
* @brief Joystick calibration structure. * @brief Joystick calibration structure.
@@ -563,6 +573,7 @@ typedef struct wiimote_t {
WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ WCONST struct gforce_t gforce; /**< current gravity forces on each axis */
WCONST struct ir_t ir; /**< IR data */ WCONST struct ir_t ir; /**< IR data */
WCONST struct speaker_t speaker; /**< speaker */
WCONST unsigned short btns; /**< what buttons have just been pressed */ WCONST unsigned short btns; /**< what buttons have just been pressed */
WCONST unsigned short btns_held; /**< what buttons are being held down */ WCONST unsigned short btns_held; /**< what buttons are being held down */
@@ -643,6 +654,18 @@ WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int le
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold); WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold); WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
/* speaker.c */
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_format(struct wiimote_t* wm, byte format);
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);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -6,6 +6,7 @@
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348"> <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348" moduleId="org.eclipse.cdt.core.settings" name="Debug"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<macros> <macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiusej"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/> <stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros> </macros>
<externalSettings> <externalSettings>
@@ -23,7 +24,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="wiiusej" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug" postbuildStep="./copy.bat"> <configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1519811348." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.895681267" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.895681267" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1030487368" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1030487368" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
@@ -323,6 +324,7 @@
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158"> <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158" moduleId="org.eclipse.cdt.core.settings" name="Release"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158" moduleId="org.eclipse.cdt.core.settings" name="Release">
<macros> <macros>
<stringMacro name="target" type="VALUE_TEXT" value="wiiusej"/>
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/> <stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.6.0_26"/>
</macros> </macros>
<externalSettings> <externalSettings>
@@ -340,7 +342,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="dll" artifactName="wiiusej" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release" postbuildStep="./copy.bat"> <configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release" postbuildStep="./copy.bat">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.905874158." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1641725860" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1641725860" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.209964646" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.209964646" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
@@ -371,6 +373,7 @@
<listOptionValue builtIn="false" value="wiiuse"/> <listOptionValue builtIn="false" value="wiiuse"/>
</option> </option>
<option id="gnu.c.link.option.ldflags.1604848740" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="-Wl,--kill-at" valueType="string"/> <option id="gnu.c.link.option.ldflags.1604848740" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="-Wl,--kill-at" valueType="string"/>
<option id="gnu.c.link.option.soname.2103161002" name="Shared object name (-Wl,-soname=)" superClass="gnu.c.link.option.soname" value="" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.657886763" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.657886763" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>

View File

@@ -27,7 +27,7 @@
</dictionary> </dictionary>
<dictionary> <dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key> <key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/WiiuseJ/Debug}</value> <value>${workspace_loc:/WiiuseJ/Release}</value>
</dictionary> </dictionary>
<dictionary> <dictionary>
<key>org.eclipse.cdt.make.core.contents</key> <key>org.eclipse.cdt.make.core.contents</key>

Binary file not shown.

BIN
cpp/wiiusej/lib/wiiuse.lib Normal file

Binary file not shown.

View File

@@ -1,23 +0,0 @@
#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);

View File

@@ -371,6 +371,16 @@ typedef struct ir_t {
} ir_t; } ir_t;
/**
* @struct speaker_t
*/
typedef struct speaker_t {
byte format;
byte vol;
byte rate;
} speaker_t;
/** /**
* @struct joystick_t * @struct joystick_t
* @brief Joystick calibration structure. * @brief Joystick calibration structure.
@@ -563,6 +573,7 @@ typedef struct wiimote_t {
WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ WCONST struct gforce_t gforce; /**< current gravity forces on each axis */
WCONST struct ir_t ir; /**< IR data */ WCONST struct ir_t ir; /**< IR data */
WCONST struct speaker_t speaker; /**< speaker */
WCONST unsigned short btns; /**< what buttons have just been pressed */ WCONST unsigned short btns; /**< what buttons have just been pressed */
WCONST unsigned short btns_held; /**< what buttons are being held down */ WCONST unsigned short btns_held; /**< what buttons are being held down */
@@ -643,6 +654,18 @@ WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int le
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold); WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold); WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
/* speaker.c */
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_format(struct wiimote_t* wm, byte format);
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);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,53 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class wiiusej_WiiUseApi */
#ifndef _Included_wiiusej_WiiUseApi
#define _Included_wiiusej_WiiUseApi
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: wiiusej_WiiUseApi
* Method: activateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerVolume
* Signature: (IS)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume
(JNIEnv *, jobject, jint, jshort);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerFrequency
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFrequency
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: streamSpeakerData
* Signature: (I[S)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData
(JNIEnv *, jobject, jint, jshortArray);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -16,8 +16,6 @@
*/ */
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
#else
#endif #endif
#include "wiiusej_WiiUseApi.h" #include "wiiusej_WiiUseApi.h"
@@ -32,14 +30,14 @@
#define WIIMOTE_STATE_CONNECTED 0x0008 #define WIIMOTE_STATE_CONNECTED 0x0008
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s)) #define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s)) #define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s))
#define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \ #define WIIUSE_GET_IR_SENSITIVITY_CORRECTED(wm, lvl) \
do { \ do { \
if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
else *lvl = 0; \ else *lvl = 0; \
} while (0) } while (0)
/********************* VARIABLES DECLARATIONS *****************************/ /********************* VARIABLES DECLARATIONS *****************************/
@@ -407,9 +405,6 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
short leds = 0; short leds = 0;
jclass cls = (*env)->GetObjectClass(env, gath); jclass cls = (*env)->GetObjectClass(env, gath);
jmethodID mid; jmethodID mid;
struct nunchuk_t* nc;
struct guitar_hero_3_t* gh;
struct classic_ctrl_t* cl;
//printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes); //printf("avant poll, nbMaxwiimotes : %i \n",nbMaxWiimotes);
if (wiiuse_poll(wiimotes, nbMaxWiimotes)) { if (wiiuse_poll(wiimotes, nbMaxWiimotes)) {
@@ -499,7 +494,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
if (mid == 0) { if (mid == 0) {
return; return;
} }
nc = (nunchuk_t*)&wiimotes[i]->exp.nunchuk; struct nunchuk_t* nc = (nunchuk_t*)&wiimotes[i]->exp.nunchuk;
(*env)->CallVoidMethod(env, gath, mid, (*env)->CallVoidMethod(env, gath, mid,
/* buttons */ /* buttons */
@@ -524,7 +519,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
if (mid == 0) { if (mid == 0) {
return; return;
} }
gh = (guitar_hero_3_t*)&wiimotes[i]->exp.gh3; struct guitar_hero_3_t* gh = (guitar_hero_3_t*)&wiimotes[i]->exp.gh3;
(*env)->CallVoidMethod(env, gath, mid, (*env)->CallVoidMethod(env, gath, mid,
/* buttons */ /* buttons */
@@ -543,7 +538,7 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
if (mid == 0) { if (mid == 0) {
return; return;
} }
cl = (classic_ctrl_t*)&wiimotes[i]->exp.classic; struct classic_ctrl_t* cl = (classic_ctrl_t*)&wiimotes[i]->exp.classic;
(*env)->CallVoidMethod(env, gath, mid, (*env)->CallVoidMethod(env, gath, mid,
/* buttons */ /* buttons */
@@ -687,65 +682,69 @@ JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration
return jShorts; return jShorts;
}*/ }*/
/* Speaker */ /**
#include "speaker.h" * Speaker
/* */
void test(struct wiimote_t* wm) { JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_enableSpeaker(JNIEnv *env, jobject obj, jint id) {
int i; wiiuse_speaker_enable(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
byte data[20] = { }
0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,
0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3};
wiiuse_speaker_activate(wm);
for (i = 0; i < 50; ++i) {
wiiuse_speaker_data(wm, data);
}
wiiuse_speaker_deactivate(wm);
}*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_disableSpeaker(JNIEnv *env, jobject obj, jint id){
(JNIEnv *env, jobject obj, jint id) { wiiuse_speaker_disable(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_muteSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_mute(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_unmuteSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_unmute(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_activate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); wiiuse_speaker_activate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
} }
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker(JNIEnv *env, jobject obj, jint id) {
(JNIEnv *env, jobject obj, jint id) {
wiiuse_speaker_deactivate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id)); wiiuse_speaker_deactivate(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id));
} }
/*
void testen(struct wiimote_t* wm, unsigned short freq) {
if (freq > 0x0000) {
cfg[2] = freq & 0x00ff;
cfg[3] = (freq & 0xff00) >> 8;
}
printf("unaangepast %d\n", freq);
printf("speaker 0x%02x%02x\n", cfg[2], cfg[3]);
fflush(stdout);
wiiuse_write_data(wm, WM_REG_SPEAKER, cfg, 9);
}*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFormat(JNIEnv *env, jobject obj, jint id, jbyte format) {
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFrequency struct wiimote_t* wm = wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id);
(JNIEnv *env, jobject obj, jint id, jint freq) { wiiuse_speaker_config(wm);
wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq); wiiuse_speaker_format(wm, format);
//short a = ((short) freq) & 0xffff;
//printf("jni %d %d\n", freq, a);
//fflush(stdout);
//testen(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (unsigned short) freq);
} }
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerRate(JNIEnv *env, jobject obj, jint id, jint rate) {
(JNIEnv *env, jobject obj, jint id, jshort vol) { struct wiimote_t* wm = wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id);
wiiuse_speaker_frequency(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), vol); wiiuse_speaker_rate(wm, rate);
wiiuse_speaker_config(wm);
} }
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume(JNIEnv *env, jobject obj, jint id, jdouble vol) {
(JNIEnv *env, jobject obj, jint id, jshortArray sArray) { struct wiimote_t* wm = wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id);
wiiuse_speaker_volume(wm, vol);
wiiuse_speaker_config(wm);
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerConfig(JNIEnv *env, jobject obj, jint id, jbyte format, jint rate, jdouble vol) {
struct wiimote_t* wm = wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id);
wiiuse_speaker_format(wm, format);
wiiuse_speaker_rate(wm, rate);
wiiuse_speaker_volume(wm, vol);
wiiuse_speaker_config(wm);
}
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData(JNIEnv *env, jobject obj, jint id, jbyteArray jbArray) {
jbyte *jbData = (*env)->GetByteArrayElements(env, jbArray, JNI_FALSE);
/* Todo: Check for data loss by using signed vs unsigned bytes */
/*int length = (int) (*env)->GetArrayLength(env, jbArray);
byte data[length];
int i = 0; int i = 0;
jshort *jShorts = (*env)->GetShortArrayElements(env, sArray, JNI_FALSE); for (i = 0; i < length; ++i) {
byte data[sizeof(jShorts)]; data[i] = (byte) jbData[i];
for (i = 0; i < sizeof(jShorts); ++i) { }*/
data[i] = (byte) jShorts[i]; wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), (byte*) jbData);
} (*env)->ReleaseByteArrayElements(env, jbArray, jbData, JNI_FALSE);
wiiuse_speaker_data(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), data);
(*env)->ReleaseShortArrayElements(env, sArray, jShorts, JNI_FALSE);
} }

View File

@@ -273,12 +273,92 @@ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_specialPoll
/* /*
* Class: wiiusej_WiiUseApi * Class: wiiusej_WiiUseApi
* Method: getCalibration * Method: enableSpeaker
* Signature: (I)[S * Signature: (I)V
*/ */
JNIEXPORT jshortArray JNICALL Java_wiiusej_WiiUseApi_getCalibration JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_enableSpeaker
(JNIEnv *, jobject, jint); (JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: disableSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_disableSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: muteSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_muteSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: unmuteSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_unmuteSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: activateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_activateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: deactivateSpeaker
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_deactivateSpeaker
(JNIEnv *, jobject, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerFormat
* Signature: (IB)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerFormat
(JNIEnv *, jobject, jint, jbyte);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerRate
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerRate
(JNIEnv *, jobject, jint, jint);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerVolume
* Signature: (ID)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerVolume
(JNIEnv *, jobject, jint, jdouble);
/*
* Class: wiiusej_WiiUseApi
* Method: setSpeakerConfig
* Signature: (IBID)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setSpeakerConfig
(JNIEnv *, jobject, jint, jbyte, jint, jdouble);
/*
* Class: wiiusej_WiiUseApi
* Method: streamSpeakerData
* Signature: (I[B)V
*/
JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_streamSpeakerData
(JNIEnv *, jobject, jint, jbyteArray);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif