Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_BUTTON
#1
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?

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
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
_BUTTON - by TerryRitchie - 04-03-2023, 02:42 AM
RE: _BUTTON - by TerryRitchie - 04-03-2023, 08:40 PM
RE: _BUTTON - by dbox - 04-03-2023, 11:07 PM
RE: _BUTTON - by TerryRitchie - 04-04-2023, 02:25 AM
RE: _BUTTON - by dbox - 04-04-2023, 03:34 AM
RE: _BUTTON - by SMcNeill - 04-03-2023, 09:03 PM
RE: _BUTTON - by TerryRitchie - 04-03-2023, 09:16 PM
RE: _BUTTON - by SMcNeill - 04-03-2023, 09:04 PM
RE: _BUTTON - by TerryRitchie - 04-03-2023, 09:26 PM
RE: _BUTTON - by RhoSigma - 04-03-2023, 10:03 PM
RE: _BUTTON - by TerryRitchie - 04-04-2023, 02:24 AM
RE: _BUTTON - by TerryRitchie - 04-09-2023, 01:17 AM
RE: _BUTTON - by SMcNeill - 04-09-2023, 03:46 AM
RE: _BUTTON - by TerryRitchie - 04-09-2023, 05:12 AM



Users browsing this thread: 2 Guest(s)