2008-02-27, 20:13
Hello,
This patch add extra functionality to the existing Wiimote support in XBMC. It adds the following:
- Changes "WiiRemote" in strings to "Wiimote" (the correct name for the device)
- Adds popup notification on successful Wiimote connection, including current battery level in the Wiimote {1}
- Adds popup notification on Wiimote disconnection
- Adds popup notification when the CWiiRemote class cannot find the Bluetooth radio, after trying to enable Wiimote support
- Enables LEDs 1 and 4 on connection, rather than just LED 1. This allows you to identify quickly whether you are connected to XBMC or a Wii, as this LED combination never occurs on the Wii.
As a result there are some extra strings in strings.xml, #21887 - #21891. I've only included English strings.
This applies to current HEAD, at the time of writing this was r11827.
Screenshot
{1}:
Patch
This patch add extra functionality to the existing Wiimote support in XBMC. It adds the following:
- Changes "WiiRemote" in strings to "Wiimote" (the correct name for the device)
- Adds popup notification on successful Wiimote connection, including current battery level in the Wiimote {1}
- Adds popup notification on Wiimote disconnection
- Adds popup notification when the CWiiRemote class cannot find the Bluetooth radio, after trying to enable Wiimote support
- Enables LEDs 1 and 4 on connection, rather than just LED 1. This allows you to identify quickly whether you are connected to XBMC or a Wii, as this LED combination never occurs on the Wii.
As a result there are some extra strings in strings.xml, #21887 - #21891. I've only included English strings.
This applies to current HEAD, at the time of writing this was r11827.
Screenshot
{1}:
Patch
Code:
Index: guilib/common/WiiRemote.cpp
===================================================================
--- guilib/common/WiiRemote.cpp (revision 11827)
+++ guilib/common/WiiRemote.cpp (working copy)
@@ -19,6 +19,10 @@
***************************************************************************/
#ifdef HAS_CWIID
#include "WiiRemote.h"
+
+// To avoid recursive include issues, we need to include these here. I know it's naughty... --micolous (2008-02-28)
+#include "../../xbmc/Application.h"
+#include "../LocalizeStrings.h"
CWiiRemote g_WiiRemote;
CCriticalSection CWiiRemote::m_lock;
@@ -174,7 +178,7 @@
//Have the first LED on the Wiiremote shine when connected
ToggleBit(m_ledState, CWIID_LED1_ON);
-
+ ToggleBit(m_ledState, CWIID_LED4_ON);
CSingleLock lock (m_lock);
CLog::Log(LOGNOTICE, "Sucessfully initialized the Wiiremote Lib");
@@ -409,6 +413,9 @@
if (hci_get_route(NULL) < 0)
{
m_enabled = false;
+ CStdString strMsgTitle = g_localizeStrings.Get(21889);
+ CStdString strMsgText = g_localizeStrings.Get(21886);
+ g_application.m_guiDialogKaiToast.QueueNotification(strMsgTitle,strMsgText);
CLog::Log(LOGERROR, "Cannot enable Wiiremote support because no bluetooth device was found");
}
else
@@ -464,6 +471,20 @@
{
EnterCriticalSection(m_lock);
SetupWiiRemote();
+ // get battery state etc.
+ cwiid_state wiimote_state;
+ int err = cwiid_get_state(m_wiiremoteHandle, &wiimote_state);
+ if (!err) {
+ CStdString strMsgTitle = g_localizeStrings.Get(21887);
+ CStdString strMsgTextRaw = g_localizeStrings.Get(21888);
+ CStdString strMsgText;
+
+ strMsgText.Format(strMsgTextRaw.c_str(),static_cast<int>(((float)(wiimote_state.battery)/CWIID_BATTERY_MAX)*100.0));
+ g_application.m_guiDialogKaiToast.QueueNotification(strMsgTitle,strMsgText);
+ } else {
+ CLog::Log(LOGERROR, "Problem probing for status of wiimote; cwiid_get_state returned non-zero");
+ }
+
#ifdef CWIID_OLD
/* CheckIn to say that this is the last msg, If this isn't called it could give issues if we Connects -> Disconnect and then try to connect again
the CWIID_OLD hack would automaticly disconnect the wiiremote as the lastmsg is too old. */
@@ -471,6 +492,7 @@
#endif
m_connected = true;
LeaveCriticalSection(m_lock);
+
CLog::Log(LOGNOTICE, "Sucessfully connected a Wiiremote");
return true;
}
@@ -498,6 +520,9 @@
if (m_connected) //It shouldn't be enabled at the same time as it is connected
{
cwiid_disconnect(m_wiiremoteHandle);
+ CStdString strMsgTitle = g_localizeStrings.Get(21890);
+ CStdString strMsgText = g_localizeStrings.Get(21891);
+ g_application.m_guiDialogKaiToast.QueueNotification(strMsgTitle,strMsgText);
CLog::Log(LOGNOTICE, "Sucessfully disconnected a Wiiremote");
}
m_connected = false;
Index: language/English/strings.xml
===================================================================
--- language/English/strings.xml (revision 11827)
+++ language/English/strings.xml (working copy)
@@ -1873,8 +1873,16 @@
<string id="21881">Enable UPnP Renderer</string>
<string id="21882">Attempt to skip introduction before DVD Menu</string>
<string id="21883">Ripped Audio CDs</string>
- <string id="21884">WiiRemote</string>
+
+ <!-- WiiRemote/Wiimote Input Device -->
+ <string id="21884">Wiimote</string>
<string id="21885">Enable mouse emulation</string>
+ <string id="21886">No Bluetooth radio found</string>
+ <string id="21887">Wiimote connected</string>
+ <string id="21888">%i%% battery remaining</string>
+ <string id="21889">Wiimote unavailable</string>
+ <string id="21890">Wiimote disconnected</string>
+ <string id="21891">Press 1 and 2 to reconnect</string>
<!-- strings 21900 thru 21999 reserved for slideshow info -->
<string id="22000">Update library on startup</string>