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

Added screen toggle (FN + F6) and touchpad toggle (FN + F10) #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Dathuss
Copy link

@Dathuss Dathuss commented Sep 24, 2023

Hey ! I added stuff to make the FN + F6 (to toggle the screen on and off) and FN + F10 (to toggle the touchpad on and off) keys work !
For the screen, I used the linux/backlight.h functions to toggle it on and off
As for the touchpad, it's a bit trickier. I get the touchpad acpi device and bind/unbind its driver when toggled. Haven't found a better solution for that.
I tried to make the code as concise as possible so that you can quickly understand how it works ! (i hope !)
All of this was tested on the 15P model, so I hope it will work on other models as well ! (there's no reason it wouldn't but we never know !)

@mpolishchuck
Copy link

Thank you for your work.

Adding info related to my Aero 17 XE5.
In my case I had to change the following constants:

#define GIGABYTE_KBD_TOUCHPAD_DEVICE_HID "ELAN0A02"
#define GIGABYTE_KBD_TOUCHPAD_DEVICE_INSTANCE_NO 0

Seems like my touchpad has different device ID. It works when I press Fn+F10. I'm able to enable/disable touchpad. So in fact need to find correct way to specify different device ID for different laptop models... Or need to try different devices.

About enabling/disabling backlight. Well, it switches something. At least no fatal errors and the function gigabyte_kbd_is_backlight_off works. But in fact nothing happens. My display is always on, which is weird.

Cannot make a promise, but if I will have more time I can do more careful investigation. Just leaving what I know already here.

@Dathuss
Copy link
Author

Dathuss commented Oct 11, 2023

hey, thanks for the info !
i'll look into adding a solution that handles the device dependant touchpad stuff.
meanwhile, can you look into /sys/class/backlight and tell what directory you see ? for me it's 'intel_backlight'. inside this directory, can you tell if running 'echo 1 > bl_power' turns off your screen ? (probably needs sudo rights for that). if it does, blindly type 'echo 0 > bl_power' and it should turn it back on.
that's a bit of a weird issue but i guess this can be circumvented by setting the screen's brightness to 0 (with backlight_device_set_brightness) when the user presses fn+f10 and store the original brightness temporarily, and restore it later

…ded)

Also moved device constants into the header file
@Dathuss
Copy link
Author

Dathuss commented Oct 11, 2023

Added support for multiple touchpad devices instead of a single constant ! If anyone notices another laptop model has different constants, you'll have to add them in gigabyte_kbd_touchpad_device_identifiers inside gigabytekbd_driver.h, and stuff should work just fine ! (hopefully). As long as this branch doesn't get merged with main, feel free to open a PR on my fork if you have any improvements !

@mpolishchuck
Copy link

Hey @Dathuss
Answering your questions.

# ls /sys/class/backlight
intel_backlight
# ls /sys/class/backlight/intel_backlight
actual_brightness  bl_power  brightness  device  max_brightness  power  scale  subsystem  type  uevent
# echo 1 > /sys/class/backlight/intel_backlight/bl_power 
# cat /sys/class/backlight/intel_backlight/bl_power 
1
# echo 0 > /sys/class/backlight/intel_backlight/bl_power 
# cat /sys/class/backlight/intel_backlight/bl_power 
0

So I have intel_backlight as well. But nothing happens when I try to write something to bl_power. I mean that pseudofile exists and I can read what I've just written. But it does not control the screen backlight.

About idea of changing brightness to zero. I think it won't work for me. Now I set brighness using light tool. When I set brightness to 0 the screen is still not turned off (brighness is the lowset but not zero).

# light -S 0
# cat /sys/class/backlight/intel_backlight/brightness 
0
# light -S 100
# cat /sys/class/backlight/intel_backlight/brightness 
1008

Fn+F6 works strange even on Windows. It performs system logout. Screen is black in this case, but I think this is something what Windows does by itself. But this is just a theory.
Maybe it works as designed.

A little question about touchpad switch on/off. Is it possible to generate XF86TouchpadOn and XF86TouchpadOff when touchpad has been enabled or disabled respectively? This may help to show a notification for the user.
I want to implement something like this this, but I do not have idea how :) I think I need to write something to rd buffer somewhere under HIDRAW_FN_F10 part of switch in gigabyte_kbd_raw_event function (like it's done for brightness up/down buttons), but no idea how to get proper code and what shoud I read to learn (I have zero experience in HID drivers development).

@Dathuss
Copy link
Author

Dathuss commented Oct 12, 2023

hey,
well, that's a real shame that backlight specific stuff seems broken for you. i'm starting to think this is a firmware issue. are you perchance on linux mint ? i also had some really broken power management related stuff on this distro. other than that, i don't know. try using another distro in a bootable disk and see if it works there. if not, idk what to tell you.
about touchpad on/off, i'd say yes and no. XF86TouchpadOn/Off can be generated but you would need to use xbindkeys for that, which also means you'd have to generate a valid keycode with the rd buffer that could be used by xbindkeys. and honestly, i have no idea how to do that. things like this are so little documented that i can barely find any information on how to generate one, or how the author of this driver even found out which values to use in the first place. so yeah... idk where to go now.

@mpolishchuck
Copy link

mpolishchuck commented Oct 22, 2023

@Dathuss

i'm starting to think this is a firmware issue. are you perchance on linux mint ? i also had some really broken power management related stuff on this distro.

I use ArchLinux. Probably you're right since I did not do anything related to firmware yet :) Probably need more experiments on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants