2019-10-23 17:12:04 +02:00
|
|
|
#ifndef LIBRARY_INTERNAL_H
|
|
|
|
#define LIBRARY_INTERNAL_H
|
|
|
|
|
|
|
|
#include "EventType.h"
|
|
|
|
#include "KeyCode.h"
|
|
|
|
#include "LayoutVersion.h"
|
2019-10-29 15:24:57 +01:00
|
|
|
#include "GraphicMode.h"
|
|
|
|
#include "Color.h"
|
2019-11-04 23:17:15 +01:00
|
|
|
#include <sys/types.h>
|
2019-11-06 13:41:24 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <functional>
|
2019-10-29 15:24:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the Control Registers
|
|
|
|
* @author Julian Hinxlage
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2019-11-04 23:17:15 +01:00
|
|
|
struct Registers {
|
2019-10-29 15:24:57 +01:00
|
|
|
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;
|
2019-11-12 14:07:02 +01:00
|
|
|
short keyboardBuffer[16];
|
|
|
|
int keyboardBuffer_index_write;
|
|
|
|
int keyboardBuffer_index_read;
|
2019-10-29 15:24:57 +01:00
|
|
|
};
|
|
|
|
|
2019-11-04 23:17:15 +01:00
|
|
|
struct InterruptEntry {
|
2019-10-29 15:24:57 +01:00
|
|
|
int pid;
|
|
|
|
int signum;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* internal values for the library.
|
|
|
|
*/
|
2019-11-04 23:17:15 +01:00
|
|
|
struct Impl {
|
2019-10-29 15:24:57 +01:00
|
|
|
int sharedMemoryPid;
|
2019-11-04 23:17:15 +01:00
|
|
|
key_t sharedMemoryKey;
|
|
|
|
int sharedMemorySize;
|
2019-11-06 13:41:24 +01:00
|
|
|
int interruptEntyCount = 64;
|
2019-11-07 16:34:15 +01:00
|
|
|
int reservedSize = 1024;
|
2019-11-06 13:41:24 +01:00
|
|
|
std::vector<std::function<void()>> eventTable;
|
2019-10-29 15:24:57 +01:00
|
|
|
};
|
2019-11-06 13:41:24 +01:00
|
|
|
|
2019-11-04 23:17:15 +01:00
|
|
|
extern Impl impl;
|
|
|
|
|
2019-11-06 12:47:34 +01:00
|
|
|
/**
|
|
|
|
* send a signal to a process
|
|
|
|
* @param pid of the process to which the signal is send
|
|
|
|
* @param signalNumber
|
|
|
|
*/
|
|
|
|
void sendSignal(pid_t pid, int signalNumber);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* calls the callback if a signal is received
|
|
|
|
* @param signalNumber
|
|
|
|
*/
|
|
|
|
void onSignal(int signalNumber, void(*callback)(int));
|
|
|
|
|
2019-11-06 13:41:24 +01:00
|
|
|
|
|
|
|
InterruptEntry *getInterrupTable();
|
2019-11-07 16:34:15 +01:00
|
|
|
Registers *getRegisters();
|
|
|
|
char *getTextArea();
|
|
|
|
char *getPixelArea();
|
|
|
|
|
2019-11-06 13:41:24 +01:00
|
|
|
|
2019-10-24 09:38:58 +02:00
|
|
|
/**
|
|
|
|
* set layout version.
|
|
|
|
* @param newValue new layout version number.
|
|
|
|
*/
|
2019-10-23 17:12:04 +02:00
|
|
|
void setLayoutVersion(LayoutVersion newValue);
|
|
|
|
|
2019-10-24 09:38:58 +02:00
|
|
|
/**
|
2019-11-07 16:34:15 +01:00
|
|
|
* set characters per column for current font.
|
|
|
|
* @param newValue characters per column.
|
2019-10-24 09:38:58 +02:00
|
|
|
*/
|
2019-11-07 16:34:15 +01:00
|
|
|
void setCharactersPerColumn(int newValue);
|
2019-10-23 17:12:04 +02:00
|
|
|
|
2019-10-24 09:38:58 +02:00
|
|
|
/**
|
|
|
|
* set characters per row for current font.
|
|
|
|
* @param newValue
|
|
|
|
*/
|
2019-10-23 17:12:04 +02:00
|
|
|
void setCharactersPerRow(int newValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* call a specific event.
|
|
|
|
* @param type
|
2019-10-24 09:38:58 +02:00
|
|
|
* @return true if there is a handler registered.
|
2019-10-23 17:12:04 +02:00
|
|
|
*/
|
|
|
|
bool callEvent(EventType type);
|
|
|
|
|
2019-10-24 09:38:58 +02:00
|
|
|
/**
|
|
|
|
* set mouse position to x,y value.
|
|
|
|
* @param x x coordinate
|
|
|
|
* @param y y coordinate
|
|
|
|
*/
|
2019-10-23 17:12:04 +02:00
|
|
|
void setMousePosition(int x, int y);
|
|
|
|
|
2019-10-24 09:38:58 +02:00
|
|
|
/**
|
|
|
|
* register pressed button.
|
|
|
|
* @param keyCode pressed key.
|
|
|
|
*/
|
2019-10-23 17:12:04 +02:00
|
|
|
void buttonPressed(KeyCode keyCode);
|
|
|
|
|
|
|
|
// 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)]
|
|
|
|
|
2019-10-29 15:24:57 +01:00
|
|
|
|
2019-10-23 17:12:04 +02:00
|
|
|
#endif
|