Reading mouse ports
Posted: Fri Feb 19, 2016 5:20 pm
I realized it was probably possible to create an ASM-less method of accessing the mouse by polling it directly. This is theoretically straight forward, but it seems like something's in the way. The port (0x60) is always reading either 21 or 28.
Running under WinXP SP3 32-bit. (Dosbox doesn't do real mouse simulation).
Running under WinXP SP3 32-bit. (Dosbox doesn't do real mouse simulation).
Code: Select all
DIM mouseBytes(2) AS INTEGER
byteCount% = 0
WAIT &H64, 2
OUT &H64, &HD4
OUT &H60, &HF4
DO UNTIL INKEY$ = "Q"
PRINT INP(&H64)
WAIT &H64, 2
OUT &H64, &HD4
OUT &H60, &HF5
IF INP(&H64) AND &H20 THEN
PRINT "Mouse active..."
mouseBytes(byteCount%) = INP(&H60)
byteCount% = byteCount% + 1
IF byteCount% = 3 THEN
IF mouseBytes(0) = &H80 OR mouseBytes(0) = &H40 THEN
ELSE
'PRINT "Byte 3"
'xDifference = (mouseBytes(0) AND 3) * 64 + mouseBytes%(1)
'yDifference = (mouseBytes(0) AND 12) * 16 + mouseBytes%(2)
'IF xDifference% >= 128 THEN :xDifference% = xDifference% - 256
'IF yDifference% >= 128 THEN :yDifference% = yDifference% - 256
'_MOUSEX% = _MOUSEX% + xDifference
'mouseY% = mouseY% + yDifference
mouseBtn1% = mouseBytes%(0) AND 32
mouseBtn2% = mouseBytes%(0) AND 16
PRINT "Byte: ", mouseBytes%(0), ", Status 1:", mouseBtn1%, ", Status 2:", mouseBtn2%
SLEEP 1
END IF
byteCount% = 0
END IF
END IF
LOOP