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

readLEDs reporting incorrect values #61

Closed
9ary opened this issue Oct 7, 2015 · 12 comments
Closed

readLEDs reporting incorrect values #61

9ary opened this issue Oct 7, 2015 · 12 comments
Assignees

Comments

@9ary
Copy link
Contributor

9ary commented Oct 7, 2015

I've wired up and configured my keyboard with a Teensy 3.1, and I was hoping I could come up with a hack to enable a numpad layer (it's a Truly Ergonomic, was a hell to mod but the original controller was fried) when numlock is on.
Still haven't wired the status LEDs but it looks like the controller is not updating the LED register value properly as readLEDs always returns the value the LEDs had when plugging the keyboard in.
I have a Logitech keyboard hooked up to the same machine and the LEDs behave properly on that. I'm running Arch 64 bit and I'm affected by #58. Happens both in X11 and in the virtual console. Just tested on Windows 10 on the same machine, same issue there.

@haata haata self-assigned this Oct 7, 2015
@haata
Copy link
Member

haata commented Oct 7, 2015

Interesting.
These were working, though I might have broken this when I fixed a bunch of USB issues in the last few months.

@9ary
Copy link
Contributor Author

9ary commented Oct 7, 2015

I've started investigating the issue, enabled all debug in usb_dev.c and I get the following output when any LED changes to any state (toggling them with another keyboard to make sure I only get LED packets).

CONTROL - pid:0xD, count:0x80034 - bmRequestType:0x21, bRequest:0x9, wValue:0x201, wIndex:0x1, len:2
WARNING - SET_REPORT - 0x201 - 0x1
STALL
CONTROL - pid:0xD, count:0x80034 - bmRequestType:0x21, bRequest:0x9, wValue:0x200, wIndex:0x0, len:1
WARNING - SET_REPORT - 0x200 - 0x0
STALL

So it's indeed trying to update the LEDs but not receiving the proper data from the PC. Since it happens on both Linux and Windows I suppose it might be a descriptor issue since the possibility of an OS bug is already cleared.

@haata
Copy link
Member

haata commented Oct 9, 2015

The USB portion seems to work correctly for me.

0x1 - Numlock
0x2 - Capslock
0x4 - Scrolllock

readLEDs only reads the current status. It doesn't automatically trigger when a change occurs (even though the state is recorded).

I do have some draft spec details on how to use USB Leds as triggers to combinations, but I won't have time to get to do the implementation until the first set of ErgoDox issues are fixed.

The easiest thing to do for now would be just to modify the led handling code here: https://github.com/kiibohd/controller/blob/master/Output/pjrcUSB/arm/usb_dev.c#L426

Now, this may be a 6KRO issue (looking at that next).

@9ary
Copy link
Contributor Author

9ary commented Oct 9, 2015

Odd, it doesn't work for me. readLEDs always reports 0 or 1 regardless of numlock and capslock. Seems to change at random when I change the LED states.

And yeah, that's exactly what I was planning to do.

@haata
Copy link
Member

haata commented Oct 9, 2015

Hmm, I'm getting random status as well now.
Time to pull out the USB analyzer :D

@tmk
Copy link

tmk commented Oct 9, 2015

I think Set report should read "data" for led status instead of wdata.

@9ary
Copy link
Contributor Author

9ary commented Oct 9, 2015

Well I just checked with usbmon, the computer is indeed sending bogus data to the keyboard and not always, while my Logitech keyboard is getting proper reports.

@haata
Copy link
Member

haata commented Oct 10, 2015

I've been messing with the code. Something larger is wrong, should have a fix soon.

@haata
Copy link
Member

haata commented Oct 10, 2015

Fixed. Tested under both 6KRO and NKRO modes and seems to be working.
f4da256

Let me know if you still have issues.

@haata haata closed this as completed Oct 10, 2015
@9ary
Copy link
Contributor Author

9ary commented Oct 10, 2015

Seems to work fine here, thanks a lot. Time to grab the soldering iron again. By the way, is the SET_REPORT function the right place to set my physical LEDs up ? Or is there a facility for that ?

@haata
Copy link
Member

haata commented Oct 10, 2015

There isn't a facility (yet) unfortunately. But I'll be adding somewhere around here: https://github.com/kiibohd/controller/blob/master/Output/pjrcUSB/arm/usb_dev.c#L692

@9ary
Copy link
Contributor Author

9ary commented Oct 10, 2015

Thanks, I'll see what I can do with that.

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