Goldside543 / goldspace

Crappy kernel I'm making
GNU General Public License v2.0
10 stars 2 forks source link

Only the first character of a command is recognized. #9

Closed Goldside543 closed 4 months ago

Goldside543 commented 4 months ago

For example, it only recognizes the "h" in help. Another, possibly related bug is that the second command and further entered doesn't recognize any character.

As a temporary fix, commands are one letter,

r-hackett commented 4 months ago

This is caused by get_char() returning 0 when it's a key release event, here.

    if (scancode & 0x80) {  // If it's a key release event
        return 0;  // Ignore it
    }

Consequently, because it is not a newline or carriage return, the first character in the 'command' buffer gets a null terminator (when you release enter). You could just check if it's not 0, like this.

            } else if (command_len < sizeof(command) - 1 && c != 0) {
                command[command_len++] = c;
                // Echo back the character to the screen
                print_char(c);
            }

I'd like to contribute to this project in time. I'd like add support for the Interrupt Descriptor Table (IDT) so we can use IRQ1 to detect keyboard events at first, if that's agreeable to you. That way, it can support exception handling Interrupt Service Routines and interrupt requests. But I hope that fixes that bug in the meantime!

edit: Also, sorry for hijacking your self-assigned issue.

Goldside543 commented 4 months ago

This is caused by get_char() returning 0 when it's a key release event, here.

    if (scancode & 0x80) {  // If it's a key release event
        return 0;  // Ignore it
    }

Consequently, because it is not a newline or carriage return, the first character in the 'command' buffer gets a null terminator (when you release enter). You could just check if it's not 0, like this.

            } else if (command_len < sizeof(command) - 1 && c != 0) {
                command[command_len++] = c;
                // Echo back the character to the screen
                print_char(c);
            }

I'd like to contribute to this project in time. I'd like add support for the Interrupt Descriptor Table (IDT) so we can use IRQ1 to detect keyboard events at first, if that's agreeable to you. That way, it can support exception handling Interrupt Service Routines and interrupt requests. But I hope that fixes that bug in the meantime!

Great! I've been stumped by this issue for days, so thanks for helping out with it! I'll add that fix soon.

edit: Also, sorry for hijacking your self-assigned issue.

No worries, lmao.

Goldside543 commented 4 months ago

Alright, I've got the change put into a bug fix branch, I'll test and merge it when I get a chance.

Again, thank you!

r-hackett commented 4 months ago

Alright, I've got the change put into a bug fix branch, I'll test and merge it when I get a chance.

Again, thank you!

You're welcome.