Merge pull request #11364 from jordan-woyak/udraw-lift

WiimoteEmu: Expose mappings for lifted UDraw and Drawsome stylus.
This commit is contained in:
Admiral H. Curtiss 2022-12-29 21:16:57 +01:00 committed by GitHub
commit f6fbeaf355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -31,6 +31,7 @@ DrawsomeTablet::DrawsomeTablet() : Extension3rdParty("Drawsome", _trans("Drawsom
// Touch
groups.emplace_back(m_touch = new ControllerEmu::Triggers(_trans("Touch")));
m_touch->AddInput(ControllerEmu::Translate, _trans("Pressure"));
m_touch->AddInput(ControllerEmu::Translate, _trans("Lift"));
}
void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_state)
@ -57,9 +58,10 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
tablet_data.stylus_y1 = u8(stylus_y);
tablet_data.stylus_y2 = u8(stylus_y >> 8);
// TODO: Expose the lifted stylus state in the UI.
const auto touch_state = m_touch->GetState(m_input_override_function);
// Note: Pen X/Y holds the last value when the pen is lifted.
const bool is_stylus_lifted = false;
const bool is_stylus_lifted = std::lround(touch_state.data[1]) != 0;
constexpr u8 NEUTRAL_STATUS = 0x8;
constexpr u8 PEN_LIFTED_BIT = 0x10;
@ -74,7 +76,6 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
// Pressure (0 - 0x7ff):
constexpr u16 MAX_PRESSURE = 0x7ff;
const auto touch_state = m_touch->GetState(m_input_override_function);
const u16 pressure = MapFloat<u16>(touch_state.data[0], 0, 0, MAX_PRESSURE);
tablet_data.pressure1 = u8(pressure);

View File

@ -48,6 +48,7 @@ UDrawTablet::UDrawTablet() : Extension3rdParty("uDraw", _trans("uDraw GameTablet
// Touch
groups.emplace_back(m_touch = new ControllerEmu::Triggers(_trans("Touch")));
m_touch->AddInput(ControllerEmu::Translate, _trans("Pressure"));
m_touch->AddInput(ControllerEmu::Translate, _trans("Lift"));
}
void UDrawTablet::BuildDesiredExtensionState(DesiredExtensionState* target_state)
@ -78,11 +79,10 @@ void UDrawTablet::BuildDesiredExtensionState(DesiredExtensionState* target_state
constexpr double center_y = (max_y + min_y) / 2.0;
// Neutral (lifted) stylus state:
u16 stylus_x = 0x7ff;
u16 stylus_y = 0x7ff;
u16 stylus_x = 0xfff;
u16 stylus_y = 0xfff;
// TODO: Expose the lifted stylus state in the UI.
bool is_stylus_lifted = false;
const bool is_stylus_lifted = std::lround(touch_state.data[1]) != 0;
const auto stylus_state = m_stylus->GetState();