MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / get_mouse_position

Function get_mouse_position

src/inputdevice.cpp:2646–2711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2644}
2645
2646static bool get_mouse_position(int *xp, int *yp, int inx, int iny)
2647{
2648 extern int mouse_monid;
2649 int monid = mouse_monid;
2650 struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
2651 struct amigadisplay *ad = &adisplays[monid];
2652 struct picasso96_state_struct *state = &picasso96_state[monid];
2653 int x, y;
2654 float fdy, fdx, fmx, fmy;
2655 bool ob = false;
2656
2657 x = inx;
2658 y = iny;
2659
2660 getgfxoffset(monid, &fdx, &fdy, &fmx, &fmy);
2661
2662#ifdef PICASSO96
2663 if (ad->picasso_on) {
2664 x -= state->XOffset;
2665 y -= state->YOffset;
2666 x = (int)(x * fmx);
2667 y = (int)(y * fmy);
2668 x += (int)(fdx * fmx);
2669 y += (int)(fdy * fmy);
2670 } else
2671#endif
2672 {
2673 if (vidinfo->outbuffer == NULL) {
2674 *xp = 0;
2675 *yp = 0;
2676 return false;
2677 }
2678 x = (int)(x * fmx);
2679 y = (int)(y * fmy);
2680 x -= (int)(fdx * 1.0) - 0;
2681 y -= (int)(fdy * 1.0) - 2;
2682 if (x < 0) {
2683 ob = true;
2684 x = 0;
2685 }
2686 if (x * fmx >= vidinfo->outbuffer->outwidth) {
2687 ob = true;
2688 x = vidinfo->outbuffer->outwidth - 1;
2689 }
2690 if (y < 0) {
2691 ob = true;
2692 y = 0;
2693 }
2694 if (y * fmy >= vidinfo->outbuffer->outheight) {
2695 ob = true;
2696 y = vidinfo->outbuffer->outheight - 1;
2697 }
2698 if (currprefs.gfx_resolution == RES_LORES) {
2699 x *= 2;
2700 } else if (currprefs.gfx_resolution == RES_SUPERHIRES) {
2701 x /= 2;
2702 }
2703 x = coord_native_to_amiga_x(x);

Callers 1

mousehack_helperFunction · 0.85

Calls 3

getgfxoffsetFunction · 0.85
coord_native_to_amiga_xFunction · 0.85
coord_native_to_amiga_yFunction · 0.85

Tested by

no test coverage detected