A method for sharing keyboard and mouse devices
Through custom network protocols and dedicated algorithms to process keyboard and mouse data in embedded systems, the problem of keyboard and mouse device sharing under embedded systems is solved, and the device sharing between embedded and desktop systems is realized, reducing hardware complexity and cost , improve management efficiency.
Patent Information
- Application Number
- CN202111264705.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-10-28
AI Technical Summary
The prior art cannot effectively realize the sharing of keyboard and mouse devices under embedded operating systems, especially since the RDP and VNC protocols are only applicable to desktop operating systems, the embedded systems cannot use these protocols for general processing of keyboard and mouse events.
Using custom network protocols and special algorithms, keyboard and mouse data is obtained in the embedded system, network data frames are formed and sent to the Zhongbiao Kirin operating system, parsing and processing events, and realizing the sharing of keyboard and mouse devices between the embedded system and the desktop system.
It reduces hardware complexity and design costs, solves the problems of data transmission and versatility, realizes keyboard and mouse device sharing between embedded systems and desktop systems, simplifies device management, improves work efficiency and saves space and energy.
Smart Images

Figure CN114047829B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer control, and in particular to a keyboard and mouse device sharing method. Background Art
[0002] The existing methods for sharing keyboard and mouse devices can be divided into two categories: one is switching through hardware, such as a KVM switch; the other is through software, such as sharing keyboard and mouse devices over the network through the RDP protocol or VNC protocol.
[0003] KVM switch is also called multi-computer controller. One KVM switch can control multiple computers or servers. The control port of KVM switch is mainly used to connect the USB port of keyboard and mouse and the VGA port of monitor. When using hardware connection, if the number of shared hosts is large, the hardware design complexity, design cost and switching logic complexity will increase, and the reliability will decrease.
[0004] The RDP (Remote Display Protocol) protocol is applicable to Windows and Linux systems and provides remote desktop control functions between clients and servers. The RDP protocol is divided into network connection layer, ISO data layer, virtual channel layer, encryption and decryption layer, and functional data layer. The connection process mainly includes the client connecting to the server, establishing a connection at the ISO data layer, sending initial protocol related information, receiving encryption and decryption keys, applying for virtual channels, sending client system information in encrypted form, verifying the encryption protocol, platform software certificate verification, establishing connections for each function, transmitting data for each function, and realizing functions.
[0005] The VNC (Virtual Network Computing) protocol is based on the RFB (Remote Frame Buffer) protocol for communication. It is a screen sharing and remote operation software that can send keyboard and mouse actions and real-time screen images through the network. Applicable systems are Windows and Linux. The VNC connection can be divided into 4 stages: handshake process, authentication process, desktop interaction and waving process.
[0006] Since the RDP protocol and VNC protocol are only applicable to desktop operating systems, Dao System, as an embedded operating system without a graphical desktop and with keyboard and mouse event code values not universal, cannot use the above two protocols. Summary of the invention
[0007] In order to solve the problems existing in the prior art, the present invention provides a keyboard and mouse device sharing method, which changes the traditional one-to-one control method and adopts a one-to-many management method, which is conducive to saving space and improving work efficiency; when there are many devices in the control system, this method can be used to connect to other devices, and local and remote control can be performed at the same time.
[0008] To achieve the above object, the present invention provides the following technical solutions:
[0009] A keyboard and mouse device sharing method comprises the following steps:
[0010] Step 1, obtain keyboard and mouse data in the system;
[0011] Step 2, compose the keyboard and mouse data into a network data frame and send it to the Kylin operating system;
[0012] Step 3, the winning Kylin operating system parses the network data frame;
[0013] Step 4: The Kylin operating system determines whether the network data frame is a keyboard event or a mouse event, and calls the corresponding data processing function for processing according to the event type;
[0014] Step 5: Kylin operating system responds to the processed keyboard and mouse events and shares them.
[0015] Preferably, in step 1, obtaining keyboard and mouse data in the system specifically includes the following process:
[0016] Start the USB event acquisition thread, obtain the keyboard and mouse values passed to the operating system in the USB driver provided in the system BSP package; use the obtained key values to compose the keyboard and mouse events into network data frames according to the USB event network protocol and put them into the send buffer.
[0017] Furthermore, in step 1, the USB event network protocol includes a data frame header, a keyboard and mouse event flag, a key code value, a relative coordinate of mouse movement, and a data frame checksum.
[0018] Preferably, in step 2, the sending network socket is initialized in the system according to the IP and port number of the other end in the configuration file; the network sending thread is started, and the data frames in the sending buffer are sent to the Kylin operating system through the initialized network socket; the Kylin operating system initializes the receiving network socket, starts the network data frame receiving thread, receives the network data frame and puts it into the receiving buffer.
[0019] Preferably, in step 3, a USB event parsing thread is started in the Kylin operating system, and USB event data packets are parsed sequentially from the receiving buffer. First, whether the data frame is valid is determined based on the frame header field and the checksum field in the data packet. If the data frame is invalid, it is discarded; if the data packet is valid, the next step is executed.
[0020] Preferably, in step 4, if it is a keyboard event, the keyboard event processing function is called, and the keyboard processing function first determines whether the keyboard event is a combination of keys or a single key;
[0021] When the keyboard event is a combination of keys, the combination key processing function is called to simulate the Linux combination key processing flow; when the keyboard event is a single key, the single key processing function is called to simulate the Linux single key processing flow;
[0022] The keyboard data under the Dao system is converted into the universal keyboard code value under Linux through a special algorithm; the keyboard data is composed into a mouse event structure under Linux and passed to the operating system, so that the Zhongbid Kylin operating system responds to keyboard events.
[0023] Preferably, in step 4, if it is a mouse event, the mouse event processing function is called, and the mouse event processing function composes the mouse horizontal and vertical position coordinate information in the data frame into a mouse event structure under Linux and passes it to the operating system, so that the Kylin operating system responds to the mouse event.
[0024] Compared with the prior art, the present invention has the following beneficial technical effects:
[0025] The present invention provides a keyboard and mouse device sharing method, which reduces the hardware complexity of the overall device compared with the hardware method, thereby reducing the risk of failure and also reducing the hardware design cost; the traditional USB device sharing protocol cannot be applied to the embedded system, the present invention solves the data transmission and data universality problems between the keyboard and mouse data domains in the system and the Kylin operating system through a custom network protocol and a special algorithm, and realizes the keyboard and mouse device sharing function between the embedded system and the desktop system; the sharing of input devices under the domestic operating system is realized by software, and the centralized management of multi-computer switching can be realized, which can save space, reduce energy consumption, save hardware costs, avoid the clutter caused by redundant keyboards and mice, make the management of equipment parts simpler and more convenient, and improve work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 The present invention is a flowchart of a keyboard and mouse device sharing method. DETAILED DESCRIPTION
[0027] The present invention is further described in detail below in conjunction with specific embodiments, which are intended to explain the present invention rather than to limit it.
[0028] The present invention provides a keyboard and mouse device sharing method, comprising the following steps:
[0029] Step 1, obtain keyboard and mouse data in the system;
[0030] Step 2, compose the keyboard and mouse data into a network data frame and send it to the Kylin operating system;
[0031] Step 3, the winning Kylin operating system parses the network data frame;
[0032] Step 4: The Kylin operating system determines whether the network data frame is a keyboard event or a mouse event, and calls the corresponding data processing function for processing according to the event type;
[0033] Step 5: Kylin operating system responds to the processed keyboard and mouse events and shares them.
[0034] The present invention provides a keyboard and mouse device sharing method, which reduces the hardware complexity of the overall device compared with the hardware method, thereby reducing the risk of failure and also reducing the hardware design cost; the traditional USB device sharing protocol cannot be applied to the embedded system, the present invention solves the data transmission and data universality problems between the keyboard and mouse data domains in the system and the Kylin operating system through a custom network protocol and a special algorithm, and realizes the keyboard and mouse device sharing function between the embedded system and the desktop system; the sharing of input devices under the domestic operating system is realized by software, and the centralized management of multi-computer switching can be realized, which can save space, reduce energy consumption, save hardware costs, avoid the clutter caused by redundant keyboards and mice, make the management of equipment parts simpler and more convenient, and improve work efficiency.
[0035] Example
[0036] like Figure 1 As shown, the present invention provides a keyboard and mouse device sharing method, including the following process:
[0037] Step 1, start the USB event acquisition thread, obtain the keyboard and mouse values passed to the operating system in the USB driver provided in the system BSP package; use the obtained key values, according to the custom USB event network protocol, to form the keyboard and mouse events into a network data frame and put it into the send buffer. The USB event network protocol includes a data frame header, a keyboard and mouse event flag, a key code value, a relative coordinate of the mouse movement, and a data frame checksum.
[0038] Step 2: Initialize the sending network socket in the system according to the peer IP and port number in the configuration file.
[0039] Step 3, start the network sending thread, and send the data frames in the sending buffer to the Kylin operating system through the network socket initialized in step 2.
[0040] Step 4, the Kylin operating system initializes the receiving network socket, starts the network data frame receiving thread, receives the network data frame in step 3 and puts it into the receiving buffer.
[0041] Step 5, the USB event parsing thread is started in the Kylin operating system, and the USB event data packets are parsed from the receiving buffer in sequence. First, the data frame is determined to be valid based on the frame header field and the checksum field in the data packet. If the data frame is invalid, it is discarded. If the data packet is valid, it is further determined whether the data packet is a keyboard event or a mouse event, and the corresponding data processing function is called according to the event type.
[0042] Step 6: If it is a keyboard event, the keyboard event processing function is called. The keyboard processing function first determines whether the keyboard event is a combination of Shift, Ctrl, Alt or a single key, and then selects the corresponding processing function to simulate the event. The keyboard data under the system is converted into the universal keyboard code value under Linux through a special algorithm. The data is composed into a mouse event structure under Linux and passed to the operating system, so that the operating system responds to the keyboard event.
[0043] Step 7: If it is a mouse event, the mouse event processing function is called. The mouse event processing function forms a mouse event structure under Linux with the mouse horizontal and vertical position coordinate information in the data frame and transmits it to the operating system, so that the operating system responds to the mouse event.
[0044] The customized network data frame format and protocol format of the present invention include keyboard events and mouse events, wherein the protocol includes the contents of functions such as Ctrl key combination, Shift key combination and Alt key combination, and realizes the key combination function, which can better simulate the user's usage habits and is more convenient to operate.
[0045] First, the data of keyboard and mouse events are obtained in the system and sent to the Kylin operating system through the network. The Kylin operating system receives and parses the network data frame, determines the legitimacy of the data frame, and then classifies and processes the keyboard events and mouse events. The different event information is combined into an event structure under Linux and reported to the operating system, so that the operating system responds to the keyboard and mouse events.
[0046] The keyboard and mouse event processing of the Zhongbid Kylin system distinguishes mouse events or keyboard events through specific flags. A special algorithm is designed for keyboard events to convert the keyboard key values of the embedded system into Linux standard key values to facilitate system processing; and according to the flags of different key combinations, the processing methods of different key combinations are set. For mouse events, the mouse horizontal and vertical position coordinate information in the data frame is composed of the mouse event structure under Linux and passed to the operating system, so that the operating system responds to the mouse event.
Claims
1. A keyboard and mouse device sharing method, characterized in that: The following steps are included: Step 1, obtain keyboard and mouse data in the system; Step 2, compose the keyboard and mouse data into a network data frame and send it to the Kylin operating system; Step 3, the Kylin operating system parses the network data frame; the USB event parsing thread is started in the Kylin operating system, and the USB event data packets are parsed from the receiving buffer in sequence. First, the validity of the data frame is determined according to the frame header field and the checksum field in the data packet. If the data frame is invalid, it is discarded; if the data packet is valid, the next step is executed; Step 4: The Kylin operating system determines whether the network data frame is a keyboard event or a mouse event, and calls the corresponding data processing function for processing according to the event type; Step 5: Kylin operating system responds to the processed keyboard and mouse events and shares them.
2. A keyboard and mouse device sharing method according to claim 1, characterized in that: In step 1, the process of obtaining keyboard and mouse data in the system specifically includes the following: Start the USB event acquisition thread, obtain the keyboard and mouse values passed to the operating system in the USB driver provided in the system BSP package; use the obtained key values to compose the keyboard and mouse events into network data frames according to the USB event network protocol and put them into the send buffer.
3. A keyboard and mouse device sharing method according to claim 2, characterized in that: In step 1, the USB event network protocol includes a data frame header, a keyboard and mouse event flag, a key code value, a relative coordinate of mouse movement, and a data frame checksum.
4. A keyboard and mouse device sharing method according to claim 1, characterized in that: In step 2, according to the IP and port number of the other end in the configuration file, the sending network socket is initialized in the system; the network sending thread is started, and the data frames in the sending buffer are sent to the Kylin operating system through the initialized network socket; the Kylin operating system initializes the receiving network socket, starts the network data frame receiving thread, receives the network data frame and puts it in the receiving buffer.
5. A keyboard and mouse device sharing method according to claim 1, characterized in that: In step 4, if it is a keyboard event, the keyboard event processing function is called, and the keyboard processing function first determines whether the keyboard event is a combination of keys or a single key; When the keyboard event is a combination of keys, the combination key processing function is called to simulate the Linux combination key processing flow; when the keyboard event is a single key, the single key processing function is called to simulate the Linux single key processing flow; The keyboard data under the Dao system is converted into the universal keyboard code value under Linux through a special algorithm; the keyboard data is composed into a mouse event structure under Linux and passed to the operating system, so that the Zhongbid Kylin operating system responds to keyboard events.
6. A keyboard and mouse device sharing method according to claim 1, characterized in that: In step 4, if it is a mouse event, the mouse event processing function is called. The mouse event processing function composes the mouse horizontal and vertical position coordinate information in the data frame into a mouse event structure under Linux and passes it to the operating system, so that the Kylin operating system responds to the mouse event.
Citation Information
Patent Citations
Desktop sharing method and system
CN101447998A
Video display modification based on sensor input for a see-through near-to-eye display
CN103946732A
Video processing method and video processing device
CN104219578A
Mouse cursor pointing direction control method, mouse cursor pointing direction control device and mouse cursor pointing direction control system
CN104731372A
System and methods for automated detection of input and output validation and resource management vulnerability
CN106687981A
