A _MOUSEMOVEMENTX question - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: A _MOUSEMOVEMENTX question (/showthread.php?tid=2445) |
A _MOUSEMOVEMENTX question - NakedApe - 02-13-2024 Howdy. I'm using X axis mouse moves to control the rotation of a new, scrappy, little spaceship. All is great until I reach the end of the range of that command (the actual edges of the desktop not the screen image), then the ship either freezes up at one extreme or can rotate no further at the other end. The command's range is -50 to _DESKTOPWIDTH - 50. There's plenty of range for the game to work; it's just annoying that you have to stay within the parameters... The question is, is there a way to overcome this and have unlimited X readings or do I need to warn the user to "unwind" the mouse position as they go and maybe provide an onscreen indicator as to where the mouse is within its range? Gracias, amigos. RE: A _MOUSEMOVEMENTX question - DSMan195276 - 02-13-2024 What platform are you using? I ask because on Windows I believe it should already work as you're describing, it should continue to report the relative movement regardless of the actual cursor position. On Linux and Mac OS the support is currently a bit more limited and it will get stuck like you're suggesting (which is something that will hopefully be fixed in the future). To clarify, you're saying that `_MouseMovementX` starts returning 0 when the mouse hits the edge of the screen even if you're still moving the mouse in that direction? RE: A _MOUSEMOVEMENTX question - bplus - 02-13-2024 ? Mousemovement has always been broken as far as I remember. Why is _MouseX, _MouseY not good enough to work with? You've seen the lectures on polling the mouse? ie While _MouseInput: Wend ' < update mouse status don't put anything inside this loop!!! unless you need Mousewheel 'THEN set mouse status variable unless you need mouse_wheel mx = _mouseX : my = _MouseY: mb1 = _Mousebutton(1) 'left mouse button down RE: A _MOUSEMOVEMENTX question - NakedApe - 02-13-2024 Actually, I figured it out. I unintentionally limited the results from the mousemovementX reads. Fixed it. I went from getting only 2 full rotations to about 5 now before hitting the skids. That oughta do it. desktop width of 1920 / 360 degrees = 5.3 rotations (02-13-2024, 07:42 PM)DSMan195276 Wrote: What platform are you using? I ask because on Windows I believe it should already work as you're describing, it should continue to report the relative movement regardless of the actual cursor position. On Linux and Mac OS the support is currently a bit more limited and it will get stuck like you're suggesting (which is something that will hopefully be fixed in the future). Yes, it hits -50 on the left and will go no further and then width - 50 on the right and stops. I can get five rotations now after fixing my error. And, yeh, I'm on a Mac. RE: A _MOUSEMOVEMENTX question - DSMan195276 - 02-13-2024 (02-13-2024, 07:44 PM)bplus Wrote: ? Mousemovement has always been broken as far as I remember.I just tested it on Windows, it works correctly. Whether you actually want that behavior depends a lot on what you're doing though (02-13-2024, 08:01 PM)NakedApe Wrote: Actually, I figured it out. I unintentionally limited the results from the mousemovementX reads. Fixed it. I went from getting only 2 full rotations to about 5 now before hitting the skids. That oughta do it.I'd be curious to see what your code is doing, `_MouseMovementX` should never stop returning values if the mouse is being moved. RE: A _MOUSEMOVEMENTX question - NakedApe - 02-13-2024 (02-13-2024, 08:06 PM)DSMan195276 Wrote:(02-13-2024, 07:44 PM)bplus Wrote: ? Mousemovement has always been broken as far as I remember.I just tested it on Windows, it works correctly. Whether you actually want that behavior depends a lot on what you're doing though I run this and get from -50 to 1870 and not a penny more. SCREEN _NEWIMAGE(1280, 720, 32) DO CLS _LIMIT 30 DO WHILE _MOUSEINPUT x = x + _MOUSEMOVEMENTX LOOP PRINT x; _DISPLAY LOOP UNTIL INKEY$ <> "" SYSTEM RE: A _MOUSEMOVEMENTX question - DSMan195276 - 02-13-2024 Are you running on Mac OS or Linux? It's not yet properly implemented on those platforms, so that would be why. RE: A _MOUSEMOVEMENTX question - bplus - 02-13-2024 Quote:I just tested it on Windows, it works correctly. Whether you actually want that behavior depends a lot on what you're doing though Big Grin Yeah well it never worked well or right since I remember and I got use to never needing it. It is quite possible it got fixed and I missed that day it was announced. I too would love to know why @NakedApe can get only 5 revolutions, I wonder if we are hitting the limit of Integer Type? RE: A _MOUSEMOVEMENTX question - bplus - 02-13-2024 Oh hey you aren't trying @NakedApe Do I win? PS I guess _Mousemovement does work AND it does HAVE TO BE inside the While _MouseInput : Wend LOOP RE: A _MOUSEMOVEMENTX question - NakedApe - 02-13-2024 (02-13-2024, 08:19 PM)bplus Wrote: Oh hey you aren't trying @NakedApe LOL, clearly I need to work harder! So if I use While _MouseInput: Wend and nothing inside that loop as you suggest, I get nada. See below. This displays two zeros wherever I put the mouse. SCREEN _NEWIMAGE(1280, 720, 32) DO CLS _LIMIT 30 WHILE _MOUSEINPUT: WEND x = x + _MOUSEMOVEMENTX x2 = _MOUSEMOVEMENTX PRINT "x2:"; y PRINT x; _DISPLAY LOOP UNTIL INKEY$ <> "" SYSTEM The other example above works tho... OK, I'm glad we're on the same page here, b+! I'll chalk this up to a macOS thing. 5 spins will work for me - for now. Thanks for the replies, DSMan and b+. |