mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
[Linux/MacOS] Further Wiimote changes for parity with Windows (#945)
This commit is contained in:
parent
d8b9a74d86
commit
5e84862e28
@ -976,7 +976,7 @@ void InputSettings2::on_controller_settings(wxCommandEvent& event)
|
||||
|
||||
case InputAPI::Keyboard: break;
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
case InputAPI::Wiimote: {
|
||||
const auto wiimote = std::dynamic_pointer_cast<NativeWiimoteController>(controller);
|
||||
wxASSERT(wiimote);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "gui/components/wxInputDraw.h"
|
||||
#include "gui/input/InputAPIAddWindow.h"
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
|
||||
WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxPoint& position, std::shared_ptr<NativeWiimoteController> controller)
|
||||
: wxDialog(parent, wxID_ANY, _("Controller settings"), position, wxDefaultSize,
|
||||
@ -56,6 +56,7 @@ WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxP
|
||||
// Motion
|
||||
m_use_motion = new wxCheckBox(box, wxID_ANY, _("Use motion"));
|
||||
m_use_motion->SetValue(m_settings.motion);
|
||||
m_use_motion->SetValue(m_settings.motion);
|
||||
m_use_motion->Enable(m_controller->has_motion());
|
||||
row_sizer->Add(m_use_motion, 0, wxALL, 5);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/timer.h>
|
||||
|
@ -62,6 +62,7 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if (ENABLE_WIIMOTE)
|
||||
target_compile_definitions(CemuInput PUBLIC SUPPORTS_WIIMOTE)
|
||||
target_sources(CemuInput PRIVATE
|
||||
api/Wiimote/WiimoteControllerProvider.h
|
||||
api/Wiimote/WiimoteControllerProvider.cpp
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "input/api/XInput/XInputControllerProvider.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAS_HIDAPI) || BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
#include "input/api/Wiimote/WiimoteControllerProvider.h"
|
||||
#endif
|
||||
|
||||
|
@ -5,8 +5,8 @@ static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306;
|
||||
static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330;
|
||||
static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22;
|
||||
|
||||
HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier)
|
||||
: m_handle(dev), m_identifier(identifier) {
|
||||
HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path)
|
||||
: m_handle(dev), m_identifier(identifier), m_path(path) {
|
||||
|
||||
}
|
||||
|
||||
@ -35,11 +35,12 @@ std::vector<WiimoteDevicePtr> HidapiWiimote::get_devices() {
|
||||
cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, boost::nowide::narrow(hid_error(nullptr)));
|
||||
}
|
||||
else {
|
||||
hid_set_nonblocking(dev, true);
|
||||
// Enough to have a unique id for each device within a session
|
||||
uint64_t id = (static_cast<uint64>(it->interface_number) << 32) |
|
||||
(static_cast<uint64>(it->usage_page) << 16) |
|
||||
(it->usage);
|
||||
wiimote_devices.push_back(std::make_shared<HidapiWiimote>(dev, id));
|
||||
wiimote_devices.push_back(std::make_shared<HidapiWiimote>(dev, id, it->path));
|
||||
}
|
||||
}
|
||||
hid_free_enumeration(device_enumeration);
|
||||
@ -47,7 +48,8 @@ std::vector<WiimoteDevicePtr> HidapiWiimote::get_devices() {
|
||||
}
|
||||
|
||||
bool HidapiWiimote::operator==(WiimoteDevice& o) const {
|
||||
return m_identifier == static_cast<HidapiWiimote&>(o).m_identifier;
|
||||
auto const& other_mote = static_cast<HidapiWiimote const&>(o);
|
||||
return m_identifier == other_mote.m_identifier && other_mote.m_path == m_path;
|
||||
}
|
||||
|
||||
HidapiWiimote::~HidapiWiimote() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
class HidapiWiimote : public WiimoteDevice {
|
||||
public:
|
||||
HidapiWiimote(hid_device* dev, uint64_t identifier);
|
||||
HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path);
|
||||
~HidapiWiimote() override;
|
||||
|
||||
bool write_data(const std::vector<uint8> &data) override;
|
||||
@ -16,7 +16,8 @@ public:
|
||||
|
||||
private:
|
||||
hid_device* m_handle;
|
||||
uint64_t m_identifier;
|
||||
const uint64_t m_identifier;
|
||||
const std::string m_path;
|
||||
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "input/api/Controller.h"
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
#include "input/api/Wiimote/NativeWiimoteController.h"
|
||||
#endif
|
||||
|
||||
@ -131,15 +131,15 @@ bool EmulatedController::has_second_motion() const
|
||||
if(controller->use_motion())
|
||||
{
|
||||
// if wiimote has nunchuck connected, we use its acceleration
|
||||
#if BOOST_OS_WINDOWS
|
||||
if(controller->api() == InputAPI::Wiimote)
|
||||
#if SUPPORTS_WIIMOTE
|
||||
if(controller->api() == InputAPI::Wiimote)
|
||||
{
|
||||
if(((NativeWiimoteController*)controller.get())->get_extension() == NativeWiimoteController::Nunchuck)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
motion++;
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ MotionSample EmulatedController::get_second_motion_data() const
|
||||
if (controller->use_motion())
|
||||
{
|
||||
// if wiimote has nunchuck connected, we use its acceleration
|
||||
#if BOOST_OS_WINDOWS
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
if (controller->api() == InputAPI::Wiimote)
|
||||
{
|
||||
if (((NativeWiimoteController*)controller.get())->get_extension() == NativeWiimoteController::Nunchuck)
|
||||
@ -211,12 +211,11 @@ void EmulatedController::add_controller(std::shared_ptr<ControllerBase> controll
|
||||
{
|
||||
controller->connect();
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
if (const auto wiimote = std::dynamic_pointer_cast<NativeWiimoteController>(controller)) {
|
||||
#ifdef SUPPORTS_WIIMOTE
|
||||
if (const auto wiimote = std::dynamic_pointer_cast<NativeWiimoteController>(controller)) {
|
||||
wiimote->set_player_index(m_player_index);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_controllers.emplace_back(std::move(controller));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user