feature (strings): implemented the noxos ascii extension
This commit is contained in:
parent
fb66944b0e
commit
be508dae9f
|
@ -27,6 +27,10 @@
|
|||
#define PS2_SCANCODE_SET_1_F11 0x57
|
||||
#define PS2_SCANCODE_SET_1_F12 0x58
|
||||
|
||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_UP 0x48
|
||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_LEFT 0x4B
|
||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_RIGHT 0x4D
|
||||
#define PS2_SCANCODE_SET_1_E0_CURSOR_DOWN 0x50
|
||||
|
||||
#define PS2_SCANCODE_SET_1_RELEASE 0x80
|
||||
#define PS2_SCANCODE_SET_1_MODIFIER 0xE0
|
||||
|
|
|
@ -6,12 +6,35 @@
|
|||
#include "stdtypes.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define STRING_EXT_SIZE(n) ((n) + 5)
|
||||
|
||||
typedef const char* string_t;
|
||||
|
||||
typedef enum {
|
||||
STRING_EXT_CMD_CLEAR,
|
||||
STRING_EXT_CMD_CURSOR_MOVE,
|
||||
STRING_EXT_CMD_CURSOR_SET,
|
||||
STRING_EXT_CMD_COLOR_SET,
|
||||
STRING_EXT_CMD_COLOR_RESET,
|
||||
STRING_EXT_CMD_RENDER_DISABLE,
|
||||
STRING_EXT_CMD_RENDER_ENABLE,
|
||||
STRING_EXT_CMD_KEYBOARD_ECHO
|
||||
} string_ext_command_E;
|
||||
|
||||
typedef struct {
|
||||
uint8_t shift_in;
|
||||
uint16_t length;
|
||||
uint8_t command;
|
||||
uint8_t data;
|
||||
// DATA BLOCKS
|
||||
// SHIFT OUT
|
||||
}__attribute__((packed)) string_ext_header_T;
|
||||
|
||||
uint32_t string_length (string_t string);
|
||||
bool string_compare (string_t a, string_t b);
|
||||
uint32_t string_find_next (string_t string, char chr);
|
||||
uint32_t string_find_last (string_t string, char chr);
|
||||
void string_add_ext_command (string_t string, string_ext_command_E command, int num_data, uint8_t data[]);
|
||||
|
||||
uint64_t variadic_format_size (string_t string, va_list args);
|
||||
uint64_t format_size (string_t string, ...);
|
||||
|
|
|
@ -24,7 +24,7 @@ int read_command(char* command_buffer) {
|
|||
}
|
||||
}
|
||||
|
||||
command_buffer[pos] = '\0';
|
||||
command_buffer[--pos] = '\0';
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -61,14 +61,45 @@ void ps2_keyboard_init() {
|
|||
pic_unmask_irq(IRQ_KEYBOARD);
|
||||
}
|
||||
|
||||
#include "utils/memory.h"
|
||||
void ps2_keyboard_read() {
|
||||
uint8_t scancode = ps2_controller_read_data();
|
||||
char chr [2]; chr[1] = '\0';
|
||||
char chr [8];
|
||||
|
||||
if (extended_key) {
|
||||
extended_key = false;
|
||||
|
||||
switch (scancode) {
|
||||
case PS2_SCANCODE_SET_1_E0_CURSOR_LEFT: {
|
||||
uint8_t data = 0;
|
||||
string_add_ext_command(chr, STRING_EXT_CMD_CURSOR_MOVE, 1, &data);
|
||||
chr[STRING_EXT_SIZE(1)+1] = '\0';
|
||||
break;
|
||||
}
|
||||
case PS2_SCANCODE_SET_1_E0_CURSOR_RIGHT: {
|
||||
uint8_t data = 1;
|
||||
string_add_ext_command(chr, STRING_EXT_CMD_CURSOR_MOVE, 1, &data);
|
||||
chr[STRING_EXT_SIZE(1)+1] = '\0';
|
||||
break;
|
||||
}
|
||||
case PS2_SCANCODE_SET_1_E0_CURSOR_UP: {
|
||||
uint8_t data = 2;
|
||||
string_add_ext_command(chr, STRING_EXT_CMD_CURSOR_MOVE, 1, &data);
|
||||
chr[STRING_EXT_SIZE(1)+1] = '\0';
|
||||
break;
|
||||
}
|
||||
case PS2_SCANCODE_SET_1_E0_CURSOR_DOWN: {
|
||||
uint8_t data = 3;
|
||||
string_add_ext_command(chr, STRING_EXT_CMD_CURSOR_MOVE, 1, &data);
|
||||
chr[STRING_EXT_SIZE(1)+1] = '\0';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
memory_hexdump(chr, 8);
|
||||
}
|
||||
|
||||
if (scancode == PS2_SCANCODE_SET_1_MODIFIER) {
|
||||
extended_key = true;
|
||||
|
@ -111,16 +142,19 @@ void ps2_keyboard_read() {
|
|||
|
||||
case PS2_SCANCODE_SET_1_BACKSPACE: {
|
||||
chr[0] = '\b';
|
||||
chr[1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
case PS2_SCANCODE_SET_1_SPACE: {
|
||||
chr[0] = ' ';
|
||||
chr[1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
case PS2_SCANCODE_SET_1_RETURN: {
|
||||
chr[0] = '\n';
|
||||
chr[1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -137,6 +171,7 @@ void ps2_keyboard_read() {
|
|||
if (string_is_char_lowercase(chr[0])) chr[0] -= 32;
|
||||
else if (string_is_char_uppercase(chr[0])) chr[0] += 32;
|
||||
}
|
||||
chr[1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,15 @@ uint32_t string_find_last(string_t string, char chr) {
|
|||
return n;
|
||||
}
|
||||
|
||||
void string_add_ext_command(string_t string, string_ext_command_E command, int num_data, uint8_t data[]) {
|
||||
string_ext_header_T* header = (string_ext_header_T*)string;
|
||||
header->shift_in = 0x0F;
|
||||
header->length = num_data;
|
||||
header->command = command;
|
||||
memory_copy(data, &header->data, num_data);
|
||||
*(&(&header->data)[num_data]) = 0x0E;
|
||||
}
|
||||
|
||||
uint64_t variadic_format_size(string_t string, va_list args) {
|
||||
const char* buffer_in = (const char*)string;
|
||||
|
||||
|
|
Loading…
Reference in New Issue