MSzturc / ThinkpadAssistant

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

Mic mute doesn't sync with led some time #2

Closed junaedahmed closed 4 years ago

junaedahmed commented 4 years ago

Hi @MSzturc ,

I just tried your new mic key led fix and it is a great addition. When testing sometimes if a keypress is missed by ThinkpadAssistant then the led and mic behavior gets altered until a keypress missing is occured.

best wishes, Junaed

MSzturc commented 4 years ago

Yop that's right. To be able to fix this you have to write a kernel Extension that synchronizes between the state of the mic with the state of the led. I found a way to register into the Audio Controller to get an Event when Microphone got muted (ex. by software). What is missing is the counterpart, that updates the led.

Currently im trying to figure out how to write my first hello world kernel extension but im pretty slow since it's completely new to me

junaedahmed commented 4 years ago

How about two key reporting system like below so that F20 only work for mic muting and led on state. F21 for mic unmute and led off state.

` Name (LED1, Zero) // _Q6A - (Fn+F4) microphone mute key. Method(_Q6A, 0, NotSerialized) { If (_OSI ("Darwin")) {

            // Toggle Mute Microphone LED
            If ((LED1 == Zero))
            {
                // Send a one-shot event (down then up) for scancode 64 to keyboard device. This
                // is picked up by VoodooPS2 and sent to macOS as the F20 key.

                //Bug: Currently it's not possivle to map F20 Key in Systemprefs
                Notify (\_SB.PCI0.LPC.KBD, 0x036b)
                // 0x02 = Enable LED
                \_SB.PCI0.LPC_.EC.HKEY.MMTS (0x02)
                LED1 = One
            }
            If (LED1 == One)
            {
                // Send a one-shot event (down then up) for scancode 64 to keyboard device. This
                // is picked up by VoodooPS2 and sent to macOS as the F21 key.

                //Bug: Currently it's not possivle to map F21 Key in Systemprefs
                Notify (\_SB.PCI0.LPC.KBD, 0x036c)

                // 0x00 = Disable LED
                \_SB.PCI0.LPC_.EC.HKEY.MMTS (Zero)
                LED1 = Zero
            }
        }
        Else
        {
            // Call original _Q6A method.
            \_SB.PCI0.LPC_.EC.XQ6A()
        }
    }

`

MSzturc commented 4 years ago

Good idea!

I've changed your approach a bit to be backwards compatible. The bug should be fixed with ThinkpadAssistant 1.3.0

junaedahmed commented 4 years ago

Hi @MSzturc ,

I have a request to make to not to keep backward compatibility, it complicates things. those who use your software will also update their ssdt accordingly. The reason I whinning is that I am playing with modifying modifire state in voodoops2keyboard. So it gets messed up quite sometime and I loose some shortcut and have to update the ssdt every time. Though it a personal nuisance. Just wanted to let you know that less modifier key would be preferable then backward compatibility.

best wishes, Junaed

MSzturc commented 4 years ago

Yeah, I know your pain! Fiddled a couple of days to be able to uses Windows like keyboard Shortcuts and it ended up to be a bit messy and i rolled it back.

The problem I have is that i run out of mapped keys

0x4f,   // 69  F18
0x50,   // 6a  F19
0x5a,   // 6b  F20
DEADKEY,// 6c  F21
DEADKEY,// 6d  F22
DEADKEY,// 6e  F23
DEADKEY,// 6f

Source

Have you an idea which mappings i could use beside F13-F20?

junaedahmed commented 4 years ago

I think without mapping VoodooPS2 still should send F21, Deadkey means it doesn't set a default adb code to sent to ApplePS2. Also I am trying to build ThinkpadAssistant from source but gave me this error Build target ThinkpadAssistant_2020-05-08T17-00-07.txt

MSzturc commented 4 years ago

As far as I know the Framework i use for global Shortcuts Masshortcut only supports adb codes.

Did you perform a pod install before build? ( if not install cocoapods from https://cocoapods.org/ and run pod install from terminal inside project folder )

Also make sure to open the Xcode workspace instead of the project file when building your project

junaedahmed commented 4 years ago

Okay last proposition. How about shift key as modifier, it's name and functionality is persistant on different OS's. Mic mute state: F20 only and Mic unmute state: SHIFT + F20.

And now the programme builds successfully but doesn't produce any app package.

MSzturc commented 4 years ago

It took me a bit of time but i managed to convert most of the library i used for global hotkey management (MASShortcut) to Swift. I run an PoC and was able to determin which shift key was pressed. Now i have to integrate it into ThinkpadAssistant which will will cost me a couple of hour but im confident to provide a new Version in the near future

junaedahmed commented 4 years ago

I understand your situation with MASShortcut. At first I suggested to use Left and Right Shift key as modifier, then I looked into the framework's doc and found that it doesn't distinguish left and right modifier keys. So I edited to only use F20 and shift + F20 combination. Again gratefull to your wonderfull work.

MSzturc commented 4 years ago

@junaedahmed

Today i released v1.4.0. It bind's mute / unmute mic on right/left shift + F20. Have fun testing