mirror of
https://github.com/Treeki/WindEmu.git
synced 2025-07-04 13:32:45 +00:00
implement touch panel for Osaris
This commit is contained in:
@ -25,10 +25,12 @@ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
mainwindow.cpp \
|
||||
pdascreenwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
mainwindow.h \
|
||||
pdascreenwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
@ -12,7 +12,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
QString romFile;
|
||||
if (args.length() > 1)
|
||||
romFile = args.first();
|
||||
romFile = args.last();
|
||||
else
|
||||
romFile = QFileDialog::getOpenFileName(nullptr, "Select a ROM");
|
||||
if (romFile.isNull()) return 0;
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QTimer>
|
||||
#include <QKeyEvent>
|
||||
#include "../WindCore/decoder.h"
|
||||
#include "clps7111.h"
|
||||
|
||||
MainWindow::MainWindow(EmuBase *emu, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
pdaScreen(emu),
|
||||
emu(emu)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -20,6 +21,8 @@ MainWindow::MainWindow(EmuBase *emu, QWidget *parent) :
|
||||
timer->setInterval(1000/64);
|
||||
connect(timer, SIGNAL(timeout()), SLOT(execTimer()));
|
||||
|
||||
pdaScreen.show();
|
||||
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
@ -100,67 +103,10 @@ void MainWindow::updateScreen()
|
||||
ui->codeLabel->setText(codeLines.join('\n'));
|
||||
|
||||
// now, the actual screen
|
||||
uint8_t *lines[1024];
|
||||
QImage img(emu->getLCDWidth(), emu->getLCDHeight(), QImage::Format_Grayscale8);
|
||||
for (int y = 0; y < img.height(); y++)
|
||||
lines[y] = img.scanLine(y);
|
||||
emu->readLCDIntoBuffer(lines);
|
||||
|
||||
ui->screen->setPixmap(QPixmap::fromImage(std::move(img)));
|
||||
pdaScreen.updateScreen();
|
||||
}
|
||||
|
||||
|
||||
static EpocKey resolveKey(int key) {
|
||||
switch (key) {
|
||||
case Qt::Key_Apostrophe: return EStdKeySingleQuote;
|
||||
case Qt::Key_Backspace: return EStdKeyBackspace;
|
||||
case Qt::Key_Escape: return EStdKeyEscape;
|
||||
case Qt::Key_Enter: return EStdKeyEnter;
|
||||
case Qt::Key_Return: return EStdKeyEnter;
|
||||
case Qt::Key_Alt: return EStdKeyMenu;
|
||||
case Qt::Key_Tab: return EStdKeyTab;
|
||||
#ifdef Q_OS_MAC
|
||||
case Qt::Key_Meta: return EStdKeyLeftCtrl;
|
||||
#else
|
||||
case Qt::Key_Control: return EStdKeyLeftCtrl;
|
||||
#endif
|
||||
case Qt::Key_Down: return EStdKeyDownArrow;
|
||||
case Qt::Key_Period: return EStdKeyFullStop;
|
||||
#ifdef Q_OS_MAC
|
||||
case Qt::Key_Control: return EStdKeyLeftFunc;
|
||||
#else
|
||||
case Qt::Key_Meta: return EStdKeyLeftFunc;
|
||||
#endif
|
||||
case Qt::Key_Shift: return EStdKeyLeftShift;
|
||||
case Qt::Key_Right: return EStdKeyRightArrow;
|
||||
case Qt::Key_Left: return EStdKeyLeftArrow;
|
||||
case Qt::Key_Comma: return EStdKeyComma;
|
||||
case Qt::Key_Up: return EStdKeyUpArrow;
|
||||
case Qt::Key_Space: return EStdKeySpace;
|
||||
}
|
||||
|
||||
if (key >= '0' && key <= '9') return (EpocKey)key;
|
||||
if (key >= 'A' && key <= 'Z') return (EpocKey)key;
|
||||
return EStdKeyNull;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
EpocKey k = resolveKey(event->key());
|
||||
if (k != EStdKeyNull)
|
||||
emu->setKeyboardKey(k, true);
|
||||
}
|
||||
|
||||
void MainWindow::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
EpocKey k = resolveKey(event->key());
|
||||
if (k != EStdKeyNull)
|
||||
emu->setKeyboardKey(k, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::on_startButton_clicked()
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "../WindCore/emubase.h"
|
||||
#include "pdascreenwindow.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -44,16 +45,13 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
PDAScreenWindow pdaScreen;
|
||||
EmuBase *emu;
|
||||
QTimer *timer;
|
||||
void updateScreen();
|
||||
void updateBreakpointsList();
|
||||
void updateMemory();
|
||||
void adjustMemoryAddress(int offset);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyReleaseEvent(QKeyEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -25,7 +25,7 @@
|
||||
<item row="4" column="0" colspan="5">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
|
107
WindQt/pdascreenwindow.cpp
Normal file
107
WindQt/pdascreenwindow.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
#include "pdascreenwindow.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
PDAScreenWindow::PDAScreenWindow(EmuBase *emu, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
emu(emu),
|
||||
lcd(new QLabel(this))
|
||||
{
|
||||
setWindowTitle("WindEmu");
|
||||
setFixedSize(emu->getDigitiserWidth(), emu->getDigitiserHeight());
|
||||
lcd->setGeometry(emu->getLCDOffsetX(), emu->getLCDOffsetY(), emu->getLCDWidth(), emu->getLCDHeight());
|
||||
|
||||
const char *who = emu->getDeviceName();
|
||||
if (strcmp(who, "Osaris") == 0) {
|
||||
// some cheap and cheerful placeholders
|
||||
int bitW = (emu->getDigitiserWidth() - emu->getLCDWidth()) / 2;
|
||||
int bitH = emu->getDigitiserHeight() / 5;
|
||||
int leftX = 0;
|
||||
int rightX = bitW + emu->getLCDWidth();
|
||||
(new QLabel("Word", this))->setGeometry(leftX, bitH * 0, bitW, bitH);
|
||||
(new QLabel("Sheet", this))->setGeometry(leftX, bitH * 1, bitW, bitH);
|
||||
(new QLabel("Data", this))->setGeometry(leftX, bitH * 2, bitW, bitH);
|
||||
(new QLabel("Agenda", this))->setGeometry(leftX, bitH * 3, bitW, bitH);
|
||||
(new QLabel("Extras", this))->setGeometry(leftX, bitH * 4, bitW, bitH);
|
||||
(new QLabel("EPOC", this))->setGeometry(rightX, bitH * 0, bitW, bitH);
|
||||
(new QLabel("Menu", this))->setGeometry(rightX, bitH * 1, bitW, bitH);
|
||||
(new QLabel("Copy/Paste", this))->setGeometry(rightX, bitH * 2, bitW, bitH);
|
||||
(new QLabel("Zoom In", this))->setGeometry(rightX, bitH * 3, bitW, bitH);
|
||||
(new QLabel("Zoom Out", this))->setGeometry(rightX, bitH * 4, bitW, bitH);
|
||||
}
|
||||
}
|
||||
|
||||
void PDAScreenWindow::updateScreen() {
|
||||
uint8_t *lines[1024];
|
||||
QImage img(emu->getLCDWidth(), emu->getLCDHeight(), QImage::Format_Grayscale8);
|
||||
for (int y = 0; y < img.height(); y++)
|
||||
lines[y] = img.scanLine(y);
|
||||
emu->readLCDIntoBuffer(lines);
|
||||
|
||||
lcd->setPixmap(QPixmap::fromImage(std::move(img)));
|
||||
}
|
||||
|
||||
static EpocKey resolveKey(int key) {
|
||||
switch (key) {
|
||||
case Qt::Key_Apostrophe: return EStdKeySingleQuote;
|
||||
case Qt::Key_Backspace: return EStdKeyBackspace;
|
||||
case Qt::Key_Escape: return EStdKeyEscape;
|
||||
case Qt::Key_Enter: return EStdKeyEnter;
|
||||
case Qt::Key_Return: return EStdKeyEnter;
|
||||
case Qt::Key_Alt: return EStdKeyMenu;
|
||||
case Qt::Key_Tab: return EStdKeyTab;
|
||||
#ifdef Q_OS_MAC
|
||||
case Qt::Key_Meta: return EStdKeyLeftCtrl;
|
||||
#else
|
||||
case Qt::Key_Control: return EStdKeyLeftCtrl;
|
||||
#endif
|
||||
case Qt::Key_Down: return EStdKeyDownArrow;
|
||||
case Qt::Key_Period: return EStdKeyFullStop;
|
||||
#ifdef Q_OS_MAC
|
||||
case Qt::Key_Control: return EStdKeyLeftFunc;
|
||||
#else
|
||||
case Qt::Key_Meta: return EStdKeyLeftFunc;
|
||||
#endif
|
||||
case Qt::Key_Shift: return EStdKeyLeftShift;
|
||||
case Qt::Key_Right: return EStdKeyRightArrow;
|
||||
case Qt::Key_Left: return EStdKeyLeftArrow;
|
||||
case Qt::Key_Comma: return EStdKeyComma;
|
||||
case Qt::Key_Up: return EStdKeyUpArrow;
|
||||
case Qt::Key_Space: return EStdKeySpace;
|
||||
}
|
||||
|
||||
if (key >= '0' && key <= '9') return (EpocKey)key;
|
||||
if (key >= 'A' && key <= 'Z') return (EpocKey)key;
|
||||
return EStdKeyNull;
|
||||
}
|
||||
|
||||
|
||||
void PDAScreenWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
EpocKey k = resolveKey(event->key());
|
||||
if (k != EStdKeyNull)
|
||||
emu->setKeyboardKey(k, true);
|
||||
}
|
||||
|
||||
void PDAScreenWindow::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
EpocKey k = resolveKey(event->key());
|
||||
if (k != EStdKeyNull)
|
||||
emu->setKeyboardKey(k, false);
|
||||
}
|
||||
|
||||
|
||||
void PDAScreenWindow::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
emu->updateTouchInput(event->x(), event->y(), true);
|
||||
}
|
||||
|
||||
void PDAScreenWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
emu->updateTouchInput(event->x(), event->y(), false);
|
||||
}
|
||||
|
||||
void PDAScreenWindow::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
emu->updateTouchInput(event->x(), event->y(), true);
|
||||
}
|
29
WindQt/pdascreenwindow.h
Normal file
29
WindQt/pdascreenwindow.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef PDASCREENWINDOW_H
|
||||
#define PDASCREENWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include "emubase.h"
|
||||
|
||||
class PDAScreenWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
EmuBase *emu;
|
||||
QLabel *lcd;
|
||||
|
||||
public:
|
||||
explicit PDAScreenWindow(EmuBase *emu, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void updateScreen();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyReleaseEvent(QKeyEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // PDASCREENWINDOW_H
|
Reference in New Issue
Block a user