| 2792 | } |
| 2793 | |
| 2794 | void tablet_lightpen(int tx, int ty, int tmaxx, int tmaxy, int touch, int buttonmask, bool touchmode, int devid, int lpnum) |
| 2795 | { |
| 2796 | int monid = 0; |
| 2797 | struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo; |
| 2798 | struct amigadisplay *ad = &adisplays[monid]; |
| 2799 | int dw, dh, ax, ay, aw, ah; |
| 2800 | float fx, fy; |
| 2801 | float xmult, ymult; |
| 2802 | float fdx, fdy, fmx, fmy; |
| 2803 | int x, y; |
| 2804 | |
| 2805 | if (ad->picasso_on) |
| 2806 | goto end; |
| 2807 | |
| 2808 | if (vidinfo->outbuffer == NULL) |
| 2809 | goto end; |
| 2810 | |
| 2811 | if (touch < 0) |
| 2812 | goto end; |
| 2813 | |
| 2814 | fx = (float)tx; |
| 2815 | fy = (float)ty; |
| 2816 | |
| 2817 | desktop_coords (0, &dw, &dh, &ax, &ay, &aw, &ah); |
| 2818 | |
| 2819 | if (tmaxx < 0 || tmaxy < 0) { |
| 2820 | tmaxx = dw; |
| 2821 | tmaxy = dh; |
| 2822 | } else if (tmaxx == 0 || tmaxy == 0) { |
| 2823 | tmaxx = aw; |
| 2824 | tmaxy = ah; |
| 2825 | } |
| 2826 | |
| 2827 | if (!touchmode) { |
| 2828 | dw = aw; |
| 2829 | dh = ah; |
| 2830 | ax = 0; |
| 2831 | ay = 0; |
| 2832 | } |
| 2833 | |
| 2834 | xmult = (float)tmaxx / dw; |
| 2835 | ymult = (float)tmaxy / dh; |
| 2836 | |
| 2837 | fx = fx / xmult; |
| 2838 | fy = fy / ymult; |
| 2839 | |
| 2840 | fx -= ax; |
| 2841 | fy -= ay; |
| 2842 | |
| 2843 | getgfxoffset(0, &fdx, &fdy, &fmx, &fmy); |
| 2844 | |
| 2845 | x = (int)(fx * fmx); |
| 2846 | y = (int)(fy * fmy); |
| 2847 | x -= (int)(fdx * fmx) - 1; |
| 2848 | y -= (int)(fdy * fmy) - 2; |
| 2849 | |
| 2850 | if (x < 0 || y < 0 || x >= aw || y >= ah) |
| 2851 | goto end; |
no test coverage detected