Method and system for centering joystick multiple points
By collecting joystick voltage data and using a weighted average algorithm to update the center point, the problem of joystick centering deviation caused by environmental disturbance and loss is solved, improving the game experience and data stability, and reducing the occurrence of drift.
Patent Information
- Application Number
- CN202410600379.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-15
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-05-15
AI Technical Summary
Existing joysticks are prone to center deviation and drift due to environmental disturbance and loss during use, which affects the user's normal gaming experience.
By collecting the voltage data of the rocker, it determines its static state and centering conditions, uses a weighted average algorithm to update the center point, and corrects and corrects the signal to ensure the accuracy and stability of the output data and reduce drift.
It effectively avoids the error of joystick centering during player play, improves the game experience, ensures the accuracy and stability of output data, and reduces the occurrence of joystick drift.
Smart Images

Figure CN118286672B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of joysticks, and in particular relates to a method and system for multi-point centering of joysticks. Background Art
[0002] With the development of Internet technology, more and more people use game controllers as input devices for controlling computer games, mobile games or smart TV games. Game controllers use joystick devices to control the movement direction of game characters.
[0003] The joystick device consists of a joystick and two sliding resistors placed in a cross shape. The joystick device can be shaken in different directions: left and right, front and back, up and down, and at any angle to output different voltage division values. The MCU collects the voltage division values through the ADC, obtains the data of the joystick, and then converts the data to obtain the movement control value required by the game, thereby controlling the movement of the characters in the game.
[0004] In the absence of external interference, the joystick will automatically return to the middle of the X and Y axes through the mechanical structure inside the joystick. This process is called centering. Of course, ideally, it returns to the origin. In the real environment, the joystick will have losses. The losses of different types of joysticks during use are different. The losses caused by using joysticks in different environments are different. The losses caused by using joysticks for different periods of time are different. Most of these losses are caused by interference with the sliding rheostat. It may be that dust or dandruff hinders the induction of the resistor, which in turn causes the current to change. The conductive material near the sensing device may also be worn out due to use, resulting in changes in resistance in specific parts and generating erroneous signals. In the existing technology, the joystick is also prone to production errors during the production or assembly process. All these will cause deviations in the centering of the joystick, resulting in the game screen or game characters still moving when the user uses the handle to play games. This is the drift phenomenon of the joystick, which greatly affects the normal use of the user.
[0005] Generally speaking, the joystick will have a preset fixed center point and its dead zone range. When the joystick value is within the dead zone, it is equivalent to being at the zero point. However, this fixed center point will also change due to excessive joystick wear and various interferences, causing the voltage data of the joystick to change. When the change is too large, it will eventually cause the joystick to offset. Summary of the invention
[0006] The present invention aims to provide a method and system for centering a joystick at multiple points, aiming to solve the technical problem that the centering of a joystick is deviated due to environmental disturbances, resulting in a joystick offset phenomenon, which affects normal use by users.
[0007] In order to solve the above technical problems, a first aspect of the present invention provides a method for centering a joystick at multiple points, the method comprising:
[0008] Collecting voltage data of the joystick, and obtaining the current coordinate value of the joystick according to the voltage data;
[0009] Determine whether the joystick is in a stationary state according to the current coordinate value. If it is in a stationary state, increase the stationary weight as the stationary weight corresponding to the current coordinate value; otherwise, clear the stationary weight and return to the first step;
[0010] Determine whether the current coordinate value and the corresponding static weight meet the preset centering condition. If so, obtain the centering weight at the end of the preset queue and increase it by a preset increment value as the centering weight corresponding to the current coordinate value, and add the current coordinate value and the corresponding centering weight into the queue. Otherwise, clear the static weight and return to the first step.
[0011] All coordinate values in the queue and the corresponding centering weights are calculated by a weighted average algorithm to obtain new coordinates, which are used as the coordinates of the new center point.
[0012] Optionally, in the method for centering the joystick multiple points as described above, after collecting the voltage data of the joystick and before obtaining the current coordinate value of the joystick according to the voltage data, the method includes:
[0013] Determine whether the time interval between two adjacent voltage data collections is greater than a preset collection time interval. If so, abandon the voltage data and wait for the next voltage data acquisition. Otherwise, continue to obtain the current coordinate value of the joystick according to the voltage data.
[0014] Optionally, in the method for centering the joystick multiple points as described above, judging whether the joystick is in a stationary state according to the current coordinate value includes:
[0015] It is determined whether the current coordinate value is consistent with the coordinate value acquired last time. If they are consistent, it is considered that the joystick is in a stationary state.
[0016] Optionally, in the method for centering the joystick multiple points as described above, judging whether the joystick is in a stationary state according to the current coordinate value further includes:
[0017] It is also determined whether the distance between the current coordinate value and the center point is greater than a preset distance value. If it is not greater than the preset distance value, and the current coordinate value is consistent with the coordinate value acquired last time, it is considered that the joystick is in a stationary state.
[0018] Optionally, in the method for centering the joystick at multiple points as described above, the preset centering condition is:
[0019] If the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold, and the current coordinate value and the center point satisfy the following formula, then it is considered that the current coordinate value and the corresponding static weight satisfy the preset centering condition;
[0020]
[0021] in, is the coordinate value of the X axis in the current coordinate value, is the Y-axis coordinate value in the current coordinate value, is the X-axis coordinate value of the center point, is the Y-axis coordinate value of the center point, The dead zone radius is the center point.
[0022] Optionally, in the method for centering the joystick multiple points as described above, before calculating all coordinate values in the queue and corresponding centering weights by a weighted average algorithm, the method includes:
[0023] Check whether there is an X-axis coordinate value or Y-axis coordinate value in the traversal queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue. If so, increase the X-axis centering weight or Y-axis centering weight at the end of the queue.
[0024] Optionally, in the aforementioned joystick multi-point centering method, when increasing the X-axis centering weight or the Y-axis centering weight of the tail of the team, the following method is adopted:
[0025] Whenever there is an X-axis coordinate value or Y-axis coordinate value in the queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue, the X-axis coordinate value or Y-axis coordinate value at the end of the queue is increased by a preset increase value.
[0026] Optionally, in the method for centering the joystick multiple points as described above, the weighted average algorithm is:
[0027]
[0028] in, is the X-axis coordinate value of the nth queue element in the queue, is the X-axis centering weight of the nth queue element in the queue, is the coordinate value of the X axis in the new coordinate;
[0029]
[0030] in, is the Y-axis coordinate value of the nth queue element in the queue. is the Y-axis centering weight of the nth queue element in the queue, is the coordinate value of the Y axis in the new coordinate;
[0031] Then, the new coordinates for .
[0032] Optionally, in the method for centering the joystick multiple points as described above, after obtaining the new coordinates and before using the new coordinates as the coordinates of the new center point, the method further includes:
[0033] Determine whether the new coordinates and the center point satisfy the following formula:
[0034]
[0035] in, is the coordinate value of the X axis in the new coordinate, is the coordinate value of the Y axis in the new coordinate, is the X-axis coordinate value of the center point, is the Y-axis coordinate value of the center point, is the dead zone radius of the center point;
[0036] If the conditions are met, the centering weight at the end of the queue is increased by a preset value as the centering weight corresponding to the new coordinate. After the new coordinate and the corresponding centering weight are added to the queue, all the coordinate values and the corresponding centering weights in the queue are calculated using a weighted average algorithm.
[0037] Otherwise, the new coordinates are used as the coordinates of the new center point.
[0038] In order to solve the above technical problems, the second aspect of the present invention provides a joystick multi-point centering system, comprising:
[0039] A data acquisition and processing module, used to acquire voltage data of the joystick, and obtain the current coordinate value of the joystick according to the voltage data;
[0040] A static state determination module is used to determine whether the joystick is in a static state according to the current coordinate value. If it is in a static state, a static weight is added as the static weight corresponding to the current coordinate value; otherwise, the static weight is cleared;
[0041] A centering condition determination module is used to determine whether the current coordinate value and the corresponding static weight satisfy a preset centering condition. If so, the centering weight at the end of the preset queue is obtained and increased by a preset increment value as the centering weight corresponding to the current coordinate value, and the current coordinate value and the corresponding centering weight are queued; otherwise, the static weight is cleared;
[0042] The center point update module is used to calculate all coordinate values in the queue and the corresponding centering weights through a weighted average algorithm to obtain new coordinates, and use the new coordinates as the coordinates of the new center point.
[0043] The positive and progressive effects of the present invention are:
[0044] 1. Before determining the centering condition, the present invention also determines whether the joystick is in a stationary state, in order to ensure that the joystick is centered when it is placed or not moved, so as to avoid the centering from disrupting the player's experience during the game.
[0045] 2. The present invention calculates the weights of historical points and latest points to update the center point and match the centering signal of the joystick, thereby playing a role of correction and error correction, ensuring the accuracy and stability of the output data, reducing the joystick drift phenomenon, and improving the user experience.
[0046] 3. The present invention also determines the interval between two adjacent collections. If the interval between collections is too large, there is a probability that the program will run abnormally and the data may be erroneous. In this case, the data should be abandoned to avoid errors.
[0047] 4. Before performing the weighted average algorithm, the present invention also performs weight-up processing on the situation where the centering weights in the queue are consistent, so as to ensure that the centering weight corresponding to the current coordinate value is the maximum value, thereby increasing the importance of the current coordinate value in the queue. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The disclosure of the present invention will become more apparent with reference to the accompanying drawings. It should be understood that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In the drawings:
[0049] Figure 1 A schematic diagram of a process of the present invention;
[0050] Figure 2 A position relationship diagram between the current coordinate value and the center point and the dead zone of the center point of the present invention;
[0051] Figure 3 A position relationship diagram of the current coordinate value of the present invention and the center point, the dead zone of the center point, and each queue element in the queue;
[0052] Figure 4 The figure is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.
[0054] It should be noted that the following embodiments and features therein may be combined with each other if there is no conflict.
[0055] In the description of the present invention, it should be noted that directional words such as the terms "outside", "middle", "inside", "outside", etc., which indicate directions and positional relationships, are based on the directions or positional relationships shown in the drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and cannot be understood as limiting the specific protection scope of the present invention.
[0056] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features. Therefore, the definition of "first" and "second" features can explicitly or implicitly include one or more of the features. In the description of the present invention, "several" and "a number" mean two or more, unless otherwise clearly and specifically defined.
[0057] Reference Figure 1 , an embodiment of the present invention provides a method for centering a joystick at multiple points, the method comprising the following steps:
[0058] S1, data collection and processing: collect the voltage data of the joystick, and obtain the current coordinate value of the joystick according to the voltage data.
[0059] Step S1 can use existing technology to collect joystick data, which refers to the voltage data of the joystick. For example, the original voltage data of the joystick is collected through ADC, and the sudden change of the joystick voltage data is filtered through median filtering to obtain the voltage data of the joystick. According to the ratio of the voltage data of the joystick to the game coordinate range, the current coordinate value of the joystick is finally obtained.
[0060] The ratio conversion method in step S1 adopts the existing technology, for example, the following conversion method:
[0061] Ccur = Vcur * B
[0062] B = (Vmax –Vmin) / (Cmax – Cmin)
[0063] Among them, Ccur is the current coordinate value, Vcur is the currently collected voltage data, B is the ratio coefficient, Vmax is the maximum voltage data obtained from the calibration mode, Vmin is the minimum voltage data obtained from the calibration mode, Cmax is the preset maximum coordinate value, and Cmin is the preset minimum coordinate value.
[0064] The calibration mode is preferably a manual calibration mode, which is actively triggered by the user, and Vmax and Vmin are obtained by the user manipulating the joystick to draw a circle.
[0065] The ideal center point for the game coordinates is 128, the minimum is 0, and the maximum is 256. For a single side, the single side distance of the game coordinates is 128, so Cmax is preferably 128 and Cmin is preferably 0.
[0066] The above conversion method is used to calculate the X-axis coordinate value and the Y-axis coordinate value of the current coordinate value respectively, and finally the current coordinate value of the joystick is obtained.
[0067] In some embodiments, in step S1, after collecting the voltage data of the joystick and before obtaining the current coordinate value of the joystick according to the voltage data, a process of judging the time interval between two adjacent collections is further included, as follows:
[0068] It is determined whether the time interval between two adjacent voltage data collections is greater than the preset collection time interval. If so, the voltage data is abandoned and the next voltage data is acquired. Otherwise, the step of obtaining the current coordinate value of the joystick according to the voltage data is continued.
[0069] Step S1 can count the time interval between two adjacent collections by adding a timer to determine whether it is greater than the preset collection time interval. Only when it is not greater, the calculation of the current coordinate value will continue. This is because data collection / reading is generally collected / read once in a large cycle of the program. Generally speaking, the time difference of a large cycle of the program will not be too large. If the time interval is too large, the program may run abnormally and the data may be wrong. At this time, the data should be abandoned to avoid errors.
[0070] S2, determine the stationary state: determine whether the joystick is in a stationary state according to the current coordinate value. If it is in a stationary state, increase the stationary weight as the stationary weight corresponding to the current coordinate value; otherwise, clear the stationary weight and return to the first step.
[0071] In step S2, the current coordinate value in a stationary state can be considered as the current stationary point. The historical coordinate value in a stationary state can be considered as a historical stationary point. The increase in the stationary weight can be a preset increase value, such as an exact value such as 1 or 2. The increase in the stationary weight can also be based on the accumulation of the stationary time as the corresponding stationary weight. At this time, the stationary weight corresponding to the current coordinate value can be determined by adding a timer. The longer the stationary time, the greater the stationary weight. When the stationary weight is cleared, the timer is also cleared and the timing starts again.
[0072] In step S2, the static state is determined preferably in the following manner:
[0073] In some embodiments, judging whether the joystick is in a stationary state according to the current coordinate value includes: judging whether the current coordinate value is consistent with the coordinate value acquired last time, and if they are consistent, it is considered that the joystick is in a stationary state.
[0074] That is, it is determined whether the coordinate values obtained from two consecutive acquisitions have changed. If there is no change, it is considered that the joystick is in a stationary state.
[0075] In some embodiments, when determining whether the joystick is in a stationary state, in addition to determining whether the coordinate values obtained from two consecutive acquisitions have changed, the distance between the joystick and the center point cannot be too large, so the following determination is also prioritized:
[0076] Judging whether the joystick is in a stationary state according to the current coordinate value also includes: judging whether the distance between the current coordinate value and the center point is greater than a preset distance value; if it is not greater than the preset distance value, and the current coordinate value is consistent with the coordinate value obtained last time, it is considered that the joystick is in a stationary state.
[0077] Specifically, one of the conditions for considering the joystick to be in a stationary state is that the current coordinate value and the center point must satisfy the following formula:
[0078]
[0079] in, is the coordinate value of the X axis in the current coordinate value, is the Y-axis coordinate value in the current coordinate value. is the X-axis coordinate value of the center point, is the Y-axis coordinate value of the center point, Preset value for distance.
[0080] By determining whether the distance between the current coordinate value and the center point is greater than the preset distance value, the update range of the joystick center point is limited, which can ensure that the distance between the joystick and the center point is not too large, reduce unnecessary updates of the center point and improve the real-time performance of the handle.
[0081] For example, Figure 2 As shown, the current coordinate value is A1, the current center point is A0, and the dead zone radius of the current center point A0 is r. When judging whether the joystick is in a stationary state, this embodiment first judges whether the distance L1 between the previous coordinate value A1 and the center point A0 is greater than the preset distance value. .
[0082] In some embodiments, in step S2, the preset distance value is preferably 28. When the distance between the current coordinate value and the center point is not greater than 28, it is determined whether the coordinate values obtained from two consecutive acquisitions have changed.
[0083] The ideal center point for the game coordinates is 128, the minimum is 0, and the maximum is 256. The preset distance value of step S2 is preferably 28 because, for a single side, the single side distance of the game coordinates is 128, 128 / 4 = 28, which is just at one quarter, just at a critical point. If the distance between the current coordinate value and the center point is greater than 28, it is too far from the center point.
[0084] S3, determine the centering condition: determine whether the current coordinate value and the corresponding stationary weight meet the preset centering condition. If so, obtain the centering weight at the end of the preset queue and increase it by a preset increase value as the centering weight corresponding to the current coordinate value. Add the current coordinate value and the corresponding centering weight to the queue. Otherwise, clear the stationary weight and return to the first step.
[0085] The centering condition in step S3 is determined in advance, and only the coordinate values and corresponding centering weights that meet the centering condition can be queued for subsequent weighted average algorithm centering calculation. When the centering condition is not met, the static weight is cleared.
[0086] In some embodiments, in step S3, the preset centering condition is: the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold, and the distance between the current coordinate value and the center point is greater than the dead zone radius of the center point, that is, there is no need to update the center point within the dead zone.
[0087] The weight threshold is pre-set according to the static weight. In step S2, if the increase in the static weight is a preset increase value, the corresponding weight threshold is a certain value, such as 10; if the increase in the static weight is the accumulation of the static time, the corresponding weight threshold is a certain time, such as 10 seconds.
[0088] The static weight corresponding to the current coordinate value is determined to ensure that the game controller is centered when it is placed or the joystick is not moving. This avoids the player's experience being disrupted by the centering during the game.
[0089] The specific formula for the dead zone radius when the distance between the current coordinate value and the center point is greater than the center point is:
[0090]
[0091] in, is the coordinate value of the X axis in the current coordinate value, is the Y-axis coordinate value in the current coordinate value. is the X-axis coordinate value of the center point, is the Y-axis coordinate value of the center point, The dead zone radius is the center point.
[0092] In some embodiments, the length of the dead zone radius of the center point is preferably 3, and when the stationary weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold, and the distance between the current coordinate value and the center point is greater than 3, it is considered that the current coordinate value and the corresponding stationary weight meet the preset centering conditions.
[0093] Assuming that the dead zone radius of the center point is greater than 3, the virtual position of the joystick is too large, and the weight of the queue is through, so 3 is prioritized. Of course, it can also be other length values less than 3.
[0094] In some embodiments, the centering weight includes an X-axis centering weight and a Y-axis centering weight.
[0095] Therefore, the preset centering weight of the tail of the queue is also divided into an X-axis centering weight and a Y-axis centering weight. After the centering condition is met, the X-axis centering weight of the tail of the queue is obtained and increased by a preset increase value as the X-axis centering weight of the current coordinate value, and the Y-axis centering weight of the tail of the queue is obtained and increased by a preset increase value as the Y-axis centering weight of the current coordinate value.
[0096] Among them, the preset increase value can be pre-set or determined according to scene requirements. For example, the preset increase value is 1, 2, 3, 5, 10 or other constants, preferably 1.
[0097] S4, update the center point: calculate all the coordinate values in the queue and the corresponding centering weights through a weighted average algorithm to obtain new coordinates, and use the new coordinates as the coordinates of the new center point.
[0098] The number of elements in the queue in step S4 can be set according to the situation, for example, 10, that is, there are 10 queue elements in the queue, of course, it can also be 5, 15 or 20. The queue contains two members, namely data (coordinate value) and Level (centering weight), that is, each queue element contains data (coordinate value) and Level (centering weight). Among them, data is divided into Xdata (X-axis coordinate value) and Ydata (Y-axis coordinate value), and Level is divided into XLevel (X-axis centering weight) and YLevel (Y-axis centering weight). The queue follows the first-in-first-out principle, and the current coordinate value and the corresponding centering weight are the queue elements at the end of the queue.
[0099] In some embodiments, before all coordinate values in the queue and the corresponding centering weights are calculated by a weighted average algorithm, the following steps are included:
[0100] Check whether there is an X-axis coordinate value or Y-axis coordinate value in the traversal queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue. If so, increase the X-axis centering weight or Y-axis centering weight at the end of the queue.
[0101] During traversal and comparison, this embodiment adopts the method of comparing the X-axis and Y-axis respectively. If there is an X-axis coordinate value or Y-axis coordinate value in the queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue, then the X-axis coordinate value or Y-axis coordinate value is considered to be a relatively important coordinate value. Therefore, it is necessary to increase the centering weight to highlight the importance of the coordinate value in the queue, so that the new center point is as close to the current coordinate value as possible to reduce drift.
[0102] In some embodiments, when increasing the X-axis centering weight or the Y-axis centering weight at the tail of the queue, the following method is used: for every X-axis coordinate value or Y-axis coordinate value in the queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the tail of the queue, the X-axis centering weight or Y-axis centering weight at the tail of the queue is increased by a preset increase value.
[0103] For example, when there is an X-axis coordinate value in the queue that is consistent with the X-axis coordinate value at the end of the queue, the X-axis centering weight of the current coordinate value is increased by one.
[0104] For example, when there are three X-axis coordinate values in the queue that are consistent with the X-axis coordinate value at the end of the queue, the X-axis centering weight of the current coordinate value increases by three.
[0105] In some embodiments, in step S4, the weighted average algorithm is:
[0106]
[0107] in, is the X-axis coordinate value of the nth queue element in the queue, is the X-axis centering weight of the nth queue element in the queue, is the coordinate value of the X axis in the new coordinate system, and n is the subscript of the queue;
[0108]
[0109] in, is the Y-axis coordinate value of the nth queue element in the queue. is the Y-axis centering weight of the nth queue element in the queue, is the coordinate value of the Y axis in the new coordinate;
[0110] Then, the new coordinates for .
[0111] In some embodiments, after obtaining the new coordinates and before using the new coordinates as the coordinates of the new center point, the method further includes:
[0112] Determine the new coordinates Whether the following formula is satisfied between the center point:
[0113]
[0114] in, The new coordinates The coordinate value of the X axis in The new coordinates The Y-axis coordinate value in is the X-axis coordinate value of the center point, is the Y-axis coordinate value of the center point, The dead zone radius is the center point.
[0115] If satisfied, the centering weight at the tail of the queue is increased by a preset increase value as the centering weight corresponding to the new coordinates. After the new coordinates and the corresponding centering weights are queued, all the coordinate values in the queue and the corresponding centering weights are calculated by the weighted average algorithm. Under the above conditions, the new coordinates and the centering weights increased by a preset increase value are queued to become the new tail element, and the original tail element becomes the previous queue element of the tail element. At this time, the centering weight of the tail element is increased by a preset increase value compared to the previous queue element. Of course, before calculating by the weighted average algorithm, it is preferred to traverse the queue to see if there is an X-axis coordinate value or Y-axis coordinate value consistent with the X-axis coordinate value or Y-axis coordinate value in the tail, so as to improve the importance of the X-axis centering weight or Y-axis centering weight at the tail of the queue.
[0116] Otherwise, the new coordinates As the new center point That is, the new center point obtained in this embodiment is within the dead zone radius of the original center point.
[0117] For example, Figure 3 As shown in the figure, the queue contains 10 queue elements, the current center point is A0, and the dead zone radius of the current center point A0 is r. The new coordinate value is calculated by weighted average to determine whether the distance between the new coordinate value and the center point A0 is greater than the dead zone radius r. If greater, the new coordinate value is re-queued and the new coordinate value is calculated; if not, the new coordinate value is the coordinate of the new center point, and the range with the new center point as the center and r as the radius is the dead zone range of the new center point.
[0118] The present invention not only performs a weighted average calculation on the historical static points and the current static points that have been queued, which can more accurately estimate the center point, but also allows the joystick with slight data deviation to be quickly and accurately placed in the dead zone of the center point. The deviation of the static point of a joystick with large wear and tear after long-term use will become larger, and the center point will also change accordingly. The present invention allows the static point of the joystick to be as close to the dead zone of the center point as possible, preventing the joystick from shifting. When the joystick is stationary, the game character is still moving, which greatly improves the gaming experience.
[0119] Embodiment 1:
[0120] Reference Figure 4 A method for centering a rocker multi-point according to the present invention comprises the following steps:
[0121] (1) ADC collects and filters data to obtain voltage data, which is then converted into the current coordinate value of the joystick.
[0122] (2) Determine whether the joystick is in a stationary state.
[0123] If it is in a stationary state, the stationary weight is accumulated and used as the stationary weight of the current coordinate value.
[0124] Otherwise, clear the static weights and return to step (1) to continue collecting, filtering and converting.
[0125] (3) Determine whether the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold.
[0126] If the static weight corresponding to the current coordinate value is less than the preset weight threshold, no subsequent work is performed until the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold.
[0127] (4) Determine whether it is within the queue range: whether the distance between the current coordinate value and the center point is greater than the dead zone radius of the center point.
[0128] If it is greater, the current coordinate value and the corresponding centering weight will be queued.
[0129] If it is not greater than, clear the static weight and return to step (1) to continue the collection, filtering and conversion work.
[0130] (5) Enter the queue and update the centering weight of each queue element in the queue, calculate it through the weighted average algorithm, and obtain the new coordinates.
[0131] (6) Determine whether the distance between the new coordinates and the current center point is greater than the dead zone radius of the center point.
[0132] If it is greater, the new coordinates are queued and step (5) is performed.
[0133] If not, the new coordinates become the coordinates of the new center point.
[0134] Embodiment 2:
[0135] Assume that the queue has 10 queue elements, queue element 0 to queue element 9, where queue element 0 is the head element and queue element 9 is the tail element. After the queue is continuously updated, each queue element has the following parameter table:
[0136]
[0137] The current center point coordinates are (130, 150), and the current dead zone radius of the center point is 3.
[0138] The current coordinate value obtained by collecting and converting the joystick data is (133, 140). The distance between the current coordinate value and the center point is less than the preset distance value 28 and greater than the dead zone radius 3.
[0139] Assuming that the current coordinate value is consistent with the coordinate value obtained in the last acquisition, it is considered that the current coordinate value is in a static state.
[0140] The static weight corresponding to the current coordinate value is equal to 10 seconds, so the current coordinate value meets the centering condition. The centering weights 40 and 71 at the end of the team are obtained, and after increasing the value by 1 once, the centering weights 41 and 72 of the current coordinate value are obtained and added to the team.
[0141] Then we traverse the queue and compare the coordinate values. We find that there are 6 X-axis coordinate values in the queue that are consistent with the X-axis coordinate value at the end of the queue. Then we add 41 to 6, and get the X-axis centering weight of 47 at the end of the queue. We find that there are 0 Y-axis coordinate values in the queue that are consistent with the Y-axis coordinate value at the end of the queue. Then the Y-axis centering weight of the end of the queue is still 72.
[0142] Then each queue element after update has the following parameter table:
[0143]
[0144] The weighted average algorithm is used for calculation to obtain the new coordinates (134, 149).
[0145] If the distance between the new coordinates and the center point is greater than the dead zone radius 3, the new coordinates and their corresponding centering weights 48 and 73 are queued again. Then the queue is traversed and the coordinate values are compared until the distance between the new coordinates and the center point is less than or equal to the dead zone radius 3, and the new coordinates become the new center point coordinates.
[0146] An embodiment of the present invention provides a joystick multi-point centering system, the system comprising:
[0147] The data acquisition and processing module is used to collect the voltage data of the joystick and obtain the current coordinate value of the joystick according to the voltage data;
[0148] The static state judgment module is used to judge whether the joystick is in a static state according to the current coordinate value. If it is in a static state, the static weight is increased as the static weight corresponding to the current coordinate value, otherwise the static weight is cleared;
[0149] A centering condition judgment module is used to judge whether the current coordinate value and the corresponding static weight meet the preset centering condition. If so, the centering weight at the end of the preset queue is obtained and increased by a preset increase value as the centering weight corresponding to the current coordinate value, and the current coordinate value and the corresponding centering weight are queued; otherwise, the static weight is cleared;
[0150] The center point update module is used to calculate all the coordinate values in the queue and the corresponding centering weights through a weighted average algorithm to obtain new coordinates, and use the new coordinates as the coordinates of the new center point.
[0151] The present invention is described in detail above in conjunction with the embodiments of the drawings, and those skilled in the art can make various variations of the present invention according to the above description. Therefore, certain details in the embodiments should not constitute limitations on the present invention, and the present invention shall be protected by the scope defined by the attached claims.
Claims
1. A method for centering a joystick at multiple points, characterized in that: The method for centering the joystick multiple points includes: Collecting voltage data of the joystick, and obtaining the current coordinate value of the joystick according to the voltage data; Determine whether the joystick is in a stationary state according to the current coordinate value. If it is in a stationary state, increase the stationary weight as the stationary weight corresponding to the current coordinate value. Otherwise, clear the stationary weight and return to the first step. The increase of the stationary weight is based on the accumulation of the stationary time as the corresponding stationary weight. The longer the stationary time, the greater the stationary weight. Determine whether the current coordinate value and the corresponding static weight meet the preset centering condition. If so, obtain the centering weight at the end of the preset queue and increase it by a preset increment value as the centering weight corresponding to the current coordinate value, and add the current coordinate value and the corresponding centering weight into the queue. Otherwise, clear the static weight and return to the first step. All coordinate values in the queue and the corresponding centering weights are calculated by a weighted average algorithm to obtain new coordinates, and the new coordinates are used as the coordinates of the new center point; The preset centering condition is: If the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold, and the current coordinate value and the center point satisfy the following formula, then it is considered that the current coordinate value and the corresponding static weight satisfy the preset centering condition; (Xcur-XOrigin) 2 +(Ycur-YOrigin) 2 >c 2 Wherein, Xcur is the coordinate value of the X axis in the current coordinate value, Ycur is the coordinate value of the Y axis in the current coordinate value, XOrigin is the coordinate value of the X axis of the center point, YOrigin is the coordinate value of the Y axis of the center point, and c is the dead zone radius of the center point; After obtaining the new coordinates and before using the new coordinates as the coordinates of the new center point, the method further includes: Determine whether the new coordinates and the center point satisfy the following formula: <h2 style=";text-align:left;direction:ltr">(Xsum-XOrigin)<h2 style=";text-align:left;direction:ltr"> 2 <h2 style=";text-align:left;direction:ltr"> +(Ysum-Yurigin)<h2 style=";text-align:left;direction:ltr"> 2 <h2 style=";text-align:left;direction:ltr"> >c<h2 style=";text-align:left;direction:ltr"> 2 Wherein, Xsum is the coordinate value of the X axis in the new coordinate, Ysum is the coordinate value of the Y axis in the new coordinate, XOrigin is the coordinate value of the X axis of the center point, YOrigin is the coordinate value of the Y axis of the center point, and c is the dead zone radius of the center point; If the conditions are met, the centering weight at the end of the queue is increased by a preset value as the centering weight corresponding to the new coordinate. After the new coordinate and the corresponding centering weight are added to the queue, all the coordinate values and the corresponding centering weights in the queue are calculated using a weighted average algorithm. Otherwise, the new coordinates are used as the coordinates of the new center point.
2. The method for centering a joystick at multiple points according to claim 1, characterized in that: After collecting the voltage data of the joystick and before obtaining the current coordinate value of the joystick according to the voltage data, the method includes: Determine whether the time interval between two adjacent voltage data collections is greater than a preset collection time interval. If so, abandon the voltage data and wait for the next voltage data acquisition. Otherwise, continue to obtain the current coordinate value of the joystick according to the voltage data.
3. The method for centering a joystick at multiple points according to claim 1, characterized in that: Judging whether the joystick is in a stationary state according to the current coordinate value includes: It is determined whether the current coordinate value is consistent with the coordinate value acquired last time. If they are consistent, it is considered that the joystick is in a stationary state.
4. The method for centering a joystick at multiple points according to claim 3, characterized in that: Judging whether the joystick is in a stationary state according to the current coordinate value, further comprising: It is also determined whether the distance between the current coordinate value and the center point is greater than a preset distance value. If it is not greater than the preset distance value, and the current coordinate value is consistent with the coordinate value acquired last time, it is considered that the joystick is in a stationary state.
5. The method for centering a joystick at multiple points according to claim 1, characterized in that: The weighted average algorithm is: (Xdata(n)*XLevel(n)+Xdata(n-1)*XLevel(n-1)+…+Xdata(1)*XLevel(1)+Xdata(0)*XLevel(0)) / (XLevel(n)+XLevel(n-1)+…+XLevel(1)+XLevel(0))=Xsum Wherein, Xdata(n) is the X-axis coordinate value of the n-th queue element in the queue, XLevel(n) is the X-axis centering weight of the n-th queue element in the queue, and Xsum is the X-axis coordinate value in the new coordinate; (Ydata(n)*YLevel(n)+Ydata(n-1)*YLevel(n-1)+…+Ydata(1)*YLevel(1)+Ydata(0)*YLevel(0)) / (YLevel(n)+YLevel(n-1)+…+YLevel(1)+YLevel(0))=Ysum Wherein, Ydata(n) is the Y-axis coordinate value of the n-th queue element in the queue, YLevel(n) is the Y-axis centering weight of the n-th queue element in the queue, and Ysum is the Y-axis coordinate value in the new coordinate; Then, the new coordinate V(new) is (Xsum, Ysum).
6. The method for centering a joystick at multiple points according to any one of claims 1 to 5, characterized in that: Before all the coordinate values in the queue and the corresponding centering weights are calculated by the weighted average algorithm, including: Check whether there is an X-axis coordinate value or Y-axis coordinate value in the traversal queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue. If so, increase the X-axis centering weight or Y-axis centering weight at the end of the queue.
7. The method for centering a joystick at multiple points according to claim 6, characterized in that: When increasing the X-axis centering weight or Y-axis centering weight of the tail of the queue, the following method is used: Each time there is an X-axis coordinate value or Y-axis coordinate value in the queue that is consistent with the X-axis coordinate value or Y-axis coordinate value at the end of the queue, the X-axis centering weight or Y-axis centering weight at the end of the queue is increased by a preset increase value.
8. A joystick multi-point centering system, characterized in that: The joystick multi-point centering system includes: A data acquisition and processing module, used to acquire voltage data of the joystick, and obtain the current coordinate value of the joystick according to the voltage data; A static state determination module is used to determine whether the joystick is in a static state according to the current coordinate value. If it is in a static state, the static weight is increased as the static weight corresponding to the current coordinate value; otherwise, the static weight is cleared, wherein the increase of the static weight is based on the accumulation of static time as the corresponding static weight, and the longer the static time, the greater the static weight; A centering condition determination module is used to determine whether the current coordinate value and the corresponding static weight satisfy a preset centering condition. If so, the centering weight at the end of the preset queue is obtained and increased by a preset increment value as the centering weight corresponding to the current coordinate value, and the current coordinate value and the corresponding centering weight are queued; otherwise, the static weight is cleared; The center point update module is used to calculate all the coordinate values in the queue and the corresponding centering weights through a weighted average algorithm to obtain new coordinates, and use the new coordinates as the coordinates of the new center point; The preset centering condition is: If the static weight corresponding to the current coordinate value is greater than or equal to the preset weight threshold, and the current coordinate value and the center point satisfy the following formula, then it is considered that the current coordinate value and the corresponding static weight satisfy the preset centering condition; (Xcur-XOrigin) 2 +(Ycur-YOrigin) 2 >c 2 Wherein, Xcur is the coordinate value of the X axis in the current coordinate value, Ycur is the coordinate value of the Y axis in the current coordinate value, XOrigin is the coordinate value of the X axis of the center point, YOrigin is the coordinate value of the Y axis of the center point, and c is the dead zone radius of the center point; The center point updating module is further used to determine whether the new coordinates and the center point satisfy the following formula after obtaining the new coordinates and before using the new coordinates as the new center point coordinates: <h2 style=";text-align:left;direction:ltr">(Xsum-XOrigin)<h2 style=";text-align:left;direction:ltr"> 2 <h2 style=";text-align:left;direction:ltr"> +(Ysum-Yurigin)<h2 style=";text-align:left;direction:ltr"> 2 <h2 style=";text-align:left;direction:ltr"> >c<h2 style=";text-align:left;direction:ltr"> 2 Wherein, Xsum is the coordinate value of the X axis in the new coordinate, Ysum is the coordinate value of the Y axis in the new coordinate, XOrigin is the coordinate value of the X axis of the center point, YOrigin is the coordinate value of the Y axis of the center point, and c is the dead zone radius of the center point; If the conditions are met, the centering weight at the end of the queue is increased by a preset value as the centering weight corresponding to the new coordinate. After the new coordinate and the corresponding centering weight are added to the queue, all the coordinate values and the corresponding centering weights in the queue are calculated using a weighted average algorithm. Otherwise, the new coordinates are used as the coordinates of the new center point.
