Program for initialize mouse cursor in C

This is program to Initialise Mouse and display its cursor. Dos.h header file is used for handling interrupts,date & time functions,producing sound,delay,sleep etc. We can do everything with mouse using C codes.

 

#include<stdio.h>

#include<dos.h>

void main()

   {

    union REGS i,o;

    i.x.ax=1;

    int86(0x33,&i,&o);

    getch();

  }

mouse cursor in c

Explanation…

In above example first initializing the mouse by using ax=1 and calling interrupt 0*33.

In fact we do not communicate with mouse directly that is why we use driver. We use “interrupts”(asynchronous signal which indicates the need for attention) to access the driver. Mouse driver maintains the cursor position & status of the mouse buttons.

By using this we can move the mouse pointer around the screen.

We can access various mouse functions(like resets the mouse& retrieve the mouse status,display the mouse cursor,hides the mouse cursor etc) using different values of AX (union REGS i,o;i.x.ax=1;) input register and passing the values to mouse port using a interrupt(#include<dos.h>).