LGWebOSRemote icon indicating copy to clipboard operation
LGWebOSRemote copied to clipboard

Direction controls...

Open ptruman opened this issue 5 years ago • 1 comments

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

ptruman avatar Aug 02 '20 12:08 ptruman

This will be coming in due course.

klattimer avatar Dec 31 '20 09:12 klattimer

Added cursor.py, and updated remote.py to include sendEnterKey.

klattimer avatar Dec 04 '23 07:12 klattimer

@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 avatar Dec 04 '23 08:12 klattimer

@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 avatar Dec 09 '23 21:12 Tenzer

@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.

klattimer avatar Dec 10 '23 11:12 klattimer

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? 

klattimer avatar Dec 10 '23 11:12 klattimer

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.

Tenzer avatar Dec 10 '23 21:12 Tenzer