blob: 7c0f22148b02e7da38f5bdb237bb5b621fbb8a06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "acpi/acpi.h"
#include "boot/tag.h"
#include "cpu/cpu.h"
#include "drivers/ps2ctrl.h"
#include "drivers/ps2kb.h"
#include "drivers/ps2mouse.h"
#include "interrupt/idt.h"
#include "interrupt/pic.h"
#include "time.h"
#include "tty/cursor.h"
#include "tty/term.h"
#include <print.h>
#include <math.h>
#include <stdlib.h>
#include <sys.h>
static double x = 0, y = 0;
void kernel_main(void* boot_info) {
term_init();
cursor_enable();
rtc_set_timezone(-4);
rtc_update();
idt_init();
pic_remap(PIC_REMAP_OFFSET);
load_boot_info(boot_info);
acpi_init();
memory_init();
ps2ctrl_init();
ps2kb_init();
ps2mouse_init();
init_registers();
while(1) {
int_wait();
struct Keycode code = ps2kb_get();
if(code.key != KEY_NONE) {
if(code.flags & KC_FLAG_ERROR) {
printk("error: %X\n", code.key);
} else if(code.flags & KC_FLAG_KEY_DOWN) {
printk("pressed: %X\n", code.key);
} else {
printk("released: %X\n", code.key);
}
}
if (code.key == KEY_ESCAPE) {
acpi_poweroff();
}
struct MouseEvent event = ps2mouse_get();
if (event.updated) {
putchar(event.lmb ? 'L' : '_');
putchar(event.rmb ? 'R' : '_');
putchar(event.mmb ? 'M' : '_');
x += event.relx / 10.0;
y -= event.rely / 10.0;
x = fclamp(x, 0, TERM_W);
y = fclamp(y, 0, TERM_H);
printk(" x%d y%d\n", (int)x, (int)y);
}
term_flush();
rtc_update();
}
}
|