flat assembler
Message board for the users of flat assembler.

Index > OS Construction > [SOLVED]Mouse driver- in PMode - don't understand something!

Author
Thread Post new topic Reply to topic
binary



Joined: 10 Oct 2009
Posts: 29
binary 10 Oct 2009, 01:43
Hello!

So I'm trying to make a basic mouse driver for protected mode.I've went to
os dev wiki , some other sites , I've searched through this forum ( I read some topics more than 4 time ) , looked trough the MenuetOS an KolibriOS source codes , and I couldn't come up with a mouse drives , I simply don't understand how to make one.

I found on os dev forums a mouse driver written in C , when I see C or C++ source codes I puke instantly.

I'm familiar with using IN and OUT functions from a basic keyboard driver(
code found around here ).

I know that I have to enable somehow the mouse by sending something to the keyboard controller , wait for something to come back , after that everything becomes fuzzy , and in the end I should have 3 bytes for buttons, X and Y.

Can someone please show me a simple example of a mouse drive in assembly, and also if it comes with a little explanation that that would be even better , but any feedback it's appreciated.

And another thing, in which registers the 3 bytes are stored?

Thank you!


Last edited by binary on 11 Oct 2009, 20:20; edited 1 time in total
Post 10 Oct 2009, 01:43
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 10 Oct 2009, 01:46
This Fasm Browser written by Dex4u :
it is not complete but does have mouse Functions you could learn from..
also many other PM Functions..

http://dex4u.com/FAB/

Download the FABsource.zip look under Functions - MouseDraw ,MouseData, and the MouseLib

Its not well documented but if you have questions about any code I am sure there is someone here that could help!
Post 10 Oct 2009, 01:46
View user's profile Send private message Reply with quote
binary



Joined: 10 Oct 2009
Posts: 29
binary 10 Oct 2009, 02:11
Thank you for the fast reply! Now I'm looking through the source code...
Post 10 Oct 2009, 02:11
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 10 Oct 2009, 02:39
Dex4u had also done a simple version for MiniDOS.
This was the latest link i had, IDK if it work4u?
http://www.dex4u.com/tuts/MouseDemo.zip
Post 10 Oct 2009, 02:39
View user's profile Send private message Reply with quote
binary



Joined: 10 Oct 2009
Posts: 29
binary 10 Oct 2009, 16:43
I looked at both examples and compared them with MenuetOS and KolibriOS mouse drivers and from what I understand , in order to use the mouse I need a Setup section of code , a section of reading the data that comes from the mouse after it's initialized , and a section to display the cursor.

The fist section is something like:

Mouse Set Up: ... RET
Keyboard Read: ... RET
Keyboard Write: ... RET
Keyboard Command: ... RET

... and I kind of understood that.

I can manage the third section.
Now the second section of code is the problem.

- After I call the "Mouse Set Up:" part what do I need to do to receive the 3 bytes from the mouse?
- Do I really need an IDT for this and why?
- Why the keyboard must be disabled when I read the output from the mouse?

PS:I just want to get the mouse working for now , I'll have time to study all the aspects of it later.

Thanks again!
Post 10 Oct 2009, 16:43
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 10 Oct 2009, 17:45
you need to preocess the mouse interrput.
i don't know if it is the same as keyboard.

each int, you receive a new byte.
you find the first one who have a bit always set to indicate it is the first.
Post 10 Oct 2009, 17:45
View user's profile Send private message Visit poster's website Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 10 Oct 2009, 18:57
See here:

http://www.computer-engineering.org/ps2mouse/

under Command Set:
E9h

This article explains the mouse..


Quote:

Do I really need an IDT for this and why?


I dont think you do.. you can enable the mouse.. but to get it to move you would need a loop to track the movement... and update the screen pos..
for testing..

but for an OS you would want to program an IDT
Post 10 Oct 2009, 18:57
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 11 Oct 2009, 02:32
I just found this.. I have not tested it.. but its a simple mouse program..
with out using IDT.... loops like I was talking about above.. looks like what you were looking for:

http://www.programmersheaven.com/download/36764/download.aspx


its realmode example but should work for pm..
Post 11 Oct 2009, 02:32
View user's profile Send private message Reply with quote
binary



Joined: 10 Oct 2009
Posts: 29
binary 11 Oct 2009, 17:04
wow! how did you found this , I thought i searched the whole Internet.
It's exactly what I was looking for. I tested it in p mode ( with some adjustments )and it works. Thanks!
Post 11 Oct 2009, 17:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.