Changeset View
Changeset View
Standalone View
Standalone View
plugins/remotekeyboard/remotekeyboardplugin.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 70 | RemoteKeyboardPlugin::RemoteKeyboardPlugin(QObject* parent, const QVariantList& args) | |||
---|---|---|---|---|---|
72 | , m_remoteState(false) | 72 | , m_remoteState(false) | ||
73 | { | 73 | { | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | RemoteKeyboardPlugin::~RemoteKeyboardPlugin() | 76 | RemoteKeyboardPlugin::~RemoteKeyboardPlugin() | ||
77 | { | 77 | { | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | bool RemoteKeyboardPlugin::receivePackage(const NetworkPackage& np) | 80 | bool RemoteKeyboardPlugin::receivePacket(const NetworkPacket& np) | ||
81 | { | 81 | { | ||
82 | if (np.type() == PACKAGE_TYPE_MOUSEPAD_ECHO) { | 82 | if (np.type() == PACKET_TYPE_MOUSEPAD_ECHO) { | ||
83 | if (!np.has("isAck") || !np.has("key")) { | 83 | if (!np.has("isAck") || !np.has("key")) { | ||
84 | qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Invalid packet of type" | 84 | qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Invalid packet of type" | ||
85 | << PACKAGE_TYPE_MOUSEPAD_ECHO; | 85 | << PACKET_TYPE_MOUSEPAD_ECHO; | ||
86 | return false; | 86 | return false; | ||
87 | } | 87 | } | ||
88 | // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keypress" << np; | 88 | // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keypress" << np; | ||
89 | Q_EMIT keyPressReceived(np.get<QString>("key"), | 89 | Q_EMIT keyPressReceived(np.get<QString>("key"), | ||
90 | np.get<int>("specialKey", 0), | 90 | np.get<int>("specialKey", 0), | ||
91 | np.get<int>("shift", false), | 91 | np.get<int>("shift", false), | ||
92 | np.get<int>("ctrl", false), | 92 | np.get<int>("ctrl", false), | ||
93 | np.get<int>("alt", false)); | 93 | np.get<int>("alt", false)); | ||
94 | return true; | 94 | return true; | ||
95 | } else if (np.type() == PACKAGE_TYPE_MOUSEPAD_KEYBOARDSTATE) { | 95 | } else if (np.type() == PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE) { | ||
96 | // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keyboardstate" << np; | 96 | // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keyboardstate" << np; | ||
97 | if (m_remoteState != np.get<bool>("state")) { | 97 | if (m_remoteState != np.get<bool>("state")) { | ||
98 | m_remoteState = np.get<bool>("state"); | 98 | m_remoteState = np.get<bool>("state"); | ||
99 | Q_EMIT remoteStateChanged(m_remoteState); | 99 | Q_EMIT remoteStateChanged(m_remoteState); | ||
100 | } | 100 | } | ||
101 | return true; | 101 | return true; | ||
102 | } | 102 | } | ||
103 | return false; | 103 | return false; | ||
104 | } | 104 | } | ||
105 | 105 | | |||
106 | void RemoteKeyboardPlugin::sendKeyPress(const QString& key, int specialKey, | 106 | void RemoteKeyboardPlugin::sendKeyPress(const QString& key, int specialKey, | ||
107 | bool shift, bool ctrl, | 107 | bool shift, bool ctrl, | ||
108 | bool alt, bool sendAck) const | 108 | bool alt, bool sendAck) const | ||
109 | { | 109 | { | ||
110 | NetworkPackage np(PACKAGE_TYPE_MOUSEPAD_REQUEST, { | 110 | NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, { | ||
111 | {"key", key}, | 111 | {"key", key}, | ||
112 | {"specialKey", specialKey}, | 112 | {"specialKey", specialKey}, | ||
113 | {"shift", shift}, | 113 | {"shift", shift}, | ||
114 | {"ctrl", ctrl}, | 114 | {"ctrl", ctrl}, | ||
115 | {"alt", alt}, | 115 | {"alt", alt}, | ||
116 | {"sendAck", sendAck} | 116 | {"sendAck", sendAck} | ||
117 | }); | 117 | }); | ||
118 | sendPackage(np); | 118 | sendPacket(np); | ||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | void RemoteKeyboardPlugin::sendQKeyEvent(const QVariantMap& keyEvent, bool sendAck) const | 121 | void RemoteKeyboardPlugin::sendQKeyEvent(const QVariantMap& keyEvent, bool sendAck) const | ||
122 | { | 122 | { | ||
123 | if (!keyEvent.contains("key")) | 123 | if (!keyEvent.contains("key")) | ||
124 | return; | 124 | return; | ||
125 | int k = translateQtKey(keyEvent.value("key").toInt()); | 125 | int k = translateQtKey(keyEvent.value("key").toInt()); | ||
126 | int modifiers = keyEvent.value("modifiers").toInt(); | 126 | int modifiers = keyEvent.value("modifiers").toInt(); | ||
Show All 23 Lines |