initial commit

This commit is contained in:
2014-09-05 14:12:37 +02:00
commit 990a6ad03d
29 changed files with 5477 additions and 0 deletions

106
hardwaresetup.cpp Normal file
View File

@@ -0,0 +1,106 @@
#include "hardwaresetup.h"
#include <unistd.h>
#include "sys/io.h"
#include <iostream>
#define BASEPORT 0xe050 /* lp1 */
HardwareSetup::HardwareSetup()
{
if (ioperm(BASEPORT, 3, 1)) {
//perror("ioperm");
}
shellBefore = false;
deaBefore = false;
}
HardwareSetup::~HardwareSetup(){
if (ioperm(BASEPORT, 3, 0)) {
//perror("ioperm");
}
}
void HardwareSetup::run(){
while(1){
usleep(10000);
if(getDea()){
if(!deaBefore){
deaBefore = true;
emit Dea();
}
}
else{
deaBefore = false;
}
if(getShell()){
if(!shellBefore){
shellBefore = true;
emit Shell();
}
}
else{
shellBefore = false;
}
}
}
bool HardwareSetup::getShell(){
int zahl[8] = {0};
if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){
return true;
}
return false;
}
bool HardwareSetup::getDea(){
int zahl[8] = {0};
if(findBit(zahl, inb(BASEPORT + 1))[6] == 0 ){
return true;
}
return false;
}
int* HardwareSetup::findBit(int *array, int zahl){
if(zahl >=128){
array[7] = 1;
zahl -= 128;
}
if(zahl >=64){
array[6] = 1;
zahl -= 64;
}
if(zahl >=32){
array[5] = 1;
zahl -= 32;
}
if(zahl >=16){
array[4] = 1;
zahl -= 16;
}
if(zahl >=8){
array[3] = 1;
zahl -= 8;
}
if(zahl >=4){
array[2] = 1;
zahl -= 4;
}
if(zahl >=2){
array[1] = 1;
zahl -= 2;
}
if(zahl >=1){
array[0] = 1;
zahl -= 1;
}
return array;
}