@@ -336,7 +336,7 @@ private void printConfig(EGL10 egl, EGLDisplay display,
336336
337337 public SDLSurfaceView (Activity act , String argument ) {
338338 super (act );
339-
339+ Log . i ( "python" , String . format ( "I'm alive!!" ));
340340 SDLSurfaceView .instance = this ;
341341
342342 mActivity = act ;
@@ -351,6 +351,10 @@ public SDLSurfaceView(Activity act, String argument) {
351351
352352 PowerManager pm = (PowerManager ) act .getSystemService (Context .POWER_SERVICE );
353353 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 );
354358 }
355359
356360
@@ -943,7 +947,7 @@ public boolean onTouchEvent(final MotionEvent event) {
943947
944948 @ Override
945949 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 ));
947951 if (mInputActivated && nativeKey (keyCode , 1 , event .getUnicodeChar ())) {
948952 return true ;
949953 } else {
@@ -953,13 +957,39 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
953957
954958 @ Override
955959 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 ));
957961 if (mInputActivated && nativeKey (keyCode , 0 , event .getUnicodeChar ())) {
958962 return true ;
959963 } else {
960964 return super .onKeyUp (keyCode , event );
961965 }
962966 }
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+ }
963993
964994 static void activateInput () {
965995 mInputActivated = true ;
0 commit comments