Skip to content

Commit

Permalink
Resolve error with keycodes
Browse files Browse the repository at this point in the history
  • Loading branch information
downthecrop committed Feb 10, 2022
1 parent d5f9db0 commit 1793c7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public boolean onTouch(View v, MotionEvent e) {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN){
KeyEncoder.sendEncodedChar((char)event.getUnicodeChar());
KeyEncoder.sendEncodedChar(event.getKeyCode(),(char)event.getUnicodeChar());
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public class KeyEncoder {
static char backspaceAndroid = 67;
static char backspaceUnicode = 8;

public static void sendEncodedChar(char in){
if(in == backspaceAndroid){
public static void sendEncodedChar(int inInt, char inChar){
if(inInt == backspaceAndroid){
AWTInputBridge.sendKey(backspaceUnicode,backspaceUnicode);
} else if(specialChars.contains(""+in)){
} else if(specialChars.contains(""+inChar)){
// Send special character to client
char c = in;
char c = inChar;
switch(c){
case '!':
c = '1';
Expand Down Expand Up @@ -89,21 +89,21 @@ public static void sendEncodedChar(char in){
c = '\\';
break;
}
if(c != in){
if(c != inChar){
AWTInputBridge.sendKey(modifier,modifier);
}
AWTInputBridge.sendKey(c,c);
} else if(Character.isDigit(in)){
AWTInputBridge.sendKey(in,in);
} else if (in == Character.toUpperCase(in)){
} else if(Character.isDigit(inChar)){
AWTInputBridge.sendKey(inChar,inChar);
} else if (inChar == Character.toUpperCase(inChar)){
// We send F12 as a modifier to avoid needing to worry about shift.
// Client takes this modifier and does a toUpperCase().
AWTInputBridge.sendKey(modifier,modifier);
AWTInputBridge.sendKey(Character.toUpperCase(in),Character.toUpperCase(in));
} else if(in == Character.toLowerCase(in)){
AWTInputBridge.sendKey(Character.toUpperCase(in),Character.toUpperCase(in));
AWTInputBridge.sendKey(Character.toUpperCase(inChar),Character.toUpperCase(inChar));
} else if(inChar == Character.toLowerCase(inChar)){
AWTInputBridge.sendKey(Character.toUpperCase(inChar),Character.toUpperCase(inChar));
} else {
AWTInputBridge.sendKey(in,in);
AWTInputBridge.sendKey(inChar,inInt);
}
}
}

0 comments on commit 1793c7c

Please sign in to comment.