yangweigbh / Libgdx-CardBoard-Extension

Android CardBoard SDK development using Libgdx
67 stars 16 forks source link

onCardboardTrigger doesn't work #7

Open snapfractalpop opened 8 years ago

snapfractalpop commented 8 years ago

Steps to reproduce:

Have you gotten this to work? If so, is there any other setup necessary? I have used the trigger in the google cardboard sdk sample (Treasure Hunt) so I know my cardboard device is not the issue.

EtK2000 commented 7 years ago

Did the trigger work for you in the sdk sample? Also, the trigger is the magnet, not touch, but there is a function to allow touch to work too. Keep in mind that some devices don't sense the magnet well.

snapfractalpop commented 7 years ago

@EtK2000, the trigger worked in the android sdk sample, but not in the sample provided here. Have you gotten it to work?

snapfractalpop commented 7 years ago

@EtK2000, I should mention, my cardboard device is a version 2 device, and doesn't use the magnet for the trigger. It uses a screen tap which should be interpretted as a trigger event. This works out of the box in the Cardboard SDK sample. I have found that in decompiled CardboardActivity.class, the default value for convertTapIntoTriggerEnabled is true:

private` boolean convertTapIntoTriggerEnabled = true;

But screen taps do not seem to work. Is there possibly an additional step that I'm overlooking, such as setting a listener?

snapfractalpop commented 7 years ago

Update:

By adding the following code at the start of the create() method in CardBoardDemo.java (at line 49), it somehow fixes the issue. I suspect that somewhere, the onTouch() method of the default OnTouchListener bound to the touch events on the view is returning true, and not allowing further handling of the event. I don't know where this is, but this cheap hack might provide a clue:

        graphics.getView().setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });

This code attaches a listener that does nothing, but it's onTouch() method returns false. If changed to return true, the onCardboardTrigger() method doesn't work.