Too new to know

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
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

Too new to know

Post 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 :)
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post 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.
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

RE:

Post 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.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

look for the microsoft windows API functions that interface with the mouse
~ Lukem95 [ Cake ]
Release: 0.08b
Image
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

yupyup

Post by perl2go »

i have used those and they work. just want to dig deeper out of curiosity.

thanks
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post 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
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

yupyup

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

Post by bewing »

But it's not always 3 bytes. Often it's 4. :wink:
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.
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

ahh...

Post 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.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

What OS do want to run the code on ?.
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

ooh!

Post by perl2go »

Windows XP
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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)
perl2go
Posts: 7
Joined: Thu May 15, 2008 1:13 pm

my thoughts...

Post 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
Post Reply