Key value conversion method for USB keyboard, keyboard converter and key value conversion system

By converting the key values of the keyboard device into matrix information and comparing them with the historical matrix information, the problem that existing keyboards cannot be customized and saved offline is solved, and the hardware-level customization and offline storage of key values are realized, improving user operation convenience.

CN115586840BActive Publication Date: 2025-07-29SHANDONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211234044.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-10
Publication Date
2025-07-29
Estimated Expiration
2042-10-10

AI Technical Summary

Technical Problem

The existing keyboard cannot achieve fully customized functions, the operation is cumbersome and cannot be saved offline, affecting user experience and productivity.

Method used

By converting the key values of the keyboard device into matrix information and comparing them with the historical matrix information, if there is a change, the matrix information is mapped into key values, and corresponding operations are performed to realize hardware-level modification and customization of key values.

Benefits of technology

After power outage or replacement of equipment, the key-value custom operation still takes effect, simplifying the operation process and reducing user usage costs and time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115586840B_ABST
    Figure CN115586840B_ABST
Patent Text Reader

Abstract

The present invention provides a key value conversion method, a keyboard converter and a key value conversion system for a USB keyboard, which relates to the technical field of keyboard operations. The key value conversion method includes: obtaining the key values of the connected keyboard device, converting the key values into matrix information, wherein the high four bits of the key value are used as the columns of the matrix, and the low four bits of the key value are used as the rows of the matrix; if the matrix information changes compared with the previously stored historical matrix information, mapping the matrix information to a key value; and performing corresponding operations according to the mapped key value. Compared with the existing method of scanning the state of key switches through the general-purpose input / output interface of a single-chip microcomputer, this method can modify, add, customize and switch key values at the hardware level of the keyboard device, so that the saved data and operations are still effective after reconnecting even after power-off, replacing terminal devices such as computers, or replacing the keyboard device, thereby improving the convenience of user operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of keyboard operation, and in particular relates to a key-value conversion method of a USB keyboard, a keyboard converter and a key-value conversion system. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute the prior art that has been known to those skilled in the art.

[0003] Keyboards are an essential component of input devices. Over time, driven by evolution and market demand, keyboards have been categorized into six main types: desktop keyboards, laptop keyboards, industrial computer keyboards, steno keyboards, dual-control keyboards, and ultra-thin keyboards. Their purpose is to better assist users in inputting content. Keyboard connectors have also largely evolved from the older PlayStation (round) connector to the current USB (flat) connector.

[0004] With the advancement of technology and the development of the information age, the input requirements for keyboards have also increased. Users will encounter many repetitive and complicated input keys when using the keyboard, and may even need to press a combination of keys that are far apart. Such a usage environment causes considerable trouble to the user's work, so now more and more new keyboards and software support certain "customization" functions for keyboard keys, allowing users to decide and set the functions on the keyboard according to their own preferences during use. However, due to cost and user demand, most keyboards on the market are unable to achieve complete customization functions. They only have simple key operations and definitions, which makes some users still unable to meet their own input needs. Although a small number of keyboards support complete customization functions, the following problems still exist:

[0005] (1) The operation is cumbersome and may even require editing and modifying the computer registry to achieve the purpose of defining key values. Improper operation may cause equipment failure and irreversible loss and damage of user data.

[0006] (2) Some software that can change keyboard key values cannot be saved offline. Once the computer is shut down, the software is closed, or a system conflict occurs, the previously modified content will be restored to the previously unused state, which is very inconvenient to use.

[0007] (3) It is impossible to perform customized operations on wireless keyboards and old keyboards, which affects the user experience and productivity level. Summary of the Invention

[0008] In order to solve the above problems, the present invention provides a key-value conversion method of a USB keyboard, a keyboard converter and a key-value conversion system.

[0009] The present invention mainly includes the following aspects:

[0010] In a first aspect, an embodiment of the present invention provides a key value conversion method for a USB keyboard, including:

[0011] Obtain the key value of the connected keyboard device, and convert the key value into matrix information, where the high four bits of the key value are used as the columns of the matrix, and the low four bits of the key value are used as the rows of the matrix;

[0012] If the matrix information has changed compared with the previously stored historical matrix information, map the matrix information to a key value;

[0013] Store the matrix information, and perform corresponding operations according to the mapped key value.

[0014] In a possible implementation manner, before obtaining the key value of the connected keyboard device and converting the key value into matrix information, it further includes:

[0015] Monitor and receive the connection status of the keyboard device;

[0016] If it is determined that a keyboard device is connected, obtain the data sent by the keyboard device by enumerating the keyboard device, and parse out the key value of the keyboard device.

[0017] In a possible implementation manner, the method of enumerating the keyboard device includes: reset; obtain the device descriptor and set the address; obtain the configuration descriptor and set the configuration; obtain the report descriptor and set the idle; after correctly enumerating the keyboard device, establish a data transmission channel for obtaining the data sent by the keyboard device.

[0018] In a possible implementation manner, during the process of obtaining the data sent by the keyboard device, create a polling thread according to the endpoint polling time in the endpoint descriptor, and send an IN token to the keyboard device at a preset time interval to grab data from the keyboard device.

[0019] In a possible implementation manner, enable the timer interrupt, and the time of the timer is determined according to the polling time of the device's endpoint descriptor. In the timer interrupt callback, the host sends an IN token to the device.

[0020] In a possible implementation manner, transmit the mapped key value to the terminal device.

[0021] In a second aspect, an embodiment of the present invention further provides a keyboard converter, including:

[0022] A data processing module, configured to obtain the key values of the connected keyboard device, convert the key values into matrix information, where the high four bits of the key values are used as the columns of the matrix, and the low four bits of the key values are used as the rows of the matrix; if the matrix information changes compared with the previously stored historical matrix information, map the matrix information to key values; store the matrix information, and perform corresponding operations according to the mapped key values.

[0023] In a possible implementation manner, it further includes: a USB host module, configured to monitor and receive the access status of the keyboard device; if it is determined that a keyboard device is accessed, obtain the data sent by the keyboard device by enumerating the keyboard device, and parse out the key values of the keyboard device.

[0024] In a possible implementation manner, it further includes: a USB device module, configured to transmit the mapped key values to the terminal device.

[0025] In a third aspect, the present invention further provides a key value conversion system, including a keyboard device, a keyboard converter as described in the second aspect above, and a terminal device, where the keyboard device is connected to the terminal device through the keyboard converter.

[0026] The above one or more technical solutions have the following beneficial effects:

[0027] The present invention provides a key value conversion method for a USB keyboard. Compared with the existing method of scanning the state of key switches through the general-purpose input / output interface of a single-chip microcomputer, by converting the obtained key values of the keyboard device into matrix information and comparing them with the previously stored historical matrix information, if a change occurs, map the matrix information to key values, and perform corresponding operations according to the mapped key values. In this way, the key values can be modified, added, customized, and switched at the hardware level of the keyboard device, so that the saved data and operations are still valid even after power-off, replacing terminal devices such as computers, or replacing the keyboard device and then reconnecting.

[0028] Moreover, once the settings and changes are completed under the WIN system, there are no requirements for the subsequent operating system, operating environment, and keyboard device, thereby simplifying the module operation process, reducing the time cost for users to use, and improving the convenience of user operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The specification drawings forming a part of the present invention are used to provide a further understanding of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention.

[0030] Figure 1 is one of the flow diagrams of a key value conversion method for a USB keyboard provided in Embodiment 1 of the present invention;

[0031] Figure 2 This is a second flow chart of a method for converting key values of a USB keyboard provided in the first embodiment of the present invention;

[0032] Figure 3 It is a structural diagram of the key-value conversion system provided by the third embodiment of the present invention. DETAILED DESCRIPTION

[0033] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0034] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0035] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0036] Example 1

[0037] like Figure 1 As shown, an embodiment of the present invention provides a keyboard key value conversion method, which specifically includes the following steps:

[0038] S101: Acquire a key value of a connected keyboard device, and convert the key value into matrix information, wherein the upper four bits of the key value are used as the columns of the matrix, and the lower four bits of the key value are used as the rows of the matrix.

[0039] In a specific implementation, a standard USB keyboard device has five types of USB descriptors: device descriptor, configuration descriptor, report descriptor, interface descriptor, and endpoint descriptor.

[0040] Taking the report descriptor of a HID keyboard device as an example, 8 bytes of data are obtained. The HID key value data is between 0 and 255. The lower four bits of the key value can be regarded as matrix columns, and the upper four bits of the key value can be regarded as matrix rows. For example, if the HID key value of A is 0x04, then it is 0 row and 4 column in the matrix, and so on for other key values. After such a conversion, all HID key values can be converted into matrix rows and columns.

[0041] S102: If the matrix information is changed compared to the historical matrix information stored last time, the matrix information is mapped to a key value.

[0042] In a specific implementation, first, a virtual matrix is established. For this embodiment, it is a keyboard without a physical entity. In essence, it is still a keyboard, except that the scanning method is different. The existing keyboard scanning method is to scan the state of key switches through the general-purpose input / output interface of a single-chip microcomputer, while in this embodiment, the data of the keyboard device is captured and then converted into matrix information. If the matrix information changes compared with the previously stored historical matrix information, the matrix information is mapped to a key value.

[0043] Specifically, first, a 16×16 matrix is established and named current_matrix, which is used to save the information of the key value data scanned currently converted into a switch matrix. Then, another 16×16 matrix is established and named previous_matrix, which is used to save the information of the key value data scanned last time converted into a switch matrix. The data filled in this matrix is all 0 or 1. The method of converting a key value into a switch matrix is as follows:

[0044] The HID key value is between 0 and 255, and when converted to hexadecimal, it is 0 to 0xff. The upper four bits are used as the rows of the switch matrix, and the lower four bits are used as the columns of the switch matrix. When the connected keyboard types in A, the USB host module will scan the key value data of 0x04, and when converted into a switch matrix, it is to set 1 at the position of row 0 and column 4. The same applies to other key values.

[0045] When judging whether the switch matrix information has changed, only a two-layer loop needs to be established. The loop variables are row (0 to 15) and col (0 to 15), and current_matrix[row][col] is compared with previous_matrix[row][col] to see if they are equal. If they are not equal, it means the matrix has changed, and then the loop is jumped out immediately. Then, we update previous_matrix to current_matrix for judging whether the matrix has changed after the next scan.

[0046] In this way, a 16×16 virtual matrix is established in advance, and key values are filled in the corresponding positions of the matrix. For example, 0x04 is filled in row 0 and column 4, 0x05 is filled in row 0 and column 5, and so on. Later, when the key value needs to be edited, only the value in this matrix needs to be modified. For example: fill 0x05 at the position of row 0 and column 4. When the connected keyboard types in A, the PC side will trigger B, and thus the key value conversion is achieved.

[0047] S103: Perform corresponding operations according to the mapped key value.

[0048] In a specific implementation, the mapped key value is sent to the device terminal, and corresponding operations are performed according to the mapped key value.

[0049] Compared with the existing method of scanning the status of key switches through the general input / output interface of a single-chip microcomputer, the key value conversion method provided by the embodiments of the present invention converts the key values of the obtained keyboard device into matrix information, and compares it with the previously stored historical matrix information. If it changes, the matrix information is mapped to a key value, and corresponding operations are performed according to the mapped key value. In this way, key values can be modified, added, customized, and switched at the hardware level of the keyboard device, so that the saved data and operations are still effective even after power-off, replacing terminal devices such as computers, or replacing the keyboard device and then reconnecting. Once this method is set and completed under the WIN system, there are no requirements for the subsequent operating system, operating environment, and keyboard device, thus simplifying the module operation process and reducing the steps and time costs for users to use.

[0050] As an optional implementation manner, as Figure 2 shown, before obtaining the key values of the connected keyboard device and converting the key values into matrix information, it further includes:

[0051] Monitoring and receiving the connection status of the keyboard device;

[0052] If it is determined that a keyboard device is connected, the data sent by the keyboard device is obtained by enumerating the keyboard device, and the key values of the keyboard device are parsed.

[0053] In specific implementation, there are many types of USB devices. In the embodiments of the present invention, only keyboard devices are enumerated, and other devices such as USB flash drives, cameras, and HUBs will be ignored. The method of enumerating the keyboard device includes: resetting; obtaining a device descriptor and setting an address; obtaining a configuration descriptor and setting a configuration; obtaining a report descriptor and setting an idle state; after correctly enumerating the keyboard device, establishing a data transmission channel for obtaining the data sent by the keyboard device.

[0054] In a specific application, after correctly enumerating the keyboard device, the configuration descriptor can be parsed to obtain the endpoints used by the keyboard device to send and receive data. This endpoint can be regarded as the channel for data exchange between the USB host and the keyboard device. The keyboard device sends data through the sending endpoint (IN EP), and the USB host sends data to the keyboard device through the receiving endpoint (OUT EP). Analyze the report descriptor. Since the key values sent by different keyboard devices have special definitions, and the report descriptor is used to describe this special definition. After parsing the report descriptor, the meaning of the data sent by the keyboard can be determined. For example, the report descriptor recommended by HID, which is also the descriptor equipped with every HID keyboard on the market, can be recognized by the computer's Basic Input Output System (BIOS). The general meaning of the descriptor is that the keyboard sends an 8-byte data packet. The first byte represents the 8 control keys of the keyboard in bits, including: left / right CTL, left / right ALT, left / right SHIFT, left / right WIN. The second byte is reserved (not used), and the remaining 6 bytes represent 6 key values in bytes. After the USB host successfully enumerates the device, establishes the data transfer channel, and parses the report data packet transmitted by the keyboard device, the key values sent by the keyboard device can be parsed according to the report descriptor therein.

[0055] As an optional implementation, during the process of obtaining the data sent by the keyboard device, a polling thread is created according to the endpoint polling time in the endpoint descriptor, and an IN token is sent to the keyboard device at a preset time interval to grab data from the keyboard device. Optionally, the timer interrupt is enabled, and the time of the timer is determined according to the polling time of the device's endpoint descriptor. In the timer interrupt callback, the host sends an IN token to the device and transfers data using the corresponding endpoint.

[0056] In this way, the wired or wireless 2.4G receiver connection of the USB interface can be recognized in real time, various stroke actions such as long press and short press of the keys can be accurately detected, and the conversion delay can be reduced to 1ms.

[0057] As an optional implementation, the mapped key values are transmitted to the terminal device.

[0058] In a specific implementation, to achieve this step, first, a HID keyboard needs to be implemented with the help of the USB device module. After this module is plugged into the terminal device (such as a PC), a keyboard device will be recognized on the PC. With the help of this keyboard device, the successfully converted key values are sent to the PC again.

[0059] Optionally, in the USB device module, a function can be added: the layer switching function. Unused key values on the keyboard can be configured as layer switches, and at the same time, two (or more) 16×16 key value matrices are stored in the EEPROM. For example, the RALT key is configured to switch to the second layer. When the user presses and holds the RALT key and then presses the A key, the key value conversion module will obtain the key value at the 0th row and 4th column of the second-layer key value matrix. The key value there can be configured according to needs. It can be configured as the number 1 key, so that pressing RALT+A can make the PC trigger the number 1 key. When the A key is pressed alone, the PC will only trigger the A key.

[0060] The implementation of multimedia keys is to add a multimedia report descriptor to the original keyboard report descriptor in the USB device module. In this way, by filling the corresponding key value into the send buffer and sending it to the PC by the USB device module, the PC can parse it and make corresponding responses. For example, in this key value conversion module, the key value 0xE9 corresponds to volume down. We only need to fill 0xE9 into the send buffer of the USB device module and send it to the PC to trigger volume down. The customization of multimedia key values is the same as that of ordinary key values. For example, if I want to implement RALT+A to achieve volume down, I only need to set RALT as the function key for layer switching and fill 0xE9 at the position of A (0th row and 4th column) in the second layer of the key value table, and so on for the rest.

[0061] For key value editing, HID RAW is needed to implement the communication of ordinary data between the PC and the USB device module. The USB device module sends the data of the established virtual matrix to the PC, and the PC can also edit this data and send it down to the USB device module. The USB device module then saves the data sent by the PC to the EEPROM, thus completing the modification and saving of the key value.

[0062] Through this method, key values can be modified, added, customized, and switched at the hardware level of the keyboard device, so that the saved data and operations are still effective even after power off, replacing terminal devices such as computers, or replacing the keyboard device and then reconnecting. Once the settings are made and completed under the WIN system, there are no requirements for subsequent operating systems, operating environments, or keyboard devices, thus simplifying the module operation process and reducing the steps and time costs for users.

[0063] Embodiment 2

[0064] The embodiment of the present invention also provides a keyboard converter, including:

[0065] A data processing module is used to obtain the key values of the connected keyboard device, convert the key values into matrix information. Specifically, the high four bits of the key values are used as the columns of the matrix, and the low four bits of the key values are used as the rows of the matrix. If the matrix information changes compared with the previously stored historical matrix information, the matrix information is mapped to key values, and corresponding operations are performed according to the mapped key values.

[0066] As an optional implementation, it further includes: a USB host module, which is used to monitor and receive the connection status of the keyboard device. When it is determined that a keyboard device is connected, the data sent by the keyboard device is obtained by enumerating the keyboard device, and the key values of the keyboard device are parsed.

[0067] The method of enumerating the keyboard device includes: resetting; obtaining the device descriptor and setting the address; obtaining the configuration descriptor and setting the configuration; obtaining the report descriptor and setting the idle state. After correctly enumerating the keyboard device, a data transmission channel is established to obtain the data sent by the keyboard device. A polling thread is created according to the polling time in the endpoint descriptor, and an IN token is sent to the keyboard device at a preset time interval to grab data from the keyboard device. The timer interrupt is enabled, and the time of the timer is determined according to the polling time of the device's endpoint descriptor. In the timer interrupt callback, the host sends an IN token to the device.

[0068] As an optional implementation, it further includes: a USB device module, which is used to transmit the mapped key values to the terminal device.

[0069] The keyboard converter provided in this embodiment is used to implement the foregoing key value conversion method of the keyboard. Therefore, the specific implementation in the keyboard converter can be seen in the embodiment part of the key value conversion method of the keyboard in the previous text, and will not be elaborated here.

[0070] Embodiment III

[0071] As Figure 3 shown, the embodiment of the present invention further provides a key value conversion system, which includes a keyboard device 1, a keyboard converter as described in Embodiment II above, and a terminal device 5. The keyboard device 1 is connected to the terminal device 5 through the keyboard converter. Among them, the keyboard converter includes a USB host module 2, a data processing module 3, and a USB device module 4.

[0072] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A key value conversion method for a USB keyboard, characterized in that, Including: Obtain the key values of the connected keyboard device, and convert the key values into matrix information, where the high four bits of the key values are used as the columns of the matrix, and the low four bits of the key values are used as the rows of the matrix; If the matrix information has changed compared with the previously stored historical matrix information, map the matrix information to key values; Store the matrix information, and perform corresponding operations according to the mapped key values.

2. The key value conversion method of the USB keyboard according to claim 1, wherein, Before obtaining the key values of the connected keyboard device and converting the key values into matrix information, it further includes: Monitor and receive the connection status of the keyboard device; If it is determined that a keyboard device is connected, obtain the data sent by the keyboard device and parse out the key values of the keyboard device by enumerating the keyboard device.

3. The key value conversion method of the USB keyboard according to claim 2, wherein The method of enumerating the keyboard device includes: reset; obtain the device descriptor and set the address; obtain the configuration descriptor and set the configuration; obtain the report descriptor and set the idle; after correctly enumerating the keyboard device, establish a data transmission channel for obtaining the data sent by the keyboard device.

4. The key value conversion method of the USB keyboard according to claim 3, characterized in that, During the process of obtaining the data sent by the keyboard device, create a polling thread according to the endpoint polling time in the endpoint descriptor, send an IN token to the keyboard device at a preset time interval, and grab data from the keyboard device.

5. The key value conversion method of the USB keyboard according to claim 4, wherein Enable the timer interrupt, and the time of the timer is determined according to the polling time of the device's endpoint descriptor. In the timer interrupt callback, the host sends an IN token to the device.

6. The key value conversion method of the USB keyboard according to claim 1, characterized in that, Transmit the mapped key values to the terminal device.

7. A keyboard converter, characterized in that, Including: A data processing module, configured to obtain the key values of the connected keyboard device, convert the key values into matrix information, where the high four bits of the key values are used as the columns of the matrix, and the low four bits of the key values are used as the rows of the matrix; if the matrix information has changed compared with the previously stored historical matrix information, map the matrix information to key values; store the matrix information, and perform corresponding operations according to the mapped key values.

8. The keyboard converter according to claim 7, characterized in that, It further includes: a USB host module, configured to monitor and receive the connection status of the keyboard device; if it is determined that a keyboard device is connected, obtain the data sent by the keyboard device and parse out the key values of the keyboard device by enumerating the keyboard device.

9. The keyboard converter according to claim 7, wherein It further includes: A USB device module, configured to transmit the mapped key values to the terminal device.

10. A key-value conversion system, characterized in that, Including a keyboard device, a keyboard converter according to any one of claims 7 to 9, and a terminal device, wherein the keyboard device is connected to the terminal device through the keyboard converter.

Citation Information

Patent Citations

  • Instrument special keyboard based on single-chip microcomputer and working method thereof

    CN103744520A

  • Information input control method, system, device, keyboard and intelligent equipment

    CN112114683A