How do you introduce mouse in c++ program?

you have to use os-specific functions. What compiler and what operating system ?

and what hardware architecture, what mouse (USB, PS/2, serial, something else maybe).

I've done it 15 years or so ago. At the time we had to write our own mousedrivers, was fun.
I think the disk with that code is by now unreadable (not that it would do much good of course as hardware and operating systems have progressed rather a lot since).

OS - Windows
Compiler - Turbo C++

for a PS2 and a USB mouse.

check out this site. If you are using ancient Turbo C++ I don't think it can access either PS2 or USB mouse ports because you will need a MS-DOS device driver which pre-dates both port types.

If you are using the newest version of Turbo C++ then you can use win32 api windows program mouse events.

Windows might play nice and provide an abstraction layer which makes the command window perceive the mouse as a serial device, but I'm far from certain about that.

check out this site. If you are using ancient Turbo C++ I don't think it can access either PS2 or USB mouse ports because you will need a MS-DOS device driver which pre-dates both port types.

If you are using the newest version of Turbo C++ then you can use win32 api windows program mouse events.

Very useful site you mentioned above. Actually I also did a search and got a similar tutorial. It works beautifully. But I haven't yet tried with a USB mouse.

Thanks for the link

The link also mentioned something about displaying images. But it didn't explain it well.

I downloaded the file from the site but the code didn't mention anything related to that.

Could you explain how to introduce images?

Thanks in advance!

I went to a site where it mentioned a similar code.

#include<iostream.h>
#include<graphics.h>
union REGS in,out;

void mousecall()
{
   in.x.ax = 1;
   int86(51,&in,&out);
}

int main()
{
   int driver = DETECT,mode;
   initgraph(&driver,&mode,"\\tc\\bgi");
   mousecall();
   getch();
   closegraph();
}

What does in.x.ax = 1 signify?
I know what the numerical value stands for.

like 1 = show the mouse pointer
3 = get the mouse status

But what is union REGS??

you have to understand a little about assembly programming. REGS is just a union on some integers that the function int86() uses to set up the microprocessor's registers before executing the interrupt instruction. google for dos interrupts and you will find this among many others.

INT 5 - Print Screen
Does this do something like screen capture?
Because since my program is DOS based program none of the screen capture programs seem to work. And I need to show screen shots of my program in my project.

yup. typically will send a character representation of the screen (ASCII Art forever!) to the parallel port.

INT 16,1 - Get Keyboard Status
INT 16,2 - Read Keyboard Flags

Could you give me the syntax to use them? Is it something like this

int16(2,&in,&out);
I don't know much about assembly language.

Can anyone give me the syntax, please?
Thanx in advance

see the instructions for int86() function. Google and you will see examples.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.