A control method and device of a keyboard indicator light, a computing device and a storage medium

By determining and updating the keyboard indicator light status information within the operating system of the computing device, the problem of inconsistent status when switching between desktop and tty environments is solved, achieving synchronized and consistent display of keyboard indicator light status.

CN115291735BActive Publication Date: 2026-03-27UNIONTECH SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-11
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

When switching between desktop and tty environments, the keyboard indicator light status is inconsistent with the actual status of the currently entered human-computer interaction environment.

Method used

A method for controlling keyboard indicator lights is provided. By determining the current and target human-computer interaction environment in the operating system of the computing device, the status information of the keyboard indicator lights is obtained and updated to ensure that the status of the keyboard indicator lights remains consistent with the target environment during the switching process.

Benefits of technology

Without altering the original code structure, ensure that the keyboard indicator light status remains consistent across different types of human-computer interaction environments, thus avoiding status display errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115291735B_ABST
    Figure CN115291735B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a keyboard indicator light control method and device, a computing device and a storage medium. The method comprises: in response to an operation of switching to a target human-computer interaction environment, judging whether a current human-computer interaction environment is different from the target human-computer interaction environment; if so, obtaining information of a saved keyboard indicator light state in the target human-computer interaction environment as first information; switching the current human-computer interaction environment to the target human-computer interaction environment; in a first switching type, issuing the first information to the keyboard; in a second switching type, updating the state information to a value representing a state in a switching process as second information, and issuing the first information to the keyboard according to the second information. It can be known that, when switching between a desktop environment and a tty environment, the keyboard indicator light state of the target human-computer interaction environment is reissued, so that the state of the keyboard indicator light is always restored to the state last set in the target human-computer interaction environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, computing device, and readable storage medium for controlling keyboard indicator lights. Background Technology

[0002] A keyboard is an input device used to operate a computing device. It is the most commonly used and primary input device. Through the keyboard, text information (letters, Chinese characters, numbers, symbols, etc.) can be input into the computing device, thereby issuing commands and inputting data.

[0003] Keyboard indicator lights are used to reflect the current keyboard status. These indicator lights have on and off states, and each indicator light state corresponds to a keyboard lock state. For example, when the Caps Lock indicator light is on, the normal Caps Lock state indicates that the keyboard is currently in uppercase input mode. When the Caps Lock indicator light is off, the normal Caps Lock state indicates that the keyboard is currently in lowercase input mode.

[0004] Existing methods for setting keyboard indicator lights include setting them in a desktop environment (such as an xorg-based desktop environment) and in a virtual terminal environment. Desktop and virtual terminal environments can be collectively referred to as human-computer interaction environments. At any given time, the computing device's environment is only one of these two: a desktop environment and a virtual terminal environment. Switching between desktop and virtual environments is possible. Virtual terminal environments (tty environments) include tty1 through tty6 environments. However, the mechanisms for setting keyboard indicator lights in these two methods are relatively independent. That is, the keyboard indicator light status in the desktop environment is not synchronized with the tty environment, and vice versa. This results in inconsistencies between the keyboard indicator light status and the actual keyboard indicator light status in the currently entered environment when switching between desktop and tty environments.

[0005] Therefore, it is desirable to provide a control method for keyboard indicator lights to solve the existing technical problem that the state of the keyboard indicator lights is inconsistent with the actual state of the keyboard indicator lights in the current human-computer interaction environment when switching between desktop environment and tty environment. Summary of the Invention

[0006] Therefore, embodiments of the present invention provide a method, apparatus, computing device, and readable storage medium for controlling keyboard indicator lights, in an attempt to solve or at least alleviate the problems mentioned above.

[0007] According to one aspect of the present invention, a method for controlling a keyboard indicator light is provided, executed in an operating system running on a computing device. The computing device includes a human-computer interaction environment, and the operating system includes state information for recording switching states. The method includes: responding to an operation to switch to a target human-computer interaction environment; determining whether the current human-computer interaction environment is different from the target human-computer interaction environment; if so, acquiring information on the saved keyboard indicator light state in the target human-computer interaction environment as first information; determining a switching type based on the current human-computer interaction environment and the target human-computer interaction environment, the switching type including a first switching type and a second switching type, the first switching type being different from the second switching type; switching the current human-computer interaction environment to the target human-computer interaction environment; under the first switching type, sending the first information to the keyboard; under the second switching type, updating the state information to a value representing the state during the switching process as second information, and sending the first information to the keyboard based on the second information.

[0008] Optionally, the human-computer interaction environment includes a desktop environment and a virtual terminal environment. The first switching type corresponds to switching from the virtual terminal environment to the desktop environment, and the second switching type corresponds to switching from the desktop environment to the virtual terminal environment.

[0009] Optionally, under the first switching type, sending the first information to the keyboard includes: writing the first information into the device file of the keyboard.

[0010] Optionally, if the switching type is the second switching type, the keyboard indicator control method provided by the present invention further includes: acquiring information about the status of the keyboard indicator in the current human-computer interaction environment as third information; wherein, the step of sending the first information to the keyboard according to the second information includes: determining the switching state according to the second information, the switching state including the switching process state and the switching completion state; if the switching state is the switching process state, then updating the third information to the opposite value of the second information as fourth information; determining whether the first information and the fourth information are the same, if not, then writing the first information into the keyboard's device file; if the switching state is the switching completion state, or when the first information and the fourth information are the same, then continuing to detect the operation of switching to the target human-computer interaction environment.

[0011] Optionally, determining the switching state based on the second information includes: determining whether the value of the second information is a first preset value; if so, determining the switching state as a state in the process of switching.

[0012] Optionally, the control method for the keyboard indicator provided by the present invention further includes: updating the value of the second information to a second preset value, and switching to a completed state when the second information is the second preset value, wherein the first preset value is different from the second preset value.

[0013] Optionally, the control method for the keyboard indicator light provided by the present invention further includes: updating the third or fourth information to the first information.

[0014] Optionally, the keyboard indicator control method provided by the present invention further includes: if the current human-computer interaction environment is not different from the target human-computer interaction environment, then continue to detect the operation of switching to the target human-computer interaction environment.

[0015] Optionally, the process of saving the keyboard indicator light status information in the desktop environment is as follows: In response to the operation of triggering a keyboard key, obtain the keyboard indicator light status information under the key operation and the keyboard indicator light status information saved in the desktop environment; determine whether the keyboard indicator light status information under the key operation is the same as the keyboard indicator light status information saved in the desktop environment. If they are different, update the keyboard indicator light status information saved in the desktop environment to the keyboard indicator light status information under the key operation. If they are the same, continue to detect the operation of triggering a keyboard key.

[0016] Optionally, the process of saving the keyboard indicator light status information in the virtual terminal environment is as follows: In response to the operation of triggering a keyboard key, the information of the keyboard indicator light status under the key operation and the information of the keyboard indicator light status already saved in the virtual terminal environment are obtained; based on the value of the second information, it is determined whether the switching state is in the process of switching; if not, it is determined whether the information of the keyboard indicator light status under the key operation is the same as the information of the keyboard indicator light status already saved in the virtual terminal environment; if they are different, the information of the keyboard indicator light status saved in the current virtual terminal environment is updated to the information of the keyboard indicator light status under the current operation; if they are the same, the operation of triggering a keyboard key is continued to be detected; if the switching state is the switching completed state, the information of the keyboard indicator light status under the key operation is updated to a value opposite to the information of the keyboard indicator light status already saved in the virtual terminal environment as the fifth information, and the second information is updated to the second preset value, and the process of determining whether the information of the keyboard indicator light status under the key operation is the same as the information of the keyboard indicator light status already saved in the virtual terminal environment is continued.

[0017] Optionally, under the first switching type, the virtual terminal environment includes all virtual terminal environments in the computing device other than those occupied by the desktop environment; under the second switching type, the virtual terminal environment includes all virtual terminal environments in the computing device.

[0018] According to another aspect of the present invention, a control device for a keyboard indicator light is provided, which is executed in an operating system running on a computing device. The computing device includes a human-computer interaction environment, and the operating system includes state information that records switching states. The device includes: a judgment module, adapted to respond to an operation of switching to a target human-computer interaction environment, and to determine whether the current human-computer interaction environment is different from the target human-computer interaction environment. If so, it acquires information on the state of the keyboard indicator light stored in the target human-computer interaction environment as first information; a switching type determination module, adapted to determine a switching type based on the current human-computer interaction environment and the target human-computer interaction environment, wherein the switching type includes a first switching type and a second switching type, and the first switching type is different from the second switching type; a switching module, adapted to switch the current human-computer interaction environment to the target human-computer interaction environment; and a state transmission module, adapted to transmit the first information acquired by the judgment module to the keyboard under the first switching type, and adapted to update the state information to a value indicating the state during the switching process under the second switching type, as second information, and transmit the first information acquired by the judgment module to the keyboard based on the second information.

[0019] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the methods described above.

[0020] According to another aspect of the present invention, a readable storage medium storing program instructions is provided, which, when read and executed by a computing device, causes the computing device to perform the method described above.

[0021] According to the control method for keyboard indicator lights of the present invention, in response to an operation of switching to a target human-computer interaction environment, it determines whether the current human-computer interaction environment is different from the target human-computer interaction environment. If so, it acquires the information of the keyboard indicator light status stored in the target human-computer interaction environment as first information; determines a switching type based on the current human-computer interaction environment and the target human-computer interaction environment, the switching type including a first switching type and a second switching type, the first switching type being different from the second switching type; switches the current human-computer interaction environment to the target human-computer interaction environment; under the first switching type, sends the first information to the keyboard; under the second switching type, updates the status information to a value representing the status during the switching process as second information, and sends the first information to the keyboard based on the second information.

[0022] As can be seen from the above, when switching between the desktop environment and the tty environment, the present invention will forcibly resend the keyboard indicator light status of the target human-computer interaction environment, so that the keyboard indicator light status can always be restored to the state last set by the user in the target human-computer interaction environment. Without changing the original code structure, the keyboard indicator light status is consistent with the keyboard lock status after switching to different types of human-computer interaction environments.

[0023] The above description is merely an overview of the technical solutions of the embodiments of the present invention. In order to better understand the technical means of the embodiments of the present invention and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of the present invention more obvious and understandable, specific implementation methods of the embodiments of the present invention are described below. Attached Figure Description

[0024] To achieve the foregoing and related objectives, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings. These aspects indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The foregoing and other objectives, features, and advantages of this disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.

[0025] Figure 1 A block diagram of a computing device 100 according to an embodiment of the present invention is shown;

[0026] Figure 2 A flowchart of a keyboard indicator control method 200 according to an embodiment of the present invention is shown;

[0027] Figure 3 A flowchart illustrating the process of saving keyboard indicator light status information in a desktop environment according to an embodiment of the present invention is shown.

[0028] Figure 4 A flowchart illustrating the storage of keyboard indicator light status information in a tty environment according to an embodiment of the present invention is shown;

[0029] Figure 5 A schematic diagram of a keyboard indicator control device 500 according to an embodiment of the present invention is shown. Detailed Implementation

[0030] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0031] Human-computer interaction environments include desktop environments and virtual terminal environments. A desktop environment, which can be understood as a graphical desktop environment, displays the desktop to the user in a graphical format. A tty environment, which can be understood as a desktop displayed to the user in text mode, requires the user to input commands (such as code) via the keyboard to perform corresponding operations.

[0032] Existing methods for controlling keyboard indicator lights include those in a desktop environment and those in a TTY environment. However, these two methods operate on relatively independent mechanisms. In other words, the keyboard indicator light status in the desktop environment is not synchronized with the TTY environment, and vice versa. This results in inconsistencies between the keyboard indicator light status and the actual keyboard lock status when switching between the desktop and TTY environments.

[0033] It should be noted that the tty environment includes tty1 through tty6 environments. The desktop environment itself occupies one tty environment. The specific tty environment used can be selected based on the actual application scenario; this invention does not impose any restrictions on this. For example, if the desktop environment occupies tty1, tty1 will be disabled, and the value of the mode variable (e.g., kb->kbmode) of tty1 will be set to a preset value. The preset value can be set according to the actual application scenario; this invention does not impose any restrictions on this. For example, the preset value is VC_OFF. That is, when the value of the mode variable of tty1 is VC_OFF, it indicates that the tty1 environment is disabled. At this time, the keyboard indicator light status information of tty1 is all at the initial value, and the keyboard indicator lights are all off under the initial value. In other words, when the tty environment is disabled, the keyboard indicator lights in that environment are all off.

[0034] The following example illustrates the situation where the keyboard backlight status is inconsistent with the actual keyboard lock status when switching between the desktop environment and the tty environment, using the desktop environment occupying the tty1 environment as an example.

[0035] For example, when switching from a desktop environment to a tty (tty2 to tty6) environment: In the desktop environment, the Caps Lock indicator light on the keyboard is on, corresponding to a normal keyboard lock state (uppercase letter input). In the tty2 to tty6 environments, the Caps Lock indicator light is off, corresponding to a normal keyboard lock state (lowercase letter input, etc.). If you then switch from the desktop environment to any of tty2 to tty6, after a successful switch, you'll find that the Caps Lock indicator light remains on, but the corresponding keyboard lock state is the opposite of the indicator light state (consistent with the state saved by the tty: lowercase letter input, etc.).

[0036] For example, when switching from the desktop environment to tty1: the desktop environment occupies tty1, so the keyboard indicator lights on tty1 remain off. Since the desktop environment doesn't synchronize with tty1, it can only send the keyboard indicator light status information from tty1 to the keyboard. However, because tty1 is occupied by the desktop environment, the keyboard indicator light status information on tty1 remains at its initial value of 0. That is, in the tty1 environment, the keyboard indicator lights are off, while in the desktop environment, the keyboard indicator lights don't remain off continuously, leading to an incorrect keyboard indicator light display.

[0037] For example, when switching from a tty (tty2 to tty6) environment to a desktop environment: In tty2 to tty6 environments, the Caps Lock indicator is off, and the corresponding keyboard lock is normal (lowercase letter input). In the desktop environment, the Caps Lock indicator is off, and the corresponding keyboard lock is normal (uppercase letter input). If you then switch from any of the tty2 to tty6 environments to the desktop environment, after a successful switch, you'll find that the Caps Lock indicator is off, but the corresponding keyboard lock state is the opposite of the indicator light (consistent with the state before the desktop environment switch: uppercase letter input).

[0038] The desktop environment described above can be selected according to the actual application scenario, and this invention does not impose any restrictions on it. For example, the desktop environment can be an xorg-based desktop environment.

[0039] In order to solve the technical problem that the keyboard indicator light status is inconsistent with the actual keyboard indicator light status of the currently entered human-computer interaction environment when switching between desktop environment and tty environment, this invention provides a keyboard indicator light control method. This method is integrated into the operating system of computing device 100. For example, the operating system can be a Linux operating system. Of course, this invention does not limit the specific type of operating system. All existing operating systems in the prior art are within the protection scope of this invention.

[0040] It is worth noting that when the operating system is started, that is, when the computing device 100 is powered on and the user is successfully logged in and enters the user interface, the keyboard indicator control method provided by this invention will be started at the same time.

[0041] The aforementioned computing device 100 can be implemented as a server, such as an application server or a web server; it can also be implemented as a desktop computer, a laptop computer, a processor chip, a tablet computer, etc., but is not limited to these. Figure 1 A block diagram of the physical components (i.e., hardware) of a computing device 100 is shown. In a basic configuration, the computing device 100 includes at least one processing unit 102 and system memory 104. According to one aspect, depending on the configuration and type of the computing device, the system memory 104 includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., read-only memory), flash memory, or any combination of such memories.

[0042] According to one aspect, system memory 104 includes operating system 105. System memory 104 also includes application program 150. According to one aspect, operating system 105, for example, is adapted to control the operation of computing device 100. Furthermore, examples are practiced in conjunction with graphics libraries, other operating systems, or any other applications, and are not limited to any particular application or system. Figure 1 The basic configuration is illustrated by the components within the dashed lines 108. According to one aspect, the computing device 100 has additional features or functions. For example, according to one aspect, the computing device 100 includes additional data storage devices (removable and / or non-removable), such as disks, optical discs, or magnetic tapes. This additional storage... Figure 1 The middle part is shown by removable storage device 109 and non-removable storage device 110.

[0043] As stated above, according to one aspect, a plurality of program modules and data files are stored in system memory 104. When the keyboard indicator control method provided by the present invention is implemented as application program 150 and executed on processing unit 102, the execution process of application program 150 includes, but is not limited to, […]. Figure 2 The method 200 shown includes one or more stages. According to one aspect, the type of application is not limited; for example, applications also include: email and contact applications, word processing applications, spreadsheet applications, database applications, slideshow applications, drawing or computer-aided applications, web browser applications, etc.

[0044] According to one aspect, examples can be practiced on circuits including discrete electronic components, packaged or integrated electronic chips containing logic gates, circuits utilizing microprocessors, or on a single chip containing electronic components or a microprocessor. For example, it can be practiced via wherein... Figure 1 Each or many of the components shown can be implemented as an example by integrating a System-on-a-Chip (SOC) on a single integrated circuit. According to one aspect, such an SOC device may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all integrated (or “burned in”) as a single integrated circuit onto a chip substrate. When operating via the SOC, the functions described herein can be operated via dedicated logic integrated on a single integrated circuit (chip) with other components of the computing device 100. Embodiments of the invention can also be implemented using other techniques capable of performing logical operations (e.g., AND, OR, and NOT), including but not limited to mechanical, optical, fluid, and quantum technologies. Additionally, embodiments of the invention can be implemented within a general-purpose computer or in any other circuit or system.

[0045] According to one aspect, computing device 100 may also have one or more input devices 112, such as a keyboard, mouse, pen, voice input device, touch input device, etc. It may also include output devices 114, such as a display, speaker, printer, etc. The foregoing devices are examples and other devices may also be used. Computing device 100 may include one or more communication connections 116 that allow communication with other computing devices 118. Examples of suitable communication connections 116 include, but are not limited to: RF transmitter, receiver and / or transceiver circuitry; Universal Serial Bus (USB), parallel and / or serial ports.

[0046] As used herein, the term computer-readable medium includes computer storage medium. Computer storage medium can include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information (e.g., computer-readable instructions, data structures, or program modules). System memory 104, removable storage device 109, and non-removable storage device 110 are examples of computer storage media (i.e., memory storage). Computer storage media can include random access memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape, magnetic tape, disk storage or other magnetic storage devices, or any other article of manufacture that can be used to store information and is accessible by computer device 100. According to one aspect, any such computer storage medium can be part of computing device 100. Computer storage media does not include carrier waves or other transmitted data signals.

[0047] According to one aspect, a communication medium is implemented by computer-readable instructions, data structures, program modules, or other data in a modulated data signal (e.g., a carrier wave or other transmission mechanism), and includes any information transmission medium. According to one aspect, the term "modulated data signal" describes a signal having one or more sets of characteristics or altered in a manner that encodes information in the signal. By way of example and not limitation, a communication medium includes wired media such as wired networks or direct wired connections, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.

[0048] Figure 2 A flowchart of a keyboard indicator control method 200 according to an embodiment of the present invention is shown. Method 200 is adapted to be executed in an operating system running on a computing device 100, and may include steps 201 to 214. Through method 200, the keyboard indicator state can be updated to the state corresponding to the target human-computer interaction environment when switching between different human-computer interaction environments.

[0049] When a user initiates an action to switch the human-computer interaction environment, for example, by using a keyboard shortcut, the user can switch to any tty environment by using any of the shortcuts Ctrl+Alt+F1 to Ctrl+Alt+F6. In a tty environment, the user can switch to the desktop environment by using the shortcut Ctrl+Alt+F1. Of course, in a tty environment, taking the desktop environment as tty1 as an example, the user can switch between tty2 and tty6 by using shortcuts Ctrl+Alt+F2 to Ctrl+Alt+F6.

[0050] When a user triggers an operation to switch the human-computer interaction environment, a switch human-computer interaction environment event is generated. Step 201 is executed to detect the switch human-computer interaction environment event. After detecting the switch human-computer interaction environment event, the system responds to the event and executes step 202 to determine whether the current human-computer interaction environment is different from the target human-computer interaction environment, that is, to determine whether the current human-computer interaction environment is different from the target human-computer interaction environment.

[0051] It should be noted that the target HCI environment can be determined by switching shortcut keys. For example, if the shortcut key is Ctrl+Alt+F6, then the target HCI environment is tty6. If the current HCI environment is different from the target HCI environment, then it can be determined that the current HCI environment is distinct from the target HCI environment; if they are the same, then it can be determined that the current HCI environment is not distinct from the target HCI environment.

[0052] If it is determined that the current human-computer interaction environment is not different from the target human-computer interaction environment, return to step 201.

[0053] When it is determined that the current human-computer interaction environment differs from the target human-computer interaction environment, step 203 is executed to obtain the keyboard indicator light status information saved in the target human-computer interaction environment. Since each human-computer interaction environment saves its keyboard indicator light status information, it is possible to obtain the keyboard indicator light status information saved in the target human-computer interaction environment. For example, the keyboard indicator light status information can be saved through the global variable `ledstate`. The specific implementation methods for saving keyboard indicator light status information in the desktop environment and the tty environment are explained below.

[0054] Figure 3 A flowchart illustrating the process of saving keyboard indicator light status information in a desktop environment according to an embodiment of the present invention is shown, such as... Figure 3 As shown, the process of saving keyboard indicator light status information in the desktop environment includes steps 310 to 350.

[0055] When a user presses any key on the keyboard, a key press event is generated. Step 310 is executed to detect and respond to the key press event. Step 320 is then executed to obtain information about the keyboard indicator light status under the key press operation. Step 330 is then executed to obtain the keyboard indicator light status information saved in the desktop environment.

[0056] After obtaining the information on the keyboard indicator light status under key press operation and the information on the keyboard indicator light status saved in the desktop environment, step 340 is executed to determine whether the information on the keyboard indicator light status under key press operation is the same as the information on the keyboard indicator light status saved in the desktop environment.

[0057] If they are different, it means that the keyboard indicator light status has changed. In this case, the information of the keyboard indicator light status in the current desktop environment needs to be updated. Execute step 350 to update the information of the keyboard indicator light status saved in the desktop environment to the information of the keyboard indicator light status under key operation.

[0058] It is worth noting that if the keyboard is in a newly started state, the information of the keyboard indicator lights stored in the human-computer interaction environment is all in the first initial value. In the first initial value, the indicator lights of the keys are off. However, if a key is triggered, the indicator lights of the keys will turn on, and the information of the key indicator lights will change. At this time, the information of the key indicator lights can be set to the first preset value. The first initial value and the first preset value can be set according to the actual application scenario, and this invention does not impose any restrictions on them. For example, the first initial value can be set to 0, and the first preset value can be set to 1.

[0059] If the keyboard indicator light status information under key operation is the same as the keyboard indicator light status information saved in the desktop environment, it means that the keyboard indicator light status has not changed. At this time, there is no need to update the keyboard indicator light status information saved in the desktop environment, so return to step 310.

[0060] Therefore, by going through steps 310 to 350, the latest information on the keyboard indicator light status can be saved in the desktop environment.

[0061] Figure 4 A flowchart illustrating the storage of keyboard indicator light status information in a tty environment according to an embodiment of the present invention is shown, such as... Figure 4 As shown, the process of saving keyboard indicator light status information in a tty environment includes steps 410 to 480.

[0062] Before describing the process of saving keyboard indicator light status information in a tty environment, it's important to note that in a tty environment, the operating system records status information for switching states. These switching states include a state during switching and a state after switching. During switching, the status information corresponds to a second preset value, and during switching, it corresponds to a third preset value. The second preset value is distinct from the third preset value. The second and third preset values ​​can be set according to the actual application scenario, and this invention does not impose any restrictions on this. For example, the second preset value can be true, and the third preset value can be false. In other words, the switching state can be determined based on the value of the status information.

[0063] When a user presses any key on the keyboard, a key press event is generated. Step 410 is executed to detect and respond to the key press event. Step 420 is then executed to obtain information about the keyboard indicator light status under the key press operation. Next, step 430 is executed to obtain the keyboard indicator light status information stored in the tty environment.

[0064] It is also worth noting that if the keyboard is newly started, the keyboard indicator light status information saved in the human-computer interaction environment is all in the first initial value. In the first initial value, the key indicator light is off. However, if a key is triggered, the key indicator light turns on, and the key indicator light information will change. At this time, the key indicator light status information can be set to the second preset value. The setting of the first initial value and the first preset value is as described above in the process of saving the keyboard indicator light status information in the desktop environment, and will not be repeated here.

[0065] After obtaining the keyboard indicator light status information under key operation and the keyboard indicator light status information stored in the tty environment, step 440 is executed to determine whether the switching state is in progress based on the value of the status information. In some embodiments, step 440 includes: if the value of the status information is a second preset value, then the switching state can be determined to be in progress; if the value of the status information is a third preset value, then the switching state can be determined to be completed.

[0066] If the switching state is "switching complete," then proceed to step 450 to determine if the keyboard indicator light status information under key press operation is the same as the keyboard indicator light status information stored in the tty environment. If they are different, it means the keyboard indicator light status has changed, so proceed to step 460 to update the keyboard indicator light status information stored in the tty environment to the keyboard indicator light status information under key press operation. If they are the same, it means the keyboard indicator light status has not changed, so there is no need to change the keyboard indicator light status, and proceed to step 410.

[0067] If the switching state is in progress, then proceed to step 470, updating the keyboard indicator light status information under key operation to the opposite value of the keyboard indicator light status information saved in the tty environment. Continue to step 480, updating the status information value to the third preset value, and then proceed to step 450. At this time, the keyboard indicator light status information under key operation is the opposite value of the keyboard indicator light status information already saved in the virtual terminal environment, while the keyboard indicator light status information already saved in the virtual terminal environment remains unchanged.

[0068] If the keyboard is in the newly started state, the status information is also the initial value. The initial value can be set to the third preset value, which is the state after the switch is completed. The status information value will only be set to the second preset value, which represents the state during the switch, when switching the human-computer interaction environment (including switching from desktop environment to tty environment, switching from tty environment to desktop environment, and switching between different tty environments).

[0069] Therefore, by going through steps 410 to 480, the latest information on the keyboard indicator light status can be saved in the tty environment.

[0070] In some implementations, the switching type may include a first switching type and a second switching type. The first switching type corresponds to switching from a tty environment to a desktop environment. Under the first switching type, the tty environment may include all other tty environments in the computing device besides the one occupied by the desktop environment. The second switching type corresponds to switching from a desktop environment to a tty environment. Since the desktop environment occupies one tty environment, under the second switching type, the tty environment may include all tty environments in the computing device. Therefore, the second switching type can also be understood as a switching between tty environments.

[0071] After obtaining the information on the saved keyboard indicator light status in the target human-computer interaction environment, proceed to step 204. Based on the current human-computer interaction environment and the target human-computer interaction environment, determine whether the switching type is the first switching type. If it is the first switching type, proceed to steps 205 to 206. If it is not the first switching type, since the human-computer interaction environment includes two types, the switching type can be determined to be the second switching type. If it is the second switching type, proceed to steps 207 to 214.

[0072] If the current human-computer interaction environment is a desktop environment and the target human-computer interaction environment is a tty environment, then the switching type can be determined as the second switching type. If the current human-computer interaction environment is a tty environment and the target human-computer interaction environment is a desktop environment, then the switching type can be determined as the first switching type.

[0073] If the switching type is the first switching type:

[0074] Continue to step 205 to switch the current human-computer interaction environment to the target human-computer interaction environment. The switching method can be selected according to the actual application scenario. This invention does not limit this, and all methods that can switch the human-computer interaction environment are within the protection scope of this invention.

[0075] For example, when the switching type is the first switching type, the xf86VTSwitch() function is called, and then the xf86VTEnter() function is called based on the xf86VTSwitch() function. The xf86VTEnter() function is used to switch the current human-computer interaction environment to the target human-computer interaction environment.

[0076] After switching to the target human-computer interaction environment, continue to step 206, and send the obtained keyboard indicator light status information to the keyboard so as to update the keyboard indicator light status to the keyboard indicator light status of the target human-computer interaction environment.

[0077] In some implementations, step 206 can be implemented by writing the acquired keyboard indicator light status information into the keyboard's device file. For example, the `XkbPushLockedStateToAll()` function is called, which indirectly calls the `write()` system call function through the libinput interface `evdev_device_led_update()`, and the `write()` system call function writes the current keyboard indicator light status information into the keyboard device file. Of course, this invention does not limit the specific implementation of writing the acquired keyboard indicator light status information into the keyboard's device file; all methods that can achieve the above function are within the protection scope of this invention.

[0078] In the first switching type, when switching between the desktop environment and the tty environment, the key code example for restoring the keyboard indicator light state to the state last set by the user in the current human-computer interaction environment is as follows:

[0079]

[0080] If the switching type is the second switching type:

[0081] Continue with step 207 to obtain information about the keyboard indicator light status in the current human-computer interaction environment as global information; that is, obtain information about the keyboard indicator light status in the current desktop environment as global information. In some implementations, the value of the keyboard indicator light status to be set is synchronized to the global variable `ledstate` using the `kbd_update_ledstate()` function.

[0082] After obtaining the keyboard indicator light status information of the current human-computer interaction environment, step 208 is executed to switch the current human-computer interaction environment to the target human-computer interaction environment. The switching method can be selected according to the actual application scenario, and this invention does not limit it. All methods that can switch the human-computer interaction environment are within the protection scope of this invention.

[0083] For example, when the switching type is the second switching type, the xf86VTSwitch() function is called, and then the xf86VTLeave() function is called based on the xf86VTSwitch() function. The xf86VTLeave() function is used to switch the current human-computer interaction environment to the target human-computer interaction environment.

[0084] During the switch to the target human-computer interaction environment, step 209 continues, updating the status information to a value representing the state during the switch. In some implementations, a second preset value represents the state during the switch, and a third value represents the state after the switch is complete. Therefore, updating the status information to the value representing the state during the switch is equivalent to updating the status information to the second preset value. The specific implementation method for updating the status information to the value representing the state during the switch can be selected according to the actual application scenario and is not limited here. Existing technologies that can achieve this function are all within the protection scope of this invention. For example, the vt_set_leds_compute_shiftstate() function can be used to update the status information to the value representing the state during the switch.

[0085] After updating the status information to a value indicating the state during the switching process, step 210 is executed to determine the switching state based on the updated status information. In some implementations, if the value of the status information is a second preset value, then the switching state can be determined to be the state during switching; if the value of the status information is a third preset value, then the switching state can be determined to be the state after switching is complete.

[0086] If the switching state is in progress, then step 211 is executed, updating the keyboard indicator light status information in the current human-computer interaction environment to the opposite value of the saved keyboard indicator light status information in the target human-computer interaction environment. That is, updating the keyboard indicator light status information in the desktop environment to the opposite value of the keyboard indicator light status information in the tty environment. Then, step 212 is executed, updating the status information value to the value corresponding to the switching completion state, that is, updating the status information value to the third preset value.

[0087] After updating the keyboard indicator light status information in the desktop environment to the opposite value to the keyboard indicator light status information in the tty environment, and updating the status information value to the value corresponding to the switching completion state, step 213 is executed to determine whether the keyboard indicator light status information in the target human-computer interaction environment is the same as the updated keyboard indicator light status information in the current human-computer interaction environment.

[0088] If they are different, it means that the keyboard indicator light status in the desktop environment is different from that in the tty environment. In this case, step 214 is executed to write the keyboard indicator light status information in the target human-computer interaction environment into the keyboard's device file, that is, to update the keyboard indicator light status to the tty environment's keyboard indicator light status. The specific implementation of step 214 is the same as that described in step 206, and will not be repeated here.

[0089] If the keyboard indicator light status is the same in the desktop environment as in the tty environment, then there is no need to update the keyboard indicator light status; proceed to step 201.

[0090] In scenarios where switching from a desktop environment to a tty environment: if the desktop environment is occupied, then that tty environment is disabled. In a disabled state, the keyboard indicator lights in the tty environment always retain their initial values, meaning they are always off. Therefore, the keyboard indicator light status information in the current human-computer interaction environment represents the keyboard indicator light status information in the desktop environment, while the saved keyboard indicator light status information in the target human-computer interaction environment is the keyboard indicator light status information from the tty environment (both initial values, all keys are off). If there are keys lit in the desktop environment, the keyboard indicator light status information in the desktop environment will inevitably differ from the off-state information in the occupied tty environment. If the keyboard indicator light status information for the tty environment is then sent, and all keyboard indicator lights are off, this will result in a display error.

[0091] In this invention, the keyboard indicator light status information in the desktop environment is updated to the opposite value to that in the tty environment. Therefore, the keyboard indicator light status in the desktop environment and the tty environment will definitely be different. This means that whenever switching between different human-computer interaction environments, the keyboard indicator light status in the tty environment will be sent to the keyboard. This ensures that the keyboard indicator light status displays correctly and does not remain constantly off, and it does not disrupt the original code logic, minimizing its impact on the original code.

[0092] If the switching status is "switching complete", then continue to step 213.

[0093] After writing the acquired keyboard indicator light status information into the keyboard's device file, step 214 is executed to update the keyboard indicator light status information of the current human-computer interaction environment, or the keyboard indicator light status information of the current human-computer interaction environment updated in step 211, to the keyboard indicator light status information of the target human-computer interaction environment. That is, the keyboard indicator light status information of the desktop environment, or the updated keyboard indicator light status information of the desktop environment, is updated to the keyboard indicator light status information of the tty environment, so that when switching between different types of human-computer interaction environments is detected again, it can serve as the keyboard indicator light status of the current human-computer interaction environment. Here, the current human-computer interaction environment can be understood as the human-computer interaction environment before switching to the target human-computer interaction environment.

[0094] In the second switching type, when switching between the desktop environment and the tty environment, the key code example for restoring the keyboard indicator light state to the state last set by the user in the current human-computer interaction environment is as follows:

[0095]

[0096] This achieves the goal of updating the keyboard indicator light status to match the target human-computer interaction environment when switching between different human-computer interaction environments. Steps 201 to 214 must be executed whenever switching between human-computer interaction environments.

[0097] Figure 5 A structural block diagram of a keyboard indicator control device 500 according to an embodiment of the present invention is shown. The device 500 includes a judgment module 510, a switching type determination module 520, a switching module 530, and a status transmission module 540, which are coupled in sequence.

[0098] The judgment module 510 is adapted to respond to the operation of switching to the target human-computer interaction environment, and to determine whether the current human-computer interaction environment is different from the target human-computer interaction environment. If so, it obtains the information of the keyboard indicator light status saved in the target human-computer interaction environment as the first information.

[0099] The switching type determination module 520 is adapted to determine the switching type based on the current human-computer interaction environment and the target human-computer interaction environment. The switching type includes a first switching type and a second switching type, and the first switching type is different from the second switching type.

[0100] The switching module 530 is suitable for switching the current human-computer interaction environment to the target human-computer interaction environment.

[0101] The status sending module 540 is adapted to send the first information obtained by the judgment module to the keyboard under the first switching type, and to update the status information to a value representing the status during the switching process as the second information under the second switching type, and send the first information obtained by the judgment module to the keyboard according to the second information.

[0102] It should be noted that the working principle of the keyboard indicator light control device 500 is similar to that of the keyboard indicator light control method 200 described above. For relevant details, please refer to the description of the keyboard indicator light control method 200 described above, which will not be repeated here.

[0103] As can be seen from the above, the keyboard indicator control method provided by the present invention will resend the keyboard indicator state of the target human-computer interaction environment when switching between the desktop environment and the tty environment, so that the state of the keyboard indicator can always be restored to the state last set by the user in the target human-computer interaction environment. Without changing the original code structure, the state of the keyboard indicator is consistent with the keyboard lock state after switching to different types of human-computer interaction environments.

[0104] The various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, USB flash drive, floppy disk, CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the present invention.

[0105] When the program code is executed on a programmable computer, the computing device generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute the keyboard indicator control method of the present invention according to instructions in the program code stored in the memory.

[0106] By way of example, and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in the form of modulated data signals such as carrier waves or other transmission mechanisms, and includes any information delivery medium. Any combination of the above is also included within the scope of readable media.

[0107] In the specification provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with the examples of this invention. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0108] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0109] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more of the various aspects of the invention, features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this method of disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0110] Those skilled in the art will understand that modules, units, or components of the devices disclosed in the examples herein can be arranged in the devices described in this embodiment, or alternatively, can be located in one or more devices different from the devices in this example. The modules in the foregoing examples can be combined into a single module or, in addition, can be divided into multiple sub-modules.

[0111] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0112] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments can be used in any combination.

[0113] Furthermore, some of the embodiments described herein are methods or combinations of method elements that can be implemented by a processor of a computer system or by other means of performing the functions. Therefore, a processor having the necessary instructions for implementing the methods or method elements forms means for implementing the methods or method elements. Furthermore, the elements described herein in the apparatus embodiments are examples of means for implementing the functions performed by elements for the purposes of carrying out the invention.

[0114] As used herein, unless otherwise specified, the use of ordinal numbers such as “first,” “second,” “third,” etc., to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects being described must have a given order in time, space, ordering, or any other manner.

[0115] Although the invention has been described with reference to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and instructional purposes, and not for the purpose of interpreting or limiting the subject matter of the invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the invention is illustrative and not restrictive, and the scope of the invention is defined by the appended claims.

Claims

1. A method for controlling a keyboard indicator light, executed in an operating system running on a computing device, the computing device including a human-computer interaction environment, the human-computer interaction environment including a desktop environment and a virtual terminal environment, the operating system including state information for recording switching states, the method comprising: In response to the operation of switching to the target human-computer interaction environment, determine whether the current human-computer interaction environment is different from the target human-computer interaction environment. If so, obtain the information of the keyboard indicator light status saved in the target human-computer interaction environment as the first information. The switching type is determined based on the current human-computer interaction environment and the target human-computer interaction environment. The switching type includes a first switching type and a second switching type. The first switching type is different from the second switching type. The first switching type corresponds to switching from the virtual terminal environment to the desktop environment, and the second switching type corresponds to switching from the desktop environment to the virtual terminal environment. Switch the current human-computer interaction environment to the target human-computer interaction environment; Under the first switching type, the first information is sent to the keyboard; Under the second switching type, the status information indicating the switching state is updated to a value representing the state during the switching process, which is used as the second information. The first information is then sent to the keyboard based on the second information. This includes obtaining the keyboard indicator light status information in the current human-computer interaction environment, switching the current human-computer interaction environment to the target human-computer interaction environment, updating the keyboard indicator light status information in the current human-computer interaction environment to a value opposite to the saved keyboard indicator light status information in the target human-computer interaction environment, determining whether the keyboard indicator light status information in the target human-computer interaction environment is the same as the updated keyboard indicator light status information in the current human-computer interaction environment, and if they are not the same, writing the keyboard indicator light status information in the target human-computer interaction environment into the keyboard's device file.

2. The method as described in claim 1, wherein, Under the first switching type, sending the first information to the keyboard includes: Write the first information into the device file of the keyboard.

3. The method as described in claim 1, wherein, Determining the switching status based on the second information includes: Determine whether the value of the second information is the first preset value. If so, determine that the switching state is the state during the switching process.

4. The method of claim 3, further comprising: The value of the second information is updated to the second preset value. When the second information is the second preset value, the corresponding state is switched to complete. The first preset value is different from the second preset value.

5. The method according to any one of claims 1 to 4, further comprising: If the current human-computer interaction environment is not different from the target human-computer interaction environment, then continue to detect the operation of switching to the target human-computer interaction environment.

6. The method of claim 1, wherein, The process of saving keyboard indicator light status information in a desktop environment is as follows: In response to a key press, obtain information about the keyboard indicator light status under the key press and information about the keyboard indicator light status saved in the desktop environment; The system checks whether the keyboard indicator light status information under key press operation is the same as the keyboard indicator light status information saved in the desktop environment. If they are different, the system updates the keyboard indicator light status information saved in the desktop environment to the keyboard indicator light status information under key press operation. If they are the same, the system continues to detect the keyboard key press operation.

7. The method of claim 4, wherein, The process of saving keyboard indicator light status information in a virtual terminal environment is as follows: In response to a key press, obtain information about the keyboard indicator light status under the key press and information about the keyboard indicator light status already saved in the virtual terminal environment; Based on the value of the second information, determine whether the switching state is in the process of switching. If not, determine whether the information of the keyboard indicator light state under the key operation is the same as the information of the keyboard indicator light state saved in the virtual terminal environment. If they are different, the keyboard indicator light status information saved in the current virtual terminal environment will be updated to the keyboard indicator light status information under the current operation. If they are the same, the operation of triggering keyboard keys will continue to be detected. If the switching state is in progress, the information of the keyboard indicator light state under the key operation is updated to the opposite value of the keyboard indicator light state information already saved in the virtual terminal environment, as the fifth information, and the second information is updated to the second preset value. Then, it is determined whether the information of the keyboard indicator light state under the key operation is the same as the information of the keyboard indicator light state already saved in the virtual terminal environment.

8. The method of claim 2, wherein, Under the first switching type, the virtual terminal environment includes all other virtual terminal environments in the computing device besides the desktop environment. Under the second switching type, the virtual terminal environment includes all virtual terminal environments in the computing device.

9. A control device for a keyboard indicator light, executed in an operating system running on a computing device, the computing device including a human-computer interaction environment, the human-computer interaction environment including a desktop environment and a virtual terminal environment, the operating system including state information for recording switching states, the device comprising: The judgment module is adapted to respond to the operation of switching to the target human-computer interaction environment, and to determine whether the current human-computer interaction environment is different from the target human-computer interaction environment. If so, it obtains the information of the keyboard indicator light status saved in the target human-computer interaction environment as the first information. The switching type determination module is adapted to determine the switching type based on the current human-computer interaction environment and the target human-computer interaction environment. The switching type includes a first switching type and a second switching type. The first switching type is different from the second switching type. The first switching type corresponds to switching from the virtual terminal environment to the desktop environment, and the second switching type corresponds to switching from the desktop environment to the virtual terminal environment. The switching module is adapted to switch the current human-computer interaction environment to the target human-computer interaction environment; The status sending module, under the first switching type, is adapted to send the first information obtained by the judgment module to the keyboard. Under the second switching type, it is adapted to update the status information indicating the switching status to a value representing the status during the switching process, as the second information, and send the first information obtained by the judgment module to the keyboard according to the second information. This includes obtaining the keyboard indicator light status information in the current human-computer interaction environment, switching the current human-computer interaction environment to the target human-computer interaction environment, updating the keyboard indicator light status information in the current human-computer interaction environment to a value opposite to the saved keyboard indicator light status information in the target human-computer interaction environment, judging whether the keyboard indicator light status information in the target human-computer interaction environment is the same as the updated keyboard indicator light status information in the current human-computer interaction environment, and if they are not the same, writing the keyboard indicator light status information in the target human-computer interaction environment into the keyboard's device file.

10. A computing device, comprising: At least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the method as described in any one of claims 1 to 8.

11. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method and device for switching KVM (Keyboard Video Mouse)

    CN104571583A

  • Method and system applied to tty terminal of Linux and supporting Chinese

    CN107885511A