diff options
| author | dapetcu21 <dapetcu21@gmail.com> | 2010-07-05 13:51:01 +0000 |
|---|---|---|
| committer | dapetcu21 <dapetcu21@gmail.com> | 2010-07-05 13:51:01 +0000 |
| commit | c8ddcb9df151ed68fe5cc0a60b16754f9390a837 (patch) | |
| tree | 4be2c424fc695cbf590cd9a19cd59243ce5cc8b0 /Source | |
| parent | ca827b99309b0aea15df07a176ab3cf3c5840d95 (diff) | |
Added nunchuck through UDP support in the new plugin.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5836 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
7 files changed, 65 insertions, 3 deletions
diff --git a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj index 01c0ade09d..1c017b1bb1 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj +++ b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj @@ -603,6 +603,14 @@ RelativePath=".\Src\WiimoteEmu\Attachment\Nunchuk.h" > </File> + <File + RelativePath=".\Src\WiimoteEmu\Attachment\UDPNunchuk.cpp" + > + </File> + <File + RelativePath=".\Src\WiimoteEmu\Attachment\UDPNunchuk.h" + > + </File> </Filter> </Filter> <Filter diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/SConscript b/Source/Plugins/Plugin_WiimoteNew/Src/SConscript index 1460385bbf..ed6a48c771 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/SConscript +++ b/Source/Plugins/Plugin_WiimoteNew/Src/SConscript @@ -11,6 +11,7 @@ files = [ 'WiimoteEmu/Attachment/Classic.cpp', 'WiimoteEmu/Attachment/Attachment.cpp', 'WiimoteEmu/Attachment/Nunchuk.cpp', + 'WiimoteEmu/Attachment/UDPNunchuk.cpp', 'WiimoteEmu/Attachment/Drums.cpp', 'WiimoteEmu/Attachment/Guitar.cpp', 'WiimoteEmu/EmuSubroutines.cpp', diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h index 94175a2634..d5011f893e 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h @@ -15,7 +15,7 @@ public: virtual void GetState( u8* const data, const bool focus = true ) {} std::string GetName() const; - const char* const name; + const char* name; std::vector<u8> reg; }; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h index fecc101e10..6531568c85 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h @@ -1,5 +1,7 @@ -#include "Attachment.h" +#ifndef NUNCHUCK_H +#define NUNCHUCK_H +#include "Attachment.h" namespace WiimoteEmu { @@ -8,7 +10,7 @@ class Nunchuk : public Attachment { public: Nunchuk(); - void GetState( u8* const data, const bool focus ); + virtual void GetState( u8* const data, const bool focus ); private: Tilt* m_tilt; @@ -23,3 +25,5 @@ private: }; } + +#endif
\ No newline at end of file diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp new file mode 100644 index 0000000000..d84c7d04ae --- /dev/null +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp @@ -0,0 +1,26 @@ +#include "UDPNunchuk.h"
+#include "UDPWrapper.h"
+#include "UDPWiimote.h"
+
+#define NUNCHUK_C 0x02 +#define NUNCHUK_Z 0x01
+
+namespace WiimoteEmu +{
+
+void UDPNunchuk::GetState( u8* const data, const bool focus )
+{
+ Nunchuk::GetState(data,focus);
+ if (!(wrp->inst)) return;
+
+ wm_extension* const ncdata = (wm_extension*)data;
+ u8 mask;
+ float x,y;
+ wrp->inst->getNunchuck(x,y,mask);
+ if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
+ if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
+ ncdata->jx=u8(0x80+x*127);
+ ncdata->jy=u8(0x80+y*127);
+}
+
+}
\ No newline at end of file diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h new file mode 100644 index 0000000000..e3b951cea5 --- /dev/null +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h @@ -0,0 +1,21 @@ +#ifndef UDPNUNCHUCK_H
+#define UDPNUNCHUCK_H
+
+#include "Nunchuk.h"
+ +class UDPWrapper; + +namespace WiimoteEmu +{ + +class UDPNunchuk : public Nunchuk +{ +public: + UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp ) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p + virtual void GetState( u8* const data, const bool focus );
+private:
+ UDPWrapper * wrp;
+};
+
+}
+#endif
\ No newline at end of file diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp index 24da0a828f..cee3863ac9 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp @@ -3,6 +3,7 @@ #include "Attachment/Nunchuk.h" #include "Attachment/Guitar.h" #include "Attachment/Drums.h" +#include "Attachment/UDPNunchuk.h" #include "WiimoteEmu.h" #include "WiimoteHid.h" @@ -292,6 +293,7 @@ Wiimote::Wiimote( const unsigned int index ) m_extension->attachments.push_back( new WiimoteEmu::Classic() ); m_extension->attachments.push_back( new WiimoteEmu::Guitar() ); m_extension->attachments.push_back( new WiimoteEmu::Drums() ); + m_extension->attachments.push_back( new WiimoteEmu::UDPNunchuk(m_udp) ); // rumble groups.push_back( m_rumble = new ControlGroup( "Rumble" ) ); |
