Skip to content

Commit 7ffe5f5

Browse files
committed
initial
1 parent 671aeef commit 7ffe5f5

File tree

7 files changed

+66
-41
lines changed

7 files changed

+66
-41
lines changed

eclipse_projects/bVNC/src/com/iiordanov/bVNC/RfbProto.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -1507,19 +1507,26 @@ public void clientRedirect(int port, String host, String x509subject) {
15071507
void writeModifierKeyEvents(int newModifiers) {
15081508
if ((newModifiers & RemoteKeyboard.CTRL_MASK) != (oldModifiers & RemoteKeyboard.CTRL_MASK))
15091509
writeKeyEvent(0xffe3, (newModifiers & RemoteKeyboard.CTRL_MASK) != 0);
1510-
1510+
15111511
if ((newModifiers & RemoteKeyboard.SHIFT_MASK) != (oldModifiers & RemoteKeyboard.SHIFT_MASK))
15121512
writeKeyEvent(0xffe1, (newModifiers & RemoteKeyboard.SHIFT_MASK) != 0);
1513-
1514-
if ((newModifiers & RemoteKeyboard.META_MASK) != (oldModifiers & RemoteKeyboard.META_MASK))
1515-
writeKeyEvent(0xffe7, (newModifiers & RemoteKeyboard.META_MASK) != 0);
1516-
1513+
15171514
if ((newModifiers & RemoteKeyboard.ALT_MASK) != (oldModifiers & RemoteKeyboard.ALT_MASK))
15181515
writeKeyEvent(0xffe9, (newModifiers & RemoteKeyboard.ALT_MASK) != 0);
15191516

15201517
if ((newModifiers & RemoteKeyboard.SUPER_MASK) != (oldModifiers & RemoteKeyboard.SUPER_MASK))
15211518
writeKeyEvent(0xffeb, (newModifiers & RemoteKeyboard.SUPER_MASK) != 0);
1522-
1519+
1520+
if ((newModifiers & RemoteKeyboard.RCTRL_MASK) != (oldModifiers & RemoteKeyboard.RCTRL_MASK))
1521+
writeKeyEvent(0xffe4, (newModifiers & RemoteKeyboard.RCTRL_MASK) != 0);
1522+
1523+
if ((newModifiers & RemoteKeyboard.RSHIFT_MASK) != (oldModifiers & RemoteKeyboard.RSHIFT_MASK))
1524+
writeKeyEvent(0xffe2, (newModifiers & RemoteKeyboard.RSHIFT_MASK) != 0);
1525+
1526+
if ((newModifiers & RemoteKeyboard.RALT_MASK) != (oldModifiers & RemoteKeyboard.RALT_MASK))
1527+
writeKeyEvent(0xffea, (newModifiers & RemoteKeyboard.RALT_MASK) != 0);
1528+
//writeKeyEvent(this.canvas.connection.getRAltAsIsoLv3Shift() ? 0xfe03 : 0xffea,
1529+
15231530
oldModifiers = newModifiers;
15241531
}
15251532
//

eclipse_projects/bVNC/src/com/iiordanov/bVNC/SpiceCommunicator.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,15 @@ private void sendModifierKeys(boolean keyDown, int key) {
326326
remoteMetaState &= ~RemoteKeyboard.ALT_MASK;
327327
}
328328
}
329-
if ((metaState & RemoteKeyboard.ALTGR_MASK) != 0) {
330-
if (!keyDown || key != RemoteKeyboard.SCAN_RIGHTALT && (remoteMetaState & RemoteKeyboard.ALTGR_MASK) == 0) {
329+
if ((metaState & RemoteKeyboard.RALT_MASK) != 0) {
330+
if (!keyDown || key != RemoteKeyboard.SCAN_RIGHTALT && (remoteMetaState & RemoteKeyboard.RALT_MASK) == 0) {
331331
android.util.Log.e("SpiceCommunicator", "Sending ALTGR: " + RemoteKeyboard.SCAN_RIGHTALT + " down: " + keyDown);
332332
sendKeyEvent(keyDown, RemoteKeyboard.SCAN_RIGHTALT);
333333
}
334334
if (keyDown) {
335-
remoteMetaState |= RemoteKeyboard.ALTGR_MASK;
335+
remoteMetaState |= RemoteKeyboard.RALT_MASK;
336336
} else {
337-
remoteMetaState &= ~RemoteKeyboard.ALTGR_MASK;
337+
remoteMetaState &= ~RemoteKeyboard.RALT_MASK;
338338
}
339339
}
340340
if ((metaState & RemoteKeyboard.SUPER_MASK) != 0) {

eclipse_projects/bVNC/src/com/iiordanov/bVNC/dialogs/MetaKeyDialog.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ void setMetaKeyList()
588588
private void updateDialogForCurrentKey()
589589
{
590590
int flags = _currentKeyBean.getMetaFlags();
591-
_checkAlt.setChecked(0 != (flags & RemoteKeyboard.ALT_MASK));
592-
_checkShift.setChecked(0 != (flags & RemoteKeyboard.SHIFT_MASK));
593-
_checkCtrl.setChecked(0 != (flags & RemoteKeyboard.CTRL_MASK));
594-
_checkSuper.setChecked(0 != (flags & RemoteKeyboard.SUPER_MASK));
591+
_checkAlt.setChecked(0 != (flags & (RemoteKeyboard.ALT_MASK | RemoteKeyboard.RALT_MASK)));
592+
_checkShift.setChecked(0 != (flags & (RemoteKeyboard.SHIFT_MASK | RemoteKeyboard.RSHIFT_MASK)));
593+
_checkCtrl.setChecked(0 != (flags & (RemoteKeyboard.CTRL_MASK | RemoteKeyboard.RCTRL_MASK)));
594+
_checkSuper.setChecked(0 != (flags & (RemoteKeyboard.SUPER_MASK | RemoteKeyboard.RSUPER_MASK)));
595595
MetaKeyBase base = null;
596596
if (_currentKeyBean.isMouseClick())
597597
{

eclipse_projects/bVNC/src/com/iiordanov/bVNC/input/RemoteKeyboard.java

+28-12
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ public abstract class RemoteKeyboard {
3434
//public final static int SCAN_END = 107;
3535

3636
// Useful shortcuts for modifier masks.
37-
public final static int CTRL_MASK = KeyEvent.META_SYM_ON;
38-
public final static int SHIFT_MASK = KeyEvent.META_SHIFT_ON;
39-
public final static int ALT_MASK = KeyEvent.META_ALT_ON;
40-
public final static int SUPER_MASK = 8;
41-
public final static int ALTGR_MASK = 16;
42-
public final static int META_MASK = 0;
37+
public final static int CTRL_MASK = KeyEvent.META_SYM_ON;
38+
public final static int SHIFT_MASK = KeyEvent.META_SHIFT_ON;
39+
public final static int ALT_MASK = KeyEvent.META_ALT_ON;
40+
public final static int SUPER_MASK = 0x8;
41+
public final static int RCTRL_MASK = 0x4000; /* KeyEvent.META_CTRL_RIGHT_ON */
42+
public final static int RSHIFT_MASK = KeyEvent.META_SHIFT_RIGHT_ON;
43+
public final static int RALT_MASK = 0x10;
44+
public final static int RSUPER_MASK = 0x70000; /* KeyEvent.META_META_RIGHT_ON */
4345

4446
protected RemoteCanvas canvas;
4547
protected Handler handler;
@@ -274,27 +276,41 @@ protected int convertEventMetaState (KeyEvent event) {
274276
*/
275277
protected int convertEventMetaState (KeyEvent event, int eventMetaState) {
276278
int metaState = 0;
277-
int altMask = KeyEvent.META_ALT_RIGHT_ON;
279+
int leftAltMask = 0;
280+
int rightAltMask = KeyEvent.META_ALT_RIGHT_ON;
278281
// Detect whether this event is coming from a default hardware keyboard.
279282
// We have to leave KeyEvent.KEYCODE_ALT_LEFT for symbol input on a default hardware keyboard.
280283
boolean defaultHardwareKbd = (event.getScanCode() != 0 && event.getDeviceId() == 0);
281284
if (!bb && !defaultHardwareKbd) {
282-
altMask = KeyEvent.META_ALT_MASK;
285+
leftAltMask = KeyEvent.META_ALT_LEFT_ON;
283286
}
284287

285288
// Add shift, ctrl, alt, and super to metaState if necessary.
286-
if ((eventMetaState & 0x000000c1 /*KeyEvent.META_SHIFT_MASK*/) != 0) {
289+
if ((eventMetaState & 0x00000040 /*KeyEvent.META_SHIFT_LEFT_ON*/) != 0) {
287290
metaState |= SHIFT_MASK;
288291
}
289-
if ((eventMetaState & 0x00007000 /*KeyEvent.META_CTRL_MASK*/) != 0) {
292+
if ((eventMetaState & 0x00000080 /*KeyEvent.META_SHIFT_RIGHT_ON*/) != 0) {
293+
metaState |= RSHIFT_MASK;
294+
}
295+
if ((eventMetaState & 0x00002000 /*KeyEvent.META_CTRL_LEFT_ON*/) != 0) {
290296
metaState |= CTRL_MASK;
291297
}
292-
if ((eventMetaState & altMask) !=0) {
298+
if ((eventMetaState & 0x00004000 /*KeyEvent.META_CTRL_RIGHT_ON*/) != 0) {
299+
metaState |= RCTRL_MASK;
300+
}
301+
if ((eventMetaState & leftAltMask) !=0) {
293302
metaState |= ALT_MASK;
294303
}
295-
if ((eventMetaState & 0x00070000 /*KeyEvent.META_META_MASK*/) != 0) {
304+
if ((eventMetaState & rightAltMask) !=0) {
305+
metaState |= RALT_MASK;
306+
}
307+
if ((eventMetaState & 0x00020000 /*KeyEvent.META_META_LEFT_ON*/) != 0) {
296308
metaState |= SUPER_MASK;
297309
}
310+
if ((eventMetaState & 0x00040000 /*KeyEvent.META_META_RIGHT_ON*/) != 0) {
311+
metaState |= RSUPER_MASK;
312+
}
313+
298314
return metaState;
299315
}
300316

eclipse_projects/bVNC/src/com/iiordanov/bVNC/input/RemoteSpiceKeyboard.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private void writeKeyEvent(boolean isUnicode, int code, int metaState, boolean d
232232
}
233233
if ((scode & SCANCODE_ALTGR_MASK) != 0) {
234234
android.util.Log.e(TAG, "Found AltGr mask.");
235-
meta |= ALTGR_MASK;
235+
meta |= RALT_MASK;
236236
scode &= ~SCANCODE_ALTGR_MASK;
237237
}
238238
android.util.Log.e(TAG, "Will send scanCode: " + scode + " with meta: " + meta);

eclipse_projects/bVNC/src/com/iiordanov/bVNC/input/RemoteVncKeyboard.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
4141
switch (evt.getScanCode()) {
4242
case SCAN_ESC: key = 0xff1b; break;
4343
case SCAN_LEFTCTRL:
44-
case SCAN_RIGHTCTRL:
4544
hardwareMetaState &= ~CTRL_MASK;
4645
break;
46+
case SCAN_RIGHTCTRL:
47+
hardwareMetaState &= ~RCTRL_MASK;
48+
break;
4749
case SCAN_F1: keysym = 0xffbe; break;
4850
case SCAN_F2: keysym = 0xffbf; break;
4951
case SCAN_F3: keysym = 0xffc0; break;
@@ -66,7 +68,7 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
6668
hardwareMetaState &= ~ALT_MASK;
6769
break;
6870
case KeyEvent.KEYCODE_ALT_RIGHT:
69-
hardwareMetaState &= ~ALT_MASK;
71+
hardwareMetaState &= ~RALT_MASK;
7072
break;
7173
}
7274
}
@@ -121,11 +123,12 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
121123
// through to the VNC server so that they get handled there, but strip
122124
// them from the character before retrieving the Unicode char from it.
123125
// Don't clear Shift, we still want uppercase characters.
124-
int metaMask = ( 0x00007000 | 0x00070000 ); // KeyEvent.META_CTRL_MASK | KeyEvent.META_META_MASK
125-
// We still want alt-key combinations to give us symbols, so we only strip out KeyEvent.META_ALT_MASK
126-
// if we've decided to send out ALT as a separate key modifier over.
127-
if ((metaState & ALT_MASK) != 0) {
128-
metaMask |= 0x00000032;
126+
int metaMask = (0x00007000 | 0x00070000); // KeyEvent.META_CTRL_MASK | KeyEvent.META_META_MASK
127+
// When events come from a default hardware keyboard, we still want alt-key combinations to
128+
// give us symbols, so we only strip out KeyEvent.META_ALT_MASK only if we've decided to send
129+
// over ALT as a separate key modifier in convertEventMetaState().
130+
if ((metaState & ALT_MASK) != 0 || (metaState & RALT_MASK) != 0) {
131+
metaMask |= 0x00000032; /* KeyEvent.META_ALT_MASK */
129132
}
130133
KeyEvent copy = new KeyEvent(evt.getDownTime(), evt.getEventTime(), evt.getAction(),
131134
evt.getKeyCode(), evt.getRepeatCount(), evt.getMetaState() & ~metaMask,
@@ -140,9 +143,11 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
140143
switch (evt.getScanCode()) {
141144
case SCAN_ESC: keysym = 0xff1b; break;
142145
case SCAN_LEFTCTRL:
143-
case SCAN_RIGHTCTRL:
144146
hardwareMetaState |= CTRL_MASK;
145147
break;
148+
case SCAN_RIGHTCTRL:
149+
hardwareMetaState |= RCTRL_MASK;
150+
break;
146151
case SCAN_F1: keysym = 0xffbe; break;
147152
case SCAN_F2: keysym = 0xffbf; break;
148153
case SCAN_F3: keysym = 0xffc0; break;
@@ -165,7 +170,7 @@ public boolean processLocalKeyEvent(int keyCode, KeyEvent evt, int additionalMet
165170
hardwareMetaState |= ALT_MASK;
166171
break;
167172
case KeyEvent.KEYCODE_ALT_RIGHT:
168-
hardwareMetaState |= ALT_MASK;
173+
hardwareMetaState |= RALT_MASK;
169174
break;
170175
}
171176
}

eclipse_projects/bVNC/src/com/iiordanov/tigervnc/vncviewer/CConn.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -816,13 +816,10 @@ public void writePointerEvent(MotionEvent ev) {
816816
synchronized void writeModifiers(int newModifiers) {
817817
if ((newModifiers & RemoteKeyboard.CTRL_MASK) != (oldModifiers & RemoteKeyboard.CTRL_MASK))
818818
writeKeyEvent(0xffe3, (newModifiers & RemoteKeyboard.CTRL_MASK) != 0);
819-
819+
820820
if ((newModifiers & RemoteKeyboard.SHIFT_MASK) != (oldModifiers & RemoteKeyboard.SHIFT_MASK))
821821
writeKeyEvent(0xffe1, (newModifiers & RemoteKeyboard.SHIFT_MASK) != 0);
822-
823-
if ((newModifiers & RemoteKeyboard.META_MASK) != (oldModifiers & RemoteKeyboard.META_MASK))
824-
writeKeyEvent(0xffe7, (newModifiers & RemoteKeyboard.META_MASK) != 0);
825-
822+
826823
if ((newModifiers & RemoteKeyboard.ALT_MASK) != (oldModifiers & RemoteKeyboard.ALT_MASK))
827824
writeKeyEvent(0xffe9, (newModifiers & RemoteKeyboard.ALT_MASK) != 0);
828825
oldModifiers = newModifiers;

0 commit comments

Comments
 (0)