Correct USB power reporting for translated native controllers
This commit is contained in:
parent
dd69f3d487
commit
a407e84a39
7 changed files with 62 additions and 7 deletions
|
|
@ -80,7 +80,7 @@ int g_sensor_status = -1;
|
|||
uint16_t g_stick_center[2]{2048, 2048};
|
||||
uint16_t g_stick_positive[2]{2047, 2047};
|
||||
uint16_t g_stick_negative[2]{2048, 2048};
|
||||
uint8_t g_power_info = 0x24; // Nominal battery until source status; no USB-power flag.
|
||||
uint8_t g_power_info = 0x01; // USB powered; no invented source charge or charging state.
|
||||
uint8_t g_report_counter;
|
||||
uint32_t g_report_serial;
|
||||
uint32_t g_pending_serial;
|
||||
|
|
@ -254,8 +254,8 @@ void poll_wii_source(uint32_t now_ms) {
|
|||
#ifdef SWITCH2_PROBE_TRACE_NATIVE_INPUT
|
||||
g_last_ir_trace_us = now_us;
|
||||
#endif
|
||||
g_power_info = 0x24;
|
||||
probe_debug_printf("[PROBE] Wii source active in slot %u; keep still for native motion calibration\n",
|
||||
g_power_info = 0x01;
|
||||
probe_debug_printf("[PROBE] Wii source active in slot %u; native bias learns in background\n",
|
||||
g_wii.slot);
|
||||
}
|
||||
g_wii_active = true;
|
||||
|
|
@ -273,7 +273,7 @@ void poll_wii_source(uint32_t now_ms) {
|
|||
}
|
||||
if (g_wii.battery != 0) {
|
||||
const unsigned level = (static_cast<unsigned>(g_wii.battery) * 9u + 127u) / 255u;
|
||||
g_power_info = static_cast<uint8_t>(level << 2);
|
||||
g_power_info = static_cast<uint8_t>((level << 2) | 0x01u);
|
||||
}
|
||||
ProbeNativeMotionSample motion{};
|
||||
motion.accel_valid = g_wii.accel_valid;
|
||||
|
|
|
|||
|
|
@ -290,9 +290,11 @@ uint32_t probe_native_gamepad_input_peek_native_report(uint8_t instance, uint32_
|
|||
if (g_report_token == UINT32_MAX) return 0; // Boot-unique, including across children/resets.
|
||||
memset(child.pending_report, 0, sizeof(child.pending_report));
|
||||
child.pending_report[0] = child.counter;
|
||||
// Bluepad32 zero denotes unknown; do not manufacture a full battery.
|
||||
// Battery telemetry belongs to the source; external power belongs to
|
||||
// these USB-powered virtual controllers. Unknown is not a full charge,
|
||||
// and the Pico does not charge the wireless source.
|
||||
const unsigned battery_level = (static_cast<unsigned>(g_source.battery) * 9u + 127u) / 255u;
|
||||
child.pending_report[1] = static_cast<uint8_t>(battery_level << 2);
|
||||
child.pending_report[1] = static_cast<uint8_t>((battery_level << 2) | 0x01u);
|
||||
memcpy(child.pending_report + 2, child.input.buttons, sizeof(child.input.buttons));
|
||||
child.pending_report[4] = 7;
|
||||
memcpy(child.pending_report + 5, child.input.stick, sizeof(child.input.stick));
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ function(switch2_usb_probe_configure target)
|
|||
endif()
|
||||
if(SWITCH2_PROBE_HUB AND SWITCH2_BRIDGE_FULL_INPUT)
|
||||
if(SWITCH2_PROBE_TRACE_NATIVE_INPUT)
|
||||
pico_set_program_version(${target} "0.72-native-gamepad-trace")
|
||||
pico_set_program_version(${target} "0.72-native-usb-power")
|
||||
else()
|
||||
pico_set_program_version(${target} "0.72-native-gamepad")
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue