parent
f0f0d4ae63
commit
29dac2230f
|
@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Continuous Integration
|
||||
|
||||
## [0.0.1] - 2019-10-24
|
||||
## [0.1.0] - 2019-10-24
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
# vKVM Library
|
||||
|
||||
# Installation
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Use the installation script provided in the Scripts repository
|
||||
to install the full package.
|
||||
|
||||
Installing a single component is currently not supported.
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
|
||||
Include this library with
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef LIBRARY_COLOR_H
|
||||
#define LIBRARY_COLOR_H
|
||||
|
||||
static const Color black = Color(0, 0, 0);
|
||||
static const Color white = Color(255, 255, 255);
|
||||
|
||||
class Color {
|
||||
|
||||
private:
|
||||
unsigned char red;
|
||||
unsigned char green;
|
||||
unsigned char blue;
|
||||
|
||||
public:
|
||||
Color(red, green, blue);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef LIBRARY_EVENTTYPE_H
|
||||
#define LIBRARY_EVENTTYPE_H
|
||||
|
||||
/**
|
||||
* @since 0.1.0
|
||||
* @uthor Johannes Theiner
|
||||
*/
|
||||
enum EventType {
|
||||
Timer = 1,
|
||||
MouseMove = 2,
|
||||
MouseButton = 3,
|
||||
KeyDown = 4,
|
||||
KeyUp = 5,
|
||||
UpdateControlRegisters = 6,
|
||||
Redraw = 7,
|
||||
RenderText = 8
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef LIBRARY_FONT_H
|
||||
#define LIBRARY_FONT_H
|
||||
|
||||
|
||||
class Font {
|
||||
private:
|
||||
Font();
|
||||
|
||||
public:
|
||||
std::string getName();
|
||||
int getHeight();
|
||||
int getWidth();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef LIBRARY_GRAPHICMODE_H
|
||||
#define LIBRARY_GRAPHICMODE_H
|
||||
|
||||
enum GraphicMode {
|
||||
Text = 1,
|
||||
TwoColors = 2,
|
||||
Gray_256 = 3,
|
||||
TrueColor = 4,
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef LIBRARY_KEYCODE_H
|
||||
#define LIBRARY_KEYCODE_H
|
||||
|
||||
|
||||
const KeyCode Backspace = KeyCode(8);
|
||||
const KeyCode tabulator = KeyCode(9);
|
||||
|
||||
class KeyCode {
|
||||
|
||||
private:
|
||||
KeyCode(int value);
|
||||
public:
|
||||
int getValue();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef LIBRARY_LAYOUTVERSION_H
|
||||
#define LIBRARY_LAYOUTVERSION_H
|
||||
|
||||
enum LayoutVersion {
|
||||
V1 = 1;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef LIBRARY_INTERNAL_H
|
||||
#define LIBRARY_INTERNAL_H
|
||||
|
||||
#include "EventType.h"
|
||||
#include "KeyCode.h"
|
||||
#include "LayoutVersion.h"
|
||||
|
||||
//TODO: documentation
|
||||
|
||||
void setLayoutVersion(LayoutVersion newValue);
|
||||
|
||||
void setTriggerReset(int newValue);
|
||||
|
||||
void setCharactersPerLine(int newValue);
|
||||
|
||||
void setCharactersPerRow(int newValue);
|
||||
|
||||
/**
|
||||
* call a specific event.
|
||||
* @param type
|
||||
* @return true if there is a handler registere
|
||||
*/
|
||||
bool callEvent(EventType type);
|
||||
|
||||
void setMousePosition(int x, int y);
|
||||
|
||||
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
|
|
@ -0,0 +1,12 @@
|
|||
//enum config file defaults {
|
||||
const int max_width_pixels = 800;
|
||||
const int max_height_pixels = 600;
|
||||
const int max_textMode_width = 800;
|
||||
const int max_textMode_height = 600;
|
||||
//};
|
||||
|
||||
|
||||
struct interruptVector {
|
||||
int pid;
|
||||
int signal;
|
||||
};
|
249
src/vkvm.h
249
src/vkvm.h
|
@ -1,74 +1,201 @@
|
|||
#ifndef LIBRARY_VKVM_H
|
||||
#define LIBRARY_VKVM_H
|
||||
|
||||
typedef int type_todo;
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "Color.h"
|
||||
#include "EventType.h"
|
||||
#include "GraphicMode.h"
|
||||
#include "Font.h"
|
||||
#include "KeyCode.h"
|
||||
#include "LayoutVersion.h"
|
||||
|
||||
private struct interruptVector {
|
||||
int pid;
|
||||
int signal;
|
||||
};
|
||||
/**
|
||||
* @since 0.1.0
|
||||
* @author Johannes Theiner
|
||||
*/
|
||||
|
||||
//enum config file defaults {
|
||||
const int max_width_pixels = 800;
|
||||
const int max_height_pixels = 600;
|
||||
const int max_textMode_width;
|
||||
const int max_textMode_height;
|
||||
// TODO: add ControlRegisters members here
|
||||
//TODO: add get/set methods
|
||||
//};
|
||||
//TODO: better documentation
|
||||
|
||||
/**
|
||||
* initialize the connection with the shared-memory application
|
||||
* @param pid pip of shared-memory application
|
||||
*/
|
||||
void initialize(int pid);
|
||||
|
||||
enum GraphicMode {
|
||||
Text,
|
||||
BlackWhite,
|
||||
Gray_256,
|
||||
TrueColor;
|
||||
};
|
||||
/**
|
||||
* set pixel at a x,y position to a certain color.
|
||||
* @param x x coordinate of pixel
|
||||
* @param y y coordinate of pixel
|
||||
* @param color color of pixel
|
||||
* @return true if operation succeeded, false if it failed.
|
||||
*/
|
||||
bool setPixel(int x, int y, Color color);
|
||||
|
||||
private struct controlRegisters {
|
||||
int layout_version
|
||||
int trigger_reset;
|
||||
int width_pixels;
|
||||
int height_pixels;
|
||||
GraphicMode graphicMode;
|
||||
int autoRedrawInterval;
|
||||
int timerInterruptInterval;
|
||||
type_todo bw_background_color;
|
||||
type_todo bw_foreground_color;
|
||||
int textMode_width;
|
||||
int textMode_height;
|
||||
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;
|
||||
};
|
||||
/**
|
||||
* get color of pixel at x,y position
|
||||
* @param x x coordinate of pixel
|
||||
* @param y y coordinate of pixel
|
||||
* @return color of pixel
|
||||
*/
|
||||
Color getPixel(int x, int y);
|
||||
|
||||
//TODO: add init
|
||||
//TODO: add methods for a event handling approach
|
||||
//TODO: add methods for a pooling approach
|
||||
/**
|
||||
* register handler for event.
|
||||
* @param type type of event.
|
||||
* @param handler function to call.
|
||||
* @return true if handler could be registered, false if it failed.
|
||||
*/
|
||||
bool registerEvent(EventType type, std::function<void()> handler);
|
||||
|
||||
// interrupts
|
||||
/*
|
||||
1 timer
|
||||
2 mouse move
|
||||
mouse button
|
||||
key down
|
||||
key up
|
||||
reread ControlRegisters
|
||||
redraw GUI // opposite direction (i.e. client to GUI)!
|
||||
render Text // text mode client -> text rendering process -> redraw GUI
|
||||
*/
|
||||
/**
|
||||
* set displayed text in Text mode
|
||||
* @param text text to display
|
||||
* @return if text could be set, false if it could not be set.
|
||||
*/
|
||||
bool setText(std::string text);
|
||||
|
||||
// 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)]
|
||||
/**
|
||||
* get currently saved/displayed text.
|
||||
*/
|
||||
std::string getText();
|
||||
|
||||
//Control registers start here
|
||||
|
||||
//all modes
|
||||
|
||||
/**
|
||||
* get version of the used layout
|
||||
* @return layout version
|
||||
*/
|
||||
LayoutVersion getLayoutVersion();
|
||||
|
||||
/**
|
||||
* reset all values to default.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* get width of window.
|
||||
* @return width of window.
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* set width of window.
|
||||
* @param newValue new width for window.
|
||||
*/
|
||||
void setWidth(int newValue);
|
||||
|
||||
/**
|
||||
* get height for window.
|
||||
* @return height of window.
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* set height of window.
|
||||
* @param newValue new height for window.
|
||||
*/
|
||||
void setHeight(int newValue);
|
||||
|
||||
/**
|
||||
* get graphics display mode.
|
||||
* @return GraphicMode.
|
||||
*/
|
||||
GraphicMode getMode();
|
||||
|
||||
/**
|
||||
* set new graphics display mode.
|
||||
* @param newValue new graphics display mode.
|
||||
*/
|
||||
void setMode(GraphicMode newValue);
|
||||
|
||||
/**
|
||||
* get interval between redraws in milliseconds.
|
||||
*/
|
||||
int getRedrawInterval();
|
||||
|
||||
/**
|
||||
* set interval between redraws.
|
||||
* @param newValue new interval in milliseconds.
|
||||
*/
|
||||
void setRedrawInterval(int newValue);
|
||||
|
||||
/**
|
||||
* get time between timer interrupts.
|
||||
* @return time between interrupts in milliseconds.
|
||||
*/
|
||||
int getTimerInterruptInterval();
|
||||
|
||||
/**
|
||||
* set time between timer interrupts.
|
||||
* @param newValue new time between interrupts in milliseconds.
|
||||
*/
|
||||
void setTimerInterruptInterval(int newValue);
|
||||
|
||||
//black/white mode
|
||||
|
||||
/**
|
||||
* get background color in two color mode.
|
||||
* @return background color.
|
||||
*/
|
||||
Color getBackgroundColor();
|
||||
|
||||
/**
|
||||
* set background color in two color mode.
|
||||
* @param newValue new background color.
|
||||
*/
|
||||
void setBackgroundColor(Color newValue);
|
||||
|
||||
/**
|
||||
* get foreground color in two color mode.
|
||||
* @return foreground color.
|
||||
*/
|
||||
Color getForegroundColor();
|
||||
|
||||
/**
|
||||
* set foreground color in two color mode.
|
||||
* @param newValue new foreground color.
|
||||
*/
|
||||
void setForegroundColor(Color newValue);
|
||||
|
||||
//text mode
|
||||
|
||||
/**
|
||||
* get characters per line in text mode.
|
||||
* @return characters per line.
|
||||
*/
|
||||
int getCharactersPerLine();
|
||||
|
||||
/**
|
||||
* get characters per row in text mode.
|
||||
* @return characters per row.
|
||||
*/
|
||||
int getCharactersPerRow();
|
||||
|
||||
/**
|
||||
* get currently used font in text mode.
|
||||
* @return currently used font.
|
||||
*/
|
||||
Font getFont();
|
||||
|
||||
/**
|
||||
* set text mode font.
|
||||
* @param newValue new text mode font.
|
||||
*/
|
||||
void setFont(Font newValue);
|
||||
|
||||
/**
|
||||
* get current mouse position
|
||||
* @return mouse position as x,y pair
|
||||
*/
|
||||
std::pair<int, int> getMousePosition();
|
||||
|
||||
/**
|
||||
* get key code of last key press.
|
||||
* @return KeyCode of last key press.
|
||||
*/
|
||||
KeyCode getLastPressedKey();
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue