Improve the win32 keyboard mapping.
- Prevent the ESC key from leaving the application. - Map the keyboard DELETE key like it should. - Map the keyboard +/= key to the + key and the _/- key to the - (US keyboard).
This commit is contained in:
parent
4c618f358f
commit
fd48f40889
3 changed files with 27 additions and 15 deletions
|
@ -65,6 +65,9 @@ Version 1.5 (2019-06-xx)
|
||||||
- Fix: Selecting an empty KML folder prevent to select the default embedded KML folder (Github Fix: #5)!
|
- Fix: Selecting an empty KML folder prevent to select the default embedded KML folder (Github Fix: #5)!
|
||||||
- Fix a crash with waveOutClose().
|
- Fix a crash with waveOutClose().
|
||||||
- Fix an issue with the Pan and zoom which was possible after closing the calc.
|
- Fix an issue with the Pan and zoom which was possible after closing the calc.
|
||||||
|
- Prevent the ESC key from leaving the application.
|
||||||
|
- Map the keyboard DELETE key like it should.
|
||||||
|
- Map the keyboard +/= key to the + key and the _/- key to the - (US keyboard).
|
||||||
|
|
||||||
|
|
||||||
Version 1.4 (2019-06-08)
|
Version 1.4 (2019-06-08)
|
||||||
|
@ -147,6 +150,7 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp") are embedded in this appli
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
- Make the regular (not keypad) '*', and '/' work (#6).
|
||||||
- In Chrome OS:
|
- In Chrome OS:
|
||||||
- The timezone seems to be GMT (localtime_r not right?)!
|
- The timezone seems to be GMT (localtime_r not right?)!
|
||||||
- sometimes there is no OK button in the KML Script Compilation Result.
|
- sometimes there is no OK button in the KML Script Compilation Result.
|
||||||
|
|
|
@ -60,14 +60,15 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||||
bitmapMainScreen = Bitmap.createBitmap(displayMetrics.widthPixels, displayMetrics.heightPixels, Bitmap.Config.ARGB_8888);
|
bitmapMainScreen = Bitmap.createBitmap(displayMetrics.widthPixels, displayMetrics.heightPixels, Bitmap.Config.ARGB_8888);
|
||||||
bitmapMainScreen.eraseColor(Color.BLACK);
|
bitmapMainScreen.eraseColor(Color.BLACK);
|
||||||
|
enableZoomKeyboard = false;
|
||||||
|
|
||||||
vkmap = new HashMap<>();
|
vkmap = new HashMap<>();
|
||||||
//vkmap.put(KeyEvent.KEYCODE_BACK, 0x08); // VK_BACK
|
//vkmap.put(KeyEvent.KEYCODE_BACK, 0x08); // VK_BACK
|
||||||
vkmap.put(KeyEvent.KEYCODE_TAB, 0x09); // VK_TAB
|
vkmap.put(KeyEvent.KEYCODE_TAB, 0x09); // VK_TAB
|
||||||
vkmap.put(KeyEvent.KEYCODE_ENTER, 0x0D); // VK_RETURN
|
vkmap.put(KeyEvent.KEYCODE_ENTER, 0x0D); // VK_RETURN
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, 0x0D); // VK_RETURN
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, 0x0D); // VK_RETURN
|
||||||
//vkmap.put(KeyEvent.KEYCODE_DEL, 0x2E); // VK_DELETE
|
vkmap.put(KeyEvent.KEYCODE_DEL, 0x08); // VK_BACK
|
||||||
vkmap.put(KeyEvent.KEYCODE_DEL, 0x08); // VK_DELETE
|
vkmap.put(KeyEvent.KEYCODE_FORWARD_DEL, 0x2E); // VK_DELETE
|
||||||
vkmap.put(KeyEvent.KEYCODE_INSERT, 0x2D); // VK_INSERT
|
vkmap.put(KeyEvent.KEYCODE_INSERT, 0x2D); // VK_INSERT
|
||||||
vkmap.put(KeyEvent.KEYCODE_SHIFT_LEFT, 0x10); // VK_SHIFT
|
vkmap.put(KeyEvent.KEYCODE_SHIFT_LEFT, 0x10); // VK_SHIFT
|
||||||
vkmap.put(KeyEvent.KEYCODE_SHIFT_RIGHT, 0x10); // VK_SHIFT
|
vkmap.put(KeyEvent.KEYCODE_SHIFT_RIGHT, 0x10); // VK_SHIFT
|
||||||
|
@ -115,16 +116,6 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
vkmap.put(KeyEvent.KEYCODE_X, 0x58); // X
|
vkmap.put(KeyEvent.KEYCODE_X, 0x58); // X
|
||||||
vkmap.put(KeyEvent.KEYCODE_Y, 0x59); // Y
|
vkmap.put(KeyEvent.KEYCODE_Y, 0x59); // Y
|
||||||
vkmap.put(KeyEvent.KEYCODE_Z, 0x5A); // Z
|
vkmap.put(KeyEvent.KEYCODE_Z, 0x5A); // Z
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_0, 0x60); // VK_NUMPAD0
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_1, 0x61); // VK_NUMPAD1
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_2, 0x62); // VK_NUMPAD2
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_3, 0x63); // VK_NUMPAD3
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_4, 0x64); // VK_NUMPAD4
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_5, 0x65); // VK_NUMPAD5
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_6, 0x66); // VK_NUMPAD6
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_7, 0x67); // VK_NUMPAD7
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_8, 0x68); // VK_NUMPAD8
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_9, 0x69); // VK_NUMPAD9
|
|
||||||
vkmap.put(KeyEvent.KEYCODE_0, 0x60); // VK_NUMPAD0
|
vkmap.put(KeyEvent.KEYCODE_0, 0x60); // VK_NUMPAD0
|
||||||
vkmap.put(KeyEvent.KEYCODE_1, 0x61); // VK_NUMPAD1
|
vkmap.put(KeyEvent.KEYCODE_1, 0x61); // VK_NUMPAD1
|
||||||
vkmap.put(KeyEvent.KEYCODE_2, 0x62); // VK_NUMPAD2
|
vkmap.put(KeyEvent.KEYCODE_2, 0x62); // VK_NUMPAD2
|
||||||
|
@ -135,9 +126,21 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
vkmap.put(KeyEvent.KEYCODE_7, 0x67); // VK_NUMPAD7
|
vkmap.put(KeyEvent.KEYCODE_7, 0x67); // VK_NUMPAD7
|
||||||
vkmap.put(KeyEvent.KEYCODE_8, 0x68); // VK_NUMPAD8
|
vkmap.put(KeyEvent.KEYCODE_8, 0x68); // VK_NUMPAD8
|
||||||
vkmap.put(KeyEvent.KEYCODE_9, 0x69); // VK_NUMPAD9
|
vkmap.put(KeyEvent.KEYCODE_9, 0x69); // VK_NUMPAD9
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_0, 0x60); // VK_NUMPAD0
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_1, 0x61); // VK_NUMPAD1
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_2, 0x62); // VK_NUMPAD2
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_3, 0x63); // VK_NUMPAD3
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_4, 0x64); // VK_NUMPAD4
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_5, 0x65); // VK_NUMPAD5
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_6, 0x66); // VK_NUMPAD6
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_7, 0x67); // VK_NUMPAD7
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_8, 0x68); // VK_NUMPAD8
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_9, 0x69); // VK_NUMPAD9
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_MULTIPLY, 0x6A); // VK_MULTIPLY
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_MULTIPLY, 0x6A); // VK_MULTIPLY
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_ADD, 0x6B); // VK_ADD
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_ADD, 0x6B); // VK_ADD
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_EQUALS, 0x6B); // VK_ADD
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_SUBTRACT, 0x6D); // VK_SUBTRACT
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_SUBTRACT, 0x6D); // VK_SUBTRACT
|
||||||
|
vkmap.put(KeyEvent.KEYCODE_MINUS, 0x6D); // VK_SUBTRACT
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_DOT, 0x6E); // VK_DECIMAL
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_DOT, 0x6E); // VK_DECIMAL
|
||||||
vkmap.put(KeyEvent.KEYCODE_NUMPAD_DIVIDE, 0x6F); // VK_DIVIDE
|
vkmap.put(KeyEvent.KEYCODE_NUMPAD_DIVIDE, 0x6F); // VK_DIVIDE
|
||||||
// vkmap.put(KeyEvent.KEYCODE_SEMICOLON, 0xBA); // VK_OEM_1 (:);)
|
// vkmap.put(KeyEvent.KEYCODE_SEMICOLON, 0xBA); // VK_OEM_1 (:);)
|
||||||
|
@ -225,11 +228,13 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
|
||||||
Integer windowsKeycode = vkmap.get(keyCode);
|
Integer windowsKeycode = vkmap.get(keyCode);
|
||||||
if (windowsKeycode != null)
|
if (windowsKeycode != null) {
|
||||||
NativeLib.keyDown(windowsKeycode);
|
NativeLib.keyDown(windowsKeycode);
|
||||||
else
|
} else
|
||||||
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
|
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
|
||||||
}
|
}
|
||||||
|
if(keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
|
return true;
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +247,8 @@ public class MainScreenView extends PanAndScaleView {
|
||||||
else
|
else
|
||||||
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
|
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
|
||||||
}
|
}
|
||||||
|
if(keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
|
return true;
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class PanAndScaleView extends View {
|
||||||
protected boolean allowDoubleTapZoom = true;
|
protected boolean allowDoubleTapZoom = true;
|
||||||
protected boolean fillBounds = false;
|
protected boolean fillBounds = false;
|
||||||
protected boolean enablePanAndScale = false;
|
protected boolean enablePanAndScale = false;
|
||||||
|
protected boolean enableZoomKeyboard = true;
|
||||||
|
|
||||||
protected Paint paint = null;
|
protected Paint paint = null;
|
||||||
protected OnTapListener onTapDownListener;
|
protected OnTapListener onTapDownListener;
|
||||||
|
@ -452,7 +453,7 @@ public class PanAndScaleView extends View {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
if(enablePanAndScale && !fillBounds) {
|
if(enableZoomKeyboard && enablePanAndScale && !fillBounds) {
|
||||||
char character = (char) event.getUnicodeChar();
|
char character = (char) event.getUnicodeChar();
|
||||||
if (character == '+') {
|
if (character == '+') {
|
||||||
scaleByStep(scaleStep, getWidth() / 2.0f, getHeight() / 2.0f);
|
scaleByStep(scaleStep, getWidth() / 2.0f, getHeight() / 2.0f);
|
||||||
|
|
Loading…
Reference in a new issue