getmouse fails after reset (0)

Windows specific questions.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

getmouse fails after reset (0)

Post by nedman47 »

Code: Select all

#include "windows.bi"
dim as integer x,y,button
reset (0)
do
   getmouse x,y,,button
   print x, y, button
   sleep 100
loop
I wrote an editor that accepts redirected input. After reading STDIN I call reset (0) to close it and allow keyboard input. But then mouse input no longer works. The above code illustrates the problem. If you comment out reset (0) then getmouse works. Is this a bug? Should I use setconsolemode to enable mouse input again? Thanks in advance.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: getmouse fails after reset (0)

Post by D.J.Peters »

No problem here what is your OS 32/64-bit Windows xp,vista,7,8,10 ?

Joshy

Code: Select all

dim as integer x,y,button
reset(0)
do
   if getmouse(x,y,,button) then
     print "error: get mouse !"
   else  
     print x, y, button
   end if  
   sleep 100
loop while asc(inkey())<>27
SARG
Posts: 1757
Joined: May 27, 2005 7:15
Location: FRANCE

Re: getmouse fails after reset (0)

Post by SARG »

What is exactly the issue ?

I didn't see a difference with or without reset instruction.

However the scrolling changes the y value becoming negative. And when the mouse is out the console y should not change but not the case.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Post by fxm »

I get the same problem as nedman47 (under Win7, 32-bit and 64-bit).
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Post by nedman47 »

I forgot to mention that this is a console app, that is, I'm running it in a "dos box".

With the reset (0) in, x and y remain zero, or y goes negative. Both buttons return 0. And right click brings up the "mark, copy, paste" menu, suggesting that the console is in the wrong state.

I'm running windows 7 and compiling with 64 bit Freebasic 1.05 for windows.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: getmouse fails after reset (0)

Post by MrSwiss »

I get the same problem as nedman47 (under Win10 - 64, 32-bit and 64-bit compiler, versions: 1.05.0/1.06.0 - 2017-03-01).

But, this also happens without: Reset() or Reset(0)

Also tested: Screen 0 (forcing console)

GetMouse() & Console issue/conflict???
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: getmouse fails after reset (0)

Post by dodicat »

Win 10
64/32 bit
Same as Mr Swiss, mouse doesn't register x,y co ordinates, buttons or wheel values.
With or without reset()

The only thing, when the numbers scroll off the page the mouse y values start to decrement themselves, even if the mouse is off the console.

Code: Select all

 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0            -1             0
 0            -2             0
 0            -3             0
 0            -4             0
 0            -5             0
 0            -6             0
 0            -7             0
 0            -8             0
 0            -9             0
 0            -10            0
 0            -11            0
 0            -12            0
 0            -13            0
 0            -14            0
 0            -15            0
 0            -16            0
 
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Post by fxm »

To enable the mouse in the console window, uncheck "QuickEdit Mode" in console properties.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: getmouse fails after reset (0)

Post by MrSwiss »

fxm is correct, this fixes the issue, but you'll have to do it, on the "FB invoked" Console.

Reason: it is not a global setting ... (aka: *local setting*, not relevant to all Console-Windows)
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Post by fxm »

From main menu for command window, you can also configure the "defaults" (above the "properties").
(the "defaults" are applied at console invocation)
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Post by nedman47 »

I never had "quick edit mode" checked, so it does not fix the issue for me.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Post by fxm »

Yes, "QuickEdit Mode" unchecked is necessary for using mouse but not sufficient after calling 'Reset(0)'.
'Reset(0)' disables the mouse without modifying the "QuickEdit Mode" setting.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Post by nedman47 »

I attempted to use GetConsoleMode to look at the mode variable. It was zero before and after reset (0). So I wonder what reset (0) is doing to disable the mouse?
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Post by fxm »

Except by reassigning a new console window, I could not find another solution to re-enable the mouse after a 'Reset(0)'.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: getmouse fails after reset (0)

Post by dodicat »

With Win 10, and putting a proper closure with your code (loop until len(inkey):sleep)
Then unchecking quick edit, in the console properties, all is well, reset or not, afterwards.
In fact the change is permanent and the console remains (quick edit unchecked) no matter how you run the console afterwards, and even after a shut down.
Post Reply