diff --git a/.ci/AppImageBuilder.yml b/.ci/AppImageBuilder.yml index 1fdff69ad..317be2317 100644 --- a/.ci/AppImageBuilder.yml +++ b/.ci/AppImageBuilder.yml @@ -34,7 +34,6 @@ AppDir: - sourceline: 'deb http://deb.debian.org/debian bullseye-updates main' key_url: 'https://ftp-master.debian.org/keys/archive-key-11-security.asc' include: - - libdrm2 - libevdev2 - libfluidsynth2 - libfreetype6 @@ -48,18 +47,12 @@ AppDir: - libqt5core5a - libqt5gui5 - libqt5widgets5 - - librtmidi5 - - libsdl2-2.0-0 - libslirp0 - libsndio7.0 - libwayland-client0 - libx11-6 - - libx11-xcb1 - - libxcb-render0 - - libxcb-shape0 - - libxcb-shm0 - - libxcb-xfixes0 - libxcb1 + - zlib1g files: exclude: - etc @@ -67,6 +60,7 @@ AppDir: - opt/libc/usr/share - usr/bin - usr/include + - usr/lib/*/libasound.so.* - usr/lib/cmake - usr/lib/pkgconfig - usr/sbin @@ -91,6 +85,7 @@ AppDir: - usr/share/pkgconfig - usr/share/poppler - usr/share/readline + - usr/share/rtmidi - usr/share/sounds - usr/share/X11 - usr/share/xml diff --git a/.ci/build.sh b/.ci/build.sh index 53c25a0b2..5cd5f3baa 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -427,6 +427,8 @@ then # TBD : else + cwd_root=$(pwd) + # Build openal-soft 1.21.1 manually to fix audio issues. This is a temporary # workaround until a newer version of openal-soft trickles down to Debian repos. if [ -d "openal-soft-1.21.1" ] @@ -435,11 +437,44 @@ else else wget -qO - https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.tar.gz | tar zxf - fi - cwd_root=$(pwd) cd openal-soft-1.21.1/build + [ -e Makefile ] && make clean cmake -G "Unix Makefiles" -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" .. - make -j$(nproc) install - cd ../.. + make -j$(nproc) install || exit 99 + cd "$cwd_root" + + # Build rtmidi without JACK support to remove the dependency on libjack. + if [ -d "rtmidi-4.0.0" ] + then + rm -rf rtmidi-4.0.0/CMakeCache.txt rtmidi-4.0.0/CMakeFiles + else + wget -qO - http://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-4.0.0.tar.gz | tar zxf - + fi + cwd_root=$(pwd) + cd rtmidi-4.0.0 + [ -e Makefile ] && make clean + cmake -G "Unix Makefiles" -D RTMIDI_API_JACK=OFF -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" . + make -j$(nproc) install || exit 99 + cd "$cwd_root" + + # Build SDL2 for joystick support with most components disabled to remove the dependencies on PulseAudio and libdrm. + if [ ! -d "SDL2-2.0.20" ] + then + wget -qO - https://www.libsdl.org/release/SDL2-2.0.20.tar.gz | tar zxf - + fi + rm -rf sdlbuild + mkdir sdlbuild + cd sdlbuild + cmake -G "Unix Makefiles" -D SDL_DISKAUDIO=OFF -D SDL_DIRECTFB_SHARED=OFF -D SDL_OPENGL=OFF -D SDL_OPENGLES=OFF -D SDL_OSS=OFF -D SDL_ALSA=OFF \ + -D SDL_ALSA_SHARED=OFF -D SDL_JACK=OFF -D SDL_JACK_SHARED=OFF -D SDL_ESD=OFF -D SDL_ESD_SHARED=OFF -D SDL_PIPEWIRE=OFF -D SDL_PIPEWIRE_SHARED=OFF \ + -D SDL_PULSEAUDIO=OFF -D SDL_PULSEAUDIO_SHARED=OFF -D SDL_ARTS=OFF -D SDL_ARTS_SHARED=OFF -D SDL_NAS=OFF -D SDL_NAS_SHARED=OFF -D SDL_SNDIO=OFF \ + -D SDL_SNDIO_SHARED=OFF -D SDL_FUSIONSOUND=OFF -D SDL_FUSIONSOUND_SHARED=OFF -D SDL_LIBSAMPLERATE=OFF -D SDL_LIBSAMPLERATE_SHARED=OFF -D SDL_X11=OFF \ + -D SDL_X11_SHARED=OFF -D SDL_WAYLAND=OFF -D SDL_WAYLAND_SHARED=OFF -D SDL_WAYLAND_LIBDECOR=OFF -D SDL_WAYLAND_LIBDECOR_SHARED=OFF \ + -D SDL_WAYLAND_QT_TOUCH=OFF -D SDL_RPI=OFF -D SDL_VIVANTE=OFF -D SDL_VULKAN=OFF -D SDL_KMSDRM=OFF -D SDL_KMSDRM_SHARED=OFF -D SDL_OFFSCREEN=OFF \ + -D SDL_HIDAPI_JOYSTICK=ON -D SDL_VIRTUAL_JOYSTICK=ON -D SDL_SHARED=ON -D SDL_STATIC=OFF -S "$cwd_root/SDL2-2.0.20" \ + -D "CMAKE_TOOLCHAIN_FILE=$cwd_root/toolchain.cmake" -D "CMAKE_INSTALL_PREFIX=$cwd_root/archive_tmp/usr" + make -j$(nproc) install || exit 99 + cd "$cwd_root" # Archive Discord Game SDK library. 7z e -y -o"archive_tmp/usr/lib" discord_game_sdk.zip "lib/$arch_discord/discord_game_sdk.so" diff --git a/src/include/86box/version.h.in b/src/include/86box/version.h.in index 170154423..18ff9a00e 100644 --- a/src/include/86box/version.h.in +++ b/src/include/86box/version.h.in @@ -46,10 +46,13 @@ #define COPYRIGHT_YEAR "@EMU_COPYRIGHT_YEAR@" /* Web URL info. */ -#define EMU_SITE L"86box.net" -#define EMU_ROMS_URL L"https://github.com/86Box/roms/releases/latest" +#define EMU_SITE "86box.net" +#define EMU_SITE_W LSTR(EMU_SITE) +#define EMU_ROMS_URL "https://github.com/86Box/roms/releases/latest" +#define EMU_ROMS_URL_W LSTR(EMU_ROMS_URL) #ifdef RELEASE_BUILD -# define EMU_DOCS_URL L"https://86box.readthedocs.io/en/v@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@/" +# define EMU_DOCS_URL "https://86box.readthedocs.io/en/v@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@/" #else -# define EMU_DOCS_URL L"https://86box.readthedocs.io" +# define EMU_DOCS_URL "https://86box.readthedocs.io" #endif +#define EMU_DOCS_URL_W LSTR(EMU_DOCS_URL) diff --git a/src/include_make/86box/version.h b/src/include_make/86box/version.h index efafaa6a3..d2a0b2791 100644 --- a/src/include_make/86box/version.h +++ b/src/include_make/86box/version.h @@ -35,10 +35,13 @@ #define COPYRIGHT_YEAR "2022" /* Web URL info. */ -#define EMU_SITE L"86box.net" -#define EMU_ROMS_URL L"https://github.com/86Box/roms/releases/latest" +#define EMU_SITE "86box.net" +#define EMU_SITE_W LSTR(EMU_SITE) +#define EMU_ROMS_URL "https://github.com/86Box/roms/releases/latest" +#define EMU_ROMS_URL_W LSTR(EMU_ROMS_URL) #ifdef RELEASE_BUILD -# define EMU_DOCS_URL L"https://86box.readthedocs.io/en/v3.0/" +# define EMU_DOCS_URL "https://86box.readthedocs.io/en/v3.2/" #else -# define EMU_DOCS_URL L"https://86box.readthedocs.io" +# define EMU_DOCS_URL "https://86box.readthedocs.io" #endif +#define EMU_DOCS_URL_W LSTR(EMU_DOCS_URL) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index a69464a1e..d48f17115 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -254,7 +254,8 @@ endif() if (UNIX AND NOT APPLE) find_package(X11 REQUIRED) - target_link_libraries(ui PRIVATE X11::X11) + target_link_libraries(ui PRIVATE X11::X11 X11::Xi) + target_sources(ui PRIVATE xinput2_mouse.cpp) find_package(PkgConfig REQUIRED) pkg_check_modules(LIBEVDEV IMPORTED_TARGET libevdev) if (LIBEVDEV_FOUND) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index d9d667c9e..cae6c6e5c 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -66,6 +66,7 @@ extern "C" #include "cocoa_mouse.hpp" #include "qt_styleoverride.hpp" + // Void Cast #define VC(x) const_cast(x) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 80a3792c3..6d7fb6592 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -168,7 +168,6 @@ MainWindow::MainWindow(QWidget *parent) : mouse_capture = state ? 1 : 0; qt_mouse_capture(mouse_capture); if (mouse_capture) { - ui->stackedWidget->grabMouse(); this->grabKeyboard(); #ifdef WAYLAND if (QGuiApplication::platformName().contains("wayland")) { @@ -176,7 +175,6 @@ MainWindow::MainWindow(QWidget *parent) : } #endif } else { - ui->stackedWidget->releaseMouse(); this->releaseKeyboard(); #ifdef WAYLAND if (QGuiApplication::platformName().contains("wayland")) { @@ -810,7 +808,6 @@ std::array x11_to_xt_vnc 0, 0, 0, - 0, 0x1D, 0x11D, 0x2A, @@ -1436,10 +1433,10 @@ void MainWindow::on_actionAbout_86Box_triggered() msgBox.setInformativeText(tr("An emulator of old computers\n\nAuthors: Sarah Walker, Miran Grca, Fred N. van Kempen (waltje), SA1988, Tiseno100, reenigne, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2 or later. See LICENSE for more information.")); msgBox.setWindowTitle("About 86Box"); msgBox.addButton("OK", QMessageBox::ButtonRole::AcceptRole); - auto webSiteButton = msgBox.addButton("86box.net", QMessageBox::ButtonRole::HelpRole); + auto webSiteButton = msgBox.addButton(EMU_SITE, QMessageBox::ButtonRole::HelpRole); webSiteButton->connect(webSiteButton, &QPushButton::released, []() { - QDesktopServices::openUrl(QUrl("https://86box.net/")); + QDesktopServices::openUrl(QUrl("https://" EMU_SITE)); }); #ifdef RELEASE_BUILD msgBox.setIconPixmap(QIcon(":/settings/win/icons/86Box-green.ico").pixmap(32, 32)); @@ -1456,7 +1453,7 @@ void MainWindow::on_actionAbout_86Box_triggered() void MainWindow::on_actionDocumentation_triggered() { - QDesktopServices::openUrl(QUrl("https://86box.readthedocs.io")); + QDesktopServices::openUrl(QUrl(EMU_DOCS_URL)); } void MainWindow::on_actionCGA_PCjr_Tandy_EGA_S_VGA_overscan_triggered() { diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 2d74af987..3d5a6a02a 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -131,6 +131,7 @@ private: friend class SpecifyDimensions; friend class ProgSettings; + friend class RendererCommon; }; #endif // QT_MAINWINDOW_HPP diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 6a35279c2..98bb6ae2d 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -668,6 +668,9 @@ ACPI Shutdown + + false + diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 16987099f..541bb4cf6 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -49,15 +49,21 @@ RendererStack::RendererStack(QWidget *parent) : { ui->setupUi(this); +#ifdef __unix__ #ifdef WAYLAND if (QApplication::platformName().contains("wayland")) { wl_init(); } #endif #ifdef EVDEV_INPUT - if (QApplication::platformName() == "xcb" || QApplication::platformName() == "eglfs") { + if (QApplication::platformName() == "eglfs") { evdev_init(); } +#endif + if (QApplication::platformName() == "xcb") { + extern void xinput2_init(); + xinput2_init(); + } #endif } @@ -91,20 +97,31 @@ void RendererStack::mousePoll() { #ifdef __APPLE__ return macos_poll_mouse(); -#else +#else /* !defined __APPLE__ */ mouse_x = mousedata.deltax; mouse_y = mousedata.deltay; mouse_z = mousedata.deltaz; mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0; mouse_buttons = mousedata.mousebuttons; + +#ifdef __unix__ #ifdef WAYLAND if (QApplication::platformName().contains("wayland")) wl_mouse_poll(); #endif + #ifdef EVDEV_INPUT - evdev_mouse_poll(); -#endif + if (QApplication::platformName() == "eglfs") evdev_mouse_poll(); + else #endif + if (QApplication::platformName() == "xcb") + { + extern void xinput2_poll(); + xinput2_poll(); + } +#endif /* defined __unix__ */ +#endif /* !defined __APPLE__ */ + } int ignoreNextMouseEvent = 1; @@ -169,8 +186,8 @@ void RendererStack::mouseMoveEvent(QMouseEvent *event) leaveEvent((QEvent*)event); ignoreNextMouseEvent--; } - else if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event); - else if (event->globalPos().x() == (util::screenOfWidget(this)->geometry().width() - 1) || event->globalPos().y() == (util::screenOfWidget(this)->geometry().height() - 1)) leaveEvent((QEvent*)event); + QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2))); + ignoreNextMouseEvent = 2; oldPos = event->pos(); #endif } @@ -183,7 +200,6 @@ void RendererStack::leaveEvent(QEvent* event) return; } if (!mouse_capture) return; - QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2))); ignoreNextMouseEvent = 2; event->accept(); } diff --git a/src/qt/qt_settingsdisplay.ui b/src/qt/qt_settingsdisplay.ui index 58a2e6aef..2ed153a21 100644 --- a/src/qt/qt_settingsdisplay.ui +++ b/src/qt/qt_settingsdisplay.ui @@ -38,6 +38,12 @@ + + + 0 + 0 + + Configure diff --git a/src/qt/qt_settingsfloppycdrom.ui b/src/qt/qt_settingsfloppycdrom.ui index dfe8283ab..8f7ffa995 100644 --- a/src/qt/qt_settingsfloppycdrom.ui +++ b/src/qt/qt_settingsfloppycdrom.ui @@ -41,6 +41,9 @@ QAbstractItemView::SelectRows + + false + false @@ -102,6 +105,9 @@ QAbstractItemView::SelectRows + + false + false diff --git a/src/qt/qt_settingsharddisks.ui b/src/qt/qt_settingsharddisks.ui index b670dd512..fa913beea 100644 --- a/src/qt/qt_settingsharddisks.ui +++ b/src/qt/qt_settingsharddisks.ui @@ -34,6 +34,9 @@ QAbstractItemView::SelectRows + + false + false diff --git a/src/qt/qt_settingsinput.ui b/src/qt/qt_settingsinput.ui index 7332ad907..8f4f46167 100644 --- a/src/qt/qt_settingsinput.ui +++ b/src/qt/qt_settingsinput.ui @@ -13,7 +13,7 @@ Form - + 0 @@ -23,102 +23,49 @@ 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Mouse: - - - - - - - - - - Configure - - - - - - - Joystick: - - - - - - - + + + + Joystick 2... + - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Joystick 1... - - - - - - - Joystick 2... - - - - - - - Joystick 3... - - - - - - - Joystick 4... - - - - + + + + Joystick: + - + + + + Joystick 4... + + + + + + + Mouse: + + + + + + + Joystick 3... + + + + Qt::Vertical + + QSizePolicy::Expanding + 20 @@ -127,6 +74,39 @@ + + + + Joystick 1... + + + + + + + + 0 + 0 + + + + Configure + + + + + + + + 0 + 0 + + + + + + + diff --git a/src/qt/qt_settingsmachine.ui b/src/qt/qt_settingsmachine.ui index e61eca023..fabb52fe9 100644 --- a/src/qt/qt_settingsmachine.ui +++ b/src/qt/qt_settingsmachine.ui @@ -93,7 +93,14 @@ - + + + + 0 + 0 + + + @@ -111,7 +118,14 @@ 0 - + + + + 0 + 0 + + + @@ -119,12 +133,19 @@ Speed: - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + + + + 0 + 0 + + + @@ -179,19 +200,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -222,6 +230,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/qt/qt_settingsnetwork.ui b/src/qt/qt_settingsnetwork.ui index 0b99769a7..751e3854d 100644 --- a/src/qt/qt_settingsnetwork.ui +++ b/src/qt/qt_settingsnetwork.ui @@ -26,24 +26,7 @@ 0 - - - - PCap device: - - - - - - - Network adapter: - - - - - - - + Qt::Vertical @@ -56,8 +39,12 @@ - - + + + + PCap device: + + @@ -67,33 +54,42 @@ - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Configure - - - - + + + + 0 + 0 + + + + + + Network adapter: + + + + + + + Configure + + + + + + + + 0 + 0 + + + + + + + diff --git a/src/qt/qt_settingsotherperipherals.ui b/src/qt/qt_settingsotherperipherals.ui index 0a8d93efb..62a4b9308 100644 --- a/src/qt/qt_settingsotherperipherals.ui +++ b/src/qt/qt_settingsotherperipherals.ui @@ -36,7 +36,14 @@ - + + + + 0 + 0 + + + @@ -92,7 +99,14 @@ - + + + + 0 + 0 + + + diff --git a/src/qt/qt_settingsotherremovable.ui b/src/qt/qt_settingsotherremovable.ui index 81b76f10a..a82c296ae 100644 --- a/src/qt/qt_settingsotherremovable.ui +++ b/src/qt/qt_settingsotherremovable.ui @@ -41,6 +41,9 @@ QAbstractItemView::SelectRows + + false + false @@ -108,6 +111,9 @@ QAbstractItemView::SelectRows + + false + false diff --git a/src/qt/qt_settingssound.ui b/src/qt/qt_settingssound.ui index f8bad2c61..65f5d7fd6 100644 --- a/src/qt/qt_settingssound.ui +++ b/src/qt/qt_settingssound.ui @@ -62,7 +62,14 @@ - + + + + 0 + 0 + + + @@ -106,11 +113,15 @@ - - - - + + + + 0 + 0 + + + @@ -153,6 +164,16 @@ + + + + + 0 + 0 + + + + diff --git a/src/qt/qt_settingsstoragecontrollers.ui b/src/qt/qt_settingsstoragecontrollers.ui index 00f7c9619..c4c44b019 100644 --- a/src/qt/qt_settingsstoragecontrollers.ui +++ b/src/qt/qt_settingsstoragecontrollers.ui @@ -50,7 +50,14 @@ - + + + + 0 + 0 + + + @@ -104,8 +111,12 @@ SCSI - - + + + + Configure + + @@ -114,47 +125,6 @@ - - - - Controller 1: - - - - - - - - - - - - - Controller 4: - - - - - - - Controller 2: - - - - - - - Configure - - - - - - - Configure - - - @@ -162,9 +132,53 @@ + + + + + 0 + 0 + + + + + + + + Configure + + + + + + + + + + + + + Controller 1: + + + + + + + Controller 2: + + + + + + + Controller 4: + + + diff --git a/src/qt/qt_specifydimensions.ui b/src/qt/qt_specifydimensions.ui index 855b9f3b7..8012ced71 100644 --- a/src/qt/qt_specifydimensions.ui +++ b/src/qt/qt_specifydimensions.ui @@ -13,81 +13,45 @@ Specify Main Window Dimensions - - - - 20 - 110 - 361 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 70 - 50 - 81 - 21 - - - - - - - 30 - 50 - 41 - 21 - - - - Width: - - - - - - 20 - 90 - 131 - 23 - - - - Lock to this size - - - - - - 200 - 50 - 51 - 21 - - - - Height: - - - - - - 250 - 50 - 81 - 21 - - - + + + + + Width: + + + + + + + + + + Height: + + + + + + + + + + Lock to this size + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/src/qt/xinput2_mouse.cpp b/src/qt/xinput2_mouse.cpp new file mode 100644 index 000000000..ff67b6a2c --- /dev/null +++ b/src/qt/xinput2_mouse.cpp @@ -0,0 +1,188 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * X11 Xinput2 mouse input module. + * + * + * + * Authors: Cacodemon345 + * + * Copyright 2022 Cacodemon345 + */ + +/* Valuator parsing and duplicate event checking code from SDL2. */ +#include +#include +#include +#include +#include + +#include "qt_mainwindow.hpp" +extern MainWindow* main_window; + +#include +#include +#include + +#include + +extern "C" +{ +#include +#include +#include +#include +#include + +#include <86box/86box.h> +#include <86box/mouse.h> +#include <86box/plat.h> +} + +int xi2flides[2] = { 0, 0 }; + +static Display* disp = nullptr; +static QThread* procThread = nullptr; +static bool xi2childinit = false; +static XIEventMask ximask; +static std::atomic exitfromthread = false; +static std::atomic xi2_mouse_x = 0, xi2_mouse_y = 0, xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0; +static int xi2opcode = 0; +static double prev_rel_coords[2] = { 0., 0. }; +static Time prev_time = 0; + +// From SDL2. +static void parse_valuators(const double *input_values, const unsigned char *mask,int mask_len, + double *output_values,int output_values_len) { + int i = 0,z = 0; + int top = mask_len * 8; + if (top > 16) + top = 16; + + memset(output_values,0,output_values_len * sizeof(double)); + for (; i < top && z < output_values_len; i++) { + if (XIMaskIsSet(mask, i)) { + const int value = (int) *input_values; + output_values[z] = value; + input_values++; + } + z++; + } +} + +static bool exitthread = false; + +void xinput2_proc() +{ + Window win; + win = DefaultRootWindow(disp); + + // XIAllMasterDevices doesn't work for click-and-drag operations. + ximask.deviceid = XIAllDevices; + ximask.mask_len = XIMaskLen(XI_LASTEVENT); + ximask.mask = (unsigned char*)calloc(ximask.mask_len, sizeof(unsigned char)); + + XISetMask(ximask.mask, XI_RawKeyPress); + XISetMask(ximask.mask, XI_RawKeyRelease); + XISetMask(ximask.mask, XI_RawButtonPress); + XISetMask(ximask.mask, XI_RawButtonRelease); + XISetMask(ximask.mask, XI_RawMotion); + if (XKeysymToKeycode(disp, XK_Home) == 69) XISetMask(ximask.mask, XI_Motion); + + XISelectEvents(disp, win, &ximask, 1); + + XSync(disp, False); + while(true) + { + XEvent ev; + XGenericEventCookie *cookie = (XGenericEventCookie*)&ev.xcookie; + XNextEvent(disp, (XEvent*)&ev); + + if (XGetEventData(disp, cookie) && cookie->type == GenericEvent && cookie->extension == xi2opcode) { + switch (cookie->evtype) { + case XI_RawMotion: { + static int ss = 0; + const XIRawEvent *rawev = (const XIRawEvent*)cookie->data; + double relative_coords[2] = { 0., 0. }; + parse_valuators(rawev->raw_values,rawev->valuators.mask, + rawev->valuators.mask_len,relative_coords,2); + + if ((rawev->time == prev_time) && (relative_coords[0] == prev_rel_coords[0]) && (relative_coords[1] == prev_rel_coords[1])) { + break; // Ignore duplicated events. + } + xi2_mouse_x = xi2_mouse_x + relative_coords[0]; + xi2_mouse_y = xi2_mouse_y + relative_coords[1]; + prev_rel_coords[0] = relative_coords[0]; + prev_rel_coords[1] = relative_coords[1]; + prev_time = rawev->time; + } + case XI_Motion: { + if (XKeysymToKeycode(disp, XK_Home) == 69) { + // No chance we will get raw motion events on VNC. + const XIDeviceEvent *motionev = (const XIDeviceEvent*)cookie->data; + if (xi2_mouse_abs_x != 0 || xi2_mouse_abs_y != 0) { + xi2_mouse_x = xi2_mouse_x + (motionev->event_x - xi2_mouse_abs_x); + xi2_mouse_y = xi2_mouse_y + (motionev->event_y - xi2_mouse_abs_y); + } + xi2_mouse_abs_x = motionev->event_x; + xi2_mouse_abs_y = motionev->event_y; + } + } + } + } + + XFreeEventData(disp, cookie); + if (exitthread) break; + } + XCloseDisplay(disp); +} + +void xinput2_exit() +{ + exitthread = true; + procThread->wait(5000); + procThread->terminate(); +} + +void xinput2_init() +{ + disp = XOpenDisplay(nullptr); + if (!disp) + { + qWarning() << "Cannot open current X11 display"; + return; + } + auto event = 0, err = 0, minor = 0, major = 2; + if (XQueryExtension(disp, "XInputExtension", &xi2opcode, &event, &err)) + { + if (XIQueryVersion(disp, &major, &minor) == Success) + { + procThread = QThread::create(xinput2_proc); + procThread->start(); + atexit(xinput2_exit); + } + } +} + +void xinput2_poll() +{ + if (procThread && mouse_capture) + { + mouse_x = xi2_mouse_x; + mouse_y = xi2_mouse_y; + XWindowAttributes winattrib{}; + if (XGetWindowAttributes(disp, main_window->winId(), &winattrib)) + { + auto globalPoint = main_window->mapToGlobal(QPoint(main_window->width() / 2, main_window->height() / 2)); + XWarpPointer(disp, XRootWindow(disp, XScreenNumberOfScreen(winattrib.screen)), XRootWindow(disp, XScreenNumberOfScreen(winattrib.screen)), 0, 0, 0, 0, globalPoint.x(), globalPoint.y()); + XFlush(disp); + } + } + xi2_mouse_x = 0; + xi2_mouse_y = 0; +} diff --git a/src/video/vid_im1024.c b/src/video/vid_im1024.c index 870f0205f..4e6453b31 100644 --- a/src/video/vid_im1024.c +++ b/src/video/vid_im1024.c @@ -1032,7 +1032,7 @@ im1024_speed_changed(void *priv) const device_t im1024_device = { "ImageManager 1024", "im1024", - DEVICE_ISA, 0, + DEVICE_ISA | DEVICE_AT, 0, im1024_init, im1024_close, NULL, { im1024_available }, im1024_speed_changed, diff --git a/src/win/win_about.c b/src/win/win_about.c index b84711a62..d3d5157c2 100644 --- a/src/win/win_about.c +++ b/src/win/win_about.c @@ -63,5 +63,5 @@ AboutDialogCreate(HWND hwnd) TaskDialogIndirect(&tdconfig, &i, NULL, NULL); if (i == IDOK) - ShellExecute(hwnd, L"open", L"https://" EMU_SITE, NULL, NULL, SW_SHOW); + ShellExecute(hwnd, L"open", L"https://" EMU_SITE_W, NULL, NULL, SW_SHOW); } diff --git a/src/win/win_toolbar.c b/src/win/win_toolbar.c index 71e9a02c3..a0291672f 100644 --- a/src/win/win_toolbar.c +++ b/src/win/win_toolbar.c @@ -120,7 +120,7 @@ ToolBarUpdatePause(int pause) static TBBUTTON buttons[] = { { PAUSE, IDM_ACTION_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 }, { HARD_RESET, IDM_ACTION_HRESET, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 }, - { ACPI_SHUTDOWN, 0, TBSTATE_INDETERMINATE, BTNS_BUTTON, { 0 }, 0, 0 }, + { ACPI_SHUTDOWN, 0, TBSTATE_HIDDEN, BTNS_BUTTON, { 0 }, 0, 0 }, { 0, 0, TBSTATE_INDETERMINATE, BTNS_SEP, { 0 }, 0, 0 }, { CTRL_ALT_DEL, IDM_ACTION_RESET_CAD, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 }, { CTRL_ALT_ESC, IDM_ACTION_CTRL_ALT_ESC, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 }, diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 6f0301d09..2070616a0 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -574,7 +574,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_DOCS: - ShellExecute(hwnd, L"open", EMU_DOCS_URL, NULL, NULL, SW_SHOW); + ShellExecute(hwnd, L"open", EMU_DOCS_URL_W, NULL, NULL, SW_SHOW); break; case IDM_UPDATE_ICONS: @@ -1171,6 +1171,7 @@ ui_init(int nCmdShow) int bRet; TASKDIALOGCONFIG tdconfig = {0}; TASKDIALOG_BUTTON tdbuttons[] = {{IDCANCEL, MAKEINTRESOURCE(IDS_2119)}}; + uint32_t helper_lang; /* Load DPI related Windows 10 APIs */ user32_handle = dynld_module("user32.dll", user32_imports); @@ -1204,6 +1205,12 @@ ui_init(int nCmdShow) return(6); } + + /* Load the desired language */ + helper_lang = lang_id; + lang_id = 0; + set_language(helper_lang); + win_settings_open(NULL); return(0); } @@ -1321,7 +1328,7 @@ ui_init(int nCmdShow) } /* Load the desired language */ - uint32_t helper_lang = lang_id; + helper_lang = lang_id; lang_id = 0; set_language(helper_lang);