Page 1 of 1
Too new to know
Posted: Thu May 15, 2008 1:23 pm
by perl2go
I am looking to make a mouse emulator. I have made a simple keyboard emulator using the kport.dll and calling the Outportb method. I am looking to see how I can use this same approach for the mouse. I have been writing software for a while but this is my first glimpse into hardware. I have found a ton via google but I don't even know enough to know if what I am looking at is basic stuff and that I just may need something even more simple.
Any suggestions on a place to start reading up on emulating a mouse would be most appreciated.
Thank you in advance.
Mike
P.S. - Many will think, "OMG, you really don't know what you are asking." Well, yes, I am just that new to this level of thinking
Posted: Thu May 15, 2008 1:55 pm
by svdmeer
I don't think your approach will work, because you can't put data back to your mouse, to simulate 'real' moves with the mouse.
Maybe it's a good idea to write a driver instead. That driver won't communicate with real hardware, but it's a virtual driver. The driver behaves like a real mouse driver, but has also functions to put information about the 'virtual moves' of the emulated mouse.
It's like the RAM-disk: A ram disk looks like a real disk for the OS, but in reality it's just a bunch of memory. You mouse driver looks like a real mouse-driver, but in reality it's just a piece of software that gets mouse-data from other software.
RE:
Posted: Thu May 15, 2008 2:14 pm
by perl2go
thank you for the info and I will start to look into that...
as long as i'm google'ing... any suggestions on where to start with that?
thanks again.
Posted: Thu May 15, 2008 2:57 pm
by lukem95
look for the microsoft windows API functions that interface with the mouse
yupyup
Posted: Thu May 15, 2008 4:00 pm
by perl2go
i have used those and they work. just want to dig deeper out of curiosity.
thanks
Posted: Thu May 15, 2008 5:22 pm
by bewing
10 or so threads down on the forum's board is a thread where another guy is trying to "dig deeper" on basically the same subject. If you read that, you will learn much -- and learn why digging deeper is probably a bad idea in your case.
http://www.osdev.org/phpBB2/viewtopic.php?t=16970
yupyup
Posted: Thu May 15, 2008 7:56 pm
by perl2go
yup, Nitro's post is exactly what i was trying to get at and I was looking at it as simplistically as he was. (due to ignorance) i got the keyboard outportb messages to work and seemed to me that since the ps/2 mouse used the same port that i could just send different instructions to accomplish the same thing with the mouse as i am with the keyboard.
my thoughts were exactly along the same lines as his...
- lock the real mouse out
- find the cursor
- take control and send new commands via virtual mouse
- finish up and release control back to the real mouse
...piece of cake? right? guess not?
scanning through
http://www.computer-engineering.org/ps2mouse/ it seems to me that i would send three bytes through outportb(). so, in my head, i am thinking rather than keyboard scan make/break codes i send the 3 bytes as indicated in the "Movement Data Packet" section.
also...
http://paginas.fe.up.pt/~jcard/ensino/L ... mouse.html
the part about "Emulation/Interfacing" & "To Emulate a Mouse"
thanks again...
Posted: Thu May 15, 2008 11:22 pm
by bewing
But it's not always 3 bytes. Often it's 4.
And non-M$ mice don't do it that way at ALL.
And what resolution do you use? Will telling the mouse to move "50" move it halfway across the screen, or just to the next pixel over?
And as said on the other thread -- any OS with any decent security should completely block you from doing any such thing, unless what you are writing is a kernel driver. Not that windoze has decent security, but the security hole required is just immense.
ahh...
Posted: Fri May 16, 2008 8:09 am
by perl2go
considering that this is a "playground" for me by me to run on my machine. i am no concerned with the security implications. if my play box crashes, so be it. lesson learned
if anyone knows where i could find examples of such communication, that would be most helpful. otherwise, i will take what i have and run...
thanks guys, this is a great forum.
Posted: Fri May 16, 2008 9:46 am
by Dex
What OS do want to run the code on ?.
ooh!
Posted: Fri May 16, 2008 10:47 am
by perl2go
Windows XP
Posted: Fri May 16, 2008 11:49 am
by Dex
See here:
http://www.codeproject.com/KB/DLL/ParkMouse.aspx
Also look into remote helper code, as XP also has "remote" technology, maybe you could use this in a loopback (127.0.0.1)
my thoughts...
Posted: Fri May 16, 2008 8:25 pm
by perl2go
thanks dex, i grabbed the source and tweaked it. i was able to feed in the coordinates i wished and moved the mouse.. however, i am trying to do i more like... without caring where the mouse was, i tried to right click like this...
do { status = Inportb((ushort)0x64); } while ((status & 2) != 0);
Outportb(0x60, 0xF4); // enable mouse
do { status = Inportb((ushort)0x64); } while ((status & 2) != 0);
Outportb(0x64, 0xD4); // send mouse write request
do { status = Inportb((ushort)0x64); } while ((status & 2) != 0);
Outportb(0x60, 0x0A); // send mouse right down
Outportb(0x60, 0x00); // send mouse x
Outportb(0x60, 0x00); // send mouse y
do { status = Inportb((ushort)0x64); } while ((status & 2) != 0);
Outportb(0x60, 0x08); // send mouse right up
Outportb(0x60, 0x00); // send mouse X
Outportb(0x60, 0x00); // send mouse Y