feat(diag): full input logging + read barrel from pointerFlags; focal-jump reject
All checks were successful
CI / Windows build (push) Successful in 12m44s
All checks were successful
CI / Windows build (push) Successful in 12m44s
Buttons (likely fix + ground truth): device diag showed ptr=12577 pen=10056 — WM_POINTER reaches the observer and GetPointerPenInfo succeeds, so the buttons were just read from the wrong field. Native now resolves the barrel from BOTH penFlags(PEN_FLAG_BARREL) AND pointerInfo.pointerFlags(POINTER_FLAG_SECONDBUTTON) — many pens use the latter. It also emits the full raw set (pointerFlags, penFlags, penMask, ButtonChangeType, tilt) plus OR-accumulated flags so a single session reveals exactly which field each button sets. Comprehensive logging (per user request "用好用的log库 / 我手动开启日志再记录"): new DiagnosticLogger emits through dart:developer log(name 'badnote.input') — capturable via `flutter run` / DevTools / `flutter logs` — AND mirrors to a file (path shown in the overlay) for the packaged GUI build that has no console. Manually enabled by the toolbar diagnostic toggle; off by default. PEN lines log on raw-field change; ZOOM lines log every scale frame + rebaselines. Zoom: scale-only glitch rejection didn't stop the jumping, so add focal/position glitch rejection — drop a 2-finger frame whose focal jumps >250px (a touch misread). The full per-frame trace (raw scale, pointerCount, applied change, focal jump, drops) is now logged so the residual cause is unambiguous. InputDiagnostics singleton accumulates the stats; the overlay shows summary + last trace lines + log path + reset. Removed the ad-hoc inline zoom min/max. Dart: analyze clean, 66/66 tests, linux build green. Native compiles on CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,15 @@ int g_pen_msgs = 0;
|
||||
int g_mouse_msgs = 0;
|
||||
int g_last_msg = 0;
|
||||
|
||||
// OR-accumulated raw flag fields, so a momentary button press is CAPTURED and
|
||||
// held (a live readout would miss it). These are the ground truth for "which
|
||||
// field/bit does the side button / eraser set?".
|
||||
int g_ptr_flags_or = 0; // POINTER_INFO.pointerFlags (POINTER_FLAG_SECONDBUTTON = barrel on many pens)
|
||||
int g_pen_flags_or = 0; // POINTER_PEN_INFO.penFlags (PEN_FLAG_BARREL/INVERTED/ERASER)
|
||||
int g_pen_mask_or = 0; // POINTER_PEN_INFO.penMask
|
||||
int g_btn_change_last = 0; // last non-zero POINTER_INFO.ButtonChangeType
|
||||
int g_tilt_abs_max = 0; // max |tiltX|,|tiltY| seen
|
||||
|
||||
} // namespace
|
||||
|
||||
void RegisterPenChannel(flutter::FlutterEngine* engine) {
|
||||
@@ -76,6 +85,10 @@ void ObservePenMessage(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
int flags = 0;
|
||||
double tilt_x = 0.0;
|
||||
double tilt_y = 0.0;
|
||||
int raw_ptr_flags = 0;
|
||||
int raw_pen_flags = 0;
|
||||
int raw_pen_mask = 0;
|
||||
int btn_change = 0;
|
||||
|
||||
if (is_pointer) {
|
||||
++g_ptr_msgs;
|
||||
@@ -85,11 +98,32 @@ void ObservePenMessage(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
POINTER_PEN_INFO ppi{};
|
||||
if (GetPointerPenInfo(pointerId, &ppi)) {
|
||||
++g_pen_msgs;
|
||||
if (ppi.penFlags & PEN_FLAG_BARREL) flags |= 1;
|
||||
if (ppi.penFlags & PEN_FLAG_INVERTED) flags |= 2;
|
||||
if (ppi.penFlags & PEN_FLAG_ERASER) flags |= 4;
|
||||
raw_pen_flags = static_cast<int>(ppi.penFlags);
|
||||
raw_pen_mask = static_cast<int>(ppi.penMask);
|
||||
raw_ptr_flags = static_cast<int>(ppi.pointerInfo.pointerFlags);
|
||||
btn_change = static_cast<int>(ppi.pointerInfo.ButtonChangeType);
|
||||
tilt_x = static_cast<double>(ppi.tiltX);
|
||||
tilt_y = static_cast<double>(ppi.tiltY);
|
||||
|
||||
// Barrel/side button can arrive in EITHER penFlags (PEN_FLAG_BARREL) or
|
||||
// pointerFlags (POINTER_FLAG_SECONDBUTTON) depending on the pen/driver,
|
||||
// so check both. Eraser end = inverted/eraser pen flags.
|
||||
const bool barrel = (ppi.penFlags & PEN_FLAG_BARREL) ||
|
||||
(ppi.pointerInfo.pointerFlags & POINTER_FLAG_SECONDBUTTON);
|
||||
const bool inverted = (ppi.penFlags & PEN_FLAG_INVERTED) != 0;
|
||||
const bool eraser = (ppi.penFlags & PEN_FLAG_ERASER) != 0;
|
||||
if (barrel) flags |= 1;
|
||||
if (inverted) flags |= 2;
|
||||
if (eraser) flags |= 4;
|
||||
|
||||
g_ptr_flags_or |= raw_ptr_flags;
|
||||
g_pen_flags_or |= raw_pen_flags;
|
||||
g_pen_mask_or |= raw_pen_mask;
|
||||
if (btn_change != 0) g_btn_change_last = btn_change;
|
||||
const int ax = ppi.tiltX < 0 ? -ppi.tiltX : ppi.tiltX;
|
||||
const int ay = ppi.tiltY < 0 ? -ppi.tiltY : ppi.tiltY;
|
||||
if (ax > g_tilt_abs_max) g_tilt_abs_max = ax;
|
||||
if (ay > g_tilt_abs_max) g_tilt_abs_max = ay;
|
||||
}
|
||||
}
|
||||
if (message == WM_POINTERUP) {
|
||||
@@ -97,8 +131,9 @@ void ObservePenMessage(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
}
|
||||
}
|
||||
|
||||
// Always emit the diagnostic counters so the Dart overlay can show whether
|
||||
// WM_POINTER / PT_PEN ever reach this observer.
|
||||
// Emit the resolved flags/tilt PLUS the full raw + OR-accumulated diagnostic
|
||||
// set, so a single device session reveals exactly which field carries the
|
||||
// button and what tilt/mask the pen reports.
|
||||
flutter::EncodableMap payload{
|
||||
{flutter::EncodableValue("flags"), flutter::EncodableValue(flags)},
|
||||
{flutter::EncodableValue("tiltX"), flutter::EncodableValue(tilt_x)},
|
||||
@@ -107,6 +142,15 @@ void ObservePenMessage(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
{flutter::EncodableValue("diagPen"), flutter::EncodableValue(g_pen_msgs)},
|
||||
{flutter::EncodableValue("diagMouse"), flutter::EncodableValue(g_mouse_msgs)},
|
||||
{flutter::EncodableValue("diagMsg"), flutter::EncodableValue(g_last_msg)},
|
||||
{flutter::EncodableValue("rawPtrFlags"), flutter::EncodableValue(raw_ptr_flags)},
|
||||
{flutter::EncodableValue("rawPenFlags"), flutter::EncodableValue(raw_pen_flags)},
|
||||
{flutter::EncodableValue("rawPenMask"), flutter::EncodableValue(raw_pen_mask)},
|
||||
{flutter::EncodableValue("btnChange"), flutter::EncodableValue(btn_change)},
|
||||
{flutter::EncodableValue("orPtrFlags"), flutter::EncodableValue(g_ptr_flags_or)},
|
||||
{flutter::EncodableValue("orPenFlags"), flutter::EncodableValue(g_pen_flags_or)},
|
||||
{flutter::EncodableValue("orPenMask"), flutter::EncodableValue(g_pen_mask_or)},
|
||||
{flutter::EncodableValue("btnChangeLast"), flutter::EncodableValue(g_btn_change_last)},
|
||||
{flutter::EncodableValue("tiltAbsMax"), flutter::EncodableValue(g_tilt_abs_max)},
|
||||
};
|
||||
g_pen_sink->Success(flutter::EncodableValue(payload));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user