mouse support in C++ (DOS)

This is a discussion on mouse support in C++ (DOS) within the C++ Programming forums, part of the General Programming Boards category; well I'm just sitting here wanting to program something interesting and I had the idea of trying to figure out ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    9

    Question mouse support in C++ (DOS)

    well I'm just sitting here wanting to program something interesting and I had the idea of trying to figure out how tog et a mouse to work in C++ DOS mode but I cant find anything on it on the net and really dont know where to start... any help would be greatly appreciated!

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    9
    hmm well thats nice... not.... I can barely read that stuff that is the worse formatted text file I have ever seen besides I dont really wanna spend the next hour reading all that... anyone know of just simple simple code that will do it I mean if I see the code I can probably figure out how it works I really dont wanna read the inner workings of it just the code itself

    thx

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    I dont really wanna spend the next hour reading all that... anyone know of just simple simple code that will do it I mean if I see the code I can probably figure out how it works I really dont wanna read the inner workings of it just the code itself

    If you don't read all of that, you will not understand what you are doing. When programming for the mouse, the inner workings is your code. You are interfacing with the mouse driver and if you don't know how to do that, then you will not have mouse support. The mouse won't do anything until you know how to interpret what it's telling you and which functions you need. Read the docs.

    There is a lot of information about the mouse on the Internet. Looking it up on a search engine comes up with about a million links for me. Where did you look?

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    9
    google.com unfortunitly like I said I dont really wanna read about the inner workings tonight all I want is the code I need to have it working and than just work with it I mean sure somewhere down the road I want to read just not tonight, too lazy I guess, but anyways I just dont wanna read it right now. So if you guys dont wanna give me the code to do it than I'll just go read it maybe later this week when I have time

    vVv - thx for the information I'll read it later (seriosuly)
    Bubba - Thx for being not so helpful!

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Ok, here goes.


    Code:
    struct tagMouse
    {
      int x;
      int y;
      int btndwn;
    }Mouse;
    
    
    void mousereset(void)
    {
      //Reset driver 
      union REGS regs;
      regs.x.ax=0x00;
      int86(0x33,& regs,& regs);
    }
    
    void showcursor(void)
    {
      //Show mouse hw cursor
      union REGS regs;
      regs.x.ax=0x0001;
      int86(0x33,& regs, &regs);
    }
    
    void hidecursor(void)
    {
      //Hide mouse hw cursor
      union REGS regs;
      regs.x.ax=0x0002;
      int86(0x33,& regs,& regs);
    }
    
    void GetMousePos(void)
    {
      //Get mouse pos and button status
      union REGS regs;
      regs.x.ax=0x0003;
      int86(0x33,& regs,& regs);
      if (screenres==320)
      {
         Mouse.x=regs.x.cx>>1;
      } else  Mouse.x=regs.x.cx;
      Mouse.y=regs.x.dx;
      Mouse.btndwn=regs.x.bx;
    }
    
    void SetMousePos(int x,int y)
    {
      //Set mouse cursor pos
      union REGS regs;
      regs.x.ax=0x0004;
      regs.x.cx=x;
      regs.x.dx=y;
      int86(0x33,& regs, & regs);
    }
    
    void  GetMouseButtonData(int buttonnum)
    {
      //Get mouse button data
      union REGS regs;
      regs.x.ax=0x0005;
      regs.x.bx=buttonnum;
      int86(0x33,& regs,& regs);
      int buttonstate=regs.x.ax; 
      int numberofpresses=regs.x.bx;
      int lastcolwhenpressed=regs.x.cx;
      int lastrowwhenpressed=regs.x.dx;
    }
    
    void GetMouseButtonReleaseData(int buttonnum)
    {
      //Get mouse button release data
      union REGS regs;
      regs.x.ax=0x0006;
      regs.x.bx=buttonnum;
      int86(0x33,& regs,& regs);
      int buttonstate=regs.x.ax; 
      int numberofreleases=regs.x.bx;
      int lastcolwhenreleased=regs.x.cx;   //x
      int lastrowwhenreleased=regs.x.dx; //y
    }
    
    void DefineHoriz(int minx,int maxx)
    {
      //Set horiz range for cursor
      union REGS regs;
      regs.x.ax=0x0007;
      regs.x.cx=minx;
      regs.x.dx=maxx;
      int86(0x33,& regs, & regs);
    }
    
    void DefineVert(int miny,int maxy)
    {
      //Set vert range for cursor
      union REGS regs;
      regs.x.ax=0x0008;
      regs.x.cx=miny;
      regs.x.dx=maxy;
      int86(0x33,& regs, & regs);
    }
    
    void SetMouseCursor(int hotpointx,int hotpointy,unsigned int cursoroffset,unsigned int cursorsegment)
    {
      //Change mouse cursor to diff image
      union REGS regs;
      SREGS sregs;
      regs.x.ax=0x0009;
      regs.x.bx=hotpointx;
      regs.x.cx=hotpointy;
      regs.x.dx=cursoroffset;
      sregs.es=cursorsegment;
      int86x(0x33,& regs, & regs, & sregs);
    }
    
    void ConditionalHide(int left,int top,int right,int bottom)
    {
      //Set cond hide box
      //Logitech and compats only - may not on EGA/VGA
      union REGS regs;
      regs.x.ax=000A;
      regs.x.cx=left;
      regs.x.dx=top;
      regs.x.si=right;
      regs.x.di=bottom;
      int86(0x33,& regs, & regs);
    }
    
    void SetMickeys(int mickeyx,int mickeyy)
    {
      //Set mickeys ratio
      union REGS regs;
      regs.x.ax=0x000F;
      regs.x.cx=mickeyx;
      regs.x.dx=mickeyy;
      int 86(0x33,& regs, & regs);
    }
    
    void SetAccel(int threshold)
    {
      //Set mouse accel
      union  REGS regs;
      regs.x.ax=0x0013;
      regs.x.dx=threshold;
      int86(0x33,& regs,& regs);
    }
    For an example of screen mask and cursor mask.

    Code:
    int Arrow[]=  {0x3fff,0x1fff,0x0fff,0x07ff,0x03ff,0x01ff,0x00ff,0x007f,0x003f,0x001f,0x01ff,0x10ff,0x30ff,0xf87f,0xf87f,0xfc3f,0x0000,0x4000,0x6000,0x7000,0x7800,0x7c00,0x7e00,0x7f00,0x7f80,0x7c00,0x4c00,0000,0x0600,0x0300,0x0300,0x0000};
    int ArrowOffset=FP_OFF(Arrow);
    int ArrowSegment=FP_SEG(Arrow);
    SetCursor(0,0,ArrowOffset,ArrowSegment);


    Your welcome.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    9
    hrmm youch if I had known it was that big I woulndt have asked for anyone to type it out... anyways I'm gonna go see what all I can figure out with it now thx a lot man!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Dev-cpp - compiler options
    By tretton in forum C Programming
    Replies: 7
    Last Post: 01-06-2006, 06:20 PM
  3. Mouse support in Dos
    By sp00k in forum C Programming
    Replies: 5
    Last Post: 05-17-2002, 11:46 PM
  4. Mouse in DOS
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-22-2001, 01:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21