Direction controls...
I'm not much up on my python/sockets, but I have a node script which I've extended to get cursor controls (left/right/up/down/click etc) working
Would you be able to extend yours to incorporate? They are really useful when using the built-in/downloaded Apps.
I see you already have getCursorSocket but are not yet using it?
In Node, I have a function for each direction/command, which runs:
var input_pointer_click = function(fn) {
input_pointer_send(function() {
pointer.send("type:click\n" + "\n\n");
}, fn);
};
var input_pointer_up = function(fn) {
input_pointer_send(function() {
pointer.send("type:button\n" + "name:UP\n" + "\n");
}, fn);
};
var input_pointer_down = function(fn) {
input_pointer_send(function() {
pointer.send("type:button\n" + "name:DOWN\n" + "\n");
}, fn);
};
var input_pointer_left = function(fn) {
input_pointer_send(function() {
pointer.send("type:button\n" + "name:LEFT\n" + "\n");
}, fn);
};
var input_pointer_right = function(fn) {
input_pointer_send(function() {
pointer.send("type:button\n" + "name:RIGHT\n" + "\n");
}, fn);
};
var input_pointer_back = function(fn) {
input_pointer_send(function() {
pointer.send("type:button\n" + "name:BACK\n" + "\n");
}, fn);
};
var input_pointer_disconnect = function(fn) {
if (pointer) {
pointer.close();
pointer = null;
};
if (typeof fn === 'function') {
fn(RESULT_OK);
}
};
var input_enter = function(fn) {
send_command("", "request", "ssap://com.webos.service.ime/sendEnterKey", null$
};
The scripts connect to the TV, run the direction command (which gets and then opens the pointer socket) and passes a command to it) - and then calls a disconnect on the socket
input_pointer_send is just issuing the commands to the opened socket.
pointer is declared globally as null, and then set once the pointer socket is opened and reset to null on disconnect
This will be coming in due course.
Added cursor.py, and updated remote.py to include sendEnterKey.
@Tenzer this is largely just hooking up cursor.py to the command line interface at this point as far as I can tell. Maybe you're interested?
@klattimer I had a quick go at this today, I could however not get the websocket connection for LGTVCursor set up. It seems like the LGTVCursor.__finalize callback never is called. Have you had this working at all?
@Tenzer not yet, I haven't had the time to look at it recently, I wrote the code a while back and had to dig it out from a couple of different places to push it up. I'll dig around on here and see if I can see why it's not triggered.
This would be an issue here I think.
def getCursorSocket(self, callback=None):
self.__send_command("request", "ssap://com.webos.service.networkinput/getPointerInputSocket", None, callback)
Maybe the address here is incorrect?
I got it working and I've made a PR with a new command for this in #147. The problem was the command getPointerInputSocket wasn't sent properly to the TV, which caused the callback to never be triggered.