Pass the VR controller "back" button to the application on the Oculus Quest
This commit is contained in:
@@ -338,6 +338,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
// Setup
|
// Setup
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.v(TAG, "Manufacturer: " + Build.MANUFACTURER);
|
||||||
Log.v(TAG, "Device: " + Build.DEVICE);
|
Log.v(TAG, "Device: " + Build.DEVICE);
|
||||||
Log.v(TAG, "Model: " + Build.MODEL);
|
Log.v(TAG, "Model: " + Build.MODEL);
|
||||||
Log.v(TAG, "onCreate()");
|
Log.v(TAG, "onCreate()");
|
||||||
@@ -1260,7 +1261,17 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.equals("X96-W")) {
|
if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.equals("X96-W")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.startsWith("TV");
|
if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.startsWith("TV")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isVRHeadset() {
|
||||||
|
if (Build.MANUFACTURER.equals("Oculus") && Build.MODEL.startsWith("Quest")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getDiagonal()
|
public static double getDiagonal()
|
||||||
@@ -1454,15 +1465,20 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
|
if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
|
||||||
// on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
|
if (SDLActivity.isVRHeadset()) {
|
||||||
// they are ignored here because sending them as mouse input to SDL is messy
|
// The Oculus Quest controller back button comes in as source mouse, so accept that
|
||||||
if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
|
} else {
|
||||||
switch (event.getAction()) {
|
// on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
|
||||||
case KeyEvent.ACTION_DOWN:
|
// they are ignored here because sending them as mouse input to SDL is messy
|
||||||
case KeyEvent.ACTION_UP:
|
if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
|
||||||
// mark the event as handled or it will be handled by system
|
Log.v("SDL", "keycode is back or forward");
|
||||||
// handling KEYCODE_BACK by system will call onBackPressed()
|
switch (event.getAction()) {
|
||||||
return true;
|
case KeyEvent.ACTION_DOWN:
|
||||||
|
case KeyEvent.ACTION_UP:
|
||||||
|
// mark the event as handled or it will be handled by system
|
||||||
|
// handling KEYCODE_BACK by system will call onBackPressed()
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user