mousemove() appears to be asynchronous

BlitzMax Forums/BlitzMax Beginners Area/mousemove() appears to be asynchronous

TrickyRic(Posted 2005) [#1]
lol, must look like i have some kind of mouse fetish with these threads huh?

anyway i didn't want to change the subject of my previous thread so instead i'll post a fresh one:

seems when i call movemouse() and then initiate the main loop where a condition checks the location of the mouse, the condition returns the co-ords prior to the movemouse being called! all i can assume here is that mouse movement is asynchronous to command execution. easy fix would be to whack a delay between these events, but i'm somewhat of a freak when it comes to making clean code, and delays always look messy to me...

please note i've already played around with pollsystem() to no avail!

system in question is gnu linux 2.6.11 running fedora 4 (flame fc all ye like, but personally i love it!), xorg 6.8.2, and the logitech mx1000 mouse. blitzmax build is 1.08.

script in question:

HideMouse()
MoveMouse half_width, half_height

While (GetChar() + MouseHit(1) + MouseHit(2) + MouseHit(3) + MouseZ() = 0) And MouseX() = half_width And MouseY() = half_height

ty.


TrickyRic(Posted 2005) [#2]
erm...

i wrote the following test scripts, and both return accurate results! something iffy must be going on here...

DrawText MouseX(), 100, 10
MoveMouse(50, 50)
DrawText MouseX(), 100, 20
Flip
WaitKey()
End

MoveMouse(50, 50)
While MouseX() = 50
Wend
End


TrickyRic(Posted 2005) [#3]
ERMMMM,,,

added a few lines:

MoveMouse(half_width, half_height)

Print half_width
Print half_height
Print MouseX()
Print MouseY()

given half_width is 200, and half_height is 150, surely debug output should be:

200
150
200
150

right? well...

Building AuroraSaver
Compiling:AuroraSaver.bmx
flat assembler version 1.52
3 passes, 4067 bytes.
Linking:AuroraSaver
Executing:AuroraSaver
200
150
0
0

Process complete

...any ideas?


bradford6(Posted 2005) [#4]
it works here...

Graphics 800,600,32

Repeat
	DrawText MouseX(),10,10
	DrawText MouseY(),100,100
Flip;Cls
Until KeyDown(KEY_ESCAPE)


half_height= 100
half_width=333
MoveMouse(half_height, half_width)

Print half_height
Print half_width
Print MouseX()
Print MouseY()




ashmantle(Posted 2005) [#5]
You probably have to move the mouse around a little for MouseX() and MouseY() to contain any values..


TrickyRic(Posted 2005) [#6]
my mouse has an off switch (to save on battery charge) and in each test i've been switching it off to be sure no accidental movement goes on. in the individual tests shown above, such as:

DrawText MouseX(), 100, 10
MoveMouse(50, 50)
DrawText MouseX(), 100, 20
Flip
WaitKey()
End

...ouput is perfect. no complaints. but with the project in question, i can't seem to get mousex() or mousey() to return ANYTHING other than 0! this is confusing the hell out of me now! even mousez() works fine, so why not these?

maybe this is some kind of linux specific bug when using hidemouse() or something? i'll keep testing...


TrickyRic(Posted 2005) [#7]
ok, now i've stripped everything as far as i possibly can - only running code in this project is the following:

Local width = 400, height = 300, mode = 16
Global half_width = width / 2, half_height = height / 2
Graphics width, height, mode
MoveMouse(half_width, half_height)
While MouseX() = half_width And MouseY() = half_height
Wend
End

...and the project just ends immediately!


TrickyRic(Posted 2005) [#8]
the followings all that appears to work reliable enough, but its still a little messy, and i don't see why such a delay would be needed!

MoveMouse(half_width, half_height)

While MouseX() = 0 Or MouseY() = 0
Wend

While (GetChar() + MouseHit(1) + MouseHit(2) + MouseHit(3) + MouseZ() = 0) And MouseX() = half_width And MouseY() = half_height