Mega Mouse with wheel

For anything related to IO (joypad, serial, XE...)

Moderator: BigEvilCorporation

Post Reply
User avatar
Sik
Very interested
Posts: 856
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Mega Mouse with wheel

Post by Sik » Sat Jul 13, 2019 3:22 pm

So I was thinking about the possibility that somebody may end up making either an adapter for USB mouses to Mega Mouse, or outright replacements for the Mega Mouse (since while it's still cheap, ball mouses honestly are awful with their tendency to catch dirt). In the case of the latter, the obvious way would be to grab an off-the-shelf mouse and modify it.

The big issue: modern mouses all come with mouse wheels, and we don't have a way to map them (there's also the problem that most mouses lack a fourth button, but oh well). We could just ignore the wheel, but why not instead actually expose it? But we're gonna need to standarize on a packet format or everybody will do whatever they feel like it.

Anyway, here's my proposal for how to extend the data fed back by the mouse, considering what stuff existing games seem to ignore (note that only 3rd nibble is different from a stock Mega Mouse):

Code: Select all

1st -  1  0  1  1
2nd -  1  1  1  1
3rd -  1  1 WD WU
4th - Yo Xo Ys Xs
5th -  C  M  R  L
6th - X7 X6 X5 X4
7th - X3 X2 X1 X0
8th - Y7 Y6 Y5 Y4
9th - Y3 Y2 Y1 Y0
  • X7-X0: X axis displacement (two's complement)
  • Y7-Y0: Y axis displacement (two's complement)
  • Xs: X axis sign extension
  • Ys: Y axis sign extension
  • Xo: 1 = X axis overflowed (invalid), 0 otherwise
  • Yo: 1 = Y axis overflowed (invalid), 0 otherwise
  • WU: 0 = wheel up, 1 otherwise
  • WD: 0 = wheel down, 1 otherwise
  • L: 1 = left button pressed, 0 otherwise
  • R: 1 = middle button pressed, 0 otherwise
  • M: 1 = right button pressed, 0 otherwise
  • C: 1 = Start button pressed, 0 otherwise
If somebody wants to go further: some mouses have a second wheel, and some mouses have more than four buttons… I'd suggest cramming the former into bits 3-2 of the 3rd nibble (so it's the "wheel nibble") and the extra buttons in the 2nd nibble (low logic, which would make them inconsistent with the 5th nibble but oh well).

If anybody is looking into making a new mouse adapter, consider looking at this please?


EDIT: I may as well include how the packet would look with the full extensions:

Code: Select all

1st -  1  0  1  1
2nd - B7 B6 B5 B4
3rd - WR WL WD WU
4th - Yo Xo Ys Xs
5th -  C  M  R  L
6th - X7 X6 X5 X4
7th - X3 X2 X1 X0
8th - Y7 Y6 Y5 Y4
9th - Y3 Y2 Y1 Y0
  • X7-X0: X axis displacement (two's complement)
  • Y7-Y0: Y axis displacement (two's complement)
  • Xs: X axis sign extension
  • Ys: Y axis sign extension
  • Xo: 1 = X axis overflowed (invalid), 0 otherwise
  • Yo: 1 = Y axis overflowed (invalid), 0 otherwise
  • WU: 0 = wheel up, 1 otherwise
  • WD: 0 = wheel down, 1 otherwise
  • WL: 0 = wheel left, 1 otherwise
  • WR: 0 = wheel right, 1 otherwise
  • L: 1 = left button pressed, 0 otherwise
  • R: 1 = middle button pressed, 0 otherwise
  • M: 1 = right button pressed, 0 otherwise
  • C: 1 = Start button pressed, 0 otherwise
  • B4: 0 = 5th button pressed, 1 otherwise
  • B5: 0 = 6th button pressed, 1 otherwise
  • B6: 0 = 7th button pressed, 1 otherwise
  • B7: 0 = 8th button pressed, 1 otherwise
Also other suggestions:
  • Avoid the value -0 (treat it like +0)
  • Avoid the value -256 (treat it like overflow)
  • Maybe even replace overflow with a clamped value instead (works around bugs in one game with a seemingly broken mouse routine)
Sik is pronounced as "seek", not as "sick".

PinoBatch
Newbie
Posts: 2
Joined: Fri May 17, 2019 2:43 am

Re: Mega Mouse with wheel

Post by PinoBatch » Sat Jul 13, 2019 4:54 pm

I'd second the elimination of overflow from new devices, seeing as the Super NES Mouse seems to get along fine with clamping instead. For comparison:

Code: Select all

 1- 8  0  0  0  0  0  0  0  0
 9-16 RB LB A1 A0  0  0  0  1
17-24 YU Y6 Y5 Y4 Y3 Y2 Y1 Y0
25-32 XL X6 X5 X4 X3 X2 X1 X0
  • RB, LB: buttons
  • A1-0: Current acceleration curve (0: none/turtle; 1: mild/rabbit; 2: strong/cheetah)
  • YU: Y displacement sign (1: up; 0: down)
  • Y6-0: Y displacement magnitude
  • XL: X displacement sign (1: left; 0: right)
  • X6-0: X displacement magnitude
(Note: Unlike Mega Mouse, Super NES Mouse displacements are sign and magnitude, not two's complement.)

Chilly Willy
Very interested
Posts: 2751
Joined: Fri Aug 17, 2007 9:33 pm

Re: Mega Mouse with wheel

Post by Chilly Willy » Sat Jul 13, 2019 5:27 pm

I like your extended mouse spec. While I like the idea of clamping the mouse move rather than having overflow, you need to keep the overflow bits for backwards compatibility. On mice that clamp rather than overflow, those bits will simply always be 0.

User avatar
Sik
Very interested
Posts: 856
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Mega Mouse with wheel

Post by Sik » Sat Jul 13, 2019 5:57 pm

Well yeah, a mouse that does clamping will have to act like overflow never happens, I mentioned it just to help account for that one edge case (blurgh). Besides, the usual way to handle overflow is to drop the packet, while clamping at least doesn't completely drop the motion (and you could even spread the motion across multiple packets if this happens, at the expense of some "lag" if it takes really long but that's unlikely).

The overflow flags could still remain useful to report an error I guess (e.g. something went wrong and mouse is unable to return valid data right now so it just returns a bogus packet with overflow flags set).
Sik is pronounced as "seek", not as "sick".

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest