-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature: ibmpc_usb lock state indicators on converter itself #755
Open
an-achronism
wants to merge
7
commits into
tmk:master
Choose a base branch
from
an-achronism:feature/ibmpc_converter_lock_state_indicators
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature: ibmpc_usb lock state indicators on converter itself #755
an-achronism
wants to merge
7
commits into
tmk:master
from
an-achronism:feature/ibmpc_converter_lock_state_indicators
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keyboard lock state indicator LEDs are updated by sending a control byte to the keyboard, which has one bit per individual LED state (the rest of the byte being 0s). The order of the bits is different between the USB HID and IBM PC/AT protocols, so they have to be reorganised before TMK sends them to the keyboard. The existing implementation of this works perfectly fine, but reorders the LED state control byte to IBM format before sending it to a single function that sends both the LED control enquiry byte (0xED) and the actual LED state control byte itself, one after the other. However, not every keyboard will respond to the enquiry byte with an acknowledgement (0xFA), e.g. IBM terminal keyboards which will respond instead with an 0xFE meaning "RESEND", in which case the LED state control byte will not be sent, meaning that it was just reorganised unnecessarily. This refactored implementation splits the sending of the enquiry byte into a separate function, so that the enquiry byte is sent first, and the control byte is only reorganised if the keyboard has already responded with the "ACK" acknowledgement byte.
Even with this change, avr-gcc 8 and 9 are still unable to compile, but it allows for a successful compilation in avr-gcc 5.4 and 5.5. 5.4 is still hanging on for dear life inside the VirtualBox VM provided in the TMK wiki: https://github.com/tmk/tmk_keyboard/wiki/Build-on-VirtualBox 5.5 is still currently available through Homebrew keg here: https://github.com/osx-cross/homebrew-avr I have not yet tested avr-gcc versions 6 or 7, because neither is straightforwardly available to me (i.e. through on a package manager on macOS, Windows, or Linux distro that can be set up quickly on a VM).
Further restructured lock state LED routine to update both the keyboard and any indicators wired to the converter itself. Tested on Unicomp New Model M and various different IBM keyboards (a 5150 one, a 122-key, and a 1990 Enhanced Keyboard). Current behaviour is that the converter LEDs always light regardless of whether the keyboard has them, which is primarily because of edge cases where a keyboard might respond indicating that it can be sent LED state control bytes even though it doesn't actually have LEDs with which to render the information.
an-achronism
changed the title
Feature: ibmpc_usb converter lock state indicators
Feature: ibmpc_usb lock state indicators on converter itself
Mar 5, 2023
Renamed in one file and not the other, which was an artefact of naming difference in another firmware. Fixed and retested now. Sorry!
My intention with splitting up ibmpc.host_set_led() into two functions was to ensure that the bit order of the USB HID LED update byte was not reconfigured to IBM order unless it was actually going to be used. However, it has been suggested that splitting the check for whether the keyboard can receive the LED byte and the subsequent sending of the LED byte into separate functions in some way implies that they are less contextually connected and inter-reliant, which could hypothetically lead to a misunderstanding and potentially the addition of code that does unwise things with these newly separate functions (e.g. you can't send the LED byte without sending the check byte immediately prior, you can't send multiple LED bytes after only ascertaining once that the keyboard is capable of receiving them, and so forth). To reduce the likelihood of this interpretation, I've removed the case- specific functions for sending the two bytes from ibmpc and called ibmpc.host_send() directly from ibmpc_usb.cpp to make it clearer that the LED byte should only be sent immediately after the check byte.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactored LED indicator routine to incorporate updating LEDs on the converter itself (LEDs wired directly to controller pins) primarily for the sake of keyboards that speak unidirectional protocols and/or have no LED indicators on them. Still safeguards sending IBM-formatted LED control byte to "XT" protocol keyboards or anything that has not yet been identified, just does it in a different place to facilitate controlling the LEDs on the converter.
If there are any issues with the way I've structured the converter LED part, I have a separate branch on which I just refactored the existing routine to make it slightly more efficient (specifically, it now only converts the USB HID format LED control byte to IBM format if it's already determined that it will be sending it to the keyboard, whereas before it did the translation anyway and could then decide afterwards that it was not going to be used).
Note: Mousekeys disabled by default because even when using avr-gcc 5.4 or 5.5, I cannot get TMK to compile either on Ubuntu 20.04 LTS or on macOS with Mousekeys disabled (not just because of my changes, but also from master branch).