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

NumLock "flash" doesn't work while DFx working #1096

Open
EMPI-PL opened this issue May 15, 2023 · 7 comments
Open

NumLock "flash" doesn't work while DFx working #1096

EMPI-PL opened this issue May 15, 2023 · 7 comments
Assignees

Comments

@EMPI-PL
Copy link

EMPI-PL commented May 15, 2023

Describe the bug
When DFx is in use numlock will not flash even with the option marked under Miscellaneous.
In fact no flashing whatsoever also for Caps and Scroll.

To Reproduce
Simple. Just mark the option and it should work, but...
Key note. In my build I use the following "addons" to RPi.

  • Drawbridge (aka arduino floppy). So we're using real floppy drive connected to RPi.
  • Amiga 500 USB Keyboard Controller click for more info. In this setup numlock is linked to DRIVE led. This should give you "real experience".

Expected behavior
It should flash numlock/drive led as the floppy is read.

@giantclambake
Copy link

giantclambake commented May 22, 2023

Whilst I can easily recreate this (amiberry 5.6.1/linux/x86-64), after a bit of reading....

AFAICT earlier revisions of amiberry used the linux kernel sysfs interface to implement this feature...

...since then, use of the sysfs interface has been deprecated, and userspace programs should use libgpiod instead...

...in the amiberry Makefile, 'USE_GPIOD=1' has been commented out....

...amiberry 5.6.x has no cited dependency for libgpiod ....

It leaves me with the impression that the keyboard LED support (for power, floppy activity, etc) has yet to be re-implemented using the libgpiod API --- no doubt the project maintainer can confirm/deny my speculation here =)

@midwan midwan self-assigned this May 23, 2023
@midwan
Copy link
Collaborator

midwan commented May 23, 2023

The keyboard LEDs are used through ioctl, but there are some cases were they don't seem to work due to how Linux works:

@midwan
Copy link
Collaborator

midwan commented May 23, 2023

Whilst I can easily recreate this (amiberry 5.6.1/linux/x86-64), after a bit of reading....

AFAICT earlier revisions of amiberry used the linux kernel sysfs interface to implement this feature...

...since then, use of the sysfs interface has been deprecated, and userspace programs should use libgpiod instead...

...in the amiberry Makefile, 'USE_GPIOD=1' has been commented out....

...amiberry 5.6.x has no cited dependency for libgpiod ....

It leaves me with the impression that the keyboard LED support (for power, floppy activity, etc) has yet to be re-implemented using the libgpiod API --- no doubt the project maintainer can confirm/deny my speculation here =)

@giantclambake That code relates to using the GPIO header pins for actual activity LEDs, not the same as using the keyboard LEDs. It's optional but since some people requested that, it's now available in the Makefile (you'll have to enable it if you want to use it).

@giantclambake
Copy link

@midwan Thanks for the clarification

@EMPI-PL
Copy link
Author

EMPI-PL commented May 23, 2023

The keyboard LEDs are used through ioctl, but there are some cases were they don't seem to work due to how Linux works:

I went over your link @midwan to the bug with DietPi.
Running setleds +num from console results with the following error:
setleds unable to read keyboard flags inappropriate ioctl for device

I'm not sure if it helps in any way but thought it may be useful.

@giantclambake
Copy link

//Adding this, Debian 10.13/amiberry v5.6.1

From X environment (xterm);

gcb@gallah:~$ setleds
setleds: Error reading current flags setting. Maybe you are not on the console?: ioctl KDGKBLED: Inappropriate ioctl for device

...follow on with...;

Alt-F2 --> login on tty2 ---> setleds works as expected (no error)

@giantclambake
Copy link

giantclambake commented Jun 4, 2023

//....just digging this further --- be mindful this is relative to Xorg desktop environment ...but first...

@EMPI-PL

Try this (user must be in sudoers list) ;

//turn capslock ON

sudo bash -c "/usr/bin/setleds -D +caps < /dev/console"

//turn capslock OFF

sudo bash -c "/usr/bin/setleds -D -caps < /dev/console"

That should work from a xterm but unfortunately needs root permissions....


In the Xwindows environment, you have to do something like this;

//runtime -- changes are volatile and lost after logout/reboot....

xkbcomp $DISPLAY myconf.xkb //dump current xkb configuration

nano myconf.xkb --> search for the following fields and remove the exclamation marks before allowExplicit;

indicator "Caps Lock" {
        !allowExplicit;
        whichModState= locked;
        modifiers= Lock;
    };
    indicator "Num Lock" {
        !allowExplicit;
        whichModState= locked;
        modifiers= NumLock;
    };
    indicator "Scroll Lock" {
         !allowExplicit;
        whichModState= locked;
        modifiers= ScrollLock;
    };

Save the edited file and load it as the current xkb config;

xkbcomp myconf.xkb $DISPLAY

Now the following commands should work ;

//turn capslock ON

$ xset led named 'Caps Lock' //alternately you can address LEDs by number 1-3 ...ie; xset led 1

//turn capslock OFF

$ xset -led named 'Caps Lock' // xset -led 1

//
//Permanent system wide changes -- non-volatile ....
//

Edit /usr/share/X11/xkb/compat/{ledcaps,lednum,ledscroll}

Remove the exclamation mark before allowExplicit; ( !allowExplicit; -> allowExplicit; ) in each file and save

Logout of X and log back in again --- now the following commands should work as normal user

$ xset led named 'Caps Lock' //alternately you can address LEDs by number 1-3 ...ie; xset led 1
$ xset -led named 'Caps Lock' // xset -led 1

This won't fix the status-quo obviously, as amiberry isn't using xset nor XChangeKeyboardControl() to control the keyboard LEDs in an xsession ...but perhaps it can?

Note: if you are using a wireless keyboard, the power management in the keyboard itself will turn off LEDs after a set time of keyboard inactivity (usually 5 ~ 10 seconds, save battery) ....I really doubt there's any way around this ; wired keyboards are fine however.

HTH

edit: Just FTR & FWIW, the LED functions work correctly when launching amiberry from console

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

No branches or pull requests

3 participants