miqt/qt/gen_qtouchdevice.cpp

73 lines
2.1 KiB
C++
Raw Normal View History

#include <QList>
#include <QString>
2024-08-29 07:01:51 +00:00
#include <QByteArray>
#include <cstring>
#include <QTouchDevice>
2024-08-29 07:01:51 +00:00
#include "qtouchdevice.h"
2024-08-29 07:01:51 +00:00
#include "gen_qtouchdevice.h"
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();
// 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()));
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]);
}
*_out = __out;
*_out_len = ret.length();
}
void QTouchDevice_Name(const QTouchDevice* self, char** _out, int* _out_Strlen) {
QString ret = self->name();
// 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();
}
uintptr_t QTouchDevice_Type(const QTouchDevice* self) {
QTouchDevice::DeviceType ret = self->type();
2024-08-29 07:01:51 +00:00
return static_cast<uintptr_t>(ret);
}
int QTouchDevice_Capabilities(const QTouchDevice* self) {
QTouchDevice::Capabilities ret = self->capabilities();
2024-08-29 07:01:51 +00:00
return static_cast<int>(ret);
}
int QTouchDevice_MaximumTouchPoints(const QTouchDevice* self) {
return self->maximumTouchPoints();
}
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));
}
void QTouchDevice_SetMaximumTouchPoints(QTouchDevice* self, int max) {
self->setMaximumTouchPoints(static_cast<int>(max));
}
void QTouchDevice_Delete(QTouchDevice* self) {
delete self;
}