sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
aain.c
1#include "aalib.h"
2int aa_initkbd(struct aa_context *c, struct aa_kbddriver *d, int mode)
3{
4 if (d->init(c, mode)) {
5 c->kbddriver = d;
6 return 1;
7 }
8 return 0;
9}
10int aa_initmouse(struct aa_context *c, struct aa_mousedriver *d, int mode)
11{
12 if (d->init(c, mode)) {
13 c->mousedriver = d;
14 c->mousemode=1;
15 return 1;
16 }
17 return 0;
18}
19void aa_getmouse(struct aa_context *c, int *x, int *y, int *z)
20{
21 *x = 0;
22 *y = 0;
23 *z = 0;
24 if (c->mousedriver) {
25 c->mousedriver->getmouse(c, x, y, z);
26 }
27}
28int aa_getevent(aa_context * c, int wait)
29{
30 int x, y, b;
31 int ch;
32 if (c->mousedriver != NULL) {
33 c->mousedriver->getmouse(c, &x, &y, &b);
34 if (x != c->mousex || y != c->mousey || b != c->buttons) {
35 c->mousex = x;
36 c->mousey = y;
37 c->buttons = b;
38 return (AA_MOUSE);
39 }
40 }
41 if (c->kbddriver == NULL)
42 return (AA_UNKNOWN);
43 if (wait) {
44 while ((ch = c->kbddriver->getkey(c, 1)) == AA_NONE) {
45 if (c->mousedriver != NULL) {
46 c->mousedriver->getmouse(c, &x, &y, &b);
47 if (x != c->mousex || y != c->mousey || b != c->buttons) {
48 c->mousex = x;
49 c->mousey = y;
50 c->buttons = b;
51 return (AA_MOUSE);
52 }
53 }
54 }
55 } else
56 ch = c->kbddriver->getkey(c, 0);
57 if (ch == AA_RESIZE && c->resizehandler != NULL)
58 c->resizehandler(c);
59 if (ch == AA_MOUSE) {
60 if (c->mousedriver != NULL) {
61 c->mousedriver->getmouse(c, &x, &y, &b);
62 if (x != c->mousex || y != c->mousey || b != c->buttons) {
63 c->mousex = x;
64 c->mousey = y;
65 c->buttons = b;
66 return (AA_MOUSE);
67 } else
68 return (aa_getevent(c, wait));
69 } else
70 return (AA_UNKNOWN);
71 }
72 return (ch);
73}
74int aa_getkey(aa_context * co, int wait)
75{
76 int c;
77 do {
78 c = aa_getevent(co, wait);
79 } while (c == AA_MOUSE || c == AA_RESIZE || c>=AA_RELEASE);
80 return (c);
81}