2

Background: I am trying to create a controller application for Google Glass with the ability to send swipes and taps by pressing a button on a bluetooth connected smartphone.

Current Status: I have been able to simulate these swipes and navigate in the application on Glass, however these swipes do not keep the display from turning off (since I am not actually touching the glass hardware, only calling my OnSwipeLeft, OnSwipeRight, etc. listeners).

Question: Is it possible to programmatically simulate tap and swipe touchpad events from a Google Glass Application, such that the screen will remain on and not dim?

afathman
  • 5,993
  • 2
  • 20
  • 28

4 Answers4

2

This is how I did it in Xamarin. It would be something similar in Java.

    private void issueKey(int keyCode)
    {
        Java.Lang.Process p = Java.Lang.Runtime.GetRuntime().Exec("input keyevent " + keyCode.ToString() + "\n");
    }
afathman
  • 5,993
  • 2
  • 20
  • 28
1

See my answer here, as it might solve your problem too: https://stackoverflow.com/a/21559601/3767

The code which let me brighten the screen when an Activity started is:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "My Tag");
wl.acquire();
//..screen will stay on during this section..
wl.release();
Community
  • 1
  • 1
Eric Levine
  • 13,536
  • 5
  • 49
  • 49
1

The touchpad is essentially a d-pad, so for the basic gestures of swiping up down left and right you can use shell commands

input keyevent 19

19 up 20 down 21 left 22 right 23 return 24 volume up 25 volume down 27 camera button

rAntonioH
  • 129
  • 2
  • 12
0

Afathman's answer is correct, but the syntax just needs a couple tweaks for Android. The following is the correct formatting:

 try {
        java.lang.Process p = java.lang.Runtime.getRuntime().exec("input keyevent " + Integer.toString(keyCode) + "\n");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Dan
  • 66
  • 5