@@ -336,7 +336,7 @@ private void printConfig(EGL10 egl, EGLDisplay display,
336
336
337
337
public SDLSurfaceView (Activity act , String argument ) {
338
338
super (act );
339
-
339
+ Log . i ( "python" , String . format ( "I'm alive!!" ));
340
340
SDLSurfaceView .instance = this ;
341
341
342
342
mActivity = act ;
@@ -351,6 +351,10 @@ public SDLSurfaceView(Activity act, String argument) {
351
351
352
352
PowerManager pm = (PowerManager ) act .getSystemService (Context .POWER_SERVICE );
353
353
wakeLock = pm .newWakeLock (PowerManager .SCREEN_BRIGHT_WAKE_LOCK , "Screen On" );
354
+ requestFocus ();
355
+ Log .i ("python" , String .format ("Focus is requested!!" ));
356
+ setFocusable (true );
357
+ setFocusableInTouchMode (true );
354
358
}
355
359
356
360
@@ -943,7 +947,7 @@ public boolean onTouchEvent(final MotionEvent event) {
943
947
944
948
@ Override
945
949
public boolean onKeyDown (int keyCode , final KeyEvent event ) {
946
- // Log.i("python", String.format("key down %d", keyCode));
950
+ Log .i ("python" , String .format ("key down %d" , keyCode ));
947
951
if (mInputActivated && nativeKey (keyCode , 1 , event .getUnicodeChar ())) {
948
952
return true ;
949
953
} else {
@@ -953,13 +957,39 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
953
957
954
958
@ Override
955
959
public boolean onKeyUp (int keyCode , final KeyEvent event ) {
956
- // Log.i("python", String.format("key up %d", keyCode));
960
+ Log .i ("python" , String .format ("key up %d" , keyCode ));
957
961
if (mInputActivated && nativeKey (keyCode , 0 , event .getUnicodeChar ())) {
958
962
return true ;
959
963
} else {
960
964
return super .onKeyUp (keyCode , event );
961
965
}
962
966
}
967
+
968
+ @ Override
969
+ public boolean onKeyMultiple (int keyCode , int count , KeyEvent event ){
970
+ String keys = event .getCharacters ();
971
+ char [] keysBuffer = new char [keys .length ()];
972
+ if (keyCode == 0 ){
973
+ // FIXME: here is hardcoed value of "q" key
974
+ // on hacker's keyboard. It is passed to
975
+ // nativeKey function to get it worked if
976
+ // we get 9 and some non-ascii characters
977
+ // but it my cause some odd behaviour
978
+ keyCode = 45 ;
979
+ }
980
+
981
+ if (mInputActivated ){
982
+ keys .getChars (0 , keys .length (), keysBuffer , 0 );
983
+ for (char c : keysBuffer ){
984
+ //Log.i("python", "Char from multiply " + (int) c);
985
+ // Calls both up/down events to emulate key pressing
986
+ nativeKey (keyCode , 1 , (int ) c );
987
+ nativeKey (keyCode , 0 , (int ) c );
988
+ }
989
+ }
990
+
991
+ return true ;
992
+ }
963
993
964
994
static void activateInput () {
965
995
mInputActivated = true ;
0 commit comments