Commit Graph

113 Commits

Author SHA1 Message Date
Dr. Dystopia 9602f36248 Remove redundant semicolons 2024-08-20 14:59:54 +02:00
JosJuice defc38b258 InputCommon: Translate ExpressionParser error messages
The _trans macro marks strings for translation but doesn't do anything
at runtime. For that, we need to use a function like GetStringT.
2024-07-28 12:09:15 +02:00
Jordan Woyak e9fe0d3d5b NumericSetting: Stop values from binding to numbered input names. 2024-04-12 15:54:18 -05:00
Jordan Woyak 5039072ae9 ExpressionParser: Support unary plus operator. 2024-04-12 15:52:35 -05:00
Tilka 8cbb2c2e44
Merge pull request #12399 from lioncash/erasing
General: Make use of std::erase_if/std::erase where applicable
2023-12-12 20:54:52 +00:00
Lioncash ded2d55438 ExpressionParser: Avoid some miscellaneous copies
Just some trivial copies that can be eliminated or turned into moves.
2023-12-12 14:03:41 -05:00
Lioncash a5bbeb721a ExpressionParser: Mark constructors explicit where applicable
Makes for consistency with the surrounding code.
2023-12-12 14:00:27 -05:00
Lioncash ea71a76ea9 ExpressionParser: Pass control qualifiers by const reference
These aren't necessarily cheap to copy, since a control qualifier will
have around 3 std::strings inside of it, so passing by value can churn
allocations a little bit.
2023-12-12 13:50:46 -05:00
Lioncash 9aea481e59 ExpressionParser: Make use of std::erase_if 2023-12-12 13:31:58 -05:00
get 1df482d51f Prefer static const std::regex
std::regex has a relatively expensive constructor, and these are unchanging regexes.
2023-06-08 09:39:23 -05:00
Pokechu22 f1f3fd5d9d InputCommon: Fix memory leak in ExpressionParser
We allocate in MakeSuppressor via `return unique_ptr(std::make_unique<...>(...).release(), InvokingDeleter{}`, so it wasn't properly getting freed.
2023-02-17 18:29:36 -08:00
Jordan Woyak f5b9049421 Input: Add "abs" input expression function. 2022-10-11 19:28:21 -05:00
Shawn Hoffman f92541fbd9 StripSpaces: only strip spaces
StripWhitespace maintains old behavior
2022-07-25 18:40:12 -07:00
Pokechu22 78bfd25964 Fix all uninitialized variable warnings (C26495) 2021-10-13 12:32:16 -07:00
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Filoppi 93e3e691f9 Expose Control Expression variables to mappings UI
-add a way to reset their value (from the mappings UI)
-fix "memory leak" where they would never be cleaned,
one would be created every time you wrote a character after a "$"
-fix ability to create variables with an empty string by just writing "$" (+added error for it)
-Add $ operator to the UI operators list, to expose this functionality even more
2021-05-24 02:38:06 +03:00
Filoppi 5f74d0e08f InputCommon: follow coding conventions 2021-05-12 18:27:24 +03:00
Filoppi f4fec42165 Add mixed comments to input code, make some tooltip clearer 2021-05-12 18:27:23 +03:00
Jordan Woyak 1daefeb20a
Merge pull request #9674 from Filoppi/fix_hotkey_suppresion_crash
Fix hotkey suppression crash
2021-04-28 18:21:07 -05:00
Filoppi 799a368a7c InputCommon: small hotkey threshold symmetry fix 2021-04-26 19:45:13 +03:00
Filoppi ba2782e9d1 InputCommon: fix hotkey suppression crash if nullptr suppressions were added to the map
Update references was failing to update the references, causing input to stay nullptr and crashing.
I fixed the case that triggered that, though also added checks against nullptrs for safety.

(cherry picked from commit 4bdcf707555a5568eddff957fa3604975ffb6ed7)
2021-04-26 19:44:04 +03:00
Pokechu22 004dfd1586 Replace uses of cassert with Common/Assert.h 2021-04-02 10:18:18 -07:00
Shawn Hoffman 7e1df34735 rename InputCommon/ControllerInterface/Device to CoreDevice 2021-01-27 14:29:48 -08:00
Admiral H. Curtiss cae741584b InputCommon: Return error, if any, from ControlReference::SetExpression(). 2020-11-08 01:04:33 +01:00
Lioncash faf509e315 ExpressionParser: Add missing <functional> include
Unbreaks Windows CMake builds.
2020-10-20 16:18:32 -04:00
Jordan Woyak 431eb4d60d ExpressionParser: Improve hotkey suppression logic. Allow activation with simultaneous press of modifier and final input. 2020-09-25 22:51:33 -05:00
Jordan Woyak 44927da420 ExpressionParser: Replace ScopeGuard with custom deleter unique_ptr. 2020-09-25 22:51:33 -05:00
Jordan Woyak d8ad8c3861 InputCommon: Make hotkeys and input detection aware of Ctrl -> L_Ctrl / R_Ctrl hierarchy. 2020-09-25 20:29:18 -05:00
Jordan Woyak aae913fbc6 InputCommon: Clean up modifier ignoring logic. 2020-09-25 20:29:18 -05:00
Jordan Woyak d2729df281 ExpressionParser: Allow duplicate and superset modifier hotkeys to function. 2020-09-25 20:29:18 -05:00
Jordan Woyak e6ba495486 ExpressionParser: Suppress inputs when hotkey modifiers are pressed. 2020-09-25 20:29:18 -05:00
Jordan Woyak 52547379c9 ExpressionParser: Add Hotkey syntax. 2020-09-25 20:29:18 -05:00
Admiral H. Curtiss 2281cde28b InputCommon: Add a handful of math functions to the expression parser. 2020-08-02 22:09:09 +02:00
Jun Su b6ff15c130 Cleanup warnings of -Wmissing-declarations
Add static to the functions which is not intentionally
export to big scope.
2020-03-24 20:16:10 +08:00
Jordan Woyak f07457b6cc InputCommon: Eliminate some duplicated button threshold logic. 2020-02-09 10:37:18 -06:00
Jordan Woyak e8152b700f InputCommon: Allow controller settings specified with input expresions. 2020-02-08 14:01:55 -06:00
Lioncash 814fd165af InputCommon/FunctionExpression: Use Yoda conditions, we do not
The general convention in the codebase is to compare the non-constant
value/string with the constant value/string, not the other way around.
2019-11-22 15:36:18 -05:00
Lioncash 1f6077922b InputCommon/FunctionExpression: Remove unnecessary 'else' in MakeFunctionExpression()
Given all conditional bodies only contain a return, the use of else here
isn't necessary.

This has the benefit of consistently vertically aligning the names.
2019-11-22 15:36:18 -05:00
Lioncash 10fea99d80 InputCommon/FunctionExpression: Make MakeFunctionExpression() take a std::string_view
There's nothing within this function that requires a copy of the string
to be made, so we can make use of a non-owning view
2019-11-22 15:36:18 -05:00
Lioncash ddf8abf507 InputCommon/FunctionExpression: Remove unused LOOP_MAX_REPS constant
This isn't used anywhere in the translation unit, so we can remove it.
2019-11-22 15:36:18 -05:00
Lioncash 64bc6f53fd InputCommon/FunctionExpression: Remove cyclical include
This header was including itself, which is likely not intended.
2019-11-22 15:36:18 -05:00
Lioncash cb8fbe872e InputCommon/FunctionExpression: Collapse namespaces
Since we target C++17, we can collapse the namespaces into a single
declaration specifier.
2019-11-22 15:36:14 -05:00
Lioncash 6586ecc7a8 InputCommon/FunctionExpression: include <algorithm>
std::min/std::max are used within this translation unit, so it needs to
be included to prevent potential compilation failures.
2019-11-22 14:41:13 -05:00
Jordan Woyak 85ceb37ccd InputCommon: Make the "input gate" not racey. 2019-11-06 16:31:02 -06:00
JosJuice c6b4438c62 InputCommon: Change "EOF" to "end of expression" in user facing string
This is hopefully clearer, since we're not dealing with a file.
2019-10-25 23:49:20 +02:00
Jordan Woyak 1fe44238b1 ExpressionParser: Add XOR operator. 2019-10-20 09:51:52 -05:00
Jordan Woyak 7295458c11 ExpressionParser: Make Lexer ctor explicit and move argument. 2019-10-12 12:28:19 -05:00
Jordan Woyak 72302d9c42 ExpressionParser: Add support for /* */ style comments. 2019-10-12 11:41:02 -05:00
Jordan Woyak 4d41bd64c8 ExpressionParser: Show error message with expected arguments. 2019-10-11 19:38:18 -05:00
Jordan Woyak b57178d246 ExpressionParser: Remove ! character from function syntax. Remove unused serialization functions. 2019-10-11 18:12:18 -05:00