Solved

Mouse Routines for DOS

Posted on 1998-01-19
2
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need example 5 128
Line meaning 9 89
What's the Difference Between a VI, the Command Prompt and a Shell 7 133
Why  my code (program) build with old compiler? 11 107
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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 conditional statements in the C programming language.

763 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