Mouse Handling in C Programming

NOTE: As tested On: Turbo C++,Version 3.0 by Borland International,Inc.
Mouse Programming : Introduction :

o	Mouse is an input device or pointing device which 
	functions by detecting two-dimensional motion relative 
	to its supporting surface.
o	In Graphics User Interface(GUI) system, mouse plays an 
	important role for user interaction. It is very
	essential key factor in GUI.
o	Today, mouse programming is mostly used in games 
	development, animation programming and to build 
	graphical applications like graphs, charts, tables etc.
o	In computer system, each device has an unique port 
	which has hexadecimal value.
o	It has designed to be machine independent enhancing 
	portability program.
o	We can easily access ports in a C program.
o	Basically, mouse uses 'interrupts' to access drivers.
o	Mouse interrupt is handled using int86 function of 
	dos.h header file.
o	Mouse has port 0X33 attached to it and keyboard 
	has attached to port 0X60.
o	We can also use address registers.
o	This is UNION of type REGS which is defined in 
	"dos.h" header file.
o	We can use two registers to communicate to a 
	device driver as one for input and other for output.
o	We can send value to device driver through the 
	input register and receive information in it embedded 
	in output register.

AX Register :
o	AX=0 --- Returns mouse status
o	AX=1 --- Show mouse pointer.
o	AX=2 --- Hide mouse pointer.
o	AX=3 --- Position of mouse. 
	(X Coordinate:CX, Y Coordinate:DX)
o	AX=3 --- Mouse button press
( If BX=0 then no any key is pressed,
If BX=1 then left button is pressed,
If BX=2 then right button is pressed,
If BX=3 then centre button is pressed. )

Leave A Comment

Your email address will not be published. Required fields are marked *