Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can someone confirm this runs on their system?
#18
(12-21-2023, 04:08 AM)justsomeguy Wrote:
(12-21-2023, 03:54 AM)TerryRitchie Wrote: The following code from lesson 21 of the tutorial works on my system to detect interaction between the mouse, keyboard, and a dpad controller I have connected. Look at line 22 of the code. You need to get the latest _DEVICEINPUT information in the same way you need to get _MOUSEINPUT, using a loop.

Code: (Select All)
DIM DeviceCount AS INTEGER ' number of controllers (simply used to activate controller statements)
DIM DeviceInput AS INTEGER ' indicates a controller has been interacted with

PRINT
PRINT " Interact with an input controller and it will highlight."
PRINT
PRINT " Press ESC to exit program."
PRINT
DeviceCount = _DEVICES '                                         activate controller statements
DO '                                                             begin controller interaction loop
    _LIMIT 10 '                                                   slow things down a bit for viewing
    LOCATE 6, 1 '                                                 position cursor
    COLOR 7, 0 '                                                  gray on black text
    PRINT " Keyboard" '                                           list controllers
    PRINT " Mouse"
    PRINT " Controller 1"
    PRINT " Controller 2"
    PRINT " Controller 3"
    PRINT " Controller 4"
    DeviceInput = _DEVICEINPUT '                                 get any controller interaction
    IF DeviceInput THEN '                                         was a controller interacted with?
        WHILE _DEVICEINPUT(DeviceInput): WEND '                   yes, get the latest controller information
        COLOR 14, 1 '                                             yellow on blue text
        IF DeviceInput = 1 THEN '                                 was the keyboard interacted with?
            LOCATE 6, 1 '                                         yes, position cursor
            PRINT " Keyboard" '                                   highlight controller
        ELSEIF DeviceInput = 2 THEN '                             no, was the mouse interacted with?
            LOCATE 7, 1 '                                         yes, position cursor
            PRINT " Mouse" '                                      highlight controller
        ELSE '                                                    no, a joystick/game pad interacted with
            LOCATE 5 + DeviceInput, 1 '                           position cursor
            PRINT " Controller "; _TRIM$(STR$(DeviceInput - 2)) ' highlight controller
        END IF
    END IF
LOOP UNTIL _KEYDOWN(27) '                                        leave when ESC key pressed
SYSTEM '                                                         return to OS
I still got no response from the keyboard.
I'm still using 3.8.0 which worked fine. I just tried it in 3.9.1 and it worked fine. I have not downloaded version 3.10.0 yet. Is this a bug in version 3.10.0?

Update: Ok, my bad, I just went back through the posts and see this is related to Linux. I'm using Windows. Sorry for the confusion.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: can someone confirm this runs on their system? - by TerryRitchie - 12-21-2023, 04:11 AM



Users browsing this thread: 3 Guest(s)