-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInOutSet.cpp
134 lines (99 loc) · 3.24 KB
/
InOutSet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include "InOutSet.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QChar>
#include <QKeyEvent>
#include <QDebug>
#include <QLabel>
#include "computer.h"
#include <QUndoCommand>
InOutSet::InOutSet(QWidget *parent) : QWidget(parent)
{
qDebug("Initializing InOutSet");
QVBoxLayout* bigVLayout = new QVBoxLayout(this);
QLabel* testingLabel = new QLabel("I/O");
QHBoxLayout* hLayout = new QHBoxLayout();
QVBoxLayout* vLayout = new QVBoxLayout();
InputMonitor = new QLabel("");
InputMonitor->setText("I");
OutputMonitor = new QLabel();
OutputMonitor->setText("O");
// connect(OutputMonitor,SIGNAL(released()),this,SLOT(kick()));
connect(Computer::getDefault(),SIGNAL(pushDisplay(val_t)),this,SLOT(pushChar(val_t)));
connect(Computer::getDefault(),SIGNAL(popDisplay()),this,SLOT(popChar()));
// CONNECT(Take,QPushButton::pressed(),this,update());
textDisplay = new QLabel(this);
textDisplay->setStyleSheet("QLabel { background-color : rgb(225,225,225); color : white; }");
textDisplay->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
textDisplay->setWordWrap(true);
textDisplay->setAlignment(Qt::AlignTop|Qt::AlignLeft);
textDisplay->setFocusPolicy(Qt::StrongFocus);
// textDisplay->setStyleSheet(":focus{background-color:rgb(255,225,255)},background-color:rgb(150,150,150)");
// textDisplay->setStyleSheet("background-color:rgb(150,150,150)");
setLayout(bigVLayout);
bigVLayout->addWidget(testingLabel);
hLayout->addWidget(textDisplay);
hLayout->addLayout(vLayout);
// vLayout->addWidget(InputMonitor);
// vLayout->addWidget(OutputMonitor);
bigVLayout->addLayout(hLayout);
textDisplay->setText("");
}
//void InOutSet::setupInOutInput()
void InOutSet::keyPressEvent(QKeyEvent *event)
{
qDebug("key pressed processing begin");
event->accept();
qDebug(QString().setNum(event->key()).toLocal8Bit());
char temp = '\0';
char* input = &temp;
switch(event->key())
{
#ifndef QT_NO_DEBUG_OUTPUT
case 0x01000037:/*F8, for easy intake*/
update();
return;
#endif
case 0x01000004://return
case 0x01000005:{qDebug("Enter");*input = ('\n');break;}
default:
{
if(event->key()<128)
{
qDebug("Normal");
*input = event->key();
}
}
}
if(input != nullptr) Computer::getDefault()->setKeyboardCharacter(*input,true);
qDebug("done with key");
}
void InOutSet::clearText()
{
textDisplay->setText("");
}
void InOutSet::update()
{
}
void InOutSet::popChar()
{
QString text = textDisplay->text();
if(text.length()>=1)
{
text.chop(1);
}
textDisplay->setText(text);
}
void InOutSet::pushChar(val_t val)
{
// Computer::getDefault()->setMemValue(DSR,0x0000);
qDebug("pushChar requested");
qDebug(QString().setNum(val).toLocal8Bit());
textDisplay->setText(textDisplay->text()+(char)val);
// Computer::getDefault()->setMemValue(DSR,Computer::getDefault()->getMemValue(DSR)&0x8000);
}
void InOutSet::kick()
{
qDebug("Kicked");
// Computer::getDefault()->setMemValue(DDR,Computer::getDefault()->getMemValue(KBDR));
}