commit 8d73001
Devine Lu Linvega
·
2024-07-01 05:21:01 +0000 UTC
parent 776b355
Do not pass memory in mouse device
3 files changed,
+27,
-27
+16,
-16
1@@ -13,33 +13,33 @@ WITH REGARD TO THIS SOFTWARE.
2 */
3
4 void
5-mouse_down(Uint8 *d, Uint8 mask)
6+mouse_down(Uint8 mask)
7 {
8- d[6] |= mask;
9- uxn_eval(PEEK2(d));
10+ uxn.dev[0x96] |= mask;
11+ uxn_eval(PEEK2(&uxn.dev[0x90]));
12 }
13
14 void
15-mouse_up(Uint8 *d, Uint8 mask)
16+mouse_up(Uint8 mask)
17 {
18- d[6] &= (~mask);
19- uxn_eval(PEEK2(d));
20+ uxn.dev[0x96] &= (~mask);
21+ uxn_eval(PEEK2(&uxn.dev[0x90]));
22 }
23
24 void
25-mouse_pos(Uint8 *d, Uint16 x, Uint16 y)
26+mouse_pos(Uint16 x, Uint16 y)
27 {
28- *(d + 2) = x >> 8, *(d + 3) = x;
29- *(d + 4) = y >> 8, *(d + 5) = y;
30- uxn_eval(PEEK2(d));
31+ uxn.dev[0x92] = x >> 8, uxn.dev[0x93] = x;
32+ uxn.dev[0x94] = y >> 8, uxn.dev[0x95] = y;
33+ uxn_eval(PEEK2(&uxn.dev[0x90]));
34 }
35
36 void
37-mouse_scroll(Uint8 *d, Uint16 x, Uint16 y)
38+mouse_scroll(Uint16 x, Uint16 y)
39 {
40- *(d + 0xa) = x >> 8, *(d + 0xb) = x;
41- *(d + 0xc) = -y >> 8, *(d + 0xd) = -y;
42- uxn_eval(PEEK2(d));
43- *(d + 0xa) = 0, *(d + 0xb) = 0;
44- *(d + 0xc) = 0, *(d + 0xd) = 0;
45+ uxn.dev[0x9a] = x >> 8, uxn.dev[0x9b] = x;
46+ uxn.dev[0x9c] = -y >> 8, uxn.dev[0x9d] = -y;
47+ uxn_eval(PEEK2(&uxn.dev[0x90]));
48+ uxn.dev[0x9a] = 0, uxn.dev[0x9b] = 0;
49+ uxn.dev[0x9c] = 0, uxn.dev[0x9d] = 0;
50 }
+4,
-4
1@@ -9,7 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
2 WITH REGARD TO THIS SOFTWARE.
3 */
4
5-void mouse_down(Uint8 *d, Uint8 mask);
6-void mouse_up(Uint8 *d, Uint8 mask);
7-void mouse_pos(Uint8 *d, Uint16 x, Uint16 y);
8-void mouse_scroll(Uint8 *d, Uint16 x, Uint16 y);
9+void mouse_down(Uint8 mask);
10+void mouse_up(Uint8 mask);
11+void mouse_pos(Uint16 x, Uint16 y);
12+void mouse_scroll(Uint16 x, Uint16 y);
+7,
-7
1@@ -170,25 +170,25 @@ emu_event(void)
2 case ButtonPress: {
3 XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
4 if(e->button == 4)
5- mouse_scroll(&uxn.dev[0x90], 0, 1);
6+ mouse_scroll(0, 1);
7 else if(e->button == 5)
8- mouse_scroll(&uxn.dev[0x90], 0, -1);
9+ mouse_scroll( 0, -1);
10 else if(e->button == 6)
11- mouse_scroll(&uxn.dev[0x90], 1, 0);
12+ mouse_scroll(1, 0);
13 else if(e->button == 7)
14- mouse_scroll(&uxn.dev[0x90], -1, 0);
15+ mouse_scroll(-1, 0);
16 else
17- mouse_down(&uxn.dev[0x90], 0x1 << (e->button - 1));
18+ mouse_down(0x1 << (e->button - 1));
19 } break;
20 case ButtonRelease: {
21 XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
22- mouse_up(&uxn.dev[0x90], 0x1 << (e->button - 1));
23+ mouse_up(0x1 << (e->button - 1));
24 } break;
25 case MotionNotify: {
26 XMotionEvent *e = (XMotionEvent *)&ev;
27 int x = clamp((e->x - PAD) / uxn_screen.scale, 0, uxn_screen.width - 1);
28 int y = clamp((e->y - PAD) / uxn_screen.scale, 0, uxn_screen.height - 1);
29- mouse_pos(&uxn.dev[0x90], x, y);
30+ mouse_pos(x, y);
31 } break;
32 }
33 }