#include "internal.h" #include "SharedMemoryAccess.h" #include "vkvm.h" #include #include Impl impl; void sendSignal(pid_t pid, int signalNumber) { kill(pid, signalNumber); } void onSignal(int signalNumber, void(*callback)(int)) { signal(signalNumber, callback); } InterruptEntry *getInterrupTable(){ return (InterruptEntry*)(getSharedMemory() + sizeof(Registers) + impl.reservedSize); } Registers *getRegisters(){ return (Registers*)getSharedMemory(); } char *getTextArea(){ return ((getSharedMemory() + sizeof(Registers) + impl.reservedSize) + sizeof(InterruptEntry) * impl.interruptEntyCount); } char *getPixelArea(){ return (((getSharedMemory() + sizeof(Registers) + impl.reservedSize) + sizeof(InterruptEntry) * impl.interruptEntyCount) + getCharactersPerRow() * getCharactersPerColumn()); } bool callEvent(EventType type) { auto ivt = getInterrupTable(); if(ivt[type].pid != 0){ sendSignal(ivt[type].pid, ivt[type].signum); } return true; } void setLayoutVersion(LayoutVersion newValue) { lockSharedMemory(); getRegisters()->layout_version = newValue; unlockSharedMemory(); } void setCharactersPerColumn(int newValue) { lockSharedMemory(); getRegisters()->characters_per_column = newValue; unlockSharedMemory(); } void setCharactersPerRow(int newValue) { lockSharedMemory(); getRegisters()->characters_per_row = newValue; unlockSharedMemory(); } void setMousePosition(int x, int y) { lockSharedMemory(); getRegisters()->mouse_pos_x = x; getRegisters()->mouse_pos_y = y; unlockSharedMemory(); } void buttonPressed(KeyCode keyCode) { //TODO }