Qonfused / ASUS-ZenBook-Duo-14-UX481-Hackintosh

OpenCore configuration for the ASUS ZenBook Duo 14" (UX481FA/FL)
https://github.com/Qonfused/ASUS-ZenBook-Duo-14-UX481-Hackintosh
BSD 3-Clause "New" or "Revised" License
30 stars 1 forks source link

[VoodooI2CHID] Fixing Physical Buttons on Trackpad #8

Closed Maleficent-Magik closed 1 year ago

Maleficent-Magik commented 2 years ago

So, after updating Kexts... the trackpad works!

CONNEXION : #4 #3

Qonfused commented 2 years ago

Does it work with gestures or just as a ps2 mouse (right/left click only)? You can try a two-finger scroll in a browser or try zooming in on an image with a pinch in Preview.

It does make sense that updating OpenCore + Kexts though should fix some instability. OpenCore versions 0.7.8 to 0.8.2 should be mostly the same; if you want to boot Ventura, you'll also need OpenCore 0.8.3 and Lilu 1.6.2.

Edit: I still do expect to have to modify some of the custom GPI0 polling/related Voodoo kexts to make sure they're pointing to the correct device names/etc.

Maleficent-Magik commented 2 years ago

So... some explanations. I updated, and deleted some Kexts that are completely useless... but also temporarily disable some kexts of VoodooI2C

So :

UPDATED :

NOT UPDATED :

REMOVED :

Temporarily suspended (Temporarily removed) :

Kexts.zip config.plist

Don't forget to change your series values please!

As Qonfused said :

Warning Please follow the below instructions before using this repository.

Please download [GenSMBIOS] (https://github.com/corpnewt/GenSMBIOS) and follow this guide for generating SMBIOS data for enabling iServices functionality.

Maleficent-Magik commented 2 years ago

About the trackpad:

Gesture:

3 fingers: open the window manager & search with Siri 2 fingers: up & down

Does not work:

2 fingers: secondary click

Touch:

Approximately OK... but I have the impression that if we touch the touch, we will have to use the touch forever until the reboot of the PC..... we would be potentially obliged to reboot the pc to get back the hand on the trackpad...

Maleficent-Magik commented 2 years ago

It does make sense that updating OpenCore + Kexts though should fix some instability. OpenCore versions 0.7.8 to 0.8.2 should be mostly the same; if you want to boot Ventura, you'll also need OpenCore 0.8.3 and Lilu 1.6.2.

So I already managed to get started on Monterey thanks to you, I'm not going to take a chance by screwing up in Ventura heh... 😂 😂

Maleficent-Magik commented 2 years ago

I made a mistake in the configuration, it is replaced.

If you have an error when starting MacOS, just download "config.plist" again ! and replace it ! I forgot a letter, sorry about the problem... I was tired haha...

ERROR : (line 1500)

Contents/MacOS/IntelBTPacher

FIXING BY :

Contents/MacOS/IntelBTPatcher

New config.plist uploaded !

config.plist

Qonfused commented 2 years ago

So far I've updated these kexts in the #update-opencore-config branch. Some things to note is that IOElectrify.kext and USBInjectAll.kext aren't needed (they're already disabled in your config though).

Maleficent-Magik commented 2 years ago

Oh I hadn't noticed, thank you!

Qonfused commented 2 years ago

I wasn't able to reproduce the same behavior after updating all the kexts, though I may need to re-test that after I reverted that commit by mistake (I don't recall whether I actually updated the Voodoo kexts at that point, though I recall testing without updating them).

I did note that VoodooI2C and VoodooI2CHID are both used for the trackpad and touchscreen, and VoodooPS2 is used only for the keyboard. I didn't see the VoodooI2CHID-AsTouchscreen.kext or the VoodooI2CHID-AsTouchscreen.kext loaded in my config (or the original config). I'm not sure what their purpose is; they're likely artifacts from previous testing.

I'm assuming that loading the root kext should be done before loading any of it's plugins, so there may be an improper loading order in my config. Below is a table of their index (only the order matters) and some relevant entry properties, shortened for brevity:

Idx Source Kext Executable Kext Plugin Enabled
34 VoodooI2C.kext Contents/MacOS/VoodooGPIO VoodooGPIO.kext Yes
35 VoodooI2C.kext Contents/MacOS/VoodooI2CServices VoodooI2CServices Yes
36 VoodooI2C.kext Contents/MacOS/VoodooInput VoodooInput.kext Yes
37 VoodooI2C.kext Contents/MacOS/VoodooI2C Yes
38 VoodooI2CHID.kext Contents/MacOS/VoodooI2CHID Yes
39 VoodooPS2Controller Contents/MacOS/VoodooPS2Controller Yes
40 VoodooPS2Controller Contents/Plugins/VoodooPS2Keyboard VoodooPS2Keyboard.kext Yes
41 VoodooPS2Controller Contents/Plugins/VoodooPS2Mouse VoodooPS2Mouse.kext No
42 VoodooPS2Controller Contents/Plugins/VoodooPS2Trackpad VoodooPS2Trackpad.kext No
43 VoodooPS2Controller Contents/Plugins/VoodooInput VoodooPS2Input.kext No

I figure this is caused by some fixes for power-optimization (e.g. GPIO pinning for the trackpad and touchscreen). In #7 I'll try to figure out which of those ACPI patches are might be interfering or are simply incompatible. I do notice an error mentioning AddressingMode7Bit and I2C1 or something along those lines, which are indicative of some kind of GPIO pinning recognizable from the voodoo guide. There may be an SSDT to enable it that isn't routed to the proper device, though I noticed that the pro-duo shares the same device-id for the trackpad so I'm not sure.

Maleficent-Magik commented 2 years ago

Missclick* (thanks to Google Chrome who scrolled down my page and clicked at the same time... my apologies)

Qonfused commented 2 years ago

Huh, seems there is a guide for fixing the GPI0 device in the ACPI patching section of the guide here. If applicable, I'll diff my changes from what may already be implemented, but I'd have to verify that the device is working correctly before any additional GPI0-related ACPI patches can get loaded.

Will have to wait until tomorrow to have time to work on that, but it is a much easier process than I imagined (and hopefully that's the issue if the device works fine when it works).

Qonfused commented 1 year ago

Noticing in #10 that the left click button maps to right click, and the right click button maps to middle click.

GPI0 device is working correctly.

Qonfused commented 1 year ago

There is some conflict that prevents touchscreen from working several seconds after startup, even with the -vi2c-force-polling boot arg. Not a new issue, but one I didn't expect to persist.

Otherwise the trackpad (excluding the physical buttons) and touchscreen for both displays work as expected.

Maleficent-Magik commented 1 year ago

There is some conflict that prevents touchscreen from working several seconds after startup,

A few seconds is fine... Worse would have been if it had been blocked for a long time...

(This title is better... better explained than the old title...)

Qonfused commented 1 year ago

Sorry I meant *after several seconds; it can occasionally happen (albeit much later) to the trackpad I've noticed, but both are resolved after closing the lid for a few seconds.

Qonfused commented 1 year ago

Moved touchscreen issue to #12.

Maleficent-Magik commented 1 year ago

So, if we use Karabiner as planned, and we use 2 simple modifiers :

A) Button 2 -> Button 3 B) Button 3 -> Button 2

Capture d’écran 2022-11-30 à 16 10 30

(As like on my screen)

this will solve the problem for the moment, Left will be Right and Right will be Left...

But I have to test if it's normal that my trackpad goes very fast and not as usual... So, "Solution not official right now"

Maleficent-Magik commented 1 year ago

update : Doesn't work right now... i need more time...

Maleficent-Magik commented 1 year ago

In looking on Issues about Karabiner, i'have found the SAME problem about we, Karabiner-Element Issues 2370

So, we need just to edit karabiner.json with that :

"simple_modifications": [
  {
    "from": {
      "pointing_button": "button2"
    },
    "to": {
      "pointing_button": "button1"
    }
  },
  {
    "from": {
      "pointing_button": "button1"
    },
    "to": {
      "pointing_button": "button2"
    }
  }
]

Originally posted by @kirintwn in https://github.com/pqrs-org/Karabiner-Elements/issues/2370#issuecomment-674669989

Qonfused commented 1 year ago

Managed to fix the buttons with a reorder of kext plugins and adding voodoops2trackpad + voodooinput in https://github.com/Qonfused/ASUS-ZenBook-Duo-14-UX481-Hackintosh/commit/0b6711556207d49135466101fb8e217ab68704dd. I downgraded voodoo kext versions as part of this, but the same fix as proposed above should be applied when updating to newer versions.

Qonfused commented 1 year ago

PR merge on Jul 22 seems to address this issue: https://github.com/VoodooI2C/VoodooI2C/commit/9ab98319b6411c4a4822cc12f840df85cc684bfc

Update VoodooI2C Satellites and support for physical buttons (https://github.com/VoodooI2C/VoodooI2C/pull/514)

  1. Always pass buttons as pressure on single-button touchpads (fix https://github.com/VoodooI2C/VoodooI2C/issues/496)
  2. Always disable Force Touch and pass buttons to buttons device on touchpads with two physical buttons (fixes inability to click without finger on the touchpad (https://github.com/VoodooI2C/VoodooI2C/issues/499) and inability to use the right button with default settings)
  3. Disable Force Touch on all touchpads if tap to click is disabled (fixes inability to make a non-force click with default settings, especially in Recovery where there is no System Preferences application)
  • NULL -> nullptr, FALSE -> false

  • Update VoodooI2CAtmelMXT

  • Update VoodooI2CHID

Co-authored-by: Michael Belyaev usrsse2@me.com

Maleficent-Magik commented 1 year ago

Managed to fix the buttons with a reorder of kext plugins and adding voodoops2trackpad + voodooinput in https://github.com/Qonfused/ASUS-ZenBook-Duo-14-UX481-Hackintosh/commit/0b6711556207d49135466101fb8e217ab68704dd. I downgraded voodoo kext versions as part of this, but the same fix as proposed above should be applied when updating to newer versions.

I need to try so 🤔... I will try this night (actually 7AM)

If this can be resolve, it's good

Qonfused commented 1 year ago

It did work consistently when I tried it then, but there has since been a regression since updating opencore. I believe the PR I just linked addresses this issue.

Maleficent-Magik commented 1 year ago

I know I'm stupid in terms of PR... but how do for get this famous Kext? and besides, is it normal that the keyboard does not backlight anymore? I know I'm asking a bit much I think? 😅

Qonfused commented 1 year ago

I had already built it in xcode but you can pull built versions from https://dortania.github.io/build-repo/ by commit.

Qonfused commented 1 year ago

There are some duplicate entries for Voodoo kexts+plugins in Kernel > Add that I'll need to fix:

= VoodooPS2Controller (enabled)
= VoodooI2C > VoodooGPIO (enabled)
= VoodooI2C > VoodooI2CServices (enabled)
= VoodooI2C > VoodooInput (enabled)
= VoodooPS2Controller > VoodooInput (disabled)
= VoodooPS2Controller > VoodooPS2Keyboard (enabled)
+ VoodooPS2Controller > VoodooPS2Mouse (enabled)
+ VoodooPS2Controller > VoodooPS2Trackpad (enabled)
...
+ VoodooI2C (enabled)
= VoodooI2C > VoodooGPIO (enabled)
= VoodooI2C > VoodooI2CServices (enabled)
= VoodooI2C > VoodooInput (enabled)
+ VoodooI2CHID (enabled)
+ VoodooPS2Controller (enabled)
= VoodooPS2Controller > VoodooPS2Keyboard (enabled)
- VoodooPS2Controller > VoodooPS2Mouse (disabled)
- VoodooPS2Controller > VoodooPS2Trackpad (disabled)
= VoodooPS2Controller > VoodooInput (disabled)

The latter here should be the correct load order + settings.

Qonfused commented 1 year ago

Just fixed kext load order in 6249948b78853d7435534ecf6434b831fec87ac9.

Maleficent-Magik commented 1 year ago

I know I'm stupid in terms of PR... but how do for get this famous Kext? and besides, is it normal that the keyboard does not backlight anymore? I know I'm asking a bit much I think? 😅

Fixed Keyboard does not backlight by reorder the Kexts... (I have badly reorder the config.plist, mybad.)

But nothing right now for the Trackpad 😅

Maleficent-Magik commented 1 year ago

Just fixed kext load order in 6249948b78853d7435534ecf6434b831fec87ac9.

But nothing about Trackpad, it's exact? (See my last comment)

Maleficent-Magik commented 1 year ago

🤔

Looking at my DSDT (DSDT.zip) and the Device Manager in the ID Compatibles section, there is a difference!

Device (GPI0)
        {
            Method (_HID, 0, NotSerialized)  // _HID: Hardware ID
            {
                If ((GPHD == One))
                {
                    Return ("PNP0C02")
                }
[...]

However, in the device manager, it is marked PNP0C50

image

This could cause a problem, no?

Qonfused commented 1 year ago

It may be a problem if it's occuping a pin that we want for the trackpad or one of the touchscreen displays, but currently they're not GPIO pinned so it shouldn't conflict for now.

I'd note that your firmware can also contain entries for devices that aren't present in your system (even for your specific config of this laptop there could be various models for something like the trackpad, etc).

Maleficent-Magik commented 1 year ago

It may be a problem if it's occuping a pin that we want for the trackpad or one of the touchscreen displays, but currently they're not GPIO pinned so it shouldn't conflict for now.

I'd note that your firmware can also contain entries for devices that aren't present in your system (even for your specific config of this laptop there could be various models for something like the trackpad, etc).

Ah yep I see.... Sorry I also try to get involved in the project so you are not alone, it's a bit discouraging to work alone and not have another person to test the project, I don't know if you know what I mean?< And also because I want to realize this project to put MacOS On this PC ^^'

So yes I make some mistakes sometimes ^^'

Maleficent-Magik commented 1 year ago

~See : https://github.com/VoodooI2C/VoodooI2C/releases/tag/2.7.1 - https://github.com/VoodooI2C/VoodooI2C/pull/514~

~Will may repair that bug, new update of VoodooI2C for 2nd button~

nvm didn't work...

Qonfused commented 1 year ago

It seems the trackpad buttons are using some generic HID interface; they don't use either of the PS2 mouse/trackpad plugins, but VoodooI2CHID. Device manager doesn't show any Synaptics/Elan SMBUS devices either so it's not a regular click pad.

Maleficent-Magik commented 1 year ago

Yes, otherwise we would have seen that it was a SMBUS or Synaptics...

So it would be more a problem related to VoodooI2CHID than VooodooI2C (And we necessarily exclude VoodooPS2 since it only manages the ATK 102 keyboard)

I checked the info.plist of VoodooI2CHID as well, the Compatible ID corresponds well to the one of the periophere manager. PNC050 (something like that)

Qonfused commented 1 year ago

Seems the PR I had linked to before was only fixing physical buttons on an actual trackpad; commit refers to digitiser/transducer buttons:

https://github.com/VoodooI2C/VoodooI2CHID/compare/6fe83a514e90b52bf872ed641627af190ef93011...c1e31809b3be441be0093b0d5aa3aeab1db56080#diff-a17b259a35228d1fa6e960ea2b4eb5931aec9585cee01403b5e89a8da9d54493

(part of https://github.com/VoodooI2C/VoodooI2C/pull/514/commits/524235cb372aca65a9150df58eeed14064c78e3f)

Also https://github.com/VoodooI2C/VoodooI2C/pull/445. The terminology used in these issues (and in VoodooI2C/VoodooI2CHID source) makes this very confusing to parse.

Maleficent-Magik commented 1 year ago

That's quite an interesting comment though...

https://github.com/VoodooI2C/VoodooI2C/blob/9ed1dcdb6e375c54d61945fe9415ccb63627d2f2/Multitouch%20Support/Native/VoodooI2CNativeEngine.cpp#L51

Here, we are talking about pressure, which is quite interesting


Also here...

https://github.com/VoodooI2C/VoodooI2CHID/blob/640c0c1c7866f130693b92435671eaf07c7af768/VoodooI2CHID/VoodooI2CMultitouchHIDEventDriver.cpp#L170-L179

Here we talk about that: "there can be no secondary button without a primary button".

So, normally, if there is a primary button, you can have a secondary button...


https://github.com/VoodooI2C/VoodooI2CHID/blob/640c0c1c7866f130693b92435671eaf07c7af768/VoodooI2CHID/VoodooI2CMultitouchHIDEventDriver.cpp#L582-L601

Here we are talking about the Dell latitude 7390 2-1, why? It's a laptop with 2 buttons like the Asus ZenBook UX481, UX*** ect... What can interest us is that the left button was set to 2, and the right button was set to 3 and not 1

So, let's study this for the Asus Zenbook...

DEFINITION :

What is a Transducer? (A transducer is an electronic device that converts energy from one form to another, the electrical signal is then turned into a usable direct current or voltage that is easily measured. Some examples of transducers include microphones and loudspeakers. There are two different types of transducers an input transducer which is a sensor and an output transducer which is an actuator. We offer linear position transducers and pressure transducers here at variohm. Click below to view the different product ranges:)

(uh... Github does not display the code as expected... bruh... Why? Idk because i'have read : GitHub Help... so... Mystery...)

Qonfused commented 1 year ago

It seems that most other devices with physical trackpad buttons are either connected via SMBus or are Synaptics clickpads; I can't find any other cases where there is an Elan trackpad w/ I2C buttons.

(uh... Github does not display the code as expected... bruh... Why? Idk because i'have read : GitHub Help... so... Mystery...)

Apparently, it only embeds the code preview when the permalink is referencing code from the same repository you're commenting on. It's rather problematic on an org level, since you may want to reference code from another project when talking about regressions/dependencies, or just manage a separate issue tracker in another repo.

Maleficent-Magik commented 1 year ago

I try to study a little by reading as I can (I do like that when I did not learn the programming language, I read and try to understand in the native language) VoodooI2CELAN.kext to understand how the Kext works...

I noticed that he is looking for things concerning the ASUS firmware... I have to continue to look at the different variants that exist...

bool VoodooI2CELANTouchpadDriver::check_ASUS_firmware(UInt8 productId, UInt8 ic_type) {
    if (ic_type == 0x0E) {
        switch (productId) {
            case 0x05 ... 0x07:
            case 0x09:
            case 0x13:
                return true;
        }
    } else if (ic_type == 0x08 && productId == 0x26) {
        return true;
    }
    return false;
}
 if (check_ASUS_firmware(product_id, ictype)) {
        IOLog("%s::%s ASUS trackpad detected, applying workaround\n", getName(), device_name);
        retVal = write_ELAN_cmd(ETP_I2C_STAND_CMD, ETP_I2C_WAKE_UP);
        if (retVal != kIOReturnSuccess) {
            IOLog("%s::%s Failed to send wake up cmd (workaround)\n", getName(), device_name);
            return false;
        }

Besides, we can forget the Gitter.im of Alexandred, it is not attractive in the sense that nobody answers / talks .

So, they don't offer Technical Support anymore, it seems. The only way to communicate would be Discord? or GitHub of VoodooI2C but in the "Issues" section : GitHub Issues VoodooI2C

Apparently, it only embeds the code preview when the permalink is referencing code from the same repository you're commenting on. It's rather problematic on an org level, since you may want to reference code from another project when talking about regressions/dependencies, or just manage a separate issue tracker in another repo.

Okay I'see, thanks ! I would use the famous ``` tags to signal code :)

Like that

 ``` << This things
Qonfused commented 1 year ago

@shiecldk Do you encounter the same button mapping issue using this kext load order?

VoodooI2C/VoodooI2CServices
VoodooI2C/VoodooGPIO
VoodooI2C/VoodooInput
VoodooI2C
VoodooI2CHID
VoodooPS2Controller
VoodooPS2Controller/VoodooPS2Keyboard
// Omit PS2Mouse / PS2Trackpad plugins
For reference, these are the kext versions tested with: Kext Version
VoodooI2C 2.7.1
VoodooI2CHID 1.0
VoodooPS2 2.2.7
shiecldk commented 1 year ago

My Ux582 actually doesn't have the physics buttons as do in the 14-inch models. I assume I wouldn't encounter this issue? This is the sequence I use:

Screen Shot 2023-01-29 at 2 04 56 AM

VoodooPS2Trackpad and VoodooPS2Mouse are not enabled.

Maleficent-Magik commented 1 year ago

Yeah the UX582 doesn't have physicals buttons, quite strange by the way as Trackpad...: image (Picture from : Root-Nation)

Qonfused commented 1 year ago

Well, I guess it's a non-issue for you then. I don't know how I haven't noticed this before lol.

shiecldk commented 1 year ago

For the temporary fix of the trackpad freezing issue. Do you think it's possible to implement some SSDT codes to turn off the trackpad with FN+F6 (_Q12) like do through sleep and wake to get it back to work?

Qonfused commented 1 year ago

My _Q12 method does work for disabling the trackpad; for reference, mine looks like this:

Method (_Q12, 0, NotSerialized)  // _Qxx: EC Query, xx=0x00-0xFF
{
    If (!(DSYN & One))
    {
        If (ATKP)
        {
            ^^^^ATKD.IANE (0x6B)
        }
    }
    ElseIf (ATKP)
    {
        ^^^^ATKD.IANE (0x6F)
    }
}

I have ATKP enabled in the KBLC SSDT. I should probably move that over to its own SSDT; I didn't realize it was being used elsewhere.

@shiecldk Is the issue here that your trackpad doesn't wake from sleep? I'm not sure if VoodooI2C will reinitialize the device after calling this method, but it should do so anyways after sleep.

shiecldk commented 1 year ago

@Qonfused Sorry my texts made you confused, lol. I can disable the Trackpad with the _Q12. I was referring to the random freezing problem on the Trackpad; when the Trackpad freezew, I can, however, reenable it by putting the laptop to sleep and waking it to get the Trackpad response again. However, it would still freeze sometime at some point.

Hence, I thought maybe we could do some time with the _Q12 method to do the same thing that sleeps and wake the laptop on the Trackpad to temporarily bypass the problem.

Maleficent-Magik commented 1 year ago

I'm thinking of opening an Issue on VoodooI2C's GitHub about the Trackpad buttons swap because I don't feel like I can find a solution...

Qonfused commented 1 year ago

--- @Qonfused https://github.com/Qonfused/ASUS-ZenBook-Duo-14-UX481-Hackintosh/issues/8#issuecomment-1354068257 (Dec 15, 2022) --- Managed to fix the buttons with a reorder of kext plugins and adding voodoops2trackpad + voodooinput in 0b67115. I downgraded voodoo kext versions as part of this, but the same fix as proposed above should be applied when updating to newer versions.

If this can be reproduced, it should provide a much clearer picture of what is actually going on with the trackpad buttons. This may be blocked by a regression in VoodooI2C code.

Maleficent-Magik commented 1 year ago

I will take care of it soon, I am overwhelmed by my law classes...

I'm sorry... I could be free in 1 or 2 weeks to try to see what it changes

Qonfused commented 1 year ago

Looking into this issue again, it seems that versions 2.7+ recognize both trackpad buttons (not just the primary button).

Previous behavior in 2.6.5 not recognizing the second button was first resolved in version 2.7 due to this PR:

The very next commit in 2.7 pulls in changes from VoodooI2CHID, which notably incorporates some work from 1Revernger1 reworking gvkt's prior PR in #58:

^^ This last PR appears directly related to this issue as the trackpad must be using different report ids as a way to distinguish between the physical trackpad device and buttons.

Qonfused commented 1 year ago

On Linux, the trackpad uses multiple drivers per the same HID device to handle the touchpad and mouse inputs as separate HID interfaces (as do the touchscreens for mouse/touchscreen/stylus inputs). It does not expose the trackpad and buttons as separate devices.