Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of Microsoft Serial Mouse on /dev/ttyS1 #1260

Open
toncho11 opened this issue Feb 20, 2025 · 7 comments
Open

Support of Microsoft Serial Mouse on /dev/ttyS1 #1260

toncho11 opened this issue Feb 20, 2025 · 7 comments

Comments

@toncho11
Copy link

Hi,

Is it possible to add Microsoft Serial Mouse on /dev/ttyS1 ?
I am trying to use mouse in ELKS.

@copy
Copy link
Owner

copy commented Feb 20, 2025

v86 emulates a PS2 mouse, which seems to be supported by elks. I wouldn't mind supporting serial mouse too, but it's probably not very widely used.

@toncho11
Copy link
Author

No. This documentation is completely outdated.
There is experimental support for PS2 mouse on a serial line, not the bios PS2. But this is not the case in copy.sh, right?
So either Microsoft serial mouse or PS2 mouse on a serial line will be welcomed.

@toncho11
Copy link
Author

And why in https://copy.sh/v86/?profile=elks it does say Mouse: No on the right. It should provide PS2 mouse, right?

@SuperMaxusa
Copy link
Contributor

But this is not the case in copy.sh, right?

Do you mean that ELKS supports PS/2 protocol via serial port?

it does say Mouse: No on the right. It should provide PS2 mouse, right?

Yes, it reacts to PS/2 mouse initialization.

v86/src/browser/main.js

Lines 2233 to 2237 in 2996c08

emulator.add_listener("mouse-enable", function(is_enabled)
{
os_uses_mouse = is_enabled;
$("info_mouse_enabled").textContent = is_enabled ? "Yes" : "No";
});

@toncho11
Copy link
Author

toncho11 commented Feb 20, 2025

Yes, PS/2 protocol via serial port (not through the BIOS INT 33h).

@copy
Copy link
Owner

copy commented Feb 21, 2025

I wouldn't mind supporting this, but it's not a high priority.

@ghaerr
Copy link

ghaerr commented Feb 23, 2025

Hi @copy and @SuperMaxusa,

Do you mean that ELKS supports PS/2 protocol via serial port?

Yes. When ELKS is setup for PS/2 mouse, it executes the following code when reading from a serial port:

/*
 * Input routine for PS/2 mouse.
 * Returns nonzero when a new mouse state has been completed.
 */
static int
ParsePS2(int byte)
{
    switch (state) {
        case IDLE:
            if (byte & PS2_CTRL_BYTE) {
                buttons = byte & (PS2_LEFT_BUTTON|PS2_RIGHT_BUTTON);
                state = XSET;
            }
            break;

        case XSET:
            if(byte > 127)
                byte -= 256;
            xd = byte;
            state = YSET;
            break;

        case YSET:
            if(byte > 127)
                byte -= 256;
            yd = -byte;
            state = IDLE;
            return 1;
    }
    return 0;
}

In other words, it parses each byte of the 3-byte PS/2 mouse message read from serial. It could easily be upgraded to the 4-byte version for mice with scroll wheels or five buttons. It doesn't write anything to the mouse.

I wouldn't mind supporting this, but it's not a high priority.

That would be fantastic, thank you! Let me know if need any help from my end.

I recently ported Microwindows to ELKS, and everything is now running, multiple applications drawing in multiple windows, all running 16-bits, see the screenshot below. @toncho11 has tested this with copy/v86 and all is also running except the mouse. At this time, the ELKS kernel doesn't know anything about mice and implementing a hardware PS/2 mouse requires trapping IRQ 12 which isn't allowed for application programs... the Microwindows server performs all the mouse reading/decoding, all from serial on ELKS (and Linux). I would like to add hardware PS/2 mouse support to the ELKS kernel but its a bit complicated and requires more changes that it should. QEMU and 86Box allow serial mouse emulation but we really like how easily copy/v86 boots and runs an OS right from the web.

16-bit ELKS running Nano-X on QEMU
Image

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants