Skip to content

Commit

Permalink
Fix for keyboards that use the deprecated META_SHIFT_ON modifier (lik…
Browse files Browse the repository at this point in the history
…e gboard).
  • Loading branch information
iiordanov committed Feb 11, 2018
1 parent ecf4cea commit a503686
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
19 changes: 9 additions & 10 deletions bVNC/src2/main/java/com/iiordanov/bVNC/RdpCommunicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,42 +129,42 @@ public void close() {

private void sendModifierKeys (boolean down) {
if ((metaState & RemoteKeyboard.CTRL_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending LCTRL " + down);
//android.util.Log.d("RdpCommunicator", "Sending LCTRL " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_LCONTROL, down);
}
if ((metaState & RemoteKeyboard.RCTRL_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending RCTRL " + down);
//android.util.Log.d("RdpCommunicator", "Sending RCTRL " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_RCONTROL, down);
}
if ((metaState & RemoteKeyboard.ALT_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending LALT " + down);
//android.util.Log.d("RdpCommunicator", "Sending LALT " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_LMENU, down);
}
if ((metaState & RemoteKeyboard.RALT_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending RALT " + down);
//android.util.Log.d("RdpCommunicator", "Sending RALT " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_RMENU, down);
}
if ((metaState & RemoteKeyboard.SUPER_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending LSUPER " + down);
//android.util.Log.d("RdpCommunicator", "Sending LSUPER " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_LWIN | VK_EXT_KEY, down);
}
if ((metaState & RemoteKeyboard.RSUPER_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending RSUPER " + down);
//android.util.Log.d("RdpCommunicator", "Sending RSUPER " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_RWIN | VK_EXT_KEY, down);
}
if ((metaState & RemoteKeyboard.SHIFT_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending LSHIFT " + down);
//android.util.Log.d("RdpCommunicator", "Sending LSHIFT " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_LSHIFT, down);
}
if ((metaState & RemoteKeyboard.RSHIFT_MASK) != 0) {
//android.util.Log.e("RdpCommunicator", "Sending RSHIFT " + down);
//android.util.Log.d("RdpCommunicator", "Sending RSHIFT " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), VK_RSHIFT, down);
}
Expand All @@ -177,7 +177,7 @@ public void processVirtualKey(int virtualKeyCode, boolean down) {
if (down) {
sendModifierKeys(true);
}
//android.util.Log.e("RdpCommunicator", "Sending VK key: " + virtualKeyCode + ". Is it down: " + down);
android.util.Log.d("RdpCommunicator", "Sending VK key: " + virtualKeyCode + ". Is it down: " + down);
try { Thread.sleep(5); } catch (InterruptedException e) {}
LibFreeRDP.sendKeyEvent(session.getInstance(), virtualKeyCode, down);
if (!down) {
Expand Down Expand Up @@ -207,6 +207,5 @@ public void modifiersChanged() {
@Override
public void requestResolution(int x, int y) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void sendKeySym (int keysym, int metaState) {
/**
* Tries to convert a unicode character to a KeyEvent and if successful sends with keyEvent().
* @param unicodeChar
* @param metaState
* @param additionalMetaState
*/
public boolean sendUnicode (char unicodeChar, int additionalMetaState) {
KeyCharacterMap fullKmap = KeyCharacterMap.load(KeyCharacterMap.FULL);
Expand Down Expand Up @@ -282,7 +282,7 @@ protected int convertEventMetaState (KeyEvent event, int eventMetaState) {
}

// Add shift, ctrl, alt, and super to metaState if necessary.
if ((eventMetaState & 0x00000040 /*KeyEvent.META_SHIFT_LEFT_ON*/) != 0) {
if ((eventMetaState & (0x00000040 | 1) /*KeyEvent.META_SHIFT_LEFT_ON/META_SHIFT_ON*/) != 0) {
metaState |= SHIFT_MASK;
}
if ((eventMetaState & 0x00000080 /*KeyEvent.META_SHIFT_RIGHT_ON*/) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public RemoteRdpKeyboard (RfbConnectable r, RemoteCanvas v, Handler h) {
}

public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMetaState) {
//android.util.Log.d("RemoteRdpKeyboard", "event: " + evt);
if (rfb != null && rfb.isInNormalProtocol()) {
RemotePointer pointer = canvas.getPointer();
boolean down = (evt.getAction() == KeyEvent.ACTION_DOWN) ||
Expand Down Expand Up @@ -78,10 +79,11 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
} else {
lastDownMetaState = 0;
}


if (keyCode == 0 /*KEYCODE_UNKNOWN*/) {
String s = evt.getCharacters();
//android.util.Log.d("RemoteRdpKeyboard", "getCharacters: " + s);

if (s != null) {
int numchars = s.length();
for (int i = 0; i < numchars; i++) {
Expand Down

0 comments on commit a503686

Please sign in to comment.