Author Topic: Mousemove bug on fullscreen mode  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Mousemove bug on fullscreen mode
« on: May 30, 2020, 05:53:44 am »
Bug: MOUSEMOVE on FULLSCREEN works in Desktop coordinates, but can't exceed screen coordinates.
If your Screen resolution and Desktop resolution are equal, works OK.
Else if your app runs on her window, also works OK.
But if you use [Alt][Enter] to put it in FULLSCREEN mode, you can't use de readed mouse coordinates to MOUSEMOVE, so you need to reescale.

Example: fine mouse move with keyboard arrows
Code: QB64: [Select]
  1. 'fine mouse move with arrows
  2. 'Bug: MOUSEMOVE on FULLSCREEN works in Desktop coordinates,
  3. '     but can't exceed screen coordinates
  4. 'press [Alt][Enter] to show FULLSCREEN
  5. DEFLNG H-P
  6. PhDtp = DESKTOPWIDTH
  7. PvDtp = DESKTOPHEIGHT
  8.  
  9. PixHor = 1366: PixVer = 768
  10. 'PixHor = 1728: PixVer = 972
  11.  
  12. SCREEN NEWIMAGE(PixHor, PixVer, 256)
  13. 'FULLSCREEN , SMOOTH
  14. SCREENMOVE 0, 0
  15. pxcenter = PixHor \ 2
  16. pycenter = PixVer \ 2
  17.  
  18. PhCar = FONTWIDTH
  19. PvCar = FONTHEIGHT
  20. pyps = PixVer - PvCar
  21.  
  22. LOCATE 1, 1
  23. PRINT "Desktop:"; PhDtp; PvDtp; "Screen:"; PixHor; PixVer
  24. ifull = FULLSCREEN
  25. LOCATE 1, 48: PRINT "FULL:"; ifull
  26. PRINT "Use Keyboard arrors to fine position the mouse cursor, press any key to mark with +, [Backspace] to retrive last mark, click to draw."
  27. PRINT "Test in FULLSCREEN, presing [Alt][Enter]: Now MOUSEMOVE works on Desktop coordinates"
  28.  
  29. mx = 0
  30. my = 0
  31. markx = PixHor \ 2
  32. marky = PixVer \ 2
  33. MOUSESHOW
  34. MOUSEMOVE pxcenter, pycenter 'center mouse
  35. PRINTSTRING (pxcenter - PhCar \ 2, pycenter - PvCar \ 2), "X"
  36.   nfull = FULLSCREEN
  37.   IF nfull - ifull THEN
  38.     LOCATE 1, 53: PRINT nfull
  39.     ifull = nfull
  40.   END IF
  41.   DO WHILE MOUSEINPUT
  42.     mx = MOUSEX
  43.     my = MOUSEY
  44.     mClick = MOUSEBUTTON(1)
  45.     ' mouseRight = MOUSEBUTTON(2)
  46.     ' mouseMiddle = MOUSEBUTTON(3)
  47.     ' MOUSEWHEEL
  48.     PRINTSTRING (0, pyps), STR$(mx) + STR$(my) + SPACE$(6)
  49.  
  50.     IF mClick THEN
  51.       PSET (mx, my)
  52.       PRINTSTRING (120, pyps), "Click:" + STR$(mx) + STR$(my) + SPACE$(6)
  53.     END IF
  54.   LOOP
  55.  
  56.   in$ = INKEY$
  57.   IF LEN(in$) THEN
  58.     '...  capture arrows & do mouse move
  59.     SELECT CASE in$
  60.       CASE CHR$(0) + "H" 'Up
  61.         IF my THEN move = 1 ELSE move = 0
  62.       CASE CHR$(0) + "K" 'Left
  63.         IF mx THEN move = 2 ELSE move = 0
  64.       CASE CHR$(0) + "M" 'Right
  65.         IF mx + 1 < PixHor THEN move = 3 ELSE move = 0
  66.       CASE CHR$(0) + "P" 'Down
  67.         IF my + 1 < PixVer THEN move = 4 ELSE move = 0
  68.       CASE CHR$(8) 'Backspace
  69.         move = 9
  70.       CASE ELSE
  71.         PRINTSTRING (mx - PhCar \ 2, my - PvCar \ 2), "+"
  72.         markx = mx: marky = my
  73.     END SELECT
  74.  
  75.     IF move THEN
  76.       mxi = mx: myi = my
  77.       PRINTSTRING (380, pyps), "Last move:" + STR$(move)
  78.       IF FULLSCREEN THEN '1:stretch, 2:squarepixels
  79.         mxmovi = CINT(mx * PhDtp / PixHor) 'scale conversion for mousemove
  80.         mymovi = CINT(my * PvDtp / PixVer)
  81.  
  82.         SELECT CASE move
  83.           CASE 1: my = my - 1
  84.           CASE 2: mx = mx - 1
  85.           CASE 3: mx = mx + 1
  86.           CASE 4: my = my + 1
  87.           CASE 9
  88.             mx = markx
  89.             my = marky
  90.           CASE ELSE
  91.         END SELECT
  92.         mxmov = CINT(mx * PhDtp / PixHor)
  93.         mymov = CINT(my * PvDtp / PixVer)
  94.         IF mxmov >= PixHor THEN move = 0
  95.         IF mymov >= PixVer THEN move = 0
  96.         IF move THEN
  97.           PRINTSTRING (480, pyps), STR$(mxmov) + STR$(mymov) + SPACE$(6)
  98.           MOUSEMOVE mxmov, mymov
  99.         ELSE
  100.           PRINTSTRING (480, pyps), STR$(mxmovi) + STR$(mymovi) + SPACE$(6)
  101.           mx = mxi: my = myi
  102.         END IF
  103.       ELSE
  104.         SELECT CASE move
  105.           CASE 1: my = my - 1
  106.           CASE 2: mx = mx - 1
  107.           CASE 3: mx = mx + 1
  108.           CASE 4: my = my + 1
  109.           CASE 9
  110.             mx = markx
  111.             my = marky
  112.           CASE ELSE
  113.         END SELECT
  114.         PRINTSTRING (480, pyps), STR$(mx) + STR$(my) + SPACE$(6)
  115.         MOUSEMOVE mx, my
  116.       END IF
  117.       move = 0
  118.     END IF
  119.   END IF
  120. LOOP UNTIL in$ = CHR$(27)
  121.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Mousemove bug on fullscreen mode
« Reply #1 on: May 30, 2020, 07:42:32 am »
Hi, I tried too. The screen resolution in fullscreen mode remains the same (this was to be expected, otherwise you would have to recalculate the coordinates in the program for each screen mode). Wait. That's actually the answer! Well, but for level C! If the _FULLSCREEN function returns 0, it is windowed mode. If FULLSCREEN returns 1 or 2, these are different fullscreen modes. From QB64, _MOUSEMOVE does move really badly, so at the C language level, in _MOUSEMOVE somewhere, something like this has to be added:

IF FULLSCREEN then Xshift = _desktopwidth / _width * x
                               Yshift = _desktopheight / _height * y

In the current version, this conversion is obviously missing and the fullscreen is not taken into account!

The only bad way to do this from the QB64 level is to switch the screen resolution according to the value of the FULLSCREEN function, and that's stupid, you would have to recalculate the coordinates.

OR am I completely out?

Here's the program I tried. Press A to enter mouse coordinates.

Code: QB64: [Select]
  1. a& = _NEWIMAGE(1366, 900, 32)
  2.  
  3.  
  4.     i$ = INKEY$
  5.     IF i$ = " " THEN _FULLSCREEN
  6.     IF UCASE$(i$) = "A" THEN
  7.         INPUT "Insert X,Y:"; x, y
  8.         IF x > _WIDTH - 1 THEN x = _WIDTH - 1
  9.         IF y > _HEIGHT - 1 THEN y = _HEIGHT - 1
  10.     END IF
  11.     'GOTO notthis
  12.  
  13.  
  14.  
  15.     IF _FULLSCREEN > 0 THEN
  16.         SCREEN 0
  17.         _FREEIMAGE a&
  18.         a& = _NEWIMAGE(_DESKTOPWIDTH, _DESKTOPHEIGHT, 32)
  19.         SCREEN a&
  20.     ELSE
  21.         IF a& < -1 THEN
  22.             SCREEN 0
  23.             _FREEIMAGE a&
  24.             a& = _NEWIMAGE(1366, 900, 32)
  25.             SCREEN a&
  26.             IF x > _WIDTH - 1 THEN x = _WIDTH - 1
  27.             IF y > _HEIGHT - 1 THEN y = _HEIGHT - 1
  28.         END IF
  29.     END IF
  30.  
  31.  
  32.  
  33.  
  34.     notthis:
  35.     CLS
  36.     LOCATE 1
  37.     PRINT _WIDTH, _HEIGHT; "Try press Alt + Enter -> returned resolution is still the same"
  38.  
  39.     _MOUSEMOVE x, y
  40.     _DISPLAY
  41.  

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Mousemove bug on fullscreen mode
« Reply #2 on: May 31, 2020, 04:27:39 pm »
Tank's a lot Petr, but your solution needs rewrite screen each cycle.
The only way is ALLOWFULLSCREEN OFF, OFF.
May be, creating a new image por the desktop in fullcreen and putting the image of original screen with squarepixels.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Mousemove bug on fullscreen mode
« Reply #3 on: May 31, 2020, 05:27:54 pm »
Next solution is hide original mouse pointer and show own pointer. As in this program (support CUR files, in ANI support is some bug now...)
Code: QB64: [Select]
  1. '$include:'cursors.bi'
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. N = LOADCURSOR("aero_arrow_l.cur")
  4.     CLS
  5.     PUTCURSOR N, _MOUSEX, _MOUSEY
  6.     _DISPLAY
  7.     _LIMIT 30
  8.  
  9. '$include:'cursors.bm'
  10.  

Next mouse cursors you can find in windows/cursors path.
« Last Edit: May 31, 2020, 05:29:17 pm by Petr »

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Mousemove bug on fullscreen mode
« Reply #4 on: June 01, 2020, 04:53:40 am »
Thank's a lot Petr, that's OK: It solves the problem of screenmove bug in fullscreen
This modified version allows some writing and retains the editing

Code: QB64: [Select]
  1. '$include:'cursors.bi'
  2. 'MousePoint-Moises1953. Modified version of Petr MousePointer test program
  3. handle& = _NEWIMAGE(800, 600, 32)
  4. SCREEN handle&
  5. N = LOADCURSOR("aero_arrow_l.cur")
  6.   SCREEN , , 0, 0
  7.   keypress = _KEYHIT '...some writing capabilities
  8.   SELECT CASE keypress
  9.     CASE 27
  10.       EXIT DO
  11.     CASE 13
  12.       PRINT
  13.     CASE 32 TO 255 '...text
  14.       PRINT CHR$(keypress);
  15.   WEND
  16.   SCREEN , , 1, 1 '... display cursor in another screen
  17.   CLS
  18.   PCOPY 0, 1 '...retrieve screen without cursor
  19.   PUTCURSOR N, _MOUSEX, _MOUSEY
  20.   _LIMIT 30
  21. SCREEN , , 0, 0
  22. '$include:'cursors.bm'
  23.  
  24.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Mousemove bug on fullscreen mode
« Reply #5 on: June 01, 2020, 01:47:00 pm »
Hi, i find and repair bug in ANI support, here it is. There is next bug, placing ANI animations to correct place, but in my documentation is nothnig about correctness betwen real/animation coordinates.