inmbolmie / 5250_usb_converter

Converter to plug an IBM 5251 terminal to a Linux PC via USB emulating a VT52 terminal
GNU General Public License v3.0
34 stars 6 forks source link

scancodeDictionaries['122KEY_EN'] does not correctly distinguish Insert and Delete keys #16

Closed dcoshea closed 7 months ago

dcoshea commented 8 months ago

scancodeDictionaries['122KEY_EN'] includes:

        # TEXT EDIT MODE KEYS BLOCK MAPPINGS
        # KEYS FROM TOP TO BOTTOM AND FROM LEFT TO RIGHT
        ...
        0x6c: [chr(0x1b), chr(0x1b), chr(0x1b), '', ''], #
        0x57: [chr(0x1B), chr(0x1B), chr(0x1B), '', ''], #
        # 0x6c

The entries shown are the last two, for the Insert and Delete keys respectively. From 5250_Information_Display_System_to_S36_S38_AS400_System_Units_Product_Attachment_Information_198910.pdf page 185 figure 103, it can be seen that those are key numbers 81 and 86 respectively. From page 189 it can be seen that those keys generate the same scan code, and if Alt is not held, based on the "ALT Key Up Note" column and the notes on page 186 it can be seen that the keys can be differentiated based on the shift state.

In the code above, the 0x6c row was presumably intended for the Insert key and the 0x57 key was presumably intended for the Delete key, but the latter scan code appears in the SHIFT_PRESS list, so presumably that entry in the table is ignored. The following # 0x6c comment is probably related to the fact that in a scan code dump the Delete key generated both 0x57 and 0x6c scan codes (due to the shift key not being held at the time).

As further evidence, on a 3476, when I replace the 0x6c entry with:

        0x6c: ["i", "d", chr(0x1b), '', ''], #

pressing Insert generates an i character and pressing Delete generates a d character, regardless of whether I'm holding shift.

Given that those keys don't currently do anything useful, and can't really be made to right now because the VT52 terminfo entry doesn't provide any suitable entries whose character sequences could be generated, it's probably not worth fixing this right now.

For the record, I think the correct terminfo capabilities are kich1 for Insert and kdch1 for Delete.

inmbolmie commented 7 months ago

Yes you are right, I think the mapping was created without realizing how those keys actually work because the up-shift and down-shift codes are not always generated (only if the shift state needs to be changed) so the 0x57 was confused for the actual key. Nevetheless those keys are tricky to use because on a regular scancode 2 keyboard those positions are for "end" and "page down" so most of the time the users would be confused anyway. That can be seen in the comments of the previous mappings.

So I think it is better to leave "insert" and "delete" mappings to the positions where they are familiar for most users and comment the others as "home" will miss "end" and "page up" will miss "page down" and maybe later if it is actually useful to anyone try to manage the 0x6C stuff.

Thanks and best regards

dcoshea commented 7 months ago

Nevetheless those keys are tricky to use because on a regular scancode 2 keyboard those positions are for "end" and "page down" so most of the time the users would be confused anyway. That can be seen in the comments of the previous mappings.

So I think it is better to leave "insert" and "delete" mappings to the positions where they are familiar for most users

Oops, I forgot I was thinking about what is written on the keys instead of what they map to on a regular PC keyboard!

Thanks!