Mouse programming

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Mouse programming

Post 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
Attachments
mouse.test.asm
(4.49 KiB) Downloaded 94 times
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: Mouse programming

Post 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
Gizmic OS
Currently - Busy with FAT12 driver and VFS
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Mouse programming

Post 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:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse programming

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Mouse programming

Post 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.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Re: Mouse programming

Post 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...
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse programming

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse programming

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Re: Mouse programming

Post 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).
Attachments
mouse_test.rar
(5.45 KiB) Downloaded 102 times
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse programming

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Re: Mouse programming

Post 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.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse programming

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
whiteOS
Member
Member
Posts: 29
Joined: Mon Oct 06, 2008 12:38 am

Re: Mouse programming

Post 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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Mouse programming

Post by bewing »

Bochs translates any mouse into a simulated PS2 mouse.
Post Reply