The old DOS drivers don't work in a "DOS Window". It's not really DOS, it's the (32-bit) Windows console.
Not true.
Console apps run in a console window. DOS apps made with Turbo C++ will use a DOS session under emulated 16-bit DOS.
Mouse code does work with Turbo C++ 3.0. Almost all mouse drivers work with interrupt 33h and if you want to know the truth I believe MS Windows installs a rudimentary one on this interrupt at boot. So there is no need for DOS drivers to use the mouse if Windows has already hooked the interrupt.
This rudimentary driver supports most of the common operations.
This will get you started with the mouse in Turbo C++. Note that if you have TASM you can use inline assembly for TC 1.0 -> 4.52.
TASM 5.0 is readily available on the web on many academic/uni/fan websites.
AFAIK MASM is readily available through the MVC Express d/l.
Simple mouse functions for TC 3.0
Code:
#ifndef Mouse_h
#define Mouse_h
#include <dos.h>
#define MOUSE_LMB 0x01
#define MOUSE_RMB 0x02
#define MOUSE_MMB 0x03
#define MOUSE_SHOW 0x01
#define MOUSE_HIDE 0x02
struct MouseInfo
{
int iX;
int iY;
int iButtonDown;
};
class CMouse
{
MouseInfo MouseProps;
public:
CMouse(void) { }
virtual ~CMouse(void) { }
void ResetDriver(void)
{
union REGS regs;
regs.x.ax=0x00;
int86(0x33,®s,®s);
}
void Show(int iMode)
{
union REGS regs;
regs.x.ax=iMode;
int86(0x33,®s,®s);
}
void Update(void);
{
union REGS regs;
regs.x.ax=0x05;
int86(0x33,®s,®s);
MouseProps.iX=regs.x.cx;
MouseProps.iY=regs.x.dx;
MouseProps.iButtonDown=regs.x.bx;
}
MouseInfo GetProps(void) {return MouseProps;}
//Add other functions here
};
#endif
Sample code:
Code:
CMouse MyMouse;
//Show mouse cursor
MyMouse.Show(MOUSE_SHOW);
//Hide mouse cursor
MyMouse.Show(MOUSE_HIDE);
//Get coords and button info
MyMouse.Update();
MouseInfo info=MyMouse.GetProps();
//Call user supplied function to draw cursor at current position
DrawCursor(info.iX,info.iY);
switch (info.iButtonDown)
{
case MOUSE_LMB:
//Left mouse button down
case MOUSE_MMB:
//Middle button down
case MOUSE_RMB
//Right button down
}
I leave it to you to add more functions. Get Ralph Brown's Interrupt List for more mouse functions residing on int 33h.