2

I am using the following code to trap Left/Right/Middle mouse button and mouse row/column in QB45:

(QB45 is Microsoft Quick Basic v4.5)

and I need a way to detect MouseWheel. I have looked at Ralf Brown's interrupt list without luck.

Any ideas? btw: I am using Int 0x33.

The code I am submitting is for the Microsoft Quickbasic IDE and requires the library file QB.QLB.

DECLARE SUB Mouse.Function (Var1, Var2)
DIM SHARED MouseX AS INTEGER, MouseY AS INTEGER

TYPE RegTypeX
  AX AS INTEGER
  BX AS INTEGER
  CX AS INTEGER
  DX AS INTEGER
  BP AS INTEGER
  SI AS INTEGER
  DI AS INTEGER
  Flags AS INTEGER
  DS AS INTEGER
  ES AS INTEGER
END TYPE

COMMON SHARED InregsX AS RegTypeX
COMMON SHARED OutregsX AS RegTypeX

DECLARE SUB InterruptX (N AS INTEGER, I AS RegTypeX, O AS RegTypeX)

 CALL Mouse.Function(0, 0) ' init mouse
 CALL Mouse.Function(1, 0) ' show mouse
 DO

 IF LEN(INKEY$) THEN
    CALL Mouse.Function(2, 0) ' hide mouse
    EXIT DO
 END IF

 ' read mouse button press
 CALL Mouse.Function(3, 0)

 Var2 = INT((OutregsX.CX - 1) / 8 + 1)
 Var3 = INT((OutregsX.DX - 1) / 8 + 1)

 IF Var3 <> Mouse.Row OR Var2 <> Mouse.Column THEN
    CALL Mouse.Function(2, 0) ' hide mouse
    Mouse.Row = Var3
    Mouse.Column = Var2
    PRINT Mouse.Row, Mouse.Column
    CALL Mouse.Function(1, 0) ' show mouse
 END IF

 Mouse.Button = False
 CALL Mouse.Function(5, 0)
 IF (OutregsX.AX AND 1) = 1 THEN
    IF OutregsX.BX > False THEN
       Mouse.Button = -1
       PRINT "Left-Click"
    END IF
 END IF
 Mouse.Button2 = False
 CALL Mouse.Function(5, 1)
 IF (OutregsX.AX AND 2) = 2 THEN
    IF OutregsX.BX > False THEN
       Mouse.Button2 = -1
       PRINT "Right-Click"
    END IF
 END IF
 Mouse.Button3 = False
 CALL Mouse.Function(5, 2)
 IF (OutregsX.AX AND 4) = 4 THEN
    IF OutregsX.BX > False THEN
       Mouse.Button3 = -1
       PRINT "Middle-Click"
    END IF
 END IF
 LOOP
 END

SUB Mouse.Function (Var1, Var2)
   InregsX.AX = Var1
   InregsX.BX = Var2
   CALL InterruptX(&H33, InregsX, OutregsX)
END SUB
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Azathoth
  • 105
  • 1
  • 9
  • 3
    Since AX and BX are integers, curious as to why you define the parameters Var1 and Var2 as single? I haven't coded mouse logic for DOS but I doubt there's anything available as an interrupt function to complete what you're looking for, as most mice did not even have scroll wheels when this QB 4.5 was in its prime. Even VB 6.0 had some problems with mouse wheel and I still have to use third-party software just to get it to work in that IDE. – Bill Hileman Feb 16 '21 at 13:23
  • 1
    I don't think any of the command interpreters back then had a scrollback buffer, so the only applications that could have taken advantage of a scroll wheel back then anyway were applications that added some form of scrolling themselves, such as text editors. I imagine you might detect specific mouse drivers (no clue how), but I honestly don't recall seeing any mice with scroll wheels back then. – MemReflect Feb 17 '21 at 02:23
  • 1
    By the way, X11 (or maybe the libinput driver?) on Linux and such maps scroll actions and other features to mouse button numbers >3; scroll down/up/right/left corresponds to Button4/5/6/7 on my machine, and my back/forward buttons are Button8/9. – MemReflect Feb 17 '21 at 02:31
  • I agree and from what I can tell DOSbox does not support MouseWheel.. – Azathoth Feb 19 '21 at 07:56
  • 1
    I found a BOSbox keyboard mapper to trap MouseWheel at http://www.dfzone.be/dosbox/ – Azathoth Feb 20 '21 at 07:01
  • 1
    That's a really good find, and it brings to mind a more general-purpose Windows utility called AutoHotkey. If you mapped the appropriate wheel scroll directions to the correct cursor keys using that utility, then it would behave predictably in QB45. For actual DOS (and DOS emulators that support it), a driver like [CuteMouse](http://wiki.freedos.org/wiki/index.php/Mouse) is probably the best solution, though I admittedly don't know how it will behave in QB45. For all I know, it may not work at all QB45. – MemReflect Feb 21 '21 at 03:33
  • I think it is a DOSbox problem because DOSbox-X traps mousewheel... – Azathoth Sep 11 '21 at 06:26

0 Answers0