Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Mouse Events in Console

  1. #1

    Mouse Events in Console

    When i run the sample script "Console_Inkey.tbasic" the mouse move event keeps firing every second even when no mouse movement is occurring.
    Also the Y value gotten from console_inkey command keeps incrementing by 1 every time. outputting something like this:
    You moved the mouse to 22,42
    You moved the mouse to 22,43
    You moved the mouse to 22,44
    You moved the mouse to 22,45
    You moved the mouse to 22,46
    You moved the mouse to 22,47
    You moved the mouse to 22,48
    You moved the mouse to 22,49
    
    this Y value will eventually increment beyond 255 and flip back to 0. still while the mouse is never touched.

    Is there a more reliable way to get mouse events from the console?

    Thanks


  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Mouse Events in Console

    A console window can have a screen buffer that goes far from the current visible console window. So at every PRINTL the Y position will increment continuously.
    Just add the following line at the beginning and you will have a fixed console buffer:
    [code=thinbasic] Console_SetScreenBufferSize(80, 25)[/code]
    Change console buffer as you prefer.

    Console_InKey is very reliable as far as I know. I've double checked here under different OS, and in all my tests mouse events are fired only when mouse is moved.

    What OS are you using? Are you using special mouse or tablet input?
    Do you have some special driver or special config in your computer?

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3

    Re: Mouse Events in Console

    Your definitely right about the buffer. That fixed the issue with mouse coords.
    Im using Winxp sp2 and average microsoft infrared mouse. Im not using any special driver and don't have any exotic hardware like usb devices ect.
    I suppose I could just look for mouse delta-movements and use the 'GetCursor' commands when I trap a button hit.

    Thanks!

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Mouse Events in Console

    Ok thanks. Can you please confirm you are using current latest thinBasic version 1.7.6.0 downloaded from official thinBasic web site?

    Can someone else help here and confirm if the mentioned script behave correctly or not? It would help a lot.
    Correct mouse events should be fired only if mouse is over the console window and it is moving.

    _________________________________________________

    Console_Inkey returns a string.
    If the string len is = 3 it means it is a mouse event. The 3rd char of this string gives the console mouse event type.

    Thanks a lot
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Mouse Events in Console

    Hi Eros,

    I have ball mouse from Microsoft ( the first one with wheel ) and no problem - it fires "event" only when I move it.

    With no locked buffer, during movmement the Y grows to 255 and then flips back to 0
    With locked buffer it simply shows "normal" coordinates.

    My brother had laser mouse, and it sometimes did wild things when on bad pad. It is possible laser mouse sensor is observing microscopic movements / false positives which are so small cursor does not move but mouse sends info anyway?


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Mouse Events in Console

    Yes, Console_Inkey returns even if micro movements are made. For my tests I have only laser mouse.
    Translated to single char console movements (on console mouse is simulated by a single char), cursor position x and y will not change of course.

    I suppose in Console applications it is more important to get mouse clicks or double clicks instead of mouse movements. But of course it it depend program by program.

    In any case you confirmed that Console_Inkey is working fine. And that was my point.
    So we need to understand why for MouseTrap (your forum name is appropriated for this post ) things are going in a different way.

    MouseTrap, did you executed exactly the script example coming from official installation or you have a executed a modified one?

    Ciao
    Eros

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: Mouse Events in Console

    MouseTrap, did you executed exactly the script example coming from official installation or you have a executed a modified one?
    I first noticed it in my own script and then confirmed with the "Console_Inkey.tbasic" script from the samples. (unmodified)

    Just to clarify:
    1)I'm not touching the mouse in any way.
    2)I suspected maybe a slight vibration from my desk, but hitting my desk to induce a vibration doesnt seem to create more events.
    3)When i intentionally make micro adjustments to the mouse i will get a diff coord returned. When its happening by itself, its the same coord returned repeatedly.

    With the tip you gave me about the buffer issue. that resolves most of my concern. The timing of the repeated events seems very non-deterministic. I wouldn't spend a lot of effort with the repeating coords because it could be a hardware issue.

    Its easy to copy the coords to local variables and only care when the coords from 'Console_Inkey' differ from locals. In that case i don't have any issue with the mouse+console.

    Thanks

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Mouse Events in Console

    Ok MouseTrap.

    I just wanted to be sure it would not be a real bug. I tested on 3 different virtual machines and 4 different physical computers and I was not able to replicate the exact problem you reported. Here console Mouse events are fired only when mouse is over the console window and mouse is moving.

    Anyhow, feel free to report again this behaves if you think it can be a bug and we will investigate further.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9

    Re: Mouse Events in Console

    Eros --

    FYI the Console_Inkey demo script works fine here for me.

    I am using a cordless Logitec laser mouse connected to XP Sp2 system via the USB.

    Don
    XPS 1710

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Mouse Events in Console

    Thanks Don.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 1 of 2 12 LastLast

Similar Threads

  1. mouse in console window
    By sandyrepope in forum Console
    Replies: 1
    Last Post: 30-05-2008, 23:40

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •