uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

mouse.c (968B)


      1 #include "../uxn.h"
      2 #include "mouse.h"
      3 
      4 /*
      5 Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
      6 
      7 Permission to use, copy, modify, and distribute this software for any
      8 purpose with or without fee is hereby granted, provided that the above
      9 copyright notice and this permission notice appear in all copies.
     10 
     11 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12 WITH REGARD TO THIS SOFTWARE.
     13 */
     14 
     15 void
     16 mouse_down(Uxn *u, Uint8 *d, Uint8 mask)
     17 {
     18 	d[6] |= mask;
     19 	uxn_eval(u, PEEK2(d));
     20 }
     21 
     22 void
     23 mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
     24 {
     25 	d[6] &= (~mask);
     26 	uxn_eval(u, PEEK2(d));
     27 }
     28 
     29 void
     30 mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
     31 {
     32 	*(d + 2) = x >> 8, *(d + 3) = x;
     33 	*(d + 4) = y >> 8, *(d + 5) = y;
     34 	uxn_eval(u, PEEK2(d));
     35 }
     36 
     37 void
     38 mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
     39 {
     40 	*(d + 0xa) = x >> 8, *(d + 0xb) = x;
     41 	*(d + 0xc) = -y >> 8, *(d + 0xd) = -y;
     42 	uxn_eval(u, PEEK2(d));
     43 	*(d + 0xa) = *(d + 0xb) = *(d + 0xc) = *(d + 0xd) = 0;
     44 }