7#include <QtCore/QDebug>
8#include <QtCore/QSocketNotifier>
9#include <QtCore/private/qcore_unix_p.h>
21#if defined(QQNXVIRTUALKEYBOARD_DEBUG)
22#define qVirtualKeyboardDebug qDebug
24#define qVirtualKeyboardDebug QT_NO_QDEBUG_MACRO
29const char *QQnxVirtualKeyboardPps::ms_PPSPath =
"/pps/services/input/control";
30const size_t QQnxVirtualKeyboardPps::ms_bufferSize = 2048;
53void QQnxVirtualKeyboardPps::close()
55 delete m_readNotifier;
64 pps_decoder_cleanup(m_decoder);
70 pps_encoder_cleanup(m_encoder);
79bool QQnxVirtualKeyboardPps::connect()
83 m_encoder =
new pps_encoder_t;
84 m_decoder =
new pps_decoder_t;
86 pps_encoder_initialize(m_encoder,
false);
87 pps_decoder_initialize(m_decoder, 0);
90 m_fd =
::open(ms_PPSPath, O_RDWR);
94 <<
':' << strerror(errno);
99 m_buffer =
new char[ms_bufferSize];
101 qCritical(
"QQnxVirtualKeyboard: Unable to allocate buffer of %zu bytes. "
102 "Size is unavailable.", ms_bufferSize);
115bool QQnxVirtualKeyboardPps::queryPPSInfo()
117 if (!prepareToSend())
121 pps_encoder_add_string(m_encoder,
"msg",
"info");
122 pps_encoder_add_string(m_encoder,
"id",
"1");
124 return writeCurrentPPSEncoder();
127void QQnxVirtualKeyboardPps::ppsDataReady()
143 if (
Q_UNLIKELY(
static_cast<size_t>(nread) > ms_bufferSize - 1)) {
144 qCritical(
"QQnxVirtualKeyboard: Keyboard buffer size too short; need %lld.", nread + 1);
150 pps_decoder_parse_pps_str(m_decoder, m_buffer);
151 pps_decoder_push(m_decoder, 0);
152#if defined(QQNXVIRTUALKEYBOARD_DEBUG)
153 pps_decoder_dump_tree(m_decoder, stderr);
157 if (
Q_UNLIKELY(pps_decoder_get_string(m_decoder,
"error", &
value) == PPS_DECODER_OK)) {
158 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS decoder error: %s",
value ?
value :
"[null]");
162 if (pps_decoder_get_string(m_decoder,
"msg", &
value) == PPS_DECODER_OK) {
163 if (strcmp(
value,
"show") == 0)
165 else if (strcmp(
value,
"hide") == 0)
167 else if (strcmp(
value,
"info") == 0)
168 handleKeyboardInfoMessage();
169 else if (strcmp(
value,
"connect") == 0)
172 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s",
value ?
value :
"[null]");
173 }
else if (pps_decoder_get_string(m_decoder,
"res", &
value) == PPS_DECODER_OK) {
174 if (strcmp(
value,
"info") == 0)
175 handleKeyboardInfoMessage();
177 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s",
value ?
value :
"[null]");
179 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS message type");
183void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
187 if (
Q_UNLIKELY(pps_decoder_push(m_decoder,
"dat") != PPS_DECODER_OK)) {
188 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS dat object not found");
191 if (
Q_UNLIKELY(pps_decoder_get_int(m_decoder,
"size", &newHeight) != PPS_DECODER_OK)) {
192 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS size field not found");
204 if (!prepareToSend())
214 pps_encoder_reset(m_encoder);
217 pps_encoder_add_string(m_encoder,
"msg",
"show");
219 return writeCurrentPPSEncoder();
226 if (!prepareToSend())
229 pps_encoder_add_string(m_encoder,
"msg",
"hide");
231 return writeCurrentPPSEncoder();
234bool QQnxVirtualKeyboardPps::prepareToSend()
236 if (m_fd == -1 && !connect())
239 pps_encoder_reset(m_encoder);
243bool QQnxVirtualKeyboardPps::writeCurrentPPSEncoder()
245 if (
::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) {
254 if (!prepareToSend())
258 pps_encoder_add_string(m_encoder,
"msg",
"options");
259 pps_encoder_start_object(m_encoder,
"dat");
261 pps_encoder_add_string(m_encoder,
"enter", enterKeyTypeStr());
262 pps_encoder_add_string(m_encoder,
"type", keyboardModeStr());
264 pps_encoder_end_object(m_encoder);
266 writeCurrentPPSEncoder();
269const char* QQnxVirtualKeyboardPps::keyboardModeStr()
const
291 return "alphanumeric";
299const char* QQnxVirtualKeyboardPps::enterKeyTypeStr()
const
303 return "enter.default";
305 return "enter.connect";
315 return "enter.search";
319 return "enter.submit";
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setHeight(int height)
void setVisible(bool visible)
EnterKeyType enterKeyType() const
KeyboardMode keyboardMode() const
~QQnxVirtualKeyboardPps()
bool hideKeyboard() override
void applyKeyboardOptions() override
bool showKeyboard() override
Combined button and popup list for selecting options.
static qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qVirtualKeyboardDebug
file open(QIODevice::ReadOnly)
gzip write("uncompressed data")