www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/22/20:08:02

Message-ID: <362FD66F.51114F5C@montana.com>
Date: Thu, 22 Oct 1998 19:05:51 -0600
From: bowman <bowman AT montana DOT com>
X-Mailer: Mozilla 4.5b2 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: I give up. My mouse function has committed suicide.
References: <70o4t0$l02$1 AT nnrp1 DOT dejanews DOT com>
Reply-To: djgpp AT delorie DOT com


billynomates AT my-dejanews DOT com wrote:
> 
> Well, I've tried everyone's suggestions and it still doesn't work - I simply
> don't know what to do any more.


I don't know if this will be of any help, but this is something I wrote
to get the mouse working in Midnight Commander. Since I had to emulate
the Linux gpm calls, I pass Gpm_Event, but that includes the position
and buttons. I only had to do the up, down, move, and double click. the
chacha with biostime is for the double click logic.


<--------------------   gpm definitions ------------------->

#ifdef DJGPP
#   define GPM_B_LEFT      1
#   define GPM_B_MIDDLE    4
#   define GPM_B_RIGHT     2
#else
#   define GPM_B_LEFT      4
#   define GPM_B_MIDDLE    2
#   define GPM_B_RIGHT     1
#endif
 
/* Xterm mouse support supports only GPM_DOWN and GPM_UP */
/* If you use others make sure your code also works without them */

enum Gpm_Etype {
  GPM_MOVE=1,
  GPM_DRAG=2,   /* exactly one in four is active at a time */
  GPM_DOWN=4,
  GPM_UP=  8,

#define GPM_BARE_EVENTS(ev) ((ev)&0xF)

  GPM_SINGLE=16,            /* at most one in three is set */
  GPM_DOUBLE=32,
  GPM_TRIPLE=64,
      
  GPM_MFLAG=128,            /* motion during click? */
  GPM_HARD=256             /* if set in the defaultMask, force an
already
                              used event to pass over to another handler
*/
};


typedef struct Gpm_Event {
  int buttons, x, y;
  enum Gpm_Etype type;
} Gpm_Event;


<---------------  my get event hack ------------------>


void Gpm_GetEvent(Gpm_Event* ev)
{
    static int x = 0;
    static int y = 0;
    static int buttons = 0;
    static long time = 0L;

    long newtime;
    union REGS r;

    r.x.ax = 0x03;
    int86(0x33, &r, &r);
    ev->type = 0;

    r.x.bx &= 0x07;
    if (r.x.bx != buttons)      
    {
        if (r.x.bx & (buttons ^ r.x.bx))
             ev->type = GPM_DOWN;
        else
        {
            newtime = biostime(0, 0);
            if (newtime < time + 10)    
                ev->type = GPM_DOUBLE;
            time = newtime;
            ev->type |= GPM_UP;
        }
    }
    buttons = r.x.bx;

    if (r.x.cx != x)
    {
        x = r.x.cx;
        if (!ev->type)
            ev->type = GPM_MOVE;
    }

    if (r.x.dx != y)
    {
        y = r.x.dx;
        if (!ev->type)
            ev->type = GPM_MOVE;
    }

    ev->buttons = buttons;
    ev->x = (x >> 3) + 1;
    ev->y = (y >> 3) + 1;

}
typedef struct Gpm_Event {
  int buttons, x, y;
  enum Gpm_Etype type;
} Gpm_Event;


void Gpm_GetEvent(Gpm_Event* ev)
{
    static int x = 0;
    static int y = 0;
    static int buttons = 0;
    static long time = 0L;

    long newtime;
    union REGS r;

    r.x.ax = 0x03;
    int86(0x33, &r, &r);
    ev->type = 0;

    r.x.bx &= 0x07;
    if (r.x.bx != buttons)      
    {
        if (r.x.bx & (buttons ^ r.x.bx))
             ev->type = GPM_DOWN;
        else
        {
            newtime = biostime(0, 0);
            if (newtime < time + 10)    
                ev->type = GPM_DOUBLE;
            time = newtime;
            ev->type |= GPM_UP;
        }
    }
    buttons = r.x.bx;

    if (r.x.cx != x)
    {
        x = r.x.cx;
        if (!ev->type)
            ev->type = GPM_MOVE;
    }

    if (r.x.dx != y)
    {
        y = r.x.dx;
        if (!ev->type)
            ev->type = GPM_MOVE;
    }

    ev->buttons = buttons;
    ev->x = (x >> 3) + 1;
    ev->y = (y >> 3) + 1;

}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019