132 lines
2.9 KiB
C++
132 lines
2.9 KiB
C++
|
#ifndef LIBRARY_INTERNAL_HPP
|
||
|
#define LIBRARY_INTERNAL_HPP
|
||
|
|
||
|
#include "EventType.hpp"
|
||
|
#include "KeyCode.hpp"
|
||
|
#include "LayoutVersion.hpp"
|
||
|
#include "GraphicMode.hpp"
|
||
|
#include "Color.hpp"
|
||
|
#include <sys/types.h>
|
||
|
#include <vector>
|
||
|
#include <functional>
|
||
|
|
||
|
namespace vkvm {
|
||
|
|
||
|
/**
|
||
|
* the Control Registers
|
||
|
* @author Julian Hinxlage
|
||
|
* @since 0.1.0
|
||
|
*/
|
||
|
struct Registers {
|
||
|
int layout_version;
|
||
|
int trigger_reset;
|
||
|
int width_pixels;
|
||
|
int height_pixels;
|
||
|
GraphicMode graphicMode;
|
||
|
int autoRedrawInterval;
|
||
|
int timerInterruptInterval;
|
||
|
Color background_color;
|
||
|
Color foreground_color;
|
||
|
int characters_per_row;
|
||
|
int characters_per_column;
|
||
|
int textMode_font;
|
||
|
int textMode_font_width;
|
||
|
int textMode_font_height;
|
||
|
int mouse_pos_x;
|
||
|
int mouse_pos_y;
|
||
|
short keyboardBuffer[16];
|
||
|
int keyboardBuffer_index_write;
|
||
|
int keyboardBuffer_index_read;
|
||
|
};
|
||
|
|
||
|
struct InterruptEntry {
|
||
|
int pid;
|
||
|
int signum;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* internal values for the library.
|
||
|
*/
|
||
|
struct Impl {
|
||
|
int sharedMemoryPid;
|
||
|
key_t sharedMemoryKey;
|
||
|
int sharedMemorySize;
|
||
|
int interruptEntyCount = 64;
|
||
|
int reservedSize = 1024;
|
||
|
std::vector<std::function<void()>> eventTable;
|
||
|
};
|
||
|
|
||
|
extern Impl impl;
|
||
|
|
||
|
/**
|
||
|
* send a signal to a process
|
||
|
* @param pid of the process to which the signal is send
|
||
|
* @param signalNumber
|
||
|
*/
|
||
|
auto sendSignal(pid_t pid, int signalNumber) -> void;
|
||
|
|
||
|
/**
|
||
|
* calls the callback if a signal is received
|
||
|
* @param signalNumber
|
||
|
*/
|
||
|
auto onSignal(int signalNumber, void(*callback)(int)) -> void;
|
||
|
|
||
|
|
||
|
auto getInterrupTable() -> InterruptEntry *;
|
||
|
|
||
|
auto getRegisters() -> Registers *;
|
||
|
|
||
|
auto getTextArea() -> char * ;
|
||
|
|
||
|
auto getPixelArea() -> char *;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* set layout version.
|
||
|
* @param newValue new layout version number.
|
||
|
*/
|
||
|
auto setLayoutVersion(LayoutVersion newValue) -> void;
|
||
|
|
||
|
/**
|
||
|
* set characters per column for current font.
|
||
|
* @param newValue characters per column.
|
||
|
*/
|
||
|
auto setCharactersPerColumn(int newValue) -> void;
|
||
|
|
||
|
/**
|
||
|
* set characters per row for current font.
|
||
|
* @param newValue
|
||
|
*/
|
||
|
auto setCharactersPerRow(int newValue) -> void;
|
||
|
|
||
|
/**
|
||
|
* call a specific event.
|
||
|
* @param type
|
||
|
* @return true if there is a handler registered.
|
||
|
*/
|
||
|
auto callEvent(EventType type) -> bool;
|
||
|
|
||
|
/**
|
||
|
* set mouse position to x,y value.
|
||
|
* @param x x coordinate
|
||
|
* @param y y coordinate
|
||
|
*/
|
||
|
auto setMousePosition(int x, int y) -> void;
|
||
|
|
||
|
/**
|
||
|
* register pressed button.
|
||
|
* @param keyCode pressed key.
|
||
|
*/
|
||
|
auto buttonPressed(KeyCode keyCode) -> void;
|
||
|
|
||
|
// Shared Memory Layout
|
||
|
// --------------------------------------------------------------------
|
||
|
// struct ControlRegisters
|
||
|
// char reserved[1024]
|
||
|
// Interrupt Vector Table [64]
|
||
|
// text area [max_textMode_width * max_textMode_height]
|
||
|
// pixel area [max_height_pixels * max_height_pixels * sizeof(uint_32)]
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|