Skip to content

Commit

Permalink
Added ability to deactivate WMP
Browse files Browse the repository at this point in the history
  • Loading branch information
Flafla2 committed Sep 3, 2015
1 parent 82da5be commit 4ec0e04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Assets/Scripts/WiimoteDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ void OnGUI()
wiimote.RequestIdentifyWiiMotionPlus();
if ((wiimote.wmp_attached || wiimote.Type == WiimoteType.PROCONTROLLER) && GUILayout.Button("Activate WMP"))
wiimote.ActivateWiiMotionPlus();
if ((wiimote.current_ext == ExtensionController.MOTIONPLUS ||
wiimote.current_ext == ExtensionController.MOTIONPLUS_CLASSIC ||
wiimote.current_ext == ExtensionController.MOTIONPLUS_NUNCHUCK) && GUILayout.Button("Deactivate WMP"))
wiimote.DeactivateWiiMotionPlus();

GUILayout.Label("Calibrate Accelerometer");
GUILayout.BeginHorizontal();
Expand Down
8 changes: 8 additions & 0 deletions Assets/Wiimote/Scripts/Wiimote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ public bool ActivateWiiMotionPlus()
return true;
}

public bool DeactivateWiiMotionPlus()
{
if (current_ext != ExtensionController.MOTIONPLUS && current_ext != ExtensionController.MOTIONPLUS_CLASSIC && current_ext != ExtensionController.MOTIONPLUS_NUNCHUCK)
Debug.LogWarning("There is a request to deactivate the Wii Motion Plus even though it has not been activated! Trying anyway.");

return SendRegisterWriteRequest(RegisterType.CONTROL, 0xA400F0, new byte[] { 0x55 }) > 0;
}

/// \brief Attempts to activate any connected extension controller
/// \sa RequestIdentifyExtension(), StatusData::ext_connected
/// \return If the activation request was successfully sent to the Wii Remote.
Expand Down
3 changes: 3 additions & 0 deletions Assets/Wiimote/Scripts/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ WiimoteApi::Wiimote::wmp_attached to see if a Wii Motion Plus is attached. If y
using WiimoteApi::Wiimote::ActivateWiiMotionPlus(). This makes the Wii Motion Plus behave as an extension controller (such as the
nunchuck or the classic controller). See *Reading from Extension Controllers* for details.

If you want to deactivate the Wii Motion Plus (and use any extension controller connected to it such as a Nunchuck or Classic
Controller) you can use WiimoteApi::Wiimote::DeactivateWiiMotionPlus().

<b>Example:</b>
~~~~~~~~~~~~~~~{.cs}
Wiimote remote; // Initialized previously
Expand Down

0 comments on commit 4ec0e04

Please sign in to comment.