Hi,
cycl0ne wrote:Brendan wrote:If you mean "arch_ps2m_init(void)" in your second post; then:
- It doesn't check if the PS/2 controller exists at all
- It doesn't do the PS/2 controller's self test (command 0xAA)
- It doesn't disable the silly "scancode set 2 to scancode set 1" translation for the first PS/2 port
- It doesn't check if the PS/2 controller supports 2 PS/2 ports or if it's an older controller that only supports one PS/2 port
- It doesn't do the "interface tests" for either PS/2 ports
- It does send the "reset/self test" command to the device on either PS/2 port (device command 0xFF)
- It doesn't check if the device reported "OK" or "faulty" after the "reset/self test" command
- It doesn't check the device ID if the device reported "OK" after the "reset/self test" command; which is needed to determine if the device is a mouse or something else (keyboard, bar-code scanner, touch screen, whatever)
- When sending commands to the mouse; you don't check if it replies with 0xFA (OK), 0xFC (error) or 0xFE (resend)
- You don't poll periodically to determine if the device has been removed
- If the user unplugs the device and plugs in a difference device (e.g. keyboard) then the new device sends a "BAT completion code" and you ignore that and continue pretending a mouse is connected
- If the user unplugs the device and plugs the exact same device back in; then the device sends a "BAT completion code" and you ignore that and fail to reset/reinitialise the device
- If you get invalid data from the mouse for any reason, you don't ask the mouse to resend the packet and just silently discard information until you see a byte that may or may not be the first byte of a packet
Then please update the Wiki,
This is
the wiki page for the PS/2 mouse. Sadly, this page is missing a lot of information; and there's
a different "mouse" page that should only contain generic information (and the PS/2 specific information, which includes information for both the PS/2 controller and the PS/2 mouse should be shifted/merged into the correct places). Mostly, you're right - the mouse pages do need work.
For virtually everything; most of the code you'll find online is pure crud. Most of it is code that "works" (until/unless something is slightly strange) and not code that works (including handling corner cases and failure modes).
cycl0ne wrote:and for the "two keyboard/mice/whatever" problem. this is driven by a special device management. as i said, the driver here just takes the mousedata from ioport to a queue. keyboard data is also in a seperate queue. and there is a third device sitting on top (called INPUT) which collects the data.
so you can plug in a second, third, fourth mouse, keyboard, whatever and all is collected and correctly assigned to the system through the input processor, because all of them have a seperate queue. its kind of a NAMED PIPE under unix/linux for the drivers.
they deliver data, someone else fetches it.
You're deliberately trying to avoid the issues. If there are 2 mouses you can't just use the same mouse driver for both because it's hard-coded to use IRQ 12 and a specific PS/2 port. If the PS/2 controller is
something very different you can't just recompile the mouse driver and use it without changing its source code. You also can't test it easily (e.g. by telling it to communicate with a dummy "unit test" driver instead of communicating with the PS/2 controller's driver).
For the code itself, it's not just a simple translator that converts raw bytes from wherever into mouse events for your named pipe. The "2 button mouse protocol" is just a default (for backward compatibility) and there are several other protocols ("3 button with scroll wheel", "5 button with scroll wheel", etc); and (eventually) your code should be attempting to enable the correct protocol for the device. In addition there's the stuff you've skipped (retries, error handling, hot-plug), plus stuff you're not using (mouse scaling, better sample rates, etc), plus stuff you're not doing on the opposite side (e.g. providing some sort of standardised "n button, n axis" pointer device abstraction for the GUI to use, including scaling the mouse movement to a normalised/device independent range).
cycl0ne wrote:The best thing is: where do you see anything that i do anything with the data that you see i have a mixed driver?
The PS/2 controller and the PS/2 mouse driver are 2 separate pieces of hardware (just like a USB controller and a USB device are a separate pieces of hardware). You should have a PS/2 controller driver and a separate PS/2 mouse driver, where these 2 drivers communicate (just like you'd have a USB controller driver and separate USB device drivers), possibly using your "named pipes" if that's how your OS does things. You've mixed the PS/2 controller driver and the PS/2 mouse driver together.
cycl0ne wrote:Dont want to sit hours on implementing this all and it wouldnt fix my problem.
The current problem (whatever it is) is just a symptom of the fact that your code is crap and needs to be redesigned then rewritten. If you found and fixed the current problem the code would still be crap that needs to be redesigned and rewritten. Finding and fixing the current problem changes nothing and is a complete waste of time.
Cheers,
Brendan