library/src/internal.h

126 lines
2.6 KiB
C
Raw Normal View History

#ifndef LIBRARY_INTERNAL_H
#define LIBRARY_INTERNAL_H
#include "EventType.h"
#include "KeyCode.h"
#include "LayoutVersion.h"
#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>
/**
* the Control Registers
* @author Julian Hinxlage
* @since 0.1.0
*/
2019-11-04 23:17:15 +01:00
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;
char keyboardBuffer[16];
int keyboardBuffer_index_w;
int keyboardBuffer_index_r;
};
2019-11-04 23:17:15 +01:00
struct InterruptEntry {
int pid;
int signum;
};
/**
* internal values for the library.
*/
2019-11-04 23:17:15 +01:00
struct Impl {
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;
int reservedSize = 1024;
2019-11-06 13:41:24 +01:00
std::vector<std::function<void()>> eventTable;
};
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();
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.
*/
void setLayoutVersion(LayoutVersion newValue);
2019-10-24 09:38:58 +02:00
/**
* set characters per column for current font.
* @param newValue characters per column.
2019-10-24 09:38:58 +02:00
*/
void setCharactersPerColumn(int newValue);
2019-10-24 09:38:58 +02:00
/**
* set characters per row for current font.
* @param newValue
*/
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.
*/
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
*/
void setMousePosition(int x, int y);
2019-10-24 09:38:58 +02:00
/**
* register pressed button.
* @param keyCode pressed key.
*/
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)]
#endif