-BUILD_NUM = 1039
+BUILD_NUM = 1041
}
};
tKeybardCallback gKB_Callback = NULL;
-Uint8 **gpKB_Map = gpKBDUS;
-Uint8 gbaKB_States[256];
+Uint32 **gpKB_Map = gpKBDUS;
+Uint8 gbaKB_States[3][256];
int gbKB_ShiftState = 0;
int gbKB_CapsState = 0;
int gbKB_KeyUp = 0;
int giKB_KeyLayer = 0;
+#if USE_KERNEL_MAGIC
+ int gbKB_MagicState = 0;
+#endif
//Uint64 giKB_ReadBase = 0;
-Uint8 gaKB_Buffer[KB_BUFFER_SIZE]; //!< Keyboard Ring Buffer
-volatile int giKB_InsertPoint = 0; //!< Writing location marker
-volatile int giKB_ReadPoint = 0; //!< Reading location marker
-volatile int giKB_InUse = 0; //!< Lock marker
+//Uint32 gaKB_Buffer[KB_BUFFER_SIZE]; //!< Keyboard Ring Buffer
+//volatile int giKB_InsertPoint = 0; //!< Writing location marker
+//volatile int giKB_ReadPoint = 0; //!< Reading location marker
+//volatile int giKB_InUse = 0; //!< Lock marker
// === CODE ===
/**
// Ignore ACKs
if(scancode == 0xFA) {
+ // Oh man! This is anachic (I'm leaving it here to represent the
+ // mess that acess once was
//kb_lastChar = KB_ACK;
return;
}
if(!ch && !gbKB_KeyUp)
Warning("UNK %i %x", giKB_KeyLayer, scancode);
- // Reset Layer
- giKB_KeyLayer = 0;
-
// Key Up?
if (gbKB_KeyUp)
{
gbKB_KeyUp = 0;
- gbaKB_States[ ch ] = 0; // Unset key state flag
+ gbaKB_States[giKB_KeyLayer][scancode] = 0; // Unset key state flag
+
+ #if USE_KERNEL_MAGIC
+ if(ch == KEY_LCTRL) gbKB_MagicState &= ~1;
+ if(ch == KEY_LALT) gbKB_MagicState &= ~2;
+ #endif
- if( !gbaKB_States[KEY_LSHIFT] && !gbaKB_States[KEY_RSHIFT] )
- gbKB_ShiftState = 0;
+ if(ch == KEY_LSHIFT) gbKB_ShiftState &= ~1;
+ if(ch == KEY_RSHIFT) gbKB_ShiftState &= ~2;
+ // Call callback
if(ch != 0 && gKB_Callback)
gKB_Callback( ch & 0x80000000 );
+ // Reset Layer
+ giKB_KeyLayer = 0;
return;
}
// Set the bit relating to the key
- gbaKB_States[ch] = 1;
- if(ch == KEY_LSHIFT || ch == KEY_RSHIFT)
- gbKB_ShiftState = 1;
+ gbaKB_States[giKB_KeyLayer][scancode] = 1;
+ // Set shift key bits
+ if(ch == KEY_LSHIFT) gbKB_ShiftState |= 1;
+ if(ch == KEY_RSHIFT) gbKB_ShiftState |= 2;
// Check for Caps Lock
if(ch == KEY_CAPSLOCK) {
gbKB_CapsState = !gbKB_CapsState;
KB_UpdateLEDs();
}
+
+ // Reset Layer
+ giKB_KeyLayer = 0;
// Ignore Non-Printable Characters
if(ch == 0) return;
// --- Check for Kernel Magic Combos
- if(gbaKB_States[KEY_LCTRL] && gbaKB_States[KEY_LALT])
+ #if USE_KERNEL_MAGIC
+ if(ch == KEY_LCTRL) gbKB_MagicState |= 1;
+ if(ch == KEY_LALT) gbKB_MagicState |= 2;
+ if(gbKB_MagicState == 3)
{
switch(ch)
{
case 'p': Threads_Dump(); break;
}
}
+ #endif
// Is shift pressed
- if(gbKB_ShiftState ^ gbKB_CapsState)
+ // - Darn ugly hacks !(!x) means (bool)x
+ if( !(!gbKB_ShiftState) ^ gbKB_CapsState)
{
switch(ch)
{
#define _KBDUS_H\r
\r
// - BASE (NO PREFIX)\r
-Uint8 gpKBDUS1[256] = {\r
+Uint32 gpKBDUS1[256] = {\r
/*00*/ 0, KEY_ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t',\r
/*10*/ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', KEY_LCTRL, 'a', 's',\r
/*20*/ 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';','\'', '`', KEY_LSHIFT,'\\', 'z', 'x', 'c', 'v',\r
/*F0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
};\r
// - 0xE0 Prefixed\r
-Uint8 gpKBDUS2[256] = {\r
+Uint32 gpKBDUS2[256] = {\r
// 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-F\r
/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_KPENTER, KEY_RCTRL, 0, 0,\r
/*F0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
};\r
// - 0xE1 Prefixed\r
-Uint8 gpKBDUS3[256] = {\r
+Uint32 gpKBDUS3[256] = {\r
// 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-F\r
/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_PAUSE, 0, 0,\r
};\r
\r
\r
-Uint8 *gpKBDUS[3] = { gpKBDUS1, gpKBDUS2, gpKBDUS3 };\r
+Uint32 *gpKBDUS[3] = { gpKBDUS1, gpKBDUS2, gpKBDUS3 };\r
\r
#endif\r
if(term->Mode == TERM_MODE_TEXT)
{
Uint8 buf[6] = {0};
- int len;
+ int len = 0;
// Ignore Modifer Keys
if(Codepoint > KEY_MODIFIERS) return;
switch(Codepoint)
{
case KEY_LEFT:
- buf[0] = '\x1B'; buf[1] = '[';
- buf[2] = 'D'; len = 3;
+ buf[0] = '\x1B'; buf[1] = '['; buf[2] = 'D';
+ len = 3;
break;
case KEY_RIGHT:
- buf[0] = '\x1B'; buf[1] = '[';
- buf[2] = 'C'; len = 3;
+ buf[0] = '\x1B'; buf[1] = '['; buf[2] = 'C';
+ len = 3;
break;
+ case KEY_UP:
+ buf[0] = '\x1B'; buf[1] = '['; buf[2] = 'A';
+ len = 3;
+ break;
+ case KEY_DOWN:
+ buf[0] = '\x1B'; buf[1] = '['; buf[2] = 'B';
+ len = 3;
+ break;
+
+ case KEY_PGUP:
+ buf[0] = '\x1B'; buf[1] = '['; buf[2] = '5'; // Some overline also
+ //len = 4; // Commented out until I'm sure
+ break;
+ case KEY_PGDOWN:
+ len = 0;
+ break;
+
+ // Attempt to encode in UTF-8
default:
len = WriteUTF8( buf, Codepoint );
- //Log("Codepoint = 0x%x", Codepoint);
+ if(len == 0) {
+ Warning("Codepoint (%x) is unrepresentable in UTF-8", Codepoint);
+ }
break;
}
- //Log("len = %i, buf = %s", len, buf);
+ if(len == 0) {
+ // Unprintable / Don't Pass
+ return;
+ }
// Write
if( MAX_INPUT_CHARS8 - term->InputWrite >= len )
enum eTplKeyboard_KeyCodes {\r
KEY_ESC = 0x1B,\r
\r
- KEY_NP_MASK = 0x80, //End of ASCII Range\r
+ KEY_NP_MASK = 0x40000000, //End of ASCII Range\r
\r
KEY_CAPSLOCK,\r
KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,\r
KEY_WIN, KEY_MENU,\r
\r
// Modifiers\r
- KEY_MODIFIERS = 0xC0,\r
+ KEY_MODIFIERS = 0x60000000,\r
KEY_LCTRL, KEY_RCTRL,\r
KEY_LALT, KEY_RALT,\r
KEY_LSHIFT, KEY_RSHIFT,\r
#include <modules.h>
// === PROTOTYPES ===
+ int Modules_LoadBuiltins();
int Module_LoadMem(void *Buffer, Uint Length, char *ArgString);
int Module_LoadFile(char *Path, char *ArgString);
int Module_int_ResolveDeps(tModule *Info);
/*
* Acess2 IP Stack
- * - Address Resolution Protocol
+ * - Stack Initialisation
*/
#define DEBUG 0
#define VERSION ((0<<8)|10)
# Acess2 Module/Driver Templater Makefile
# Makefile.tpl
+_CPPFLAGS := $(CPPFLAGS)
+
-include ../../Makefile.cfg
-CPPFLAGS = -I../../Kernel/include -I../../Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH)
+CPPFLAGS = -I../../Kernel/include -I../../Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
CFLAGS = -Wall -Werror -fno-stack-protector $(CPPFLAGS)
OBJ := $(addsuffix .$(ARCH),$(OBJ))
char *Readline(tReadline *Info)
{
char *ret;
- int len, pos, space = 1023;
+ int len, pos, space = 1023-8-8; // optimised for the heap manager
char ch;
int scrollbackPos = Info->NumHistory;
//if(Length) *Length = len;
// Add to history
- if( strcmp( Info->History[ Info->NumHistory-1 ], ret) != 0 )
+ if( Info->UseHistory )
{
- void *tmp;
- Info->NumHistory ++;
- tmp = realloc( Info->History, Info->NumHistory * sizeof(char*) );
- if(tmp != NULL)
+ if( strcmp( Info->History[ Info->NumHistory-1 ], ret) != 0 )
{
- Info->History = tmp;
- Info->History[ Info->NumHistory-1 ] = strdup(ret);
+ void *tmp;
+ Info->NumHistory ++;
+ tmp = realloc( Info->History, Info->NumHistory * sizeof(char*) );
+ if(tmp != NULL)
+ {
+ Info->History = tmp;
+ Info->History[ Info->NumHistory-1 ] = strdup(ret);
+ }
}
}