Skip to content

Commit 33f3b19

Browse files
committed
Mouse: report instantaneous cont4 deltas (bypass accumulator)
ms_present=1 is confirmed on hardware (D-pad goes dead when a USB mouse is attached), so detection works, but the report-counter-gated accumulator never produced movement. Report the live cont4 delta directly - same approach as the working virtual mouse - to get the deltas through to the SNES.
1 parent c3557d2 commit 33f3b19

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎rtl/ioport.sv‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@ wire signed [15:0] ms_dy = MOUSE_DATA[31:16];
9090
// Movement accumulated between SNES polls -> sign + 7-bit magnitude
9191
reg signed [15:0] ms_acc_x, ms_acc_y;
9292
reg [15:0] ms_rpt_last;
93-
wire [15:0] ms_absx = ms_acc_x[15] ? (~ms_acc_x + 16'sd1) : ms_acc_x;
94-
wire [15:0] ms_absy = ms_acc_y[15] ? (~ms_acc_y + 16'sd1) : ms_acc_y;
93+
// Report the instantaneous cont4 delta directly (bypassing the accumulator and
94+
// the report-counter gate) — same approach as the working virtual mouse, which
95+
// reports the live stick deflection rather than an accumulated value.
96+
wire [15:0] ms_absx = ms_dx[15] ? (~ms_dx + 16'sd1) : ms_dx;
97+
wire [15:0] ms_absy = ms_dy[15] ? (~ms_dy + 16'sd1) : ms_dy;
9598
wire [6:0] ms_mx = (ms_absx > 16'd127) ? 7'd127 : ms_absx[6:0];
9699
wire [6:0] ms_my = (ms_absy > 16'd127) ? 7'd127 : ms_absy[6:0];
97-
wire ms_sx = ms_acc_x[15];
98-
wire ms_sy = ~ms_acc_y[15];
100+
wire ms_sx = ms_dx[15];
101+
wire ms_sy = ~ms_dy[15];
99102

100103
reg joystick_detected = 0;
101104
reg [1:0] speed = 0;

0 commit comments

Comments
 (0)