Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MouseControl continuously requesting pointer input socket. #65

Open
alexey-odintsov opened this issue Aug 5, 2015 · 1 comment
Open

Comments

@alexey-odintsov
Copy link

I'm working with Android app that translates Gyroscope data to TV cursor movements.
You can find test source code at https://github.com/alexey-odintsov/MouseSocketTest (it's short).

Currently I'm migrating project from ConnectSDK 1.4 to 1.5 Lite and encountered a problem:
Every time gyroscope data comes my code checks MouseControl availability and invokes move method:

public class App extends Application {
    public static ConnectableDevice tv;

    // return MouseControl
    public static MouseControl getMouse() {
        if (tv != null && tv.isConnected()) {
            return tv.getCapability(MouseControl.class);
        } else {
            return null;
        }
    }
    ...
}

class MySensorsListener implements SensorEventListener {
    // this method is invoked continuously every N millisecond
    public void onSensorChanged(SensorEvent event) {
        ...
        if (App.getMouse() != null) {
            App.getMouse().move(dx, dy);
        }
    }
}

public class MainActivity extends AppCompatActivity {
    ...
    // connected to device
    public void onDeviceReady(ConnectableDevice device) {
        if (App.getMouse() != null) {
            App.getMouse().connectMouse();
        }
    }
}

With ConnectSDK 1.4.2 this code works great, but with ConnectSDK 1.5 mouse movements sometimes don't work.

It seems that mouseSocket is not ready and it's created every time move method invoked.

Normal working socket logs are:

webOS Socket [IN] : {"type":"hello","payload":{...}}
webOS Socket [OUT] : {"type":"register","id":3,"payload":{...}}
webOS Socket [IN] : {"type":"registered","id":3,"payload":{...}}
webOS Socket [OUT] : {"type":"subscribe","id":"1","uri":"ssap:\/\/com.webos.service.ime\/registerRemoteKeyboard"}
webOS Socket [IN] : {"type":"response","id":"1","payload":{"subscribed":true}}
webOS Socket [OUT] : {"type":"request","id":"4","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [IN] : {"type":"response","id":"4","payload":{"socketPath":"wss://192.168.0..../netinput.pointer.sock","returnValue":true}}

Socket logs when mouse is not working:

webOS Socket [IN] : {"type":"hello","payload":{...}}
webOS Socket [OUT] : {"type":"register","id":3,"payload":{...}}
webOS Socket [IN] : {"type":"registered","id":3,"payload":{...}}
webOS Socket [OUT] : {"type":"subscribe","id":"1","uri":"ssap:\/\/com.webos.service.ime\/registerRemoteKeyboard"}
webOS Socket [IN] : {"type":"response","id":"1","payload":{"subscribed":true}}
webOS Socket [OUT] : {"type":"request","id":"4","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"5","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"6","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"7","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"8","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"9","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"10","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
webOS Socket [OUT] : {"type":"request","id":"11","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}
...
webOS Socket [OUT] : {"type":"request","id":"50","uri":"ssap:\/\/com.webos.service.networkinput\/getPointerInputSocket"}

I've found a workaround by exposing isMouseConnected API inside WebOSTVService class and updating MouseControl interface method signature:

public boolean isMouseConnected() {
        return mouseSocket != null && mouseSocket.isConnected();
}

And by adding checking to my code:

if (App.getMouse() != null && App.getMouse().isMouseConnected()) {
    App.getMouse().move(dx, dy);
}

But I believe there is something must be done with MouseControl socket creation logic.

@xuanhieu147
Copy link

did you find a way to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants