Thread: can't get my mouse to work on dos borland c++ 3

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    4

    can't get my mouse to work on dos borland c++ 3

    ... or any other DOS programs. Any ideas why?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Oh because I don't know maybe cause it is like 20 years old and people are using windows now.
    Woop?

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    If prog man's right, get a new compiler, and then look at the last post in this thread.

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    The old DOS drivers don't work in a "DOS Window". It's not really DOS, it's the (32-bit) Windows console.

    If you boot to true 16-bit DOS, if you have the original DOS drivers for your mouse, and if you have a serial mouse, it should work. I don't really remember if you could use a PS2 mouse (round connector) with DOS.

    And BTW - Get a new compiler! Microsoft Visual C++ Express is free. So is Bloodshed. Then, leave the mouse out of console applications. Wait 'till you're ready to learn GUI programming,
    Last edited by DougDbug; 05-25-2006 at 02:11 PM.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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,&regs,&regs);
        }
    
        void Show(int iMode)
        {
            union REGS regs;
            regs.x.ax=iMode;
            int86(0x33,&regs,&regs);
        }
    
         void Update(void);
         {
            union REGS regs;
            regs.x.ax=0x05;
            int86(0x33,&regs,&regs);
    
           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.
    Last edited by VirtualAce; 05-25-2006 at 11:11 PM.

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Quote Originally Posted by Bubba
    I leave it to you to add more functions. Get Ralph Brown's Interrupt List for more mouse functions residing on int 33h.
    http://www.ctyme.com/intr/int-33.htm
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creepy DOS and BIOS functions (need help!!!)
    By James00 in forum C Programming
    Replies: 9
    Last Post: 05-05-2003, 12:40 AM
  2. mouse
    By stilllearning in forum C Programming
    Replies: 0
    Last Post: 04-15-2003, 03:34 PM
  3. Friggin Mouse on Laptop
    By OneStiffRod in forum Tech Board
    Replies: 2
    Last Post: 03-27-2003, 07:49 PM
  4. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM
  5. Mouse in DOS
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-22-2001, 12:14 PM