Page 1 of 1

Mouse programming

Posted: Wed Oct 15, 2008 1:42 pm
by kmtdk
Hi all
well
today i have tried to make a mouse driver ( for Pmode):
but now after trying everything i could, it still dont work.
The problem is, that when i read the "data" the mose is suposed to send, i get something unvalid...
I have tryed with both stream mode, and remote mode, but the same problem comes.
the code is attached ( it is the hole test program)
What i do is:
enable aux for mouse,
reset mouse, ( i have also tryed with or without the "IRQ12" option)
set enable data reporting

then i use the comman ("E8") to get the data.
i cant realy figure it out ...
(sorry about the notes, cause they are in danish )
KMt dk

Re: Mouse programming

Posted: Thu Oct 16, 2008 6:42 am
by System123
I don't know much about mouse programming but I can see an error in the first line.

Code: Select all

mov ax,0x0013
int 0x10
xor di,di
mov ax,0xa000
mov es,ax
call print.cursor
you CAN'T use interrupts in PMode unless you reprogrammed them and even then you can't use int 10 as this is reserved for hardware exceptions

Re: Mouse programming

Posted: Thu Oct 16, 2008 10:50 am
by i586coder
NICE TOPIC 8)

well,I tried mouse programming in my UNEXT/os
it's flat mode kernel,whatever

my question: what is your device :?:
1. serial
2. ps/2
mouse

in most cases your probelm not in implement's -
but in mouse protocol :wink: ,
since there is many mouse protocols.

personally i use 3 byte protocol packet for microsoft serial mouse
anyway,as rule to program mouse driver you need
1. detect mouse setting(serial,ps/2)
2. setup mouse protocol well

you can use this link,may be useful for you


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


good luck :mrgreen:

Re: Mouse programming

Posted: Thu Oct 16, 2008 11:26 am
by kmtdk
well first: this is the test program, meaning that it is real mode:
secound: the input is valid ( new tests) but it dont chage EVER ;
so the only input is this ( i have tryed with : laser, optical, ps2 , and none worked on bochs)
byte 1 :0x08
byte 2 :0x00
byte 3 :0x00


KMT dk

Re: Mouse programming

Posted: Thu Oct 16, 2008 12:53 pm
by bewing
In Real mode, the BIOS handles all the mouse input, AFAIK. It receives all the IRQ12s, and then goes and reads the mouse bytes before you can get them. So you would need to hook the IRQ12 handler. It's much easier to do it in Pmode, I think.

And do you know that you need to "turn on" the mouse in bochs, before it will send you data? You either need to hit F12, or Shift+Lbutton+Rbutton, or something like that.

Re: Mouse programming

Posted: Fri Oct 17, 2008 4:01 am
by mystran
I have a relatively well commented mouse driver for my pet kernel, might have posted it in the past, but could repost when I get back to home, if there's interest... could be useful as reference, supports PS/2 as either basic 2 button, wheel version and 5 button+wheel...

Re: Mouse programming

Posted: Fri Oct 17, 2008 3:06 pm
by kmtdk
I would be very pleased, to see a driver ;P ( THX )
but after reading what bewing had written, i think i know why ( but i still dont godt it, when in remote mode, since there would not happen eney int's.. )
if "bios" reads the data, useing the command 0xE8 then it resets the count ( the reason why i only get "0" movments" but vaild packets , have not had time enough to test this ideer )

KMT dk

Re: Mouse programming

Posted: Sun Oct 19, 2008 1:09 pm
by kmtdk
well
"my" ideer did not seem to work, so if any can show me a example witch work ( do you have to "chage" the mose's state in order to enable it: what i mean is, do you need to test the mose for 5 buttons, or whell in order to make it usable , or have i missed something)

KMT dk

Re: Mouse programming

Posted: Mon Oct 20, 2008 11:21 am
by Masterkiller
Three of four days ago I wrote basic mouse support for unreal mode. It is not a driver, it is just a test code, that create a cursor moved by the mouse. Since it is only a test code, it is neither optimized, nor "correct", rely on it only theoritically. It works only for PS/2 mouse.

If you do not change mouseID after reset you will get 3 bytes packets, else you will get 4. MouseID will not change if does not support it (e.g. no scroller and 4 and 5 buttons).
For protected mode driver you should not wait in the interrupt for bytes to come. If in IRQ12 handler you get one byte from mouse only, and bit 0 in status of the KC is cleared, save that byte, save somewhere that you have 1 byte from mouse and send EOI. When mouse is ready with the second byte of the 3 or 4 byte packet it will interrupt again. So if system is multitasking it will not wait slow Keyboard Controller (KC).

Re: Mouse programming

Posted: Mon Oct 20, 2008 1:01 pm
by kmtdk
well
looking at the code, the inti part is 99 % the same
and also the problem (tested on real, and bochs ..), it dont get Any info...
so the mouse never moves, if it was supossed to ..


KMT dk

Re: Mouse programming

Posted: Mon Oct 20, 2008 5:18 pm
by Masterkiller
Well, I tested especially that code and to me works on MS Virtual PC, Bochs and real hardware. What type mouse you are using? I use USB mouse, but I have USB-to-PS2 connector. It works only if connected to PS/2.

Re: Mouse programming

Posted: Mon Oct 20, 2008 11:10 pm
by kmtdk
well
i have read the USB HID part about the mouse:
It emu a ps/2 mouse until you have tool it to be used as a USB; so of cause i havn not used the ps/2 port, due to the fact, that i dont have one working right now, but i will try it agin. ( Shuld bochs not make the usb to a ps/2 mouse, so i dont have to connect a ps/2 mouse, or im worng ?)


KMT dk

Re: Mouse programming

Posted: Mon Oct 20, 2008 11:48 pm
by whiteOS
everything looks good until here:

Code: Select all

mouse.set.data:
call keyboard.wait
mov al,0xd4
out 0x64,al
call keyboard.wait
ret
You never set the data.

Re: Mouse programming

Posted: Mon Oct 20, 2008 11:48 pm
by bewing
Bochs translates any mouse into a simulated PS2 mouse.