MSzturc / ThinkpadAssistant

An Assistant Application that allows you to use all your Function Keys on a T-Series Thinkpad Laptop
118 stars 13 forks source link

Compatibility Update #12

Closed Sniki closed 4 years ago

Sniki commented 4 years ago

Hi @MSzturc

Im the person who created the ThinkPad Haswell generation "hotpatches" for Lenovo ThinkPads:

I want to thank you for this amazing project to push ThinkPad support even further.

A couple of questions that i wanted to ask, i am in the process of replacing my Clover projects on Github with OpenCore, i have them locally for a few months but was busy to update till now. Anyway, Changes that i see are:

Those seems the ones i need to change into my SSDTs before sending a pull request with added support for all the above listed thinkpads.

However i wanted to know what do you do with those:

"ActionSwipeLeft",  "37 d, 21 d, 21 u, 37 u",
"ActionSwipeRight", "37 d, 1e d, 1e u, 37 u",
"SleepPressTime",   "1500",
"Swap command and option", ">y",
"e038=e05b", //AltGr=Left Windows

ActionSwipeLeft and ActionSwipeRight: what do those changes do from the original ? What does SleepPressTime also do, delay presses until gui fades from screen ? Do you swap alt with windows logo key ? (will the app work if we leave it as it is with alt instead ?) Just curiosity questions.

I will update files during this week and send a pull request.

Thanks a lot for this amazing work that you did.

Regards, Sniki

MSzturc commented 4 years ago

ActionSwipeLeft and ActionSwipeRight: what do those changes do from the original ?

Action Swipes are gestures on the Trackpad. They are not needed to work with the Thinkpad Assistant. They are performed when you Swipe fast to the left/right side of the Touchpad.

"ActionSwipeLeft", "37 d, 21 d, 21 u, 37 u", Parameter describes which keys should be pressed (d) and release in which sequence

 0x37,   // e0 5b  Left GUI(Windows)
 0x21,   // 1a  [{

from https://github.com/acidanthera/VoodooPS2/blob/master/VoodooPS2Keyboard/ApplePS2ToADBMap.h

"SleepPressTime", "1500",

This is part of the action swipes and defines how long VoodooPS2 should wait in milliseconds until the a next ActionSwipe should be processed.

"Swap command and option", ">y", Swap's windows and Alt. For me it's a more natural approach to use Alt based shortcuts since my thumb lies normally on the left alt/ left side of the space key, but this is a personal flavour. Shortcut's like the Spotlight shortcut based on this swap. If you disable it you have to modify them.

"e038=e05b", //AltGr=Left Windows This one is specially for german keyboard layouts. On german layout the right Alt key is called AltGr and is used for shortcuts like the @-Symbol. Normally you dont need this

Im planning to split the SSDT's to a Touchpad configuration file and a Thinkpad Assistant Keybinding file.

Sniki commented 4 years ago

Ok so i guess the AltGr key and the swap command and option key is not necessary and personal preference (in your case for german layout).

Thanks for the clarification. Will install macOS on my T440s today and test it.

Another question, maybe off-topic but since you have the T460, are touchpad physical buttons and trackpoint working correctly for you on latest VoodooPS2 and VoodooInput release kexts ?

MSzturc commented 4 years ago

Another question, maybe off-topic but since you have the T460, are touchpad physical buttons and trackpoint working correctly for you on latest VoodooPS2 and VoodooInput release kexts ?

Nope, I saw your Issue Report. The behaviour on T460 is exactly as you described it. Dont get confused by the Version Number. For my T460 build i compiled the last working VodooPS2Controller myself (which has the same Versionnumber as the official release since i was to lazy to give it a diffrent one )

Sniki commented 4 years ago

Another question, maybe off-topic but since you have the T460, are touchpad physical buttons and trackpoint working correctly for you on latest VoodooPS2 and VoodooInput release kexts ?

Nope, I saw your Issue Report. The behaviour on T460 is exactly as you described it. Dont get confused by the Version Number. For my T460 build i compiled the last working VodooPS2Controller myself (which has the same Versionnumber as the official release since i was to lazy to give it a diffrent one )

Great, thanks for confirming. What i did is took previous VoodooPS2 and added latest VoodooInput and combined them. During this week i will experiment into that and see what happened, probably they removed code that was important, something that happened previously as well.

Sniki commented 4 years ago

@MSzturc Just tested the application after i changed my SSDT and i can confirm it works fine on Lenovo ThinkPad T440S, the same does apply for T440 and X240 and L440.

It is almost perfect but it just misses the Keyboard Backlit GUI. Do you think we can make that as well ? It should have the 3 levels:

The shortcut is FN+Space.

Let me know if there is something i can help you with regarding to this feature.

Thanks in advance.

MSzturc commented 4 years ago

Well you could do it on your own by an ACPI Patch. Basically it's like the Mute Button Led toggle but with 3 state.

The Device you are looking for is _SB.PCI0.LPC_.EC.HKEY.MLCS It has one Parameter:

0x0 - off 0x1 - level 1 0x2 - level 2

To get the State of the Keyboard Backlight you use _SB.PCI0.LPC_.EC.HKEY.MLCG without parameter

tylernguyen commented 4 years ago

@Sniki @MSzturc

+1 for the cause. There is already a macOS HUD for keyboard backlight. Can we use it to make it feel more native or would we have to create our own? The HUD would need to cycle from max to off.

Similarly, my x1c6 is also controlled using Fn+Spacebar which injects EC _Q1F. I assume this would first need to be renamed within OpenCore to XQ1F?

Sniki commented 4 years ago

Well you could do it on your own by an ACPI Patch. Basically it's like the Mute Button Led toggle but with 3 state.

The Device you are looking for is SB.PCI0.LPC.EC.HKEY.MLCS It has one Parameter:

0x0 - off 0x1 - level 1 0x2 - level 2

To get the State of the Keyboard Backlight you use SB.PCI0.LPC.EC.HKEY.MLCG without parameter

@MSzturc Does this mean that it would work with the native GUI from macOS instead of providing one from the App ?

So what you mean is i need to find the method invoked from FN+Spacebar which @tylernguyen says on his X1C6 is _Q1F which we can rename it to XQ1F and do something like:

Method (_Q1F, 0, NotSerialized)
        {
            If (_OSI ("Darwin"))
            {
                \_SB.PCI0.LPC.EC.HKEY.MLCG ()
            }
            Else
            {
                \_SB.PCI0.LPC.EC.XQ1F ()
            }
        }

Am i correct or wrong ?

tylernguyen commented 4 years ago

@Sniki Similarly to the Mute LED patch, there would need to be a few if cases to check to keyboard state. So:

Off -> Dim Dim -> Bright Bright -> Off

This would get awkward very quick with various different mappings we need. It would have to some combination of left/right shift and a function buttons.

We could call this LED2 within the patch since LED1 is for the mute button.

Sniki commented 4 years ago

@Sniki Similarly to the Mute LED patch, there would need to be a few if cases to check to keyboard state. So:

Off -> Dim Dim -> Bright Bright -> Off

This would get awkward very quick with various different mappings we need. It would have to some combination of left/right shift and a function buttons.

We could call this LED2 within the patch since LED1 is for the mute button.

I understand but that is out of the scope of my knowledge unfortunately so im afraid that i won't be able to make this on my own and will need some assistance.

Will try to sweat my brain into this a bit more and see if i can get something started

@MSzturc wanted to ask you this, do you mind if we keep this issue open and get some brainstorming here until we get something working and then do like a PR and close this ?

tylernguyen commented 4 years ago

@Sniki This is my draft:

Scope (_SB.PCI0.LPCB.EC)
    {
        Name (LED2, Zero)
        // _Q61F- Keyboard backlight
        Method (_Q1F, 0, NotSerialized) // cycle keyboard backlight
        {
            If (_OSI ("Darwin"))
            {
                // Cycle keyboard backlight states

                If ((LED2 == Zero))
                {
                    // Custom mapping needs to be decided on.

                    //  Off to dim
                    \_SB.PCI0.LPCB.EC.HKEY.MLCG (0x01)
                    LED2 = One
                }
                Else

                If ((LED2 == One))
                {
                    // Custom mapping needs to be decided on.

                    //  dim to bright
                    \_SB.PCI0.LPCB.EC.HKEY.MLCG (0x02)
                    LED2 = Two
                }

                Else

                {
                    // Custom mapping needs to be decided on.

                    // bright to off
                    \_SB.PCI0.LPCB.EC.HKEY.MLCG (Zero)
                    LED2 = Zero
                }
            }
            Else
            {
                // Call original _Q6A method.
                \_SB.PCI0.LPCB.EC.XQ1F()
            }
        }

@MSzturc I cannot test this until we have a custom mapping decided on as well as for ThinkpadAsssitant to have a keyboard HUD to test against. Is that something you could help with?

MSzturc commented 4 years ago

Okay, lets see

Please use the following mapping:

0x00 to left shift + f16 0x01 to right shift + f16 0x02 to left shift + f19

MSzturc commented 4 years ago

@hexart For this Feature I need 3 Custom Vector graphics that represent the state of the keyboard ( off, dimmed & bright ).

Something like this: image

Do you have time to support us?

Sniki commented 4 years ago

Ok, this is the updated draft of @tylernguyen by @MSzturc suggestions. Added the key combinations as you requested, fixed spacing and warnings:

// Backlit Keyboard GUI indicator for Lenovo ThinkPads

DefinitionBlock("", "SSDT", 2, "T440S", "_KBD", 0)
{
    External(_SB.PCI0.LPC.EC, DeviceObj)
    External(_SB.PCI0.LPC.KBD, DeviceObj)
    External(_SB.PCI0.LPC.EC.HKEY.MLCG, MethodObj)
    External(_SB.PCI0.LPC.EC.XQ1F, MethodObj)

    Scope (_SB.PCI0.LPC.EC)
    {
        Name (LED2, Zero)
        // _Q61F- Keyboard backlight
        Method (_Q1F, 0, NotSerialized) // cycle keyboard backlight
        {
            If (_OSI ("Darwin"))
            {
                // Cycle keyboard backlight states

                If ((LED2 == Zero))
                {
                    // Right Shift + F16.
                    Notify (\_SB.PCI0.LPC.KBD, 0x0136)
                    Notify (\_SB.PCI0.LPC.KBD, 0x0367)
                    Notify (\_SB.PCI0.LPC.KBD, 0x01b6)
                    //  Off to dim
                    \_SB.PCI0.LPC.EC.HKEY.MLCG (0x01)
                    LED2 = 1
                }
                Else
                {
                    If ((LED2 == One))
                    {
                        // Left Shift + F19.
                        Notify (\_SB.PCI0.LPC.KBD, 0x012a)
                        Notify (\_SB.PCI0.LPC.KBD, 0x036a)
                        Notify (\_SB.PCI0.LPC.KBD, 0x01aa)
                        //  dim to bright
                        \_SB.PCI0.LPC.EC.HKEY.MLCG (0x02)
                        LED2 = 2
                    }
                    Else
                    {
                        If ((LED2 == 2))
                        {
                            // Left Shift + F16.
                            Notify (\_SB.PCI0.LPC.KBD, 0x012a)
                            Notify (\_SB.PCI0.LPC.KBD, 0x0367)
                            Notify (\_SB.PCI0.LPC.KBD, 0x01aa)
                            // bright to off
                            \_SB.PCI0.LPC.EC.HKEY.MLCG (Zero)
                            LED2 = 0
                        }
                        Else
                        {
                            // Call original _Q6A method.
                            \_SB.PCI0.LPC.EC.XQ1F ()
                        }
                    }
                }
            }
        }
    }
}

Is this supposed to be correct ? Hint: Spacing seems to brake when i paste it here, it's fine on the SSDT

MSzturc commented 4 years ago

Got first Proof of Concept working

backlit

Now i need a nice graphic and a better Status text

Keyboard Backlight dimmed

Any suggestions for a shorter Status Text?

MSzturc commented 4 years ago

Here is the final SSDT i used for this:

`Name (LED2, Zero)

    // _Q1F - (Fn+Space) Toggle Keyboard Backlight.
    Method (_Q1F, 0, NotSerialized) // cycle keyboard backlight
    {
        If (_OSI ("Darwin"))
        {
            // Cycle keyboard backlight states

            If ((LED2 == Zero))
            {
                // Right Shift + F16.
                Notify (\_SB.PCI0.LPC.KBD, 0x0136)
                Notify (\_SB.PCI0.LPC.KBD, 0x0367)
                Notify (\_SB.PCI0.LPC.KBD, 0x01b6)
                //  Off to dim
                \_SB.PCI0.LPC.EC.HKEY.MLCS (One)
                LED2 = One
            }
            Else
            {
                If ((LED2 == One))
                {
                    // Left Shift + F19.
                    Notify (\_SB.PCI0.LPC.KBD, 0x012a)
                    Notify (\_SB.PCI0.LPC.KBD, 0x036a)
                    Notify (\_SB.PCI0.LPC.KBD, 0x01aa)
                    //  dim to bright
                    \_SB.PCI0.LPC.EC.HKEY.MLCS (0x02)
                    LED2 = 2
                }
                Else
                {
                    If ((LED2 == 2))
                    {
                        // Left Shift + F16.
                        Notify (\_SB.PCI0.LPC.KBD, 0x012a)
                        Notify (\_SB.PCI0.LPC.KBD, 0x0367)
                        Notify (\_SB.PCI0.LPC.KBD, 0x01aa)
                        // bright to off
                        \_SB.PCI0.LPC.EC.HKEY.MLCS (Zero)
                        LED2 = Zero
                    }
                    Else
                    {
                        // Call original _Q6A method.
                        \_SB.PCI0.LPC.EC.XQ1F ()
                    }
                }
            }
        }
    }`

@tylernguyen @Sniki Corrected typo: It should be MLCS not MLCG

Sniki commented 4 years ago

@MSzturc thanks a lot, what if we do something similar to apple:

As for the GUI, here is the example from my 13" Retina MacBookPro (early 2015) with Force Touch: Off, Level 8 (half) and Level 16 (full)

Off Level 1 Level 2

So what we may want to look ideally as close to Apple design as possible would be either the same look or stick the bars till the half so we have two long bars so we know there are 2 backlit levels only. Something like this (dirty Preview app edit but just for example):

Level 1 (ThinkPad Assistant) Level 2 (ThinkPad Assistant) Off

As for the naming maybe just Keyboard Backlight OFF / Low / High or Dim/Bright/Off

tylernguyen commented 4 years ago

@MSzturc @sniki @hexart Looks awesome! Glad I could be of some help.

Honestly, I do not like the native macOS HUD so much. It doesn't even look like a keyboard to me. I prefer a simple keyboard icon over the sun-looking thing.

As for the off state, I prefer a big bar across similar to the other HUD we have already, this keeps it uniform looking across all Fn keys.

For the dim and bright state, two big bars similar to how @sniki suggest looks fine.

Sniki commented 4 years ago

@tylernguyen Thanks for the draft and the _Q1F Method that you discovered that it’s the one for Fn+SpaceBar.

Yes, i agree that the native Apple HUD for Backlight Keyboard doesn’t look much like a Keyboard but i would prefer it since i like to have my setup as close resembling to Apple style as possible so i might consider forking and replacing icons with the Apple ones for my personal use (and without text).

However i think i found some good minimal ones that we may want to use and that could look better than Apple model. here are some examples:

image

image

image

image

What do you guys think ? Also the long bar would be nice to be included. That long bar design is similar to Linux > Gnome UI.

hexart commented 4 years ago

Sure. I'll see what I can do.

MSzturc commented 4 years ago

With v1.7.0 Keyboard Backlight HUD is supported. Moved the discussion about the hud icons to #16

acaleechurn commented 4 years ago

Hello,

Would it be possible to port the audio jack fix to Linux? I have a corebooted T440p and the only thing which does not work properly is audio. When inserted the headphone is detected but there is no output. Docking audio also does not work but if i plug in a second headphone in the laptop jack while the other one is connected to the dock, I get docking audio. The Coreboot guys don't know how to fix this yet...

If i play with hdajackretask, i can enable the dock audio but the speakers are then permanently muted :(