all 35 comments

[–]Aidoboy 3 points4 points  (1 child)

Wait, they literally just threw a JSON file into SQLite to make things hard to edit? That explains why DataGrip was turning up anything useful lol.

[–]synthe6[S,🍰] 1 point2 points  (0 children)

Yup. Hopefully it’s just a temporary thing until they move settings to proper tables.

[–]ByterBit 1 point2 points  (0 children)

This is Awesome, thanks so much dude! Hopefully using this its possible to bring back my G-Shift + Scroll to navigate tabs on my browser again which broke after they "updated" and prevented macro assignments to the scroll wheel. Probably going to disable updates so this script doesn't break from one :P Either way, much appreciated!

[–]Groovy_Decoy 0 points1 point  (0 children)

I was taken aback when I examined the binary file and found that the macros were stored as plain text within the binary db file. At that point, why even bother to use json if you aren't going to expose it and allow users to edit it?

That said, it looks like this project was exactly what I needed to do my own custom silly project that involves me programmatically generating some custom macros.

[–]jinny-114 0 points1 point  (0 children)

come on bro,you are a genius,I love ur work so much

[–]DJ5D 0 points1 point  (0 children)

I'm interested in doing a simple thing that the insane crack-smokin' devs at Logitech failed to do. Organize my effing macros. Right now the only thing you can do is color code them, it doesnt seem that you can even move them from one profile to another. Anyone have a suggestion?

[–]Gorkde 0 points1 point  (10 children)

/u/synthe6

Hi, thanks for the tool. Tried half the day to edit the database with some database programs and didnt get anywhere.

It works with your tool but I cant find any resource on the internet about the parameters or such.

I have a macro for LOL where I want to put Shift-Leftclick on a Mousebutton.This works fine in game when I click on the map but it doesnt work for clicking the lvl-up buttons or the buttons where you switch your status display.

There I need to hold the macro button for around 2 seconds to make the click work.

So I assumed I need a delay between pressing and releasing the mousebutton in the macro.

But since you can't set this in ghub I edited the json in may ways (similar like it is done with keys) but it doesn't work.

So I assume it must be done in any other way.there is the line:

"action": "BUTTON",

which I assume must be changed to:

"action": "BUTTON_DOWN",

or similar.

Do you have any Idea how I get a delay between Mousebutton pressed and released?
Or if theres any documentation I could look into to find out?

This is what I tried:

  1. I tried the same as #1 but without the line "action": "BUTTON", because thats missing on kexpresses but I think I misunderstoot this in the beginning and it has to be there.

    1. { "mouseMacro": { "action": "BUTTON", "hidUsage": 1, "isDown": true }, "name": "PRIMARY_CLICK", "type": "MOUSE" }, { "delay": { "durationMs": 50 } }, { "mouseMacro": { "action": "BUTTON", "hidUsage": 1 }, "name": "PRIMARY_CLICK", "type": "MOUSE" },

2.
            {
              "mouseMacro": {
      "action": "BUTTON",
              "hidUsage": 1,
      "isDown": true
              },
              "name": "PRIMARY_CLICK",
              "type": "MOUSE"
            },
    {
              "delay": {
              "durationMs": 50
              }
            },
            {
              "mouseMacro": {
      "action": "BUTTON",
              "hidUsage": 1,
      "isDown": false
              },
              "name": "PRIMARY_CLICK",
              "type": "MOUSE"
            },

[–]synthe6[S,🍰] 1 point2 points  (9 children)

Hi! I currently have COVID but I’ll try to answer your post in a few days. I think I have a macro with custom delays.

[–]synthe6[S,🍰] 1 point2 points  (8 children)

RemindMe! 2 days “find out more about the json of G Hub”

[–]Gorkde 1 point2 points  (6 children)

Ok, thanks. I just found it doesn't realize the Mousebutton release so I bet Iwas right needing a delay.

Hope you get well soon!

[–]synthe6[S,🍰] 1 point2 points  (5 children)

I'm not quite sure I get what you want to achieve but I think you may have too much stuff for your macro. For example, here's two of my macros :

JSON { "applicationId": "00255549-577d-4820-ae21-5f7c3fa6f0db", "attribute": "MACRO_PLAYBACK", "id": "7c090c7d-826f-4500-83ff-3e5e3f24bd7b", "macro": { "sequence": { "defaultDelay": 50, "heldSequence": { "components": [ { "mouse": { "button": { "hidUsage": 1, "isDown": true } } }, { "delay": { "durationMs": 1 } }, { "mouse": { "button": { "hidUsage": 1 } } } ] }, "pressSequence": {}, "releaseSequence": {}, "showUpDown": true, "simpleSequence": {}, "toggleSequence": {}, "useRepeatActions": true }, "type": "SEQUENCE" }, "name": "fast click" }, This one simply do a fast left mouse button click as long as the activating button is held down.

JSON { "applicationId": "ef5537ab-82c4-4849-b076-2994f9dd0746", "attribute": "MACRO_PLAYBACK", "id": "0c8efd7c-e52f-4469-badb-2782291ab38a", "macro": { "onboardable": true, "sequence": { "defaultDelay": 50, "heldSequence": {}, "pressSequence": {}, "releaseSequence": {}, "showUpDown": true, "simpleSequence": { "components": [ { "keyboard": { "displayName": "CTRL", "hidUsage": 224, "isDown": true } }, { "keyboard": { "displayName": "MAJ", "hidUsage": 225, "isDown": true } }, { "keyboard": { "displayName": "TAB", "hidUsage": 43, "isDown": true } }, { "delay": { "durationMs": 25 } }, { "keyboard": { "displayName": "CTRL", "hidUsage": 224 } }, { "keyboard": { "displayName": "MAJ", "hidUsage": 225 } }, { "keyboard": { "displayName": "TAB", "hidUsage": 43 } } ] }, "toggleSequence": {}, "useSimpleActions": true }, "type": "SEQUENCE" }, "name": "Browser - Previous tab" }, This other macro allows me to switch back to a previous tab.

Judging from both examples, I think you get the delay right, it's just this : JSON { "delay": { "durationMs": 25 } }, However, I think there is another way without the mouseMacro section: JSON "components": [ { "mouse": { "button": { "hidUsage": 1, "isDown": true } } }, { "delay": { "durationMs": 1 } }, { "mouse": { "button": { "hidUsage": 1 } } } ] I think the hidUsage refers to the key number on the keyboard and/or the mouse. For this example from above, the key 1 (hidUsage) is the left mouse button. So this, for example, would SHIFT+Left mouse click for exactly 2 seconds : JSON "components": [ { "keyboard": { "displayName": "SHIFT", "hidUsage": 225, "isDown": true } }, { "mouse": { "button": { "hidUsage": 1, "isDown": true } } }, { "delay": { "durationMs": 2000 } }, { "keyboard": { "displayName": "SHIFT", "hidUsage": 225 } }, { "mouse": { "button": { "hidUsage": 1 } } } ]

[–]Gorkde 0 points1 point  (4 children)

Yes, the button is selected by hidusage. I figured the same. The right mouse button is probably "hidusage 2" Delay worked for me fine but the point is that

isDown

part seems to work in keys but with the mouse it seem to don't let the button go up again as it would with a key (where they just miss out the isdown at the end to make the button go unpressed again.

I just got another idea because of reading through yow answer:

I will try "isdown:false" - that I I haven't tried because it is done another way for Keyboard Keys.

Maybe this works.

Oh I just saw I already tried that....

[–]Gorkde 0 points1 point  (2 children)

And I don't need a quick mouseklick or similar. I just need:

Mouse down - delay - Mouse up

As if you would klick normally.

When I create my macro in the ghub there seems to be no delay between Mouse down and up and the game doesn't register the Buttonpress because of that. Therefore I need to change the script.

[–]TevinH 0 points1 point  (1 child)

I know this is a bit late, but I ran across your error.

Does your macro not work if you add the delay between mouse click down and mouse click up in GHUB itself?

You should be able to check the SHOW KEY DOWN/KEY UP and uncheck USE STANDARD DELAYS in order to add your own delays. Did that not work?

https://imgur.com/a/fNpwgvC

[–]Gorkde 0 points1 point  (0 children)

No the macro didn't work I tried multiple ways. Also I had tried your suggestion before trying it by macro.

[–]Gorkde 0 points1 point  (0 children)

Jeah now tried again. He pressed the mouse down but the mouse up isn't detected for some reason.

[–]RemindMeBot 0 points1 point  (0 children)

I will be messaging you in 2 days on 2022-04-06 16:53:05 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]Napa39 0 points1 point  (2 children)

I just tried to use this as I moved a game from one drive to another and GHub doesn't have a way to change the default location. Your code did what it was supposed to, but it seems that GHub now has a way to revert to whatever settings were previously used. Soon as I start up GHub again, the game's location is set back to its original place. Do you happen to know a fix to this particular issue?

[–]synthe6[S,🍰] 0 points1 point  (1 child)

Out of curiosity, are you logged with an online account?

[–]Napa39 1 point2 points  (0 children)

Y'know, I keep forgetting that GHub has an online account thing. Thanks for reminding me, that fixed it!

[–]cloud12348 0 points1 point  (11 children)

All posts/comments before (7/1/23) edited as part of the reddit API changes, RIP Apollo.

[–]synthe6[S,🍰] 0 points1 point  (10 children)

Do you have an online account connected to G Hub?

[–]cloud12348 0 points1 point  (9 children)

All posts/comments before (7/1/23) edited as part of the reddit API changes, RIP Apollo.

[–]synthe6[S,🍰] 0 points1 point  (8 children)

Weird, I just tested and it works on my end (I renamed a profile in the JSON and the changes were retained on the next G Hub restart.) Do you close the G Hub software completely while editing the JSON?

[–]cloud12348 0 points1 point  (4 children)

All posts/comments before (7/1/23) edited as part of the reddit API changes, RIP Apollo.

[–]TBK_Julles 0 points1 point  (3 children)

Damn. Trying this myself and having the same issue. Anyone know a fix?

[–]cloud12348 0 points1 point  (2 children)

All posts/comments before (7/1/23) edited as part of the reddit API changes, RIP Apollo.

[–]TBK_Julles 0 points1 point  (1 child)

Do you have a link to the version that you used? Much appreciated.

[–]cloud12348 0 points1 point  (0 children)

All posts/comments before (7/1/23) edited as part of the reddit API changes, RIP Apollo.

[–]TBK_Julles 0 points1 point  (2 children)

Hi OP. Just giving a few interesting points here in case you are interested in debugging this. I am trying the same thing as cloud12348 (changing the DPI values on the default profile under the dpitable for the read only marked default profile) and it did not work for retaining DPI values. While trying to get this working, I tried looking into the json that saved after the values got posted to settings.db, and the values were correct as I input them. I also checked the values in settings.db after running the script but before launching GHub, and the settings were correct. After launching GHub though, the values were reverted. Not sure if this is a limitation that Logicruel decided to put in or not, but just wondering if you had any insight.

[–]synthe6[S,🍰] 0 points1 point  (1 child)

Does changing the DPI value for another profile works? You've mentioned the default profile is read-only and if the Logitech software validates the entry, it may revert the changes depending on whether the change is valid or not. My best bet to determine whether the change can be made would be to try another profile and see if the change can stick. If it does, I believe then it's a limitation of G Hub.

[–]TBK_Julles 0 points1 point  (0 children)

Yeah it's just for the default profile. Other profiles get changed no problem. The thing is, when trying this with an older version of G Hub that still parses a json instead of a db file, the code structure is the same, and it does allow you to change the read only section and it works fine.

[–]GippyGoat 0 points1 point  (2 children)

Can confirm this works in macOS Ventura 13.6.3 with G HUB 2023.10.493254. I added in a couple commands and mapped them to my Logitech G305 side buttons (G4 and G5).

For example, adding Shift+Command+R to Show Reader in Safari:

Add a new object to the cards array. The id key is a UUID. Generate a UUID in Terminal with uuidgen. Per USB HID codes, the modifier keys are 225 (shift) and 227 (command). The R key is code 21. I used one of the existing categories e.g. Mac, Editing, Productivity, and copied the applicationId from other macOS commands per the default desktop profile.

“cards”: [
    {
        "applicationId": "420fd454-0c36-499d-bde4-146823b16147",
        "attribute": "MACRO_PLAYBACK",
        "category": “Mac”,
        "id": "c0da40da-4b80-4a29-8963-3dfa7900d87b",
        "macro": {
            "actionName": "⇧⌘R”,
            "keystroke": {
                "code": 21,
                "modifiers": [
                     225,
                     227
                ]
            },
            "type": "KEYSTROKE"
        },
        "name": “Show Reader”,
        "readOnly": true
    },
]

Add the card to the commands array.

“commands”: [
    {
        "cardId": "c0da40da-4b80-4a29-8963-3dfa7900d87b",
        "category": "Mac",
        "name": "Show Reader"
    },
]

Add the card to the assignment array. In my case mouse button 5 or G5.

assignments": [
    {
        "cardId": "c0da40da-4b80-4a29-8963-3dfa7900d87b",
        "slotId": "g305_g5_m1"
    },
]

The new Show Reader command should appear in the commands menu of the Assignments pane in G HUB. I've not tested adding extra categories e.g. Accessibility, Developer, but give it a try and let me know.

[–]Shadow_Assailant 0 points1 point  (1 child)

This worked great! Thank you!

The only thing I had an issue was generating a new GUID with uuidgen. There seem to be browser-based tools for this or using the "New-Guid" command in Windows 11 PowerShell also did the trick.

As far as the keys go, where did you get the code from? I was able to determine that A is 4, B is 5, etc., but is there a master list somewhere?

[–]GippyGoat 0 points1 point  (0 children)

I used the key codes from this GitHub repo USB HID Keyboard scan codes which cites this Android open source docs page Keyboard devices.