sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
aastdin.c
1
#include "
config.h
"
2
#include <string.h>
3
#include <stdio.h>
4
#include <signal.h>
5
#include <setjmp.h>
6
#include <sys/time.h>
7
#include <sys/types.h>
8
#include <
ps2ip.h
>
9
#ifdef GPM_MOUSEDRIVER
10
#include <gpm.h>
11
#endif
12
#include "
aalib.h
"
13
static
int
iswaiting;
14
static
int
__resized;
15
#ifdef GPM_MOUSEDRIVER
16
extern
int
__curses_usegpm;
17
#endif
18
static
jmp_buf buf;
19
#ifdef SIGWINCH
20
static
void
handler(
int
i)
21
{
22
__resized = 2;
23
signal(SIGWINCH, handler);
24
if
(iswaiting)
25
longjmp(buf, 1);
26
}
27
#endif
28
static
int
stdin_init(
struct
aa_context
*context,
int
mode)
29
{
30
#ifdef SIGWINCH
31
signal(SIGWINCH, handler);
32
#endif
33
#ifdef GPM_MOUSEDRIVER
34
aa_recommendlowmouse(
"gpm"
);
35
#endif
36
return
1;
37
}
38
static
void
stdin_uninit(
aa_context
* c)
39
{
40
#ifdef SIGWINCH
41
signal(SIGWINCH, SIG_IGN);
/*this line may cause problem... */
42
#endif
43
}
44
static
int
stdin_getchar(
aa_context
* c1,
int
wait)
45
{
46
int
c;
47
int
flag;
48
struct
timeval tv;
49
50
if
(wait) {
51
setjmp(buf);
52
iswaiting = 1;
53
}
54
if
(__resized == 2) {
55
__resized = 1;
56
return
(AA_RESIZE);
57
}
58
if
(!wait) {
59
fd_set readfds;
60
tv.tv_sec = 0;
61
tv.tv_usec = 0;
62
FD_ZERO(&readfds);
63
FD_SET(0, &readfds);
64
#ifdef GPM_MOUSEDRIVER
65
if
(__curses_usegpm) {
66
FD_SET(gpm_fd, &readfds);
67
}
68
#endif
69
#ifdef GPM_MOUSEDRIVER
70
if
(!(flag = select((__curses_usegpm ? gpm_fd : 0) + 1, &readfds, NULL, NULL, &tv)))
71
#else
72
if
(!(flag = select(1, &readfds, NULL, NULL, &tv)))
73
#endif
74
return
AA_NONE;
75
76
}
77
#ifdef GPM_MOUSEDRIVER
78
if
(__curses_usegpm) {
79
c = Gpm_Getc(stdin);
80
}
else
81
#endif
82
c = getc(stdin);
83
iswaiting = 0;
84
if
(c == 27)
85
return
(AA_ESC);
86
if
(c == 10)
87
return
(13);
88
if
(c > 0 && c < 127 && c != 127)
89
return
(c);
90
switch
(c) {
91
#ifdef KEY_MOUDE
92
case
KEY_MOUSE:
93
return
AA_MOUSE
94
#endif
95
case
127:
96
return
(AA_BACKSPACE);
97
}
98
if
(feof(stdin))
return
AA_NONE;
99
return
(AA_UNKNOWN);
100
}
101
102
103
struct
aa_kbddriver
kbd_stdin_d =
104
{
105
"stdin"
,
"Standard input keyboard driver 1.0"
,
106
0,
107
stdin_init,
108
stdin_uninit,
109
stdin_getchar,
110
};
config.h
aalib.h
ps2ip.h
aa_context
Definition
aalib.h:78
aa_kbddriver
Definition
aalib.h:111
aalib
src
aastdin.c
Generated by
1.18.0