04-03-2023, 02:42 AM
I'm looking to write an input driver for the project I'm working on. _BUTTON and the various related functions seems to be what I'm looking for. However, the table for the keyboard device button numbers, found here in the wiki: https://qb64phoenix.com/qb64wiki/index.p...er_Devices
does not match the output when I run the example code found on the same page. The keyboard numbers I'm getting are completely different from the chart. Why is this?
does not match the output when I run the example code found on the same page. The keyboard numbers I'm getting are completely different from the chart. Why is this?
Code: (Select All)
PRINT "Use relative mouse movement mode with ESC key exit only?(Y/N) ";
K$ = UCASE$(INPUT$(1))
PRINT K$
PRINT
FOR i = 1 TO _DEVICES 'DEVICES MUST be read first!
PRINT STR$(i) + ") " + _DEVICE$(i) + " Buttons:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
NEXT
IF K$ = "Y" THEN dummy = _MOUSEMOVEMENTX 'enable relative mouse movement reads
PRINT
DO
x& = _DEVICEINPUT 'determines which device is currently being used
IF x& = 1 THEN
PRINT "Keyboard: ";
FOR b = 1 TO _LASTBUTTON(x&)
bb = _BUTTONCHANGE(b)
IF bb THEN PRINT b; bb; _BUTTON(b);
NEXT
PRINT
END IF
IF x& > 1 THEN ' skip keyboard reads
PRINT "Device:"; x&;
FOR b = 1 TO _LASTBUTTON(x&)
PRINT _BUTTONCHANGE(b); _BUTTON(b);
NEXT
FOR a = 1 TO _LASTAXIS(x&)
PRINT _AXIS(a); 'mouse axis returns -1 to 1 with 0 center screen
NEXT
FOR w = 1 TO _LASTWHEEL(x&)
PRINT _WHEEL(w); 'wheels 1 and 2 of mouse return relative pixel moves when enabled
NEXT
PRINT
END IF
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
END