|
38 | 38 | #include "InputCommon/ControlReference/ExpressionParser.h" |
39 | 39 | #include "InputCommon/ControllerEmu/Control/Control.h" |
40 | 40 | #include "InputCommon/ControllerEmu/ControlGroup/Attachments.h" |
| 41 | +#include "InputCommon/ControllerEmu/ControlGroup/IRPassthrough.h" |
41 | 42 | #include "InputCommon/ControllerEmu/Setting/NumericSetting.h" |
42 | 43 | #include "InputCommon/ControllerInterface/ControllerInterface.h" |
43 | 44 | #include "InputCommon/GCAdapter.h" |
@@ -407,11 +408,22 @@ Device::Device(unsigned device, unsigned p) : m_device(device), m_port(p) |
407 | 408 | AddButton(RETRO_DEVICE_ID_MOUSE_BUTTON_5, "Button5"); |
408 | 409 | return; |
409 | 410 | case RETRO_DEVICE_POINTER: |
410 | | - AddButton(RETRO_DEVICE_ID_POINTER_PRESSED, "Pressed0", 0); |
411 | | - AddAxis(RETRO_DEVICE_ID_POINTER_X, -0x8000, "X0-", 0); |
412 | | - AddAxis(RETRO_DEVICE_ID_POINTER_X, 0x7FFF, "X0+", 0); |
413 | | - AddAxis(RETRO_DEVICE_ID_POINTER_Y, -0x8000, "Y0-", 0); |
414 | | - AddAxis(RETRO_DEVICE_ID_POINTER_Y, 0x7FFF, "Y0+", 0); |
| 411 | + // Four touch indices, one per IR object. Index 0 keeps its old names. |
| 412 | + { |
| 413 | + static const char* const kPressed[] = { "Pressed0", "Pressed1", "Pressed2", "Pressed3" }; |
| 414 | + static const char* const kXNeg[] = { "X0-", "X1-", "X2-", "X3-" }; |
| 415 | + static const char* const kXPos[] = { "X0+", "X1+", "X2+", "X3+" }; |
| 416 | + static const char* const kYNeg[] = { "Y0-", "Y1-", "Y2-", "Y3-" }; |
| 417 | + static const char* const kYPos[] = { "Y0+", "Y1+", "Y2+", "Y3+" }; |
| 418 | + for (unsigned i = 0; i < 4; ++i) |
| 419 | + { |
| 420 | + AddButton(RETRO_DEVICE_ID_POINTER_PRESSED, kPressed[i], i); |
| 421 | + AddAxis(RETRO_DEVICE_ID_POINTER_X, -0x8000, kXNeg[i], i); |
| 422 | + AddAxis(RETRO_DEVICE_ID_POINTER_X, 0x7FFF, kXPos[i], i); |
| 423 | + AddAxis(RETRO_DEVICE_ID_POINTER_Y, -0x8000, kYNeg[i], i); |
| 424 | + AddAxis(RETRO_DEVICE_ID_POINTER_Y, 0x7FFF, kYPos[i], i); |
| 425 | + } |
| 426 | + } |
415 | 427 | return; |
416 | 428 | case RETRO_DEVICE_KEYBOARD: |
417 | 429 | return; |
@@ -946,6 +958,37 @@ void UpdateWiimoteMappings(const WiimoteUpdateFlags& f, unsigned port, unsigned |
946 | 958 | } |
947 | 959 | } |
948 | 960 |
|
| 961 | + // Raw IR: the frontend supplies the camera's view directly, bypassing the |
| 962 | + // Point group and Total Yaw/Pitch. Objects arrive on pointer indices 0-3, |
| 963 | + // X/Y over the camera's 0..1 field, PRESSED marking the object visible. |
| 964 | + // Size is a constant; games only read it to reject noise. |
| 965 | + if (f.irPassthrough) |
| 966 | + { |
| 967 | + auto* wmIRPass = static_cast<ControllerEmu::IRPassthrough*>( |
| 968 | + wm->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::IRPassthrough)); |
| 969 | + const bool passthrough = |
| 970 | + Libretro::Options::GetCached<bool>(Libretro::Options::wiimote::IR_PASSTHROUGH); |
| 971 | + |
| 972 | + if (wmIRPass) |
| 973 | + { |
| 974 | + const std::string devPointer = |
| 975 | + Libretro::Input::GetQualifiedName(port, RETRO_DEVICE_POINTER); |
| 976 | + wmIRPass->enabled.SetValue(passthrough); |
| 977 | + static const char* const kObj[] = { "0", "1", "2", "3" }; |
| 978 | + for (int i = 0; i < 4; ++i) |
| 979 | + { |
| 980 | + // Cleared when off; AreInputsBound() is half of what selects this path. |
| 981 | + const std::string idx = kObj[i]; |
| 982 | + wmIRPass->SetControlExpression(i * 3 + 0, |
| 983 | + passthrough ? "`" + devPointer + ":X" + idx + "+`" : ""); |
| 984 | + wmIRPass->SetControlExpression(i * 3 + 1, |
| 985 | + passthrough ? "`" + devPointer + ":Y" + idx + "+`" : ""); |
| 986 | + wmIRPass->SetControlExpression(i * 3 + 2, |
| 987 | + passthrough ? "`" + devPointer + ":Pressed" + idx + "` * 0.2" : ""); |
| 988 | + } |
| 989 | + } |
| 990 | + } |
| 991 | + |
949 | 992 | if (f.swingAngle) |
950 | 993 | { |
951 | 994 | ControllerEmu::ControlGroup* wmSwing = wm->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Swing); |
@@ -1516,6 +1559,8 @@ void retro_set_controller_port_device_wii(unsigned port, unsigned device) |
1516 | 1559 | f.irModifier = true; |
1517 | 1560 | f.swingModifier = true; |
1518 | 1561 | f.sideways = true; |
| 1562 | + // Raised at setup so the option applies on a cold boot. |
| 1563 | + f.irPassthrough = true; |
1519 | 1564 | Libretro::Input::UpdateWiimoteMappings(f, port, device); |
1520 | 1565 |
|
1521 | 1566 | wmShake->SetControlExpression(0, bindMouse("L2", devMouse + ":Middle")); // Wiimote shake X |
|
0 commit comments