Will any serial mouse connect to Classic Macs?Identify an early 90s optical mouseWhat were the applications of 5/6-bit serial port formats?Xerox Parc and the three-button mouseSerial Receipt Printer GarbageCan the ADB keyboard and mouse be converted to the 128K Macintosh?Macintosh Performa 200 Mouse and Keyboard IssueReading data over serial from an old punched tape readerBasic test for a RS232 serial terminalCreative uses for serial port?A way to connect Microsoft Green-Eyed mouse to modern computer?

Expansion with *.txt in the shell doesn't work if no .txt file exists

AC contactor 1 pole or 2?

Weed in Massachusetts: underground roots, skunky smell when bruised

What is AM-CM inequality?

Why are so many countries still in the Commonwealth?

This message is flooding my syslog, how to find where it comes from?

How do professional electronic musicians/sound engineers combat listening fatigue?

How can I receive packages while in France?

401(k) investment after being fired. Do I own it?

Does the Intel 8086 CPU have user mode and kernel mode?

Is this photo showing a woman posing in the nude before teenagers real?

Basic Questions on Wiener Filtering

Drillers for petroleum strike gusher of blood

Assuring luggage isn't lost with short layover

What's the difference between 2a and 10a charging options?

Spoken encryption

High income, sudden windfall

How to handle a player that cannot be convinced his actions are a problem for both GM and party

Trying to build a function to compute divided difference for arbitrary list of points

Anybody know what this small Nintendo stand is for?

Why are off grid solar setups only 12, 24, 48 VDC?

What is the difference between 1/3, 1/2, and full casters?

Explain why watch 'jobs' does not work but watch 'ps' work?

How can I stop myself from micromanaging other PCs' actions?



Will any serial mouse connect to Classic Macs?


Identify an early 90s optical mouseWhat were the applications of 5/6-bit serial port formats?Xerox Parc and the three-button mouseSerial Receipt Printer GarbageCan the ADB keyboard and mouse be converted to the 128K Macintosh?Macintosh Performa 200 Mouse and Keyboard IssueReading data over serial from an old punched tape readerBasic test for a RS232 serial terminalCreative uses for serial port?A way to connect Microsoft Green-Eyed mouse to modern computer?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















The Macintosh 128k, 512k, and Plus use a DE-09 Serial port for the mouse. Is there some proprietary data-transfer method? Or is any DE-09 Serial mouse compatible?



Furthermore: has anyone documented this data-transfer protocol?



Edit: the reason I ask is because I'd like to build a custom mouse-input system (and eventually keyboard), perhaps over bluetooth. I am brainstorming a raspberry pi → Macintosh. Please comment with any insight.










share|improve this question







New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2





    I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

    – Tommy
    8 hours ago











  • @Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

    – Michael Austin
    8 hours ago











  • I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

    – Tommy
    8 hours ago











  • @Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

    – Michael Austin
    8 hours ago











  • Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

    – Chris Stratton
    7 hours ago


















2















The Macintosh 128k, 512k, and Plus use a DE-09 Serial port for the mouse. Is there some proprietary data-transfer method? Or is any DE-09 Serial mouse compatible?



Furthermore: has anyone documented this data-transfer protocol?



Edit: the reason I ask is because I'd like to build a custom mouse-input system (and eventually keyboard), perhaps over bluetooth. I am brainstorming a raspberry pi → Macintosh. Please comment with any insight.










share|improve this question







New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2





    I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

    – Tommy
    8 hours ago











  • @Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

    – Michael Austin
    8 hours ago











  • I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

    – Tommy
    8 hours ago











  • @Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

    – Michael Austin
    8 hours ago











  • Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

    – Chris Stratton
    7 hours ago














2












2








2








The Macintosh 128k, 512k, and Plus use a DE-09 Serial port for the mouse. Is there some proprietary data-transfer method? Or is any DE-09 Serial mouse compatible?



Furthermore: has anyone documented this data-transfer protocol?



Edit: the reason I ask is because I'd like to build a custom mouse-input system (and eventually keyboard), perhaps over bluetooth. I am brainstorming a raspberry pi → Macintosh. Please comment with any insight.










share|improve this question







New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











The Macintosh 128k, 512k, and Plus use a DE-09 Serial port for the mouse. Is there some proprietary data-transfer method? Or is any DE-09 Serial mouse compatible?



Furthermore: has anyone documented this data-transfer protocol?



Edit: the reason I ask is because I'd like to build a custom mouse-input system (and eventually keyboard), perhaps over bluetooth. I am brainstorming a raspberry pi → Macintosh. Please comment with any insight.







apple-macintosh serial mouse






share|improve this question







New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









Michael AustinMichael Austin

1134 bronze badges




1134 bronze badges




New contributor



Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Michael Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









  • 2





    I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

    – Tommy
    8 hours ago











  • @Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

    – Michael Austin
    8 hours ago











  • I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

    – Tommy
    8 hours ago











  • @Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

    – Michael Austin
    8 hours ago











  • Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

    – Chris Stratton
    7 hours ago













  • 2





    I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

    – Tommy
    8 hours ago











  • @Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

    – Michael Austin
    8 hours ago











  • I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

    – Tommy
    8 hours ago











  • @Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

    – Michael Austin
    8 hours ago











  • Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

    – Chris Stratton
    7 hours ago








2




2





I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

– Tommy
8 hours ago





I don't know the wiring offhand but it's definitely just a plain quadrature mouse input — no serial communications and therefore no protocol in that sense.

– Tommy
8 hours ago













@Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

– Michael Austin
8 hours ago





@Tommy I saw that term "quadrature" on the mouse's Wikipedia, but I don't understand what it is. Do you have a reference that will put it in beginner-friendly terms?

– Michael Austin
8 hours ago













I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

– Tommy
8 hours ago





I'll find a pinout and write it up as an answer later this morning if nobody beats me to it. I just finished writing a Macintosh emulator, so I have a bunch of appropriate documents waiting on my computer.

– Tommy
8 hours ago













@Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

– Michael Austin
8 hours ago





@Tommy wow that would be great! Sounds like a cool project. Feel free to put a GitHub link here if you want :)

– Michael Austin
8 hours ago













Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

– Chris Stratton
7 hours ago






Schematic of an Apple quadrature mouse port with crude drawing of what someone believes the mouse to do: applefritter.com/comment/73859#comment-73859 there does not appear to be a difference between internals of early Mac/Lisa/AppleII type solutions.

– Chris Stratton
7 hours ago











1 Answer
1






active

oldest

votes


















5














The pre-ADB Macintoshes use a simple quadrature-encoded mouse input, no formal serial protocol.



Quadrature encoding is a simple, physical process, that lends itself to a convenient cheat if you're synthesising input. Picture a cog, with an optical sensor pointing through the grooves. If you observed the digital output of that sensor, you'd be able to tell how fast the cog is turning, which is half the problem solved.



(Disclaimer: it's not really a cog, but that's an easy image)



What a quadrature encoder does is it uses two sensors, half a groove apart. Then if the cog is turning one way you'd expect to see the time-ordered input:



sensor 1 on, sensor 2 on, sensor 1 off, sensor 2 off, sensor 1 on, etc


But if it's turning the other way, you'd instead see:



sensor 2 on, sensor 1 on, sensor 2 off, sensor 1 off, sensor 2 on, etc


Which the Macintosh (and most other similar computers) collapse into a simple process:



  • every time sensor 1 changes state, observe the the mouse has moved by one pixel;

  • if sensor 2 has the same value as sensor 1 when sensor 1 has just changed, that's one pixel left; otherwise it's one pixel right.

(for appropriate values of 'left' and 'right', of course)



This is specifically embodied in the Macintosh by having inputs 'X1' and 'Y1' wired up to its serial controller chip, the SCC, to generate interrupts anytime they transition, and having inputs 'X2' and 'Y2' wired up as inputs to the 6522 VIA, which the processor manually polls upon receiving the X1 or Y1 interrupt.



So the shortcut I currently take in my emulator is very straightforward:



  • keep a couple of values representing "x offset not yet communicated" and "y offset not yet communicated", into which modern-style instantaneous mouse delta reports are accumulated;

  • when motion is outstanding, toggle X1 and Y1 at a fixed frequency that's close to the maximum rate the Macintosh can process the relevant interrupts at; and

  • upon each toggling, set X2 and Y2 as either the same value as X1 or Y1, if motion is leftward and downward, or the opposite value, if motion is rightward or upward.

That's a cheat coupled to the known software implementation of mouse input reading — really X2 and Y2 should mutate in between changes to X1 and Y1, rather than in lockstep with them. I will banish it from my emulator at some point, but it definitely works.



I unscientifically arrived at a figure of toggling X1/Y1 every 1,250 cycles relative to the internal 7,833,600 Hz clock. Obviously you don't have access to that clock, but that implies that ~6266 Hz is not too fast for handling mouse input. My thinking here was that since I'm receiving mouse pointer movements of multiple pixels atomically, feeding them to the emulated Macintosh "as close to atomically as possible" is technically as accurate as the available information, even if it's nothing like how someone would move a real mouse.



On the pinout, per here:



  • pin 5 is X1, the one that indicates velocity of x movement;

  • pin 4 is X2, the one that — through comparison to X1 — indicates direction of x movement;

  • pin 9 is Y1, for velocity of y movement;

  • pin 8 is Y2, for direction of y movement exactly as per x.

Otherwise it looks line pins 1 and 3 are grounds, for the chassis and electronics respectively, pin 2 is +5v, pin 7 is for the button, and 6 isn't connected to anything.



EDIT:



So, in case it's any help, this is all there is to the virtual mouse electronics in the current version of my emulator. It accepts multiple buttons because I'm sure I'll reuse it for other machines. The actual stuff of feeding the SCC and 6522 isn't in that file, naturally, it's Macintosh-specific wiring outside of the mouse itself.



EXAMPLE:



One-dimensional pseudocode:



int x_delta;

func add_x_motion(int number_of_pixels)
x_delta += number_of_pixels;


// update() is called by a timer roughly 6,000 times/second;
// the timer needn't be very precise.
func update()
// Do nothing if no pixels are left to communicate.
if(!x_delta) return;

// Toggle x1 (/pin 5) to indicate a single pixel's movement.
toggle_x1_output();

// Set x2 (/ pin 4) to the same level as x1 to indicate motion
// to the left. Set it to the opposite level to indicate motion
// to the right. And then reduce `x_delta` appropriately.
if(x_delta < 0)
set_x2_output(get_x1_output());
++ x_delta;
else
set_x2_output(!get_x1_output());
-- x_delta;







share|improve this answer

























  • And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

    – Tommy
    7 hours ago







  • 2





    Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

    – Solomon Slow
    7 hours ago











  • I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

    – Tommy
    7 hours ago












  • P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

    – Solomon Slow
    6 hours ago











  • @SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

    – alephzero
    6 hours ago














Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "648"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Michael Austin is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11859%2fwill-any-serial-mouse-connect-to-classic-macs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














The pre-ADB Macintoshes use a simple quadrature-encoded mouse input, no formal serial protocol.



Quadrature encoding is a simple, physical process, that lends itself to a convenient cheat if you're synthesising input. Picture a cog, with an optical sensor pointing through the grooves. If you observed the digital output of that sensor, you'd be able to tell how fast the cog is turning, which is half the problem solved.



(Disclaimer: it's not really a cog, but that's an easy image)



What a quadrature encoder does is it uses two sensors, half a groove apart. Then if the cog is turning one way you'd expect to see the time-ordered input:



sensor 1 on, sensor 2 on, sensor 1 off, sensor 2 off, sensor 1 on, etc


But if it's turning the other way, you'd instead see:



sensor 2 on, sensor 1 on, sensor 2 off, sensor 1 off, sensor 2 on, etc


Which the Macintosh (and most other similar computers) collapse into a simple process:



  • every time sensor 1 changes state, observe the the mouse has moved by one pixel;

  • if sensor 2 has the same value as sensor 1 when sensor 1 has just changed, that's one pixel left; otherwise it's one pixel right.

(for appropriate values of 'left' and 'right', of course)



This is specifically embodied in the Macintosh by having inputs 'X1' and 'Y1' wired up to its serial controller chip, the SCC, to generate interrupts anytime they transition, and having inputs 'X2' and 'Y2' wired up as inputs to the 6522 VIA, which the processor manually polls upon receiving the X1 or Y1 interrupt.



So the shortcut I currently take in my emulator is very straightforward:



  • keep a couple of values representing "x offset not yet communicated" and "y offset not yet communicated", into which modern-style instantaneous mouse delta reports are accumulated;

  • when motion is outstanding, toggle X1 and Y1 at a fixed frequency that's close to the maximum rate the Macintosh can process the relevant interrupts at; and

  • upon each toggling, set X2 and Y2 as either the same value as X1 or Y1, if motion is leftward and downward, or the opposite value, if motion is rightward or upward.

That's a cheat coupled to the known software implementation of mouse input reading — really X2 and Y2 should mutate in between changes to X1 and Y1, rather than in lockstep with them. I will banish it from my emulator at some point, but it definitely works.



I unscientifically arrived at a figure of toggling X1/Y1 every 1,250 cycles relative to the internal 7,833,600 Hz clock. Obviously you don't have access to that clock, but that implies that ~6266 Hz is not too fast for handling mouse input. My thinking here was that since I'm receiving mouse pointer movements of multiple pixels atomically, feeding them to the emulated Macintosh "as close to atomically as possible" is technically as accurate as the available information, even if it's nothing like how someone would move a real mouse.



On the pinout, per here:



  • pin 5 is X1, the one that indicates velocity of x movement;

  • pin 4 is X2, the one that — through comparison to X1 — indicates direction of x movement;

  • pin 9 is Y1, for velocity of y movement;

  • pin 8 is Y2, for direction of y movement exactly as per x.

Otherwise it looks line pins 1 and 3 are grounds, for the chassis and electronics respectively, pin 2 is +5v, pin 7 is for the button, and 6 isn't connected to anything.



EDIT:



So, in case it's any help, this is all there is to the virtual mouse electronics in the current version of my emulator. It accepts multiple buttons because I'm sure I'll reuse it for other machines. The actual stuff of feeding the SCC and 6522 isn't in that file, naturally, it's Macintosh-specific wiring outside of the mouse itself.



EXAMPLE:



One-dimensional pseudocode:



int x_delta;

func add_x_motion(int number_of_pixels)
x_delta += number_of_pixels;


// update() is called by a timer roughly 6,000 times/second;
// the timer needn't be very precise.
func update()
// Do nothing if no pixels are left to communicate.
if(!x_delta) return;

// Toggle x1 (/pin 5) to indicate a single pixel's movement.
toggle_x1_output();

// Set x2 (/ pin 4) to the same level as x1 to indicate motion
// to the left. Set it to the opposite level to indicate motion
// to the right. And then reduce `x_delta` appropriately.
if(x_delta < 0)
set_x2_output(get_x1_output());
++ x_delta;
else
set_x2_output(!get_x1_output());
-- x_delta;







share|improve this answer

























  • And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

    – Tommy
    7 hours ago







  • 2





    Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

    – Solomon Slow
    7 hours ago











  • I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

    – Tommy
    7 hours ago












  • P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

    – Solomon Slow
    6 hours ago











  • @SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

    – alephzero
    6 hours ago
















5














The pre-ADB Macintoshes use a simple quadrature-encoded mouse input, no formal serial protocol.



Quadrature encoding is a simple, physical process, that lends itself to a convenient cheat if you're synthesising input. Picture a cog, with an optical sensor pointing through the grooves. If you observed the digital output of that sensor, you'd be able to tell how fast the cog is turning, which is half the problem solved.



(Disclaimer: it's not really a cog, but that's an easy image)



What a quadrature encoder does is it uses two sensors, half a groove apart. Then if the cog is turning one way you'd expect to see the time-ordered input:



sensor 1 on, sensor 2 on, sensor 1 off, sensor 2 off, sensor 1 on, etc


But if it's turning the other way, you'd instead see:



sensor 2 on, sensor 1 on, sensor 2 off, sensor 1 off, sensor 2 on, etc


Which the Macintosh (and most other similar computers) collapse into a simple process:



  • every time sensor 1 changes state, observe the the mouse has moved by one pixel;

  • if sensor 2 has the same value as sensor 1 when sensor 1 has just changed, that's one pixel left; otherwise it's one pixel right.

(for appropriate values of 'left' and 'right', of course)



This is specifically embodied in the Macintosh by having inputs 'X1' and 'Y1' wired up to its serial controller chip, the SCC, to generate interrupts anytime they transition, and having inputs 'X2' and 'Y2' wired up as inputs to the 6522 VIA, which the processor manually polls upon receiving the X1 or Y1 interrupt.



So the shortcut I currently take in my emulator is very straightforward:



  • keep a couple of values representing "x offset not yet communicated" and "y offset not yet communicated", into which modern-style instantaneous mouse delta reports are accumulated;

  • when motion is outstanding, toggle X1 and Y1 at a fixed frequency that's close to the maximum rate the Macintosh can process the relevant interrupts at; and

  • upon each toggling, set X2 and Y2 as either the same value as X1 or Y1, if motion is leftward and downward, or the opposite value, if motion is rightward or upward.

That's a cheat coupled to the known software implementation of mouse input reading — really X2 and Y2 should mutate in between changes to X1 and Y1, rather than in lockstep with them. I will banish it from my emulator at some point, but it definitely works.



I unscientifically arrived at a figure of toggling X1/Y1 every 1,250 cycles relative to the internal 7,833,600 Hz clock. Obviously you don't have access to that clock, but that implies that ~6266 Hz is not too fast for handling mouse input. My thinking here was that since I'm receiving mouse pointer movements of multiple pixels atomically, feeding them to the emulated Macintosh "as close to atomically as possible" is technically as accurate as the available information, even if it's nothing like how someone would move a real mouse.



On the pinout, per here:



  • pin 5 is X1, the one that indicates velocity of x movement;

  • pin 4 is X2, the one that — through comparison to X1 — indicates direction of x movement;

  • pin 9 is Y1, for velocity of y movement;

  • pin 8 is Y2, for direction of y movement exactly as per x.

Otherwise it looks line pins 1 and 3 are grounds, for the chassis and electronics respectively, pin 2 is +5v, pin 7 is for the button, and 6 isn't connected to anything.



EDIT:



So, in case it's any help, this is all there is to the virtual mouse electronics in the current version of my emulator. It accepts multiple buttons because I'm sure I'll reuse it for other machines. The actual stuff of feeding the SCC and 6522 isn't in that file, naturally, it's Macintosh-specific wiring outside of the mouse itself.



EXAMPLE:



One-dimensional pseudocode:



int x_delta;

func add_x_motion(int number_of_pixels)
x_delta += number_of_pixels;


// update() is called by a timer roughly 6,000 times/second;
// the timer needn't be very precise.
func update()
// Do nothing if no pixels are left to communicate.
if(!x_delta) return;

// Toggle x1 (/pin 5) to indicate a single pixel's movement.
toggle_x1_output();

// Set x2 (/ pin 4) to the same level as x1 to indicate motion
// to the left. Set it to the opposite level to indicate motion
// to the right. And then reduce `x_delta` appropriately.
if(x_delta < 0)
set_x2_output(get_x1_output());
++ x_delta;
else
set_x2_output(!get_x1_output());
-- x_delta;







share|improve this answer

























  • And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

    – Tommy
    7 hours ago







  • 2





    Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

    – Solomon Slow
    7 hours ago











  • I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

    – Tommy
    7 hours ago












  • P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

    – Solomon Slow
    6 hours ago











  • @SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

    – alephzero
    6 hours ago














5












5








5







The pre-ADB Macintoshes use a simple quadrature-encoded mouse input, no formal serial protocol.



Quadrature encoding is a simple, physical process, that lends itself to a convenient cheat if you're synthesising input. Picture a cog, with an optical sensor pointing through the grooves. If you observed the digital output of that sensor, you'd be able to tell how fast the cog is turning, which is half the problem solved.



(Disclaimer: it's not really a cog, but that's an easy image)



What a quadrature encoder does is it uses two sensors, half a groove apart. Then if the cog is turning one way you'd expect to see the time-ordered input:



sensor 1 on, sensor 2 on, sensor 1 off, sensor 2 off, sensor 1 on, etc


But if it's turning the other way, you'd instead see:



sensor 2 on, sensor 1 on, sensor 2 off, sensor 1 off, sensor 2 on, etc


Which the Macintosh (and most other similar computers) collapse into a simple process:



  • every time sensor 1 changes state, observe the the mouse has moved by one pixel;

  • if sensor 2 has the same value as sensor 1 when sensor 1 has just changed, that's one pixel left; otherwise it's one pixel right.

(for appropriate values of 'left' and 'right', of course)



This is specifically embodied in the Macintosh by having inputs 'X1' and 'Y1' wired up to its serial controller chip, the SCC, to generate interrupts anytime they transition, and having inputs 'X2' and 'Y2' wired up as inputs to the 6522 VIA, which the processor manually polls upon receiving the X1 or Y1 interrupt.



So the shortcut I currently take in my emulator is very straightforward:



  • keep a couple of values representing "x offset not yet communicated" and "y offset not yet communicated", into which modern-style instantaneous mouse delta reports are accumulated;

  • when motion is outstanding, toggle X1 and Y1 at a fixed frequency that's close to the maximum rate the Macintosh can process the relevant interrupts at; and

  • upon each toggling, set X2 and Y2 as either the same value as X1 or Y1, if motion is leftward and downward, or the opposite value, if motion is rightward or upward.

That's a cheat coupled to the known software implementation of mouse input reading — really X2 and Y2 should mutate in between changes to X1 and Y1, rather than in lockstep with them. I will banish it from my emulator at some point, but it definitely works.



I unscientifically arrived at a figure of toggling X1/Y1 every 1,250 cycles relative to the internal 7,833,600 Hz clock. Obviously you don't have access to that clock, but that implies that ~6266 Hz is not too fast for handling mouse input. My thinking here was that since I'm receiving mouse pointer movements of multiple pixels atomically, feeding them to the emulated Macintosh "as close to atomically as possible" is technically as accurate as the available information, even if it's nothing like how someone would move a real mouse.



On the pinout, per here:



  • pin 5 is X1, the one that indicates velocity of x movement;

  • pin 4 is X2, the one that — through comparison to X1 — indicates direction of x movement;

  • pin 9 is Y1, for velocity of y movement;

  • pin 8 is Y2, for direction of y movement exactly as per x.

Otherwise it looks line pins 1 and 3 are grounds, for the chassis and electronics respectively, pin 2 is +5v, pin 7 is for the button, and 6 isn't connected to anything.



EDIT:



So, in case it's any help, this is all there is to the virtual mouse electronics in the current version of my emulator. It accepts multiple buttons because I'm sure I'll reuse it for other machines. The actual stuff of feeding the SCC and 6522 isn't in that file, naturally, it's Macintosh-specific wiring outside of the mouse itself.



EXAMPLE:



One-dimensional pseudocode:



int x_delta;

func add_x_motion(int number_of_pixels)
x_delta += number_of_pixels;


// update() is called by a timer roughly 6,000 times/second;
// the timer needn't be very precise.
func update()
// Do nothing if no pixels are left to communicate.
if(!x_delta) return;

// Toggle x1 (/pin 5) to indicate a single pixel's movement.
toggle_x1_output();

// Set x2 (/ pin 4) to the same level as x1 to indicate motion
// to the left. Set it to the opposite level to indicate motion
// to the right. And then reduce `x_delta` appropriately.
if(x_delta < 0)
set_x2_output(get_x1_output());
++ x_delta;
else
set_x2_output(!get_x1_output());
-- x_delta;







share|improve this answer















The pre-ADB Macintoshes use a simple quadrature-encoded mouse input, no formal serial protocol.



Quadrature encoding is a simple, physical process, that lends itself to a convenient cheat if you're synthesising input. Picture a cog, with an optical sensor pointing through the grooves. If you observed the digital output of that sensor, you'd be able to tell how fast the cog is turning, which is half the problem solved.



(Disclaimer: it's not really a cog, but that's an easy image)



What a quadrature encoder does is it uses two sensors, half a groove apart. Then if the cog is turning one way you'd expect to see the time-ordered input:



sensor 1 on, sensor 2 on, sensor 1 off, sensor 2 off, sensor 1 on, etc


But if it's turning the other way, you'd instead see:



sensor 2 on, sensor 1 on, sensor 2 off, sensor 1 off, sensor 2 on, etc


Which the Macintosh (and most other similar computers) collapse into a simple process:



  • every time sensor 1 changes state, observe the the mouse has moved by one pixel;

  • if sensor 2 has the same value as sensor 1 when sensor 1 has just changed, that's one pixel left; otherwise it's one pixel right.

(for appropriate values of 'left' and 'right', of course)



This is specifically embodied in the Macintosh by having inputs 'X1' and 'Y1' wired up to its serial controller chip, the SCC, to generate interrupts anytime they transition, and having inputs 'X2' and 'Y2' wired up as inputs to the 6522 VIA, which the processor manually polls upon receiving the X1 or Y1 interrupt.



So the shortcut I currently take in my emulator is very straightforward:



  • keep a couple of values representing "x offset not yet communicated" and "y offset not yet communicated", into which modern-style instantaneous mouse delta reports are accumulated;

  • when motion is outstanding, toggle X1 and Y1 at a fixed frequency that's close to the maximum rate the Macintosh can process the relevant interrupts at; and

  • upon each toggling, set X2 and Y2 as either the same value as X1 or Y1, if motion is leftward and downward, or the opposite value, if motion is rightward or upward.

That's a cheat coupled to the known software implementation of mouse input reading — really X2 and Y2 should mutate in between changes to X1 and Y1, rather than in lockstep with them. I will banish it from my emulator at some point, but it definitely works.



I unscientifically arrived at a figure of toggling X1/Y1 every 1,250 cycles relative to the internal 7,833,600 Hz clock. Obviously you don't have access to that clock, but that implies that ~6266 Hz is not too fast for handling mouse input. My thinking here was that since I'm receiving mouse pointer movements of multiple pixels atomically, feeding them to the emulated Macintosh "as close to atomically as possible" is technically as accurate as the available information, even if it's nothing like how someone would move a real mouse.



On the pinout, per here:



  • pin 5 is X1, the one that indicates velocity of x movement;

  • pin 4 is X2, the one that — through comparison to X1 — indicates direction of x movement;

  • pin 9 is Y1, for velocity of y movement;

  • pin 8 is Y2, for direction of y movement exactly as per x.

Otherwise it looks line pins 1 and 3 are grounds, for the chassis and electronics respectively, pin 2 is +5v, pin 7 is for the button, and 6 isn't connected to anything.



EDIT:



So, in case it's any help, this is all there is to the virtual mouse electronics in the current version of my emulator. It accepts multiple buttons because I'm sure I'll reuse it for other machines. The actual stuff of feeding the SCC and 6522 isn't in that file, naturally, it's Macintosh-specific wiring outside of the mouse itself.



EXAMPLE:



One-dimensional pseudocode:



int x_delta;

func add_x_motion(int number_of_pixels)
x_delta += number_of_pixels;


// update() is called by a timer roughly 6,000 times/second;
// the timer needn't be very precise.
func update()
// Do nothing if no pixels are left to communicate.
if(!x_delta) return;

// Toggle x1 (/pin 5) to indicate a single pixel's movement.
toggle_x1_output();

// Set x2 (/ pin 4) to the same level as x1 to indicate motion
// to the left. Set it to the opposite level to indicate motion
// to the right. And then reduce `x_delta` appropriately.
if(x_delta < 0)
set_x2_output(get_x1_output());
++ x_delta;
else
set_x2_output(!get_x1_output());
-- x_delta;








share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 7 hours ago









TommyTommy

18.5k1 gold badge52 silver badges93 bronze badges




18.5k1 gold badge52 silver badges93 bronze badges












  • And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

    – Tommy
    7 hours ago







  • 2





    Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

    – Solomon Slow
    7 hours ago











  • I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

    – Tommy
    7 hours ago












  • P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

    – Solomon Slow
    6 hours ago











  • @SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

    – alephzero
    6 hours ago


















  • And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

    – Tommy
    7 hours ago







  • 2





    Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

    – Solomon Slow
    7 hours ago











  • I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

    – Tommy
    7 hours ago












  • P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

    – Solomon Slow
    6 hours ago











  • @SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

    – alephzero
    6 hours ago

















And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

– Tommy
7 hours ago






And, as an aside: the keyboard is an actual serial protocol, responding to queries with properly enumerated key up and key down events. But probably still not a great hassle. Pleasantly enough, the clock for serial keyboard communications in both directions is provided by the keyboard itself, so you can probably even be a bit irregular, and it's pretty slow at just 100 kHz.

– Tommy
7 hours ago





2




2





Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

– Solomon Slow
7 hours ago





Actually, that "quadrature" principle is how all mechanical mice worked. The only question is, at which end of the mouse cord were the quadrature signals decoded. In most mice, the decoder was in the body of the mouse itself, and then some serial protocol was used to send the data to the computer.

– Solomon Slow
7 hours ago













I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

– Tommy
7 hours ago






I didn't mean to imply otherwise; @SolomonSlow is 100% correct. I literally meant that the physical input on a pre-ADB Macintosh is for raw quadrature input.

– Tommy
7 hours ago














P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

– Solomon Slow
6 hours ago





P.S., The very first optical mice I ever saw also appeared to work in a similar way. They only worked on a special pad that was made of shiny aluminum with a fine pattern of colored stripes running in one direction, and different colored stripes at a 90 degree angle. I assume that a pair of photo detectors must have generated a quadrature signal for one axis by watching one of the two colors, while another pair watched for the other color. The mice in question were attached to Sun-1 Workstations.

– Solomon Slow
6 hours ago













@SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

– alephzero
6 hours ago






@SolomonSlow the two sensors were definitely linked to the different orientations of the mouse pad somehow. That had the side effect that mouse movement was relative to the pad, not to the direction the mouse was pointing in, at least for small amounts of deviation. On of the tricks we used to play on newbie Sun users was to turn the pad through 90 degrees and see how long it took them to figure out why the mouse wasn't working.

– alephzero
6 hours ago











Michael Austin is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Michael Austin is a new contributor. Be nice, and check out our Code of Conduct.












Michael Austin is a new contributor. Be nice, and check out our Code of Conduct.











Michael Austin is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Retrocomputing Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11859%2fwill-any-serial-mouse-connect-to-classic-macs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單