Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to manage with efficacy the mouse input...
#9
yeah and cause my lazyness I follow the short typing way: memorize the values in variables and put them in comparison with actual machine state got by keyword  _Mousebutton()

Code: (Select All)
_Title "Lubuntu window's cohordinates bug: MOD after lessons on forum"

''Screen      Text          Graphics          Colors      Video    Text      Default
'' Mode  Rows  Columns  Width  Height  Attrib.  BPP  Pages    Block    QB64 Font

''  0  25/43/50  80/40    No graphics    16/16 DAC  4    0-7    -----    _FONT 16
''  1      25      40      320    200    16/4 BG    4    none    8 X 8    _FONT 8
''  2      25      80      640    200      2/mono    1    none    8 X 8    _FONT 8
''  .................................................................................
''  7      25      40      320    200    16/16 DAC  4    0-7    8 X 8    _FONT 8
''  8      25      80      640    200    16/16      4    0-3    8 X 8    _FONT 8
''  9      25      80      640    350    16/64 DAC  4    0-1    8 X 14  _FONT 14
'' 10      25      80      640    350    4/2 GScale 2    none    8 X 14  _FONT 14
'' 11    30/60    80      640    480      2/mono    1    none    8 X 16  _FONT 16
'' 12    30/60    80      640    480    16/262K    4    none    8 X 16  _FONT 16
'' 13      25      40      320    200    256/65K    8    none    8 X 8    _FONT 8
'' _NEWIMAGE width. height, 32
Randomize Timer
Dim ScrM As Integer, ScrMod As String, FeaT As String, Action As Integer
Dim Shared As Integer M1, M2, M3
ScrM = 0: ScrMod = "0": FeaT = "80/40 width  * 25/43/50 height": Action = 0
M1 = 0: M2 = 0: M3 = 0
Do While Action <> 99
    WaitStopMouseInput
    Mainscreen
    Mainloop ScrM, ScrMod, FeaT, Action
    WaitStopMouseInput
    If Action = 3 Then
        If ScrM = 10 Then
            Screen _NewImage(1000, 800, 32)
        Else
            Screen Val(ScrMod)
        End If
        test ScrMod, FeaT
    End If
Loop
End

Sub test (Sm As String, F As String)
    Cls
    r = 1

    Do
        M1 = 0: M2 = 0: M3 = 0
        WaitStopMouseInput
        mx = _MouseX
        my = _MouseY
        For row = 1 To 10
            Select Case Sm
                Case "32bit"
                    Color _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
                Case "2", "11"
                    Color 1
                Case "10"
                    Color Int(Rnd * 3) + 1
                Case Else
                    Color row
            End Select
            If Sm = "0" Then r = 1 Else r = _FontHeight
            Locate row, 1
            Print mx; "  "; Int(my / r); "  "; row
        Next row
        Locate 22
        Print "Screen mode  " + Sm + "  " + F
        Print "Press RIGHT mouse button or Escape key to exit";

        Select Case Sm
            Case "0"
                ' do not do graphic lines
            Case Else
                ' it draws 2 lines to show vertexes and center of the screen, more a box on the edge of screen
                Line (1, 1)-(_Width(0), _Height(0))
                Line (_Width(0), 1)-(1, _Height(0))
                Line (1, 1)-(_Width(0) - 1, _Height(0) - 1), , B
        End Select
        _Limit 20
    Loop Until _MouseButton(2) = -1 Or InKey$ = Chr$(27) ' here it was M2
    WaitStopMouseInput
    Screen 0
    Cls
End Sub

Sub WaitStopMouseInput
    Do While _MouseInput
        ' before it was here wasting resources
    Loop ' loop to clean mouse input buffer
    'M1 = _MouseButton(1): M2 = _MouseButton(2): M3 = _MouseButton(3)
End Sub

Sub Mainscreen
    Screen 0
    Print "Tool for testing the setting of screen viewport on the window application"
    Locate 3
    Color 5
    Print "press U for Previous Screen Mode and D for Following Screen Mode"
    Print " Enter for testing selected Screen mode"
    Color 4
    Print "press Left button of mouse for Previous Screen Mode and Right button of "
    Print " mouse for following Screen Mode"
    Print " Middle button of mouse for testing selected Screen Mode"
    Color 14
    Print " press Escape key or together Left and Right mouse buttons for quitting"
    Color 1
    Locate 13
    Print "SCREEN " + Space$(15) + " Features"

End Sub

Sub Mainloop (S As Integer, Sm As String, F As String, A As Integer)
    Do

        Locate 14, 1
        Print Space$(80);
        Locate 14, 1
        Print "  " + Sm + Space$(15 - (Len(Sm))) + F
        While TakeInput(A) = 0
            _Limit 20
        Wend
        Select Case A
            Case 1
                'up action
                S = S + 1
                If S > 10 Then S = 0
            Case 2
                ' down action
                S = S - 1
                If S < 0 Then S = 10
            Case 3, 99
                ' execute action or exit
                Exit Sub
        End Select
        A = 0 '  it restores neutral value of A
        Select Case S
            Case 0
                Sm = "0"
                F = "80/40 width  * 25/43/50 height"
            Case 1
                Sm = "1"
                F = " 320    200"
            Case 2
                Sm = "2"
                F = "640    200"
            Case 3
                Sm = "7"
                F = "320    200"
            Case 4
                Sm = "8"
                F = "640    200"
            Case 5
                Sm = "9"
                F = "640    200"
            Case 6
                Sm = "10"
                F = "640    350"
            Case 7
                Sm = "11"
                F = "640    480"
            Case 8
                Sm = "12"
                F = "640    480"
            Case 9
                Sm = "13"
                F = "320    200"
            Case 10
                Sm = "32bit"
                F = "variable W & H "
        End Select
    Loop
End Sub

Function TakeInput (Action As Integer)
    Action = 0
    M1 = _MouseButton(1): M2 = _MouseButton(2): M3 = _MouseButton(3)
    WaitStopMouseInput
    C$ = InKey$
    If (C$ = Chr$(27) Or ((_MouseButton(1) And Not (M1 = -1)) And (_MouseButton(2) And Not (M2 = -1)))) Then Action = 99
    If (C$ = "U" Or (_MouseButton(1) And Not (M1 = -1))) Then Action = 1
    If (C$ = "D" Or (_MouseButton(2) And Not (M2 = -1))) Then Action = 2
    If (C$ = Chr$(13) Or (_MouseButton(3) And Not (M3 = -1))) Then Action = 3
    M1 = _MouseButton(1): M2 = _MouseButton(2): M3 = _MouseButton(3)
    TakeInput = Action
End Function

1. Modding WaitStopMouseInput for not adjourning too quickly mouse button status variables
2. Comparing that hardware status to variables memoring the mouse button status

Tonight I'll code the event driven mode posted by Petr.
Doing is learning

Thanks all you!
Reply


Messages In This Thread
RE: How to manage with efficacy the mouse input... - by TempodiBasic - 11-18-2025, 09:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating my Mouse/Keyboard/Buttons/Fields routine. Pete 36 5,513 04-03-2025, 11:26 PM
Last Post: Pete
  seperate input from multiple mice v0.54 graphic demo madscijr 1 704 06-21-2024, 01:12 PM
Last Post: madscijr
  read 2 or more USB mice on one PC - fully working with keyboard input madscijr 2 1,114 06-16-2024, 01:48 AM
Last Post: madscijr
  IT'S ALIVE! reading seperate input from multiple mice plugged into one PC v0.30 madscijr 1 796 05-26-2024, 04:14 PM
Last Post: madscijr
  Mouse Routines to Use and Hack TerryRitchie 3 1,207 08-15-2023, 12:11 AM
Last Post: grymmjack

Forum Jump:


Users browsing this thread: 1 Guest(s)