Solved

Mouse Routines for DOS

Posted on 1998-01-19
2
245 Views
Last Modified: 2010-05-18
I need a set of routines to access the mouse through DOS.  I already have one, but it has problems with mode 13h.  I need a routine that works with mode 13h, it DOES NOT have to be compatible with any other screen modes.

Thanks in advance!
0
Comment
Question by:Egore
2 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 1257030
Are you referring to something other than the standard DOS mouse calls? If so, could you specify the required functionality?

0
 

Accepted Solution

by:
andersh012098 earned 100 total points
ID: 1257031
Here are some very basic mouse routines.
I haven't written any error checking but if initmouse() doesn't return 0 everything should work just fine.
Remember that in mode 13h you have to divide the mouse X coordinate with 2 too get the correct screen X coordinate. (This is due to historical reasons)
I haven't made any comments because the code is so simple. It just calls diffrent functions on interrupt 33h.
To use this first call initmouse() and check so it doesn't return 0. Then call showmouse() to make the mouse vissible on the screen.
To get the status of the mouse just call getmouse with four integers and you'll get X and Y coordinate of the mouse and the status of the left and right mouse buttons.
I haven't included support for 3 buttons because I don't have one to test if it works... You can write it ourself if you want to. In initmouse() BX will contain the number of mouse buttons and in getmouse ((_BX & 4) == 4) will get the status of the center button.

int initmouse()
{
   asm {
      mov ax,0
      int 33h
   }
   return _AX;
}

void showmouse()
{
   asm {
      mov ax,1
      int 33h
   }
}

void hidemouse()
{
   asm {
      mov ax,2
      int 33h
   }
}

void getmouse(int& x,int &y,int left_button_down,int right_button_down)
{
   asm {
      mov ax,3
      int 33h
   }
   x = _CX;
   y = _DX;
   left_button_down = ((_BX & 1) == 1);
   right_button_down = ((_BX & 2) == 2);
}

void setmouse(int x,int y)
{
   asm {
      mov ax,4
      mov cx,x
      mov dx,y
      int 33h
   }
}

void setxlimits(int minx,int maxx)
{
   asm {
      mov ax,7
      mov cx,minx
      mov dx,maxx
      int 33h
   }
}

void setylimits(int miny,int maxy)
{
   asm {
      mov ax,8
      mov cx,miny
      mov dx,maxy
      int 33h
   }
}

Hope that you can get it to work correctly.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now