WiimoteReal/IOAndroid: Don't "find" already in-use Wii remotes.

This commit is contained in:
Jordan Woyak 2025-09-30 18:29:00 -05:00
parent df809959d0
commit c84d30c782
2 changed files with 20 additions and 1 deletions

View File

@ -5,6 +5,8 @@
#include <jni.h> #include <jni.h>
#include <fmt/format.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/Flag.h" #include "Common/Flag.h"
@ -37,7 +39,12 @@ void WiimoteScannerAndroid::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
env->CallStaticBooleanMethod(s_adapter_class, openadapter_func)) env->CallStaticBooleanMethod(s_adapter_class, openadapter_func))
{ {
for (int i = 0; i < MAX_WIIMOTES; ++i) for (int i = 0; i < MAX_WIIMOTES; ++i)
{
if (!IsNewWiimote(WiimoteAndroid::GetIdFromDolphinBarIndex(i)))
continue;
found_wiimotes.emplace_back(new WiimoteAndroid(i)); found_wiimotes.emplace_back(new WiimoteAndroid(i));
}
} }
} }
@ -50,6 +57,16 @@ WiimoteAndroid::~WiimoteAndroid()
Shutdown(); Shutdown();
} }
std::string WiimoteAndroid::GetId() const
{
return GetIdFromDolphinBarIndex(m_mayflash_index);
}
std::string WiimoteAndroid::GetIdFromDolphinBarIndex(int index)
{
return fmt::format("Android {}", index);
}
// Connect to a Wiimote with a known address. // Connect to a Wiimote with a known address.
bool WiimoteAndroid::ConnectInternal() bool WiimoteAndroid::ConnectInternal()
{ {

View File

@ -17,7 +17,9 @@ class WiimoteAndroid final : public Wiimote
public: public:
WiimoteAndroid(int index); WiimoteAndroid(int index);
~WiimoteAndroid() override; ~WiimoteAndroid() override;
std::string GetId() const override { return "Android " + std::to_string(m_mayflash_index); }
std::string GetId() const override;
static std::string GetIdFromDolphinBarIndex(int index);
protected: protected:
bool ConnectInternal() override; bool ConnectInternal() override;