Logitech / logi_craft_sdk

Provide (API) SDK specifications to map your app functions to Logitech Craft dial controller called "Crown".
575 stars 110 forks source link

unclear what is required for tool options overlay to appear #23

Open LordLyng opened 5 years ago

LordLyng commented 5 years ago

I've been oweking on an VS Code extension utilizing the Craft. I have however encoutnered an issue where the tool options overlay aren't diplayed on touch events.

defaults.json:

{
    "GUID": "82df029a-a6c0-4559-95b2-09b50b2bb0ee",
    "info": {
        "name": "Visual Studio Code",
        "publisher": "Microsoft",
        "version": "1.0",
        "win_name": "Code.exe",
        "mac_bundle": "",
        "mac_path": "",
        "mac_paths": [
            {
                "path": "",
                "mac_minimum_supported_version": "0.0.0",
                "mac_maximum_supported_version": "*.*.*"
            }
        ],
        "win_minimum_supported_version": "0.0.0",
        "win_maximum_supported_version": "*.*.*"
    },
    "crown": {
        "rotate": {
            "default_task": "changetoolvalue",
            "tasks": [
                "changetoolvalue"
            ],
            "short_list": [
                "changetoolvalue"
            ]
        },
        "press": {
            "default_task": "playpause",
            "tasks": [
                "playpause"
            ],
            "short_list": [
                "playpause"
            ]
        }
    }
}

tools.json:

{
    "GUID": "82df029a-a6c0-4559-95b2-09b50b2bb0ee",
    "tools": [
        {
            "name": "default",
            "enabled": true,
            "tool_options": [
                {
                    "index": 0,
                    "name": "fileSelector",
                    "image_file_path": "tabs.png",
                    "enabled": true,
                    "ratchet_enabled": true
                },
                {
                    "index": 1,
                    "name": "debug",
                    "image_file_path": "circular.png",
                    "enabled": true,
                    "ratchet_enabled": true
                }
            ]
        }
    ],
    "tasks": [
        {
            "name": "changetoolvalue",
            "win_id": "0x10064",
            "mac_id": 615
        }
    ]
}

don't mind the values they are literally palceholders for seing it work.

On my client i register my plugin, and then send a toolchange request to select the default tool. Touching the Crown doesn't display overlay and following turn events doesn't have a currnet_tool_option in it's task options

naokihada commented 5 years ago

Hi @LordLyng,

I cannot really tell only from manifest file. It's better to have communication (JSON messages) log attached.

To have overlay shows up, it needs a couple conditions.

Even flow would be following: 1) Plugin initiate to connect Send "register" message 2) LogiOption receive 1)'s message Generate session_id Send "register_ack" to plugin with session_id (GUID) 3) Plugin receive 2)'s message Send "tool_change" event with 2)'s session_id ex) {"message_type":"tool_change","session_id":"ba382f6b-444c-4613-9aaa-6bc83cb3dc4e","tool_id":"default"} note: sample session_id is randomly generated now.

LordLyng commented 5 years ago

Interestingly enough i initially gave up. I thought it was related to the focus manager in Options, since i supplied what i thought to be the correct exe name and PID but i noticed that options sent an activation message to my extension no matter which instance of VS code received focus.

After revisiting my code to create a communication log for this post, the overlay was working. It did however show up with "missing description" for all tool options. which i found weird since i did supply a language file.

This has led me to believe that maybe options caches plugins? So maybe the overlay wasn't showing because i had already loaded a previous version of the plugin where there were no more than one options per tool.

Is there any official guidelines as to what is needed for Options to reload the plugin correctly during development? IS it enough to edit the files? Should i remove the profile and install it again? Does it require Options to restart? When is the profiles loaded?

Furthermore, I've been snooping around in the default plugins that ship with options. Here i noticed that many of these supply a long list of tasks in tools.json - all these tasks seems to relate to some kind of system function as they are mapped with id's for both mac and windows. Is there any documentation available for what tasks are available and how they should be configured?

naokihada commented 5 years ago

You can make sure Logi Option restart following steps. I think it is easier than reinstalling.

Mac: 1) Stop deamon /bin/launchctl unload /Library/LaunchAgents/com.logitech.manager.daemon.plist

2) Start deamon /bin/launchctl load /Library/LaunchAgents/com.logitech.manager.daemon.plist

Win: 1) Stop Logitech Options related tasks from Task Manager Task Manager: Process Tab: Sort by Name: Seach for LogiOptions It might have a couple related tasks.

2) Start Logitech Option Open Logitech Option UI

ju2pom commented 5 years ago

You might have a look to a library I wrote in C# that should ease plugin development for the Craft: https://github.com/ju2pom/logicraftsdk.NET Let me know if you find it useful.