Add Wacom SD-510C tablet emulation
This commit is contained in:
@@ -42,6 +42,7 @@ extern "C" {
|
||||
#include <86box/discord.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/vid_ega.h>
|
||||
#include <86box/version.h>
|
||||
@@ -188,6 +189,12 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
vmname.truncate(vmname.size() - 1);
|
||||
this->setWindowTitle(QString("%1 - %2 %3").arg(vmname, EMU_NAME, EMU_VERSION_FULL));
|
||||
|
||||
connect(this, &MainWindow::hardResetCompleted, this, [this]() {
|
||||
ui->actionMCA_devices->setVisible(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
ui->menuTablet_tool->menuAction()->setVisible(mouse_mode >= 1);
|
||||
});
|
||||
|
||||
connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection);
|
||||
|
||||
connect(this, &MainWindow::setTitle, this, [this, toolbar_label](const QString &title) {
|
||||
@@ -622,6 +629,16 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
actGroup = new QActionGroup(this);
|
||||
actGroup->addAction(ui->actionCursor_Puck);
|
||||
actGroup->addAction(ui->actionPen);
|
||||
|
||||
if (tablet_tool_type == 1) {
|
||||
ui->actionPen->setChecked(true);
|
||||
} else {
|
||||
ui->actionCursor_Puck->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1671,7 +1688,6 @@ MainWindow::refreshMediaMenu()
|
||||
{
|
||||
mm->refresh(ui->menuMedia);
|
||||
status->refresh(ui->statusbar);
|
||||
ui->actionMCA_devices->setVisible(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2411,3 +2427,16 @@ MainWindow::on_actionApply_fullscreen_stretch_mode_when_maximized_triggered(bool
|
||||
device_force_redraw();
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCursor_Puck_triggered()
|
||||
{
|
||||
tablet_tool_type = 0;
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPen_triggered()
|
||||
{
|
||||
tablet_tool_type = 1;
|
||||
config_save();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ signals:
|
||||
void destroyRendererMonitor(int monitor_index);
|
||||
void initRendererMonitorForNonQtThread(int monitor_index);
|
||||
void destroyRendererMonitorForNonQtThread(int monitor_index);
|
||||
void hardResetCompleted();
|
||||
|
||||
void setTitle(const QString &title);
|
||||
void setFullscreen(bool state);
|
||||
@@ -134,6 +135,12 @@ protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_actionPen_triggered();
|
||||
|
||||
private slots:
|
||||
void on_actionCursor_Puck_triggered();
|
||||
|
||||
private slots:
|
||||
void on_actionShow_non_primary_monitors_triggered();
|
||||
|
||||
|
||||
@@ -61,8 +61,16 @@
|
||||
<property name="title">
|
||||
<string>&Action</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuTablet_tool">
|
||||
<property name="title">
|
||||
<string>Tablet tool</string>
|
||||
</property>
|
||||
<addaction name="actionPen"/>
|
||||
<addaction name="actionCursor_Puck"/>
|
||||
</widget>
|
||||
<addaction name="actionKeyboard_requires_capture"/>
|
||||
<addaction name="actionRight_CTRL_is_left_ALT"/>
|
||||
<addaction name="menuTablet_tool"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionHard_Reset"/>
|
||||
<addaction name="actionCtrl_Alt_Del"/>
|
||||
@@ -851,6 +859,22 @@
|
||||
<string>Apply fullscreen stretch mode when maximized</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCursor_Puck">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cursor/Puck</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPen">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pen</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -58,8 +58,10 @@ double mouse_x_error = 0.0, mouse_y_error = 0.0;
|
||||
}
|
||||
|
||||
struct mouseinputdata {
|
||||
atomic_int deltax, deltay, deltaz;
|
||||
atomic_int mousebuttons;
|
||||
atomic_int deltax, deltay, deltaz;
|
||||
atomic_int mousebuttons;
|
||||
atomic_bool mouse_tablet_in_proximity;
|
||||
std::atomic<double> x_abs, y_abs;
|
||||
};
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
@@ -116,6 +118,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
|
||||
RendererStack::~RendererStack()
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -142,9 +145,12 @@ void
|
||||
RendererStack::mousePoll()
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
mouse_tablet_in_proximity = mousedata.mouse_tablet_in_proximity;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
|
||||
@@ -166,7 +172,7 @@ int ignoreNextMouseEvent = 1;
|
||||
void
|
||||
RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture && (isMouseDown & 1) && (mouse_get_buttons() != 0)) {
|
||||
if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture && (isMouseDown & 1) && (mouse_get_buttons() != 0) && mouse_mode == 0) {
|
||||
plat_mouse_capture(1);
|
||||
this->setCursor(Qt::BlankCursor);
|
||||
if (!ignoreNextMouseEvent)
|
||||
@@ -180,7 +186,7 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
isMouseDown &= ~1;
|
||||
return;
|
||||
}
|
||||
if (mouse_capture) {
|
||||
if (mouse_capture || mouse_mode >= 1) {
|
||||
mousedata.mousebuttons &= ~event->button();
|
||||
}
|
||||
isMouseDown &= ~1;
|
||||
@@ -190,7 +196,7 @@ void
|
||||
RendererStack::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
isMouseDown |= 1;
|
||||
if (mouse_capture) {
|
||||
if (mouse_capture || mouse_mode >= 1) {
|
||||
mousedata.mousebuttons |= event->button();
|
||||
}
|
||||
event->accept();
|
||||
@@ -238,9 +244,26 @@ RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
RendererStack::enterEvent(QEnterEvent *event)
|
||||
#else
|
||||
RendererStack::enterEvent(QEvent *event)
|
||||
#endif
|
||||
{
|
||||
mousedata.mouse_tablet_in_proximity = 1;
|
||||
|
||||
if (mouse_mode == 1)
|
||||
QApplication::setOverrideCursor(Qt::BlankCursor);
|
||||
}
|
||||
|
||||
void
|
||||
RendererStack::leaveEvent(QEvent *event)
|
||||
{
|
||||
mousedata.mouse_tablet_in_proximity = 0;
|
||||
if (mouse_mode == 1)
|
||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
if (QApplication::platformName().contains("wayland")) {
|
||||
event->accept();
|
||||
return;
|
||||
@@ -501,3 +524,16 @@ RendererStack::changeEvent(QEvent *event)
|
||||
config_save();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
RendererStack::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
QMouseEvent* mouse_event = (QMouseEvent*)event;
|
||||
if (mouse_mode >= 1) {
|
||||
mousedata.x_abs = (mouse_event->localPos().x()) / (long double)width();
|
||||
mousedata.y_abs = (mouse_event->localPos().y()) / (long double)height();
|
||||
}
|
||||
}
|
||||
return QStackedWidget::event(event);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QStackedWidget>
|
||||
#include <QWidget>
|
||||
#include <QCursor>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
@@ -30,6 +31,11 @@ public:
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void enterEvent(QEnterEvent *event) override;
|
||||
#else
|
||||
void enterEvent(QEvent *event) override;
|
||||
#endif
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
@@ -45,6 +51,7 @@ public:
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
bool event(QEvent* event) override;
|
||||
|
||||
enum class Renderer {
|
||||
Software,
|
||||
|
||||
@@ -74,6 +74,12 @@ ui_window_title(wchar_t *str)
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
ui_hard_reset_completed()
|
||||
{
|
||||
emit main_window->hardResetCompleted();
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
qt_blit(int x, int y, int w, int h, int monitor_index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user