The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: sinsi on July 06, 2007, 05:54:00 AM

Title: USB keyboard and mouse
Post by: sinsi on July 06, 2007, 05:54:00 AM
Does a USB keyboard still send IRQ1 or is it all done via the USB controller? And what about the mouse?

I ask because I've gotten the "roll your own" bug  ::) (thanks Bogdan...I think)
Title: Re: USB keyboard and mouse
Post by: Tedd on July 06, 2007, 03:05:34 PM
Initially, while in real mode and if the bios is set for it, then it will simulate the legacy keyboard by translating the usb keyboard input - so it appears the keyboard is still a legacy one, and can be used as such. When you set up your own interrupt handlers then it becomes your problem - and the keyboard only comes in through the usb controller (as it is, and always was, a usb device.)
Same for the mouse.

(Unless it's the chipset that magically does this, then I suppose you could enable it - with the help of bios - and it should just work; but I don't think that's what happens.)
Title: Re: USB keyboard and mouse
Post by: BogdanOntanu on July 06, 2007, 06:16:36 PM
Yes usually BIOS will emulate USB mouse and keyboard as PS/2 mouse and keyboard while in real mode. In protected mode this emulation might or might not continue.

From my experience I would say that 80% of BIOS will emulate USB mouse and keyboard in real mode while only 50% or less will continue this emulation when the CPU is in protected mode.

The emulation is usually done via SMM code that is inaccessible even to OS  programmers. You might have an option in your BIOS setup for enabling/disabling this kind of emulation.

The bottom line: you can get lucky 50% of the times but normally you will need some USB drivers for mouse and keyboard as soon as you are in protected mode :D. And do not forget that USB drivers are kind of complicated to write.
Title: Re: USB keyboard and mouse
Post by: sinsi on July 07, 2007, 12:05:58 AM
Why isn't anything easy?

Thanks for the info guys.
Title: Re: USB keyboard and mouse
Post by: ninjarider on July 12, 2007, 08:36:09 PM
let me know what you find out.

im about to test switching to p mode myself and find out if the usb works or not.
Title: Re: USB keyboard and mouse
Post by: ninjarider on July 20, 2007, 07:35:34 PM
well it doesn't work on my dell optiplex 240gx i think. latest bios edition.

not i have to find out how to right usb drivers for it.
Title: Re: USB keyboard and mouse
Post by: MichaelW on July 21, 2007, 03:50:33 AM
Mark Larson posted some USB-related code that might contain some useful information  here (http://www.masm32.com/board/index.php?topic=392.msg2437#msg2437).
Title: Re: USB keyboard and mouse
Post by: sinsi on July 21, 2007, 04:55:04 AM
Can't get the 2 links to work...help us donkey!  :bdg
Quote from: Mark_Larson on January 14, 2005, 04:41:33 PM

Donkey has been kind enough to host both files.  Here are the links.  Thanks Donkey!!!


http://www.members.shaw.ca/contact_donkey/files/markl/USBCOMP.ZIP
http://www.members.shaw.ca/contact_donkey/files/markl/ICH2.ZIP

And thanks MichaelW for your good memory.
Title: Re: USB keyboard and mouse
Post by: ninjarider on July 22, 2007, 07:07:58 PM
not workin
Title: Re: USB keyboard and mouse
Post by: MichaelW on July 22, 2007, 10:18:56 PM
The links do not work, but ICH2.ZIP is still available as an attachment on the post that I linked. The other is just an EXE, no source.