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

Device change button does not affect other connected devices #28

Open metrailer opened 4 years ago

metrailer commented 4 years ago

When using the device switch button on the MX Keys the MX Master 3 does not also switch devices or vice versa. Providing this option allows better swapping between devices.

arblackman commented 2 years ago

Ah. Ok. Im pretty sure that the commend you are sending via hidapitester is specifically for communicating the dongle.

Vid/pid 046D/C52B is the address of the dongle.

On Mon, 1 Nov 2021 at 19:29, Adrian Alexandrescu @.***> wrote:

Thank you arblackman for quick response :)

But , let me explain my situation.I am conected with MX3 mouse to PC2 via Bluetooth(I dont have a dongle inserted to PC2), and I want to send a command to dongle . This command will change the device back to PC1, and it looks like : "hidapitester.exe --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output "0x10,0x01,0x09,0x1c,0x00,0x00,0x00"

Unfortunately , I get an error like [image: image] https://user-images.githubusercontent.com/51136509/139727140-c9879381-ee25-4f35-b055-5b0b3772387b.png Ps: hidapitester.exe can be downloaded from here https://github.com/todbot/hidapitester/releases

My question is : why this error uccurs ? And how you can get rid of this error if you know ? :D . I see here , there are people which executed command succesfully from device2 and device1 and don't understand how is that possible.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Logitech/logi_craft_sdk/issues/28#issuecomment-956524874, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5IDLUBKNGRRX4SUZTZXEDUJ3TBRANCNFSM4I5HZXJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Seyphaton commented 2 years ago

Awesome detectives here :) I would love to see Logitechs helping hand here...

tsplat commented 2 years ago

I have a slightly different setup, using a Logitech M720 mouse and a K850 keyboard (sold as the MK850 mouse/keyboard set). They're both connected to System 1 using a single Logitech unifying receiver and System 2 using Bluetooth. Both systems are running Windows 10. The Bluetooth side requires long HID++ commands to initiate switching, which I figured out using this article: https://github.com/pwr-Solaar/Solaar/issues/1154. So, my commands turned out to be these:

Switch keyboard from System 1 to System 2: .\hidapitester.exe --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x08,0x11,0x01,0x00,0x00

Switch mouse from System 1 to System 2: .\hidapitester.exe --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x09,0x11,0x01,0x00,0x00

Switch keyboard from System 2 to System 1: .\hidapitester.exe --vidpid 046D:B34D --usage 0x0202 --usagePage 0xFF43 --open --length 19 --send-output 0x11,0x00,0x08,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

Switch mouse from System 2 to System 1: .\hidapitester.exe --vidpid 046D:B015 --usage 0x0202 --usagePage 0xFF43 --open --length 19 --send-output 0x11,0x00,0x09,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

The above mouse commands always work fine, and the command for switching the keyboard to System 2 always works fine too, but I'm having some problems with the keyboard when switching from System 2 to System 1 only. It works with no issues most of the time. However, every once it a while, after running hidapitester.exe to switch the keyboard back to System 1, the keyboard will immediately "bounce" back to System 2. This is visible by observing the white "Easy Switch" buttons on the keyboard. I'll see the "1" key solidly illuminate briefly followed by "2" flashing once and then solidly illuminating again. A few successive retries typically yield the same "bouncing" behavior, and then the normal switching behavior will resume and things will be fine again for a while.

That's a bit irritating and I never have this problem with the mouse, or when the keyboard switches to System 2. An easy workaround is just to send many of the same hidapitester.exe commands to switch the keyboard. Unfortunately, an even bigger problem is that the keyboard will eventually get "broken" if the "bouncing" behavior happens over the course of many system switches. The "shift" key will get stuck on System 2 only. This is not visible on the Windows 10 On-Screen Keyboard and the caps-lock key can't be used to fix it. The only fix that I've found is to reboot System 2.

I used Wireshark to try to figure out what is going on during a normal "Logitech Flow" keyboard switch on the Bluetooth-connected System 2, just to see if there is more involved than just sending the above control commands. The only thing I noticed is there there are 3 USB URB_INTERRUPT packets sent to the keyboard right before the system switch control command gets sent. Each one has a Packet Data Length of 0. I'm thinking that these may prep the keyboard for the switch to System 1 by telling it to flush any remaining input (or something like that) but I'm not sure. Also, I don't know how to send those URB_INTERRUPT packets with hidapitester.exe.

Has anyone else experienced this keyboard "bouncing" and "shift-key-stuck" behavior? Have you had any luck with sending URB_INTERRUPT packets to fix it? I thought that maybe the keyboard has trouble switching when it is in use (for Bluetooth only), so I bound the switching script to a mouse button to ensure the keyboard remained idle before and during the switch. However, I still observe the same issues after a while. I also thought that this may be a driver issue on System 2. However, using the keyboard switching buttons never causes the bad behavior and the mouse always switches fine with hidapitester.exe, so I'm hoping that there is a way to fix the problem by sending additional USB flush/quiesce/interrupt commands before/during the keyboard switch to System 1.

If anyone has any ideas, please let me know. Also, thanks for all the work put into this so far and all the detailed posts. I would not have gotten this far without them.

dnlw07 commented 2 years ago

@tsplat unfortunately, I also face similar issue. I don't know better way than sending switch command multiple times.

tsplat commented 2 years ago

@dnlw07 - Thanks for your reply. Have you also run into the "shift-key-stuck" problem?

dnlw07 commented 2 years ago

@tsplat No, I don't. Only issue I face is that during the mouse/keyboards switch there is 20% chance that the channel will bounce back. I can live with that but its annoying.

KonradFoit commented 2 years ago

Hello all, So a little backstory: I've got Logitech MX Ergo for a few years now, and I recently bought MX Keys with switching hosts in mind, to have a nice setup with 3 monitors, mouse and keyboard which I would be able to switch with one click between my private PC and company issued laptop for work. Oh boy, was I disappointed that this is impossible with stock Logitech software. There is Flow, but I am constantly connected via VPN on my laptop and with that, Flow simply doesn't work. Not to mention that there isn't even an option to launch a batch file upon switch or basically perform any additional action, so switching monitors was never an option. So I started searching and got here. With quite a bit of inspiration from you guys, I was able to put together a neat little python script that achieves everything I wanted. Well, almost, because firstly I found out that two of my old monitors are damaged, and don't react to control signals (even hardware buttons), and later that I am only able to use MX Keys easy switch keys, not the MX Ergo switch button on top (explained in my repo). However, I'm still considering this as a win, and I'm totally happy with it. I even find it useful to be able to just switch the mouse for a moment, to switch music on the PC or whatever. And here it goes, here's my script: https://github.com/KonradFoit/logi-kvm Feel free to ask questions, use it anyway you want. If you'll find some other cool features of some other Logitech devices, feel free to reach me or even make a pull request. Cheers!

JLeikam commented 2 years ago

Great thread! Thanks everyone for posting. I managed to get this working for my setup and wanted to post my findings in case it helps someone else with a similar setup:

Keyboard: Logitech Ergo K860  Mouse: Logitech MX Vertical

My use case is switching both my keyboard and mouse between two systems using a script. Both systems have a logitech unifying receiver which I seemed to have better luck with instead of bluetooth.


Here are the commands I used:

On my secondary system, I have a script to switch to my first system. The script runs the following commands: Swap to Channel 1 of Logitech Ergo K860 Keyboard: ./hidapitester --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output "0x10,0x01,0x09,0x1c,0x00,0x00,0x00"

Swap to Channel 1 of MX Vertical Mouse: ./hidapitester --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output "0x10,0x02,0x0c,0x1c,0x00,0x00,0x00"

Then on my first system, I have a script to switch to the secondary one: Swap to Channel 2 of Logitech Ergo K860 Keyboard: ./hidapitester --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output "0x10,0x01,0x09,0x1c,0x01,0x00,0x00"

Swap to Channel 2 of MX Vertical Mouse: ./hidapitester --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output "0x10,0x02,0x0c,0x1c,0x01,0x00,0x00"


Here's a rough breakdown of the anatomy of the --send-output part of the command (note the examples below are switching to channel 1):

Logitech Ergo K860

Header Receiver Slot ID Const/Magic Number Target Channel Padding Padding
0x10 0x01 0x09 0x1c 0x00 0x00 0x00

MX Vertical

Header Receiver Slot ID Const/Magic Number Target Channel Padding Padding
0x10 0x02 0x0c 0x1c 0x00 0x00 0x00

Some notes:

Hope that helps!

KonradFoit commented 2 years ago

@JLeikam if you'll look at readme in me repo, you'll find that what you refer to as "ID" in this message is the number of the CHANGE HOST feature of the device. You can find that easily, e.g. with Solaar by running solaar show and look for CHANGE HOST.

JLeikam commented 2 years ago

@KonradFoit Nice! That's good to know. In my case, I was switching between windows and mac, so wasn't able to use Solaar.

vp777 commented 1 year ago

Adding to what @JLeikam said, the id for MX Master 3 is: 0x0a

GaMartinelli commented 1 year ago

Perhaps I misunderstood how this is supposed to work.

Running hidapitester from RECEIVER_2, I can switch MX Anywhere 3 TO RECEIVER_1 or RECEIVER_3, but I can't switch FROM RECEIVER_1 or RECEIVER_3.

What I'm trying to do, if I have MX Keys and MX Mouse set to RECEIVER_2, once I switch the keyboard using the easy keys, I want to bind a command to some other key to take control of the mouse as well, is that possible?

Also, seems like the values for my MX Anywhere 3 is different from the one posted before, so if anyone needs, it's 0x10,0x02,0x0a,0x1e,0x00,0x00,0x00 0x10,0x02,0x0a,0x1e,0x01,0x00,0x00 0x10,0x02,0x0a,0x1e,0x02,0x00,0x00

OliverPearmain commented 1 year ago

Amazing insights here, thank you to all that have contributed.

Question, does this method work when your Logitech device(s) are connected via bluetooth or does it only work when using the a Bolt or Unifying receiver?

bthamburg commented 1 year ago

...I'm having some problems with the keyboard when switching from System 2 to System 1 only. It works with no issues most of the time. However, every once it a while, after running hidapitester.exe to switch the keyboard back to System 1, the keyboard will immediately "bounce" back to System 2. ... If anyone has any ideas, please let me know.

I've the same. "busdog" tells me to send the command twice, if I press easy switch. So I send all command double time like:

Switch mouse from 2->1 (one line): hidapitester --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x09,0x11,0x00,0x00,0x00 --length 7 --send-output 0x10,0x02,0x09,0x11,0x00,0x00,0x00

Z-bit-Code commented 1 year ago

Hi, I'm new here and have literally no experience in what You are doing, Did anybody manage to create a working solution for both Win11 and Linux? I would love to switch both devices back and forth with only one keystroke on the MX keys.

meliksah commented 1 year ago

Hi community.

I created cross platform application for linux macos and windows to change source whenever go to edge of screen. It is creating system tray icon and you can activate or do the settings from there. You can emulate mouse movement for not sleeping even you can sync your clipboard from your local network as well. I hope it helps everyone

https://github.com/meliksah/lcs

happy coding :)

executables are in here: https://github.com/meliksah/lcs/releases/tag/v0.0.2

Q3X8 commented 1 year ago

TIP FOR PEOPLE REPLACING DEVICES

My MX Vertical had a failing button so I replaced it with another one. Getting InputSwitcher working again was quite a pain but I finally figured it out. Even though I unpaired the old device and everything, it was still getting weird. I finally figured something out in BusDog: This was for the old mouse --send-output 0x10,0x01,0x0c,0x1e,0x01,0x00,0x00

I was having a hell of a time figuring stuff out. Big tip: When using BusDog, the only button you care about pushing is the easy switch button(s) I got the info not when I left my device but when I pushed the button to come back to it

Anyways, long story short, for whatever reason I had to change the second byte/chunk whatever from 0x01 to 0x03

and I changed the 4th byte but I'm not 100% sure I had to, but I'm over testing it. Hopefully this saves someone else a couple hours old --send-output 0x10,0x01,0x0c,0x1e,0x01,0x00,0x00 new --send-output 0x10,0x03,0x0c,0x1a,0x01,0x00,0x00

Someone should be a champ and get the IDs of all the Logitech products. ..maybe they should get paid for doing that. Seems like a perfect task for an employee of Logitech. Not like they have access to any of the devices or anything right? Maybe wrap all this in a nice little program for their paying customers. smh

nefricore commented 10 months ago

Massive thanks to everyone involved in this!

Complete newbie in this area, so after struggling a bit with figuring it out, I thought of leaving my setup here in case anyone finds it useful:

PC 1: desktop, Win 10, regular Logi Options+, via Logi Bolt PC 2: laptop behind VPN + proxy, Win 10, the offline version of Logi Options+ with Flow (which can't connect because of the VPN I'm guessing), via Bluetooth Peripherals: MX Master 3S + MX Keys S

marcelhoffs has left some very useful directions about Bluetooth connections at the end of his readme at: https://github.com/marcelhoffs/input-switcher . I took the id for the mouse from there and it worked right away via the dongle. However I couldn't find any info about the id of the keyboard (the id for the MX Keys didn't do the trick). Since I don't have a Linux machine, I setup Flow with a third PC and traced it using Wireshark and USBPcap. You can filter by usb.data_fragment to get what's being sent. One of the first entries contained the id for the MX Keys S which for added confusion turned out to be the same as the id for the mouse O.o.

So PC1 to PC2 turned out to be: rem Switch MX Master 3S, Logi Bolt, slot 2, to channel 1 .\hidapitester.exe --vidpid 046D:C548 --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x0a,0x1e,0x00,0x00,0x00

rem Switch MX Keys S, Logi Bolt, slot 3, to channel 1 .\hidapitester.exe --vidpid 046D:C548 --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x0a,0x1a,0x00,0x00,0x00

The first index in the Logi Bolt wasn't in use probably as a result of all the switching, reconnecting and testing. The 4th byte seems to have several valid values so literally the only meaningful difference was the position in the Logi Bolt (the 2nd byte).

The reverse direction was trickier. I followed the same logic however instead of slots there are different Bluetooth pseudo devices. The slot byte seems irrelevant. I used hidapitester.exe --list-detail to get the ids for the Bluetooth devices so the result came out as:

rem Switch MX Master 3S, via Bluetooth, slot N/A, to channel 2 .\hidapitester.exe --vidpid 046D:B034 --usage 0x0202 --usagePage 0xff43 --open --length 11 --send-output 0x11,0x00,0x0a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

rem Switch MX Keys S, via Bluetooth, slot N/A, to channel 2 .\hidapitester.exe --vidpid 046D:B378 --usage 0x0202 --usagePage 0xff43 --open --length 11 --send-output 0x11,0x00,0x0a,0x1a,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

pleshakovalexander commented 9 months ago

I have same issue with MX ergo mouse and Ergo K860 keyboard

davide-stefanini commented 4 months ago

Hey @nefricore, I managed to switch the keyboard (MX Keys S) following your message, but I'm having trouble finding the id for the mouse (I have a MX Anywhere 3S). Looking at your commands it seems the device id is the third value of the string, but how did you find it? My keyboard value is 0x0a, I tried every value from 0x00 to 0x1e and still nothing... Is there a way to find out that value?

nefricore commented 4 months ago

Hey @davide-stefanini , I came across three different methods to get the ID:

I hope that helps.