Merge pull request #2214 from Cacodemon345/c345/haiku
qt: Add support for Haiku
This commit is contained in:
@@ -72,7 +72,7 @@ extern "C" {
|
||||
#include "qt_mediamenu.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
#ifdef __unix__
|
||||
#if defined __unix__ && !defined __HAIKU__
|
||||
#ifdef WAYLAND
|
||||
#include "wl_mouse.hpp"
|
||||
#endif
|
||||
@@ -82,6 +82,32 @@ extern "C" {
|
||||
#undef KeyRelease
|
||||
#endif
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <os/AppKit.h>
|
||||
#include <os/InterfaceKit.h>
|
||||
|
||||
extern MainWindow* main_window;
|
||||
|
||||
filter_result keyb_filter(BMessage *message, BHandler **target, BMessageFilter *filter)
|
||||
{
|
||||
if (message->what == B_KEY_DOWN || message->what == B_KEY_UP
|
||||
|| message->what == B_UNMAPPED_KEY_DOWN || message->what == B_UNMAPPED_KEY_UP)
|
||||
{
|
||||
int key_state = 0, key_scancode = 0;
|
||||
key_state = message->what == B_KEY_DOWN || message->what == B_UNMAPPED_KEY_DOWN;
|
||||
message->FindInt32("key", &key_scancode);
|
||||
QGuiApplication::postEvent(main_window, new QKeyEvent(key_state ? QEvent::KeyPress : QEvent::KeyRelease, 0, QGuiApplication::keyboardModifiers(), key_scancode, 0, 0));
|
||||
if (key_scancode == 0x68 && key_state)
|
||||
{
|
||||
QGuiApplication::postEvent(main_window, new QKeyEvent(QEvent::KeyRelease, 0, QGuiApplication::keyboardModifiers(), key_scancode, 0, 0));
|
||||
}
|
||||
}
|
||||
return B_DISPATCH_MESSAGE;
|
||||
}
|
||||
|
||||
static BMessageFilter* filter;
|
||||
#endif
|
||||
|
||||
extern void qt_mouse_capture(int);
|
||||
extern "C" void qt_blit(int x, int y, int w, int h);
|
||||
|
||||
@@ -93,6 +119,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
MediaMenu::ptr = mm;
|
||||
status = std::make_unique<MachineStatus>(this);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
filter = new BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, keyb_filter);
|
||||
((BWindow*)this->winId())->AddFilter(filter);
|
||||
#endif
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
ui->setupUi(this);
|
||||
ui->stackedWidget->setMouseTracking(true);
|
||||
@@ -234,9 +264,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->actionHardware_Renderer_OpenGL->setVisible(QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES);
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES && vid_api == 1) vid_api = 0;
|
||||
|
||||
if (QApplication::platformName().contains("eglfs") && vid_api >= 1) {
|
||||
fprintf(stderr, "OpenGL renderers are unsupported on EGLFS.\n");
|
||||
if ((QApplication::platformName().contains("eglfs") || QApplication::platformName() == "haiku")) {
|
||||
if (vid_api >= 1) fprintf(stderr, "OpenGL renderers are unsupported on %s.\n", QApplication::platformName().toUtf8().data());
|
||||
vid_api = 0;
|
||||
ui->actionHardware_Renderer_OpenGL->setVisible(false);
|
||||
ui->actionHardware_Renderer_OpenGL_ES->setVisible(false);
|
||||
ui->actionOpenGL_3_0_Core->setVisible(false);
|
||||
}
|
||||
|
||||
QActionGroup* actGroup = nullptr;
|
||||
@@ -469,7 +502,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
}
|
||||
qt_nvr_save();
|
||||
config_save();
|
||||
#ifdef __unix__
|
||||
#if defined __unix__ && !defined __HAIKU__
|
||||
extern void xinput2_exit();
|
||||
if (QApplication::platformName() == "xcb") xinput2_exit();
|
||||
#endif
|
||||
@@ -1059,6 +1092,117 @@ static std::unordered_map<uint32_t, uint16_t> evdev_to_xt =
|
||||
{111, 0x153}
|
||||
};
|
||||
|
||||
#ifdef __HAIKU__
|
||||
static std::unordered_map<uint8_t, uint16_t> be_to_xt =
|
||||
{
|
||||
{0x01, 0x01},
|
||||
{B_F1_KEY, 0x3B},
|
||||
{B_F2_KEY, 0x3C},
|
||||
{B_F3_KEY, 0x3D},
|
||||
{B_F4_KEY, 0x3E},
|
||||
{B_F5_KEY, 0x3F},
|
||||
{B_F6_KEY, 0x40},
|
||||
{B_F7_KEY, 0x41},
|
||||
{B_F8_KEY, 0x42},
|
||||
{B_F9_KEY, 0x43},
|
||||
{B_F10_KEY, 0x44},
|
||||
{B_F11_KEY, 0x57},
|
||||
{B_F12_KEY, 0x58},
|
||||
{0x11, 0x29},
|
||||
{0x12, 0x02},
|
||||
{0x13, 0x03},
|
||||
{0x14, 0x04},
|
||||
{0x15, 0x05},
|
||||
{0x16, 0x06},
|
||||
{0x17, 0x07},
|
||||
{0x18, 0x08},
|
||||
{0x19, 0x09},
|
||||
{0x1A, 0x0A},
|
||||
{0x1B, 0x0B},
|
||||
{0x1C, 0x0C},
|
||||
{0x1D, 0x0D},
|
||||
{0x1E, 0x0E},
|
||||
{0x1F, 0x152},
|
||||
{0x20, 0x147},
|
||||
{0x21, 0x149},
|
||||
{0x22, 0x45},
|
||||
{0x23, 0x135},
|
||||
{0x24, 0x37},
|
||||
{0x25, 0x4A},
|
||||
{0x26, 0x0F},
|
||||
{0x27, 0x10},
|
||||
{0x28, 0x11},
|
||||
{0x29, 0x12},
|
||||
{0x2A, 0x13},
|
||||
{0x2B, 0x14},
|
||||
{0x2C, 0x15},
|
||||
{0x2D, 0x16},
|
||||
{0x2E, 0x17},
|
||||
{0x2F, 0x18},
|
||||
{0x30, 0x19},
|
||||
{0x31, 0x1A},
|
||||
{0x32, 0x1B},
|
||||
{0x33, 0x2B},
|
||||
{0x34, 0x153},
|
||||
{0x35, 0x14F},
|
||||
{0x36, 0x151},
|
||||
{0x37, 0x47},
|
||||
{0x38, 0x48},
|
||||
{0x39, 0x49},
|
||||
{0x3A, 0x4E},
|
||||
{0x3B, 0x3A},
|
||||
{0x3C, 0x1E},
|
||||
{0x3D, 0x1F},
|
||||
{0x3E, 0x20},
|
||||
{0x3F, 0x21},
|
||||
{0x40, 0x22},
|
||||
{0x41, 0x23},
|
||||
{0x42, 0x24},
|
||||
{0x43, 0x25},
|
||||
{0x44, 0x26},
|
||||
{0x45, 0x27},
|
||||
{0x46, 0x28},
|
||||
{0x47, 0x1C},
|
||||
{0x48, 0x4B},
|
||||
{0x49, 0x4C},
|
||||
{0x4A, 0x4D},
|
||||
{0x4B, 0x2A},
|
||||
{0x4C, 0x2C},
|
||||
{0x4D, 0x2D},
|
||||
{0x4E, 0x2E},
|
||||
{0x4F, 0x2F},
|
||||
{0x50, 0x30},
|
||||
{0x51, 0x31},
|
||||
{0x52, 0x32},
|
||||
{0x53, 0x33},
|
||||
{0x54, 0x34},
|
||||
{0x55, 0x35},
|
||||
{0x56, 0x36},
|
||||
{0x57, 0x148},
|
||||
{0x58, 0x51},
|
||||
{0x59, 0x50},
|
||||
{0x5A, 0x4F},
|
||||
{0x5B, 0x11C},
|
||||
{0x5C, 0x1D},
|
||||
{0x5D, 0x38},
|
||||
{0x5E, 0x39},
|
||||
{0x5F, 0x138},
|
||||
{0x60, 0x11D},
|
||||
{0x61, 0x14B},
|
||||
{0x62, 0x150},
|
||||
{0x63, 0x14D},
|
||||
{0x64, 0x52},
|
||||
{0x65, 0x53},
|
||||
|
||||
{0x0e, 0x137},
|
||||
{0x0f, 0x46},
|
||||
{0x66, 0x15B},
|
||||
{0x67, 0x15C},
|
||||
{0x68, 0x15D},
|
||||
{0x69, 0x56}
|
||||
};
|
||||
#endif
|
||||
|
||||
static std::array<uint32_t, 256>& selected_keycode = x11_to_xt_base;
|
||||
|
||||
uint16_t x11_keycode_to_keysym(uint32_t keycode)
|
||||
@@ -1068,6 +1212,8 @@ uint16_t x11_keycode_to_keysym(uint32_t keycode)
|
||||
finalkeycode = (keycode & 0xFFFF);
|
||||
#elif defined(__APPLE__)
|
||||
finalkeycode = darwin_to_xt[keycode];
|
||||
#elif defined(__HAIKU__)
|
||||
finalkeycode = be_to_xt[keycode];
|
||||
#else
|
||||
static Display* x11display = nullptr;
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
|
||||
Reference in New Issue
Block a user