menu: Do not ignore key pressed during countdown

This commit is contained in:
mintsuki 2020-09-28 22:39:28 +02:00
parent fed6645044
commit 562e3c7c88
7 changed files with 48 additions and 15 deletions

View File

@ -42,7 +42,7 @@ echfs-test: test.img
echfs-utils -m -p0 test.img import test/limine.cfg limine.cfg
echfs-utils -m -p0 test.img import test/bg.bmp bg.bmp
./limine-install limine.bin test.img
qemu-system-x86_64 -net none -smp 4 -hda test.img -debugcon stdio
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon stdio
ext2-test: test.img
$(MAKE) -C test
@ -60,7 +60,7 @@ ext2-test: test.img
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./limine-install limine.bin test.img
qemu-system-x86_64 -hda test.img -smp 4 -debugcon stdio
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon
fat32-test: test.img
$(MAKE) -C test
@ -78,4 +78,4 @@ fat32-test: test.img
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./limine-install limine.bin test.img
qemu-system-x86_64 -hda test.img -smp 4 -debugcon stdio
qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon

Binary file not shown.

View File

@ -74,10 +74,8 @@ uint64_t strtoui16(const char *s) {
return n;
}
int getchar(void) {
struct rm_regs r = {0};
rm_int(0x16, &r, &r);
switch ((r.eax >> 8) & 0xff) {
int getchar_internal(uint32_t eax) {
switch ((eax >> 8) & 0xff) {
case 0x4b:
return GETCHAR_CURSOR_LEFT;
case 0x4d:
@ -87,7 +85,13 @@ int getchar(void) {
case 0x50:
return GETCHAR_CURSOR_DOWN;
}
return (char)(r.eax & 0xff);
return (char)(eax & 0xff);
}
int getchar(void) {
struct rm_regs r = {0};
rm_int(0x16, &r, &r);
return getchar_internal(r.eax);
}
static void gets_reprint_string(int x, int y, const char *s, size_t limit) {

View File

@ -9,6 +9,8 @@ int_08_isr:
iret
bits 32
extern getchar_internal
global pit_sleep_and_quit_on_keypress
pit_sleep_and_quit_on_keypress:
; Hook int 0x08
@ -69,7 +71,6 @@ pit_sleep_and_quit_on_keypress:
; on keypress
xor ax, ax
int 0x16
mov eax, 1
jmp .done
.timeout:
@ -102,4 +103,8 @@ pit_sleep_and_quit_on_keypress:
mov edx, dword [0x80*4]
mov dword [0x08*4], edx
push eax
call getchar_internal
pop edx
ret

View File

@ -202,6 +202,19 @@ static void escape_parse(char c) {
break;
}
break;
case 'K':
switch (esc_value0) {
case 2: {
int x = get_cursor_pos_x();
int y = get_cursor_pos_y();
set_cursor_pos(0, y);
for (int i = 0; i < cols; i++)
raw_putchar(' ');
set_cursor_pos(x, y);
break;
}
}
break;
default:
escape = 0;
raw_putchar('?');

View File

@ -134,23 +134,26 @@ refresh:
if (max_entries == 0)
panic("Config contains no entries.");
print("\n");
print("\nArrows to choose, enter to select, 'e' to edit command line.");
int c;
if (skip_timeout == false) {
print("\n\n");
for (int i = timeout; i; i--) {
print("\rBooting automatically in %u, press any key to stop the countdown...", i);
if (pit_sleep_and_quit_on_keypress(18)) {
if ((c = pit_sleep_and_quit_on_keypress(18))) {
skip_timeout = true;
goto refresh;
print("\e[2K\r\e[2A");
goto timeout_aborted;
}
}
goto autoboot;
}
print("Arrows to choose, enter to select, 'e' to edit command line.");
for (;;) {
int c = getchar();
c = getchar();
timeout_aborted:
switch (c) {
case GETCHAR_CURSOR_UP:
if (--selected_entry == -1)

View File

@ -21,3 +21,11 @@ PROTOCOL=stivale2
KERNEL_PARTITION=0
KERNEL_PATH=boot/test.elf
KERNEL_CMDLINE=something
:MyOS 1
PROTOCOL=stivale2
KERNEL_PARTITION=0
KERNEL_PATH=boot/test.elf
KERNEL_CMDLINE=something