2024-08-25 04:08:24 +00:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QTouchDevice>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qtouchdevice.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qtouchdevice.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTouchDevice* QTouchDevice_new() {
|
|
|
|
return new QTouchDevice();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QTouchDevice_Devices(const QTouchDevice*** _out, size_t* _out_len) {
|
|
|
|
QList<const QTouchDevice*> ret = QTouchDevice::devices();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QList<> from C++ memory to manually-managed C memory
|
2024-08-29 07:01:51 +00:00
|
|
|
const QTouchDevice** __out = static_cast<const QTouchDevice**>(malloc(sizeof(const QTouchDevice*) * ret.length()));
|
2024-08-25 04:08:24 +00:00
|
|
|
for (size_t i = 0, e = ret.length(); i < e; ++i) {
|
2024-08-29 07:01:51 +00:00
|
|
|
__out[i] = const_cast<const QTouchDevice*>(ret[i]);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
*_out = __out;
|
|
|
|
*_out_len = ret.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QTouchDevice_Name(QTouchDevice* self, char** _out, int* _out_Strlen) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QString ret = const_cast<const QTouchDevice*>(self)->name();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
uintptr_t QTouchDevice_Type(QTouchDevice* self) {
|
|
|
|
QTouchDevice::DeviceType ret = const_cast<const QTouchDevice*>(self)->type();
|
|
|
|
return static_cast<uintptr_t>(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
int QTouchDevice_Capabilities(QTouchDevice* self) {
|
|
|
|
QTouchDevice::Capabilities ret = const_cast<const QTouchDevice*>(self)->capabilities();
|
|
|
|
return static_cast<int>(ret);
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
int QTouchDevice_MaximumTouchPoints(QTouchDevice* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QTouchDevice*>(self)->maximumTouchPoints();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QTouchDevice_SetName(QTouchDevice* self, const char* name, size_t name_Strlen) {
|
|
|
|
QString name_QString = QString::fromUtf8(name, name_Strlen);
|
|
|
|
self->setName(name_QString);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QTouchDevice_SetType(QTouchDevice* self, uintptr_t devType) {
|
|
|
|
self->setType(static_cast<QTouchDevice::DeviceType>(devType));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QTouchDevice_SetCapabilities(QTouchDevice* self, int caps) {
|
|
|
|
self->setCapabilities(static_cast<QTouchDevice::Capabilities>(caps));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QTouchDevice_SetMaximumTouchPoints(QTouchDevice* self, int max) {
|
|
|
|
self->setMaximumTouchPoints(static_cast<int>(max));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QTouchDevice_Delete(QTouchDevice* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|