2021-12-27 00:02:24 -05:00
|
|
|
#include "../uxn.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
|
|
|
|
/*
|
2023-01-02 09:40:23 -05:00
|
|
|
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
2021-12-27 00:02:24 -05:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2023-01-01 14:31:14 -05:00
|
|
|
mouse_down(Uxn *u, Uint8 *d, Uint8 mask)
|
2021-12-27 00:02:24 -05:00
|
|
|
{
|
2023-01-01 14:31:14 -05:00
|
|
|
d[6] |= mask;
|
2023-03-01 13:42:03 -05:00
|
|
|
uxn_eval(u, PEEK16(d));
|
2021-12-27 00:02:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-01 14:31:14 -05:00
|
|
|
mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
|
2021-12-27 00:02:24 -05:00
|
|
|
{
|
2023-01-01 14:31:14 -05:00
|
|
|
d[6] &= (~mask);
|
2023-03-01 13:42:03 -05:00
|
|
|
uxn_eval(u, PEEK16(d));
|
2021-12-27 00:02:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-01 14:31:14 -05:00
|
|
|
mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
2021-12-27 00:02:24 -05:00
|
|
|
{
|
2023-03-01 13:53:44 -05:00
|
|
|
POKE16(d + 0x2, x);
|
|
|
|
POKE16(d + 0x4, y);
|
2023-03-01 13:42:03 -05:00
|
|
|
uxn_eval(u, PEEK16(d));
|
2021-12-27 00:02:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-01 14:31:14 -05:00
|
|
|
mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
2021-12-27 00:02:24 -05:00
|
|
|
{
|
2023-03-01 13:53:44 -05:00
|
|
|
POKE16(d + 0xa, x);
|
|
|
|
POKE16(d + 0xc, -y);
|
2023-03-01 13:42:03 -05:00
|
|
|
uxn_eval(u, PEEK16(d));
|
2023-03-01 13:53:44 -05:00
|
|
|
POKE16(d + 0xa, 0);
|
|
|
|
POKE16(d + 0xc, 0);
|
2021-12-29 12:58:31 -05:00
|
|
|
}
|