Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Fn-lock status for vivobook on startupp #1596

Closed
seerge opened this issue Nov 13, 2023 · 10 comments
Closed

Detect Fn-lock status for vivobook on startupp #1596

seerge opened this issue Nov 13, 2023 · 10 comments
Labels
question Further information is requested

Comments

@seerge
Copy link
Owner

seerge commented Nov 13, 2023

For a while now, after the laptop wakes up from sleep, I have to turn on and off Fn Lock so that secondary functions of F keys work (volume, etc.). It seems that after waking up from sleep/hibernation, the F keys work as normal F keys. I thought it was just some minor quirk of the app so I didn't report or open an issue. However, this issue lead me to think more about why this is happening.

Just for context (from Computer Hope) :

The FnLk, F-Lock key is a toggle on a PC compatible keyboard used to enable or disable the F1 through F12 keys' secondary functions (hotkeys)...
Pressing and releasing the F-Lock key toggles on, or enables, the F1-F12 keys to use their standard functions. Pressing the F-Lock key again toggles off (disables) the F1-F12 key standard functions, and turns on the ability to use the secondary functions on those keys.

On my device (Vivobook X515, with dedicated Fn-Lock), if I turn on Fn-Lock via the keyboard (Fn+Esc), G-Helper reports that Fn-Lock is off and vice versa. So it seems, that the Fn-Lock toggle in G-Helper (v0.129) is reversed?

Also, I noticed that upon waking up from sleep, the Fn-Lock on G-Helper stays on. On laptops with a dedicated Fn-Lock with an LED indicator, it is of course turned off. So, I think G-Helper should turn off Fn-Lock upon waking up from sleep/hibernation.

So the flow might be like:

G-Helper starts up/wakes from sleep/Fn-Lock OFF: UI Fn-Lock OFF (grey) & run this command with Control_status=0 (for laptops with a dedicated Fn-Lock) & process the secondary functions of F-keys {if WMI 78 (dedicated Fn-Lock) -> Fn-Lock ON}

Fn-Lock ON: UI Fn-Lock ON (blue) & run this command with Control_status=1 & do not process F keys' secondary functions (that is, F keys work normally) but still listen to certain WMI events like 78 {if WMI 78 -> Fn-Lock OFF}

Thanks!

Originally posted by @krystean in #1581 (comment)

@seerge
Copy link
Owner Author

seerge commented Nov 13, 2023

@krystean I have separated this, as otherwise it confuses guy from original issue. As this is not related to his case anyhow.

Can you check if running this command returns correct (actual) status of hardware fn-lock in your case (as 1 and 0) ?

Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DSTS -Arguments @{Device_ID=0x00100023}

@krystean
Copy link

@seerge Sorry about that and thank you!

The output of the command you gave above is:

device_status ReturnValue PSComputerName
------------- ----------- --------------
        65536        True

The output of the command:

Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DEVS -Arguments @{Device_ID=0x00100023; Control_status=1}

which turns on Fn-Lock, that is Control_status=1, is:

result ReturnValue PSComputerName
------ ----------- --------------
     1        True

The result is 0 if Control_status=0.

Thanks!

@seerge seerge added the question Further information is requested label Nov 13, 2023
@seerge
Copy link
Owner Author

seerge commented Nov 13, 2023

@krystean good, but what does

Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DSTS -Arguments @{Device_ID=0x00100023}

return when fn-lock is on ?

If it's readable it should be 65537

@krystean
Copy link

@seerge

The output of the command

Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DSTS -Arguments @{Device_ID=0x00100023}

when Fn-Lock is off:

device_status ReturnValue PSComputerName
------------- ----------- --------------
        65536        True

when Fn-Lock is on:

device_status ReturnValue PSComputerName
------------- ----------- --------------
        65536        True

It's 65536 when both on and off.

Thanks!

@seerge
Copy link
Owner Author

seerge commented Nov 13, 2023

@krystean then it's a bad news :) it means you can't read a status of fn-lock, therefore g-helper can't sync it's visualization with what actually happens.

Maximum i can offer - is to reset fn-lock in app (i.e. in UI) to OFF every time app starts. Will that work ?

@krystean
Copy link

@seerge Instead of reading the status of the Fn-Lock from the system, can we instead enforce the status on G-Helper? :) In config.json there's an fn_lock key that gets updated whenever Fn-Lock is toggled on the UI. Is it posible that whenever the value of fn_lock is read (eg at startup), the command

Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DEVS -Arguments @{Device_ID=0x00100023; Control_status=<fn_lock_value>}

is run using the value of fn_lock and whenever the value is updated (eg, turning it on and off in the UI), the command is run with the value it's changed into?

Thanks!

@seerge
Copy link
Owner Author

seerge commented Nov 14, 2023

@krystean this build will run fn-lock command on app start based on config setting
GHelper.zip

@krystean
Copy link

krystean commented Nov 14, 2023

@seerge Thanks! I tried reading the code and made a few changes myself and I think I figured it out:

changes.txt

I corrected the ternary operation in the first change. I think I had a hand in this as I remember you had to flip the command when the Fn-Lock was still a checkbox in Extra. Sorry lol

The second change is copying the line you added in f8df547 for init-ing FnLock so that it runs during logon too because Fn keys' alternate functions revert to Windows default ones after waking up from sleep.

Applying these changes on my end make Fn-Lock work as I expect, however, I don't know if it's the best practice lol

Thanks!

seerge added a commit that referenced this issue Nov 15, 2023
@seerge
Copy link
Owner Author

seerge commented Nov 15, 2023

@krystean try this build

GHelper.zip

@krystean
Copy link

@seerge This works even better! Fn-Lock turns on even on the lock screen. Thanks!

@seerge seerge closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants