#include <idl4glue.h>
#include "libc/stdint.h"
#include <config.h>
#include <if/types.h>
#include "ConsoleBuffer.h"
#include <stdio.h>
#include <stdlib.h>
const unsigned int INPUT_BUFFER_LENGTH = 256;
const unsigned int VIDEO_BUFFER_LENGTH = 4000;
const unsigned int CONSOLE_BUFFER_LENGTH = 8000;
class VirtualConsole {
uint8_t* inputBuffer;
char* videoBuffer;
int myConsoleId;
unsigned int nextFreeIn;
uint32_t keyStatus;
ConsoleBuffer *consoleBuffer;
int hasFocus;
public:
VirtualConsole(int consoleId, char* videoMemStart);
~VirtualConsole();
idlsize_t write(const buffer_t *buffer, const uint32_t pos);
CORBA_unsigned_long read(idlsize_t readsize, CORBA_char* buf);
void addInput(uint8_t c);
void ClearInputBuffer();
void setFocus(int f) {
hasFocus = f;
}
void update() {
consoleBuffer->update();
}
void PageUp() {
consoleBuffer->PageUp();
}
void PageDown() {
consoleBuffer->PageDown();
}
int CTRLpressed() {
return (keyStatus & 0x00000001) || (keyStatus & 0x00000002);
}
int ALTpressed() {
return (keyStatus & 0x00000004) || (keyStatus & 0x00000008);
}
int SHIFTpressed() {
return (keyStatus & 0x00000010) || (keyStatus & 0x00000020);
}
void setCTRL(int i) {
if(i) {
keyStatus |= 0x00000003;
} else {
keyStatus &= 0xfffffffc;
}
}
void setALT(int i) {
if(i) {
keyStatus |= 0x0000000c;
} else {
keyStatus &= 0xfffffff3;
}
}
void setSHIFT(int i) {
if(i) {
keyStatus |= 0x00000030;
} else {
keyStatus &= 0xffffffcf;
}
}
};