Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update keyboard.c #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/kernel/hardware/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,31 @@ key_codes translate(uint8_t scancode) {
extended_read = false;
return scancode_mappings[0];
}

// read single character
char readSgCh() {
char ch;
printf("Enter a character: ");
ch = getchar();
getchar(); // erase "Enter" input
return ch;
}

// read string
void readString(char *str, int size) {
printf("Enter a string: ");
fgets(str, size, stdin);
size_t len = strlen(str);
if (len > 0 && str[len - 1] == '\n') {
str[len - 1] = '\0';
}
}

// read integer
int readInteger() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);
while (getchar() != '\n');
return number;
}
Loading