Recent

Author Topic: A problem with ptcmouse  (Read 447 times)

TBMan

  • Full Member
  • ***
  • Posts: 178
A problem with ptcmouse
« on: May 14, 2025, 08:50:33 pm »
If you change the code to anything but 320x200 there isn't a problem, the circle draws at the point of the left mouse button click. In 320x200 mode all bets are off.

Code: Pascal  [Select][+][-]
  1. program play15;
  2. uses ptcgraph,ptccrt,ptcmouse;
  3.  
  4.  
  5. var
  6.  
  7.   gm,gd:smallint;
  8.   mx,my,mb:longint;
  9.  
  10.  
  11.  
  12. begin
  13.  
  14.   gd := vesa;
  15.   Gm := installusermode(320, 200, 256, 2, 8000, 6000);
  16.   initgraph(gd, gm, '');
  17.   initmouse;
  18.   showmouse;
  19.  
  20.   mx := 0; my := 0;
  21. repeat
  22.   getmousestate(mx,my,mb);
  23.  
  24.   if lpressed then
  25.      begin
  26.        setcolor(14);
  27.        circle(mx,my,8);
  28.      while lpressed do begin end;
  29.      end;
  30. until keypressed;
  31. closegraph;
  32. end.
  33.  
  34.  

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: A problem with ptcmouse
« Reply #1 on: May 14, 2025, 09:08:24 pm »
Confirmed for Linux.

Because a lot of changes happened with ptc in trunk (kvm units) it should really be checked against that as well but am not able to do so myself atm (maybe tomorrow).

I haven't looked at the implementation either so for that also atm, no clue as of why.
Today is tomorrow's yesterday.

TBMan

  • Full Member
  • ***
  • Posts: 178
Re: A problem with ptcmouse
« Reply #2 on: May 15, 2025, 07:46:02 pm »
It's odd. Hopefully someone can provide a fix.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: A problem with ptcmouse
« Reply #3 on: May 15, 2025, 09:13:00 pm »
@TBMan It has something to do with scaling. Not sure if it was done intentional (e.g. even while sounding perhaps strange there might be an argument to justify this behaviour).

Until cleared/fixed, perhaps you can use following workaround ?:

Code: Pascal  [Select][+][-]
  1. program play15;
  2.  
  3. uses
  4.   {$ifdef linux}
  5.   cthreads, // *nix platforms require this
  6.   {$endif}
  7.   sysutils,
  8.   ptcgraph,ptccrt,ptcmouse;
  9.  
  10. var
  11.   gm,gd:smallint;
  12.   mx,my,mb:longint;
  13.   txt:string;
  14. begin
  15.   gd := vesa;
  16.   Gm := installusermode(320, 200, 256, 2, 8000, 6000);
  17.  
  18.   initgraph(gd, gm, '');
  19.   initmouse;
  20.   showmouse;
  21.  
  22.   mx := 0; my := 0;
  23.  
  24.   repeat
  25.     getmousestate(mx, my, mb);
  26.  
  27.     // workaround
  28.     mx := mx shr 1;
  29.     my := my shr 1;
  30.  
  31.     // verify coords
  32.     bar(10, 10, 160, 30);
  33.     writestr(txt, 'mx = ', mx, ', my = ', my);
  34.     outTextXY(10,10, txt);
  35.  
  36.     if lpressed then
  37.     begin
  38.       setcolor(14);
  39.       circle(mx,my,8);
  40.       while lpressed do begin end;
  41.     end;
  42.     // prevent hoggin' cpu
  43.     sleep(2);
  44.   until keypressed;
  45.  
  46.   closegraph;
  47. end.
  48.  
Today is tomorrow's yesterday.

TBMan

  • Full Member
  • ***
  • Posts: 178
Re: A problem with ptcmouse
« Reply #4 on: May 15, 2025, 09:40:51 pm »
That's fine for now, thanks.

 

TinyPortal © 2005-2018