mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +01:00
WiimoteEmu: Add user-accessible controls that report the desired state of the IR camera objects.
This commit is contained in:
parent
c3903fcc7e
commit
617fcc3cf8
@ -49,6 +49,7 @@
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IMUCursor.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IRPassthrough.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
|
||||
@ -250,6 +251,8 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), m_bt_device_index(i
|
||||
_trans("Camera field of view (affects sensitivity of pointing).")},
|
||||
fov_default.y, 0.01, 180);
|
||||
|
||||
groups.emplace_back(m_ir_passthrough = new ControllerEmu::IRPassthrough(
|
||||
IR_PASSTHROUGH_GROUP, _trans("Point (Passthrough)")));
|
||||
groups.emplace_back(m_imu_accelerometer = new ControllerEmu::IMUAccelerometer(
|
||||
ACCELEROMETER_GROUP, _trans("Accelerometer")));
|
||||
groups.emplace_back(m_imu_gyroscope =
|
||||
@ -360,6 +363,8 @@ ControllerEmu::ControlGroup* Wiimote::GetWiimoteGroup(WiimoteGroup group) const
|
||||
return m_imu_gyroscope;
|
||||
case WiimoteGroup::IMUPoint:
|
||||
return m_imu_ir;
|
||||
case WiimoteGroup::IRPassthrough:
|
||||
return m_ir_passthrough;
|
||||
default:
|
||||
ASSERT(false);
|
||||
return nullptr;
|
||||
@ -447,6 +452,33 @@ void Wiimote::UpdateButtonsStatus(const DesiredWiimoteState& target_state)
|
||||
m_status.buttons.hex = target_state.buttons.hex & ButtonData::BUTTON_MASK;
|
||||
}
|
||||
|
||||
static std::array<CameraPoint, CameraLogic::NUM_POINTS>
|
||||
GetPassthroughCameraPoints(ControllerEmu::IRPassthrough* ir_passthrough)
|
||||
{
|
||||
std::array<CameraPoint, CameraLogic::NUM_POINTS> camera_points;
|
||||
for (size_t i = 0; i < camera_points.size(); ++i)
|
||||
{
|
||||
const ControlState size = ir_passthrough->GetObjectSize(i);
|
||||
if (size <= 0.0f)
|
||||
continue;
|
||||
|
||||
const ControlState x = ir_passthrough->GetObjectPositionX(i);
|
||||
const ControlState y = ir_passthrough->GetObjectPositionY(i);
|
||||
|
||||
camera_points[i].position.x =
|
||||
std::clamp(std::lround(x * ControlState(CameraLogic::CAMERA_RES_X - 1)), long(0),
|
||||
long(CameraLogic::CAMERA_RES_X - 1));
|
||||
camera_points[i].position.y =
|
||||
std::clamp(std::lround(y * ControlState(CameraLogic::CAMERA_RES_Y - 1)), long(0),
|
||||
long(CameraLogic::CAMERA_RES_Y - 1));
|
||||
camera_points[i].size =
|
||||
std::clamp(std::lround(size * ControlState(CameraLogic::MAX_POINT_SIZE)), long(0),
|
||||
long(CameraLogic::MAX_POINT_SIZE));
|
||||
}
|
||||
|
||||
return camera_points;
|
||||
}
|
||||
|
||||
void Wiimote::BuildDesiredWiimoteState(DesiredWiimoteState* target_state,
|
||||
SensorBarState sensor_bar_state)
|
||||
{
|
||||
@ -470,7 +502,11 @@ void Wiimote::BuildDesiredWiimoteState(DesiredWiimoteState* target_state,
|
||||
ConvertAccelData(GetTotalAcceleration(), ACCEL_ZERO_G << 2, ACCEL_ONE_G << 2);
|
||||
|
||||
// Calculate IR camera state.
|
||||
if (sensor_bar_state == SensorBarState::Enabled)
|
||||
if (m_ir_passthrough->enabled)
|
||||
{
|
||||
target_state->camera_points = GetPassthroughCameraPoints(m_ir_passthrough);
|
||||
}
|
||||
else if (sensor_bar_state == SensorBarState::Enabled)
|
||||
{
|
||||
target_state->camera_points = CameraLogic::GetCameraPoints(
|
||||
GetTotalTransformation(),
|
||||
|
@ -34,6 +34,7 @@ class Force;
|
||||
class IMUAccelerometer;
|
||||
class IMUGyroscope;
|
||||
class IMUCursor;
|
||||
class IRPassthrough;
|
||||
class ModifySettingsButton;
|
||||
class Output;
|
||||
class Tilt;
|
||||
@ -59,6 +60,7 @@ enum class WiimoteGroup
|
||||
IMUAccelerometer,
|
||||
IMUGyroscope,
|
||||
IMUPoint,
|
||||
IRPassthrough,
|
||||
};
|
||||
|
||||
enum class NunchukGroup;
|
||||
@ -121,6 +123,7 @@ public:
|
||||
static constexpr const char* ACCELEROMETER_GROUP = "IMUAccelerometer";
|
||||
static constexpr const char* GYROSCOPE_GROUP = "IMUGyroscope";
|
||||
static constexpr const char* IR_GROUP = "IR";
|
||||
static constexpr const char* IR_PASSTHROUGH_GROUP = "IRPassthrough";
|
||||
|
||||
static constexpr const char* A_BUTTON = "A";
|
||||
static constexpr const char* B_BUTTON = "B";
|
||||
@ -300,6 +303,7 @@ private:
|
||||
ControllerEmu::IMUAccelerometer* m_imu_accelerometer;
|
||||
ControllerEmu::IMUGyroscope* m_imu_gyroscope;
|
||||
ControllerEmu::IMUCursor* m_imu_ir;
|
||||
ControllerEmu::IRPassthrough* m_ir_passthrough;
|
||||
|
||||
ControllerEmu::SettingValue<bool> m_sideways_setting;
|
||||
ControllerEmu::SettingValue<bool> m_upright_setting;
|
||||
|
@ -504,6 +504,7 @@
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\IMUAccelerometer.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\IMUCursor.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\IMUGyroscope.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\IRPassthrough.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\MixedTriggers.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\ModifySettingsButton.h" />
|
||||
<ClInclude Include="InputCommon\ControllerEmu\ControlGroup\Slider.h" />
|
||||
@ -1162,6 +1163,7 @@
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\IMUAccelerometer.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\IMUCursor.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\IMUGyroscope.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\IRPassthrough.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\MixedTriggers.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\ModifySettingsButton.cpp" />
|
||||
<ClCompile Include="InputCommon\ControllerEmu\ControlGroup\Slider.cpp" />
|
||||
|
@ -48,6 +48,8 @@ void WiimoteEmuMotionControlIMU::CreateMainLayout()
|
||||
auto* groups_layout = new QHBoxLayout();
|
||||
groups_layout->addWidget(
|
||||
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUPoint)));
|
||||
groups_layout->addWidget(
|
||||
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IRPassthrough)));
|
||||
groups_layout->addWidget(CreateGroupBox(
|
||||
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUAccelerometer)));
|
||||
groups_layout->addWidget(
|
||||
|
@ -37,6 +37,8 @@ add_library(inputcommon
|
||||
ControllerEmu/ControlGroup/IMUCursor.h
|
||||
ControllerEmu/ControlGroup/IMUGyroscope.cpp
|
||||
ControllerEmu/ControlGroup/IMUGyroscope.h
|
||||
ControllerEmu/ControlGroup/IRPassthrough.cpp
|
||||
ControllerEmu/ControlGroup/IRPassthrough.h
|
||||
ControllerEmu/ControlGroup/MixedTriggers.cpp
|
||||
ControllerEmu/ControlGroup/MixedTriggers.h
|
||||
ControllerEmu/ControlGroup/ModifySettingsButton.cpp
|
||||
|
@ -49,7 +49,8 @@ enum class GroupType
|
||||
Shake,
|
||||
IMUAccelerometer,
|
||||
IMUGyroscope,
|
||||
IMUCursor
|
||||
IMUCursor,
|
||||
IRPassthrough,
|
||||
};
|
||||
|
||||
class ControlGroup
|
||||
|
@ -0,0 +1,51 @@
|
||||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IRPassthrough.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
IRPassthrough::IRPassthrough(std::string name_, std::string ui_name_)
|
||||
: ControlGroup(std::move(name_), std::move(ui_name_), GroupType::IRPassthrough,
|
||||
ControlGroup::DefaultValue::Disabled)
|
||||
{
|
||||
AddInput(Translatability::Translate, _trans("Object 1 X"));
|
||||
AddInput(Translatability::Translate, _trans("Object 1 Y"));
|
||||
AddInput(Translatability::Translate, _trans("Object 1 Size"));
|
||||
AddInput(Translatability::Translate, _trans("Object 2 X"));
|
||||
AddInput(Translatability::Translate, _trans("Object 2 Y"));
|
||||
AddInput(Translatability::Translate, _trans("Object 2 Size"));
|
||||
AddInput(Translatability::Translate, _trans("Object 3 X"));
|
||||
AddInput(Translatability::Translate, _trans("Object 3 Y"));
|
||||
AddInput(Translatability::Translate, _trans("Object 3 Size"));
|
||||
AddInput(Translatability::Translate, _trans("Object 4 X"));
|
||||
AddInput(Translatability::Translate, _trans("Object 4 Y"));
|
||||
AddInput(Translatability::Translate, _trans("Object 4 Size"));
|
||||
}
|
||||
|
||||
ControlState IRPassthrough::GetObjectPositionX(size_t object_index) const
|
||||
{
|
||||
return controls[object_index * 3 + 0]->GetState();
|
||||
}
|
||||
|
||||
ControlState IRPassthrough::GetObjectPositionY(size_t object_index) const
|
||||
{
|
||||
return controls[object_index * 3 + 1]->GetState();
|
||||
}
|
||||
|
||||
ControlState IRPassthrough::GetObjectSize(size_t object_index) const
|
||||
{
|
||||
return controls[object_index * 3 + 2]->GetState();
|
||||
}
|
||||
|
||||
} // namespace ControllerEmu
|
@ -0,0 +1,23 @@
|
||||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class IRPassthrough : public ControlGroup
|
||||
{
|
||||
public:
|
||||
IRPassthrough(std::string name, std::string ui_name);
|
||||
|
||||
ControlState GetObjectPositionX(size_t object_index) const;
|
||||
ControlState GetObjectPositionY(size_t object_index) const;
|
||||
ControlState GetObjectSize(size_t object_index) const;
|
||||
};
|
||||
} // namespace ControllerEmu
|
Loading…
x
Reference in New Issue
Block a user