mgth/LittleBigMouse · error · ArgumentException
Invalid VIDAA remote key.
Error message
Invalid VIDAA remote key.
What it means
TranslateKey maps library-facing remote key names to VIDAA protocol key codes. Keys not matching a known alias and not already starting with 'KEY_' are rejected with ArgumentException naming the key parameter. It is a whitelist check to avoid sending garbage key codes to the TV.
Solutions
- Use a recognized key constant (e.g. KEY_POWER, KEY_VOLUP, KEY_OK) or an alias from the mapping table
- Uppercase the name and prefix it with KEY_ if your key is not in the alias table
- Extend/wrap TranslateKey with your own mapping before calling it
- Check the VIDAA remote key list in the protocol source for valid names
Example fix
// before
var code = HisenseVidaaProtocol.TranslateKey("volume_up"); // throws
// after
var code = HisenseVidaaProtocol.TranslateKey("KEY_VOLUP"); Defensive patterns
Strategy: validation
Validate before calling
bool IsValidVidaaKey(string k) =>
k.StartsWith("KEY_", StringComparison.Ordinal) || KnownAliases.Contains(k); Type guard
bool IsRemoteKey(object k) => k is string s && s.Length > 0 && (s.StartsWith("KEY_") || AliasTable.ContainsKey(s)); Try / catch
try { code = TranslateKey(key); }
catch (ArgumentException ex) { log.Warn($"Unknown key {key}"); } Prevention
- Centralize key constants instead of inline strings
- Keep UI button bindings in one validated map
- Use exact uppercase KEY_ names
- Extend the alias table rather than inventing keys at call sites
When it happens
Trigger: Calling TranslateKey with a name like "volume_up", "OK", "power", or an empty string that isn't in the alias table and lacks the KEY_ prefix.
Common situations: Binding UI buttons to invented key names; translating from another remote-control library's key names; casing mistakes (VIDAA keys are uppercase with underscores).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Enter a valid projector IPv4 address.
- Enter a VIDAA picture-setting menu ID between 1 and 999.
- Enter a VIDAA picture-setting value between -1000 and 1000.
- Enter a volume between 0 and 100.
- A Wi-Fi MAC address is required for VIDAA authentication.
AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16).
Data as JSON: /api/errors/e698626fb50d54c1.
Report an issue: GitHub.
Appendix: source
Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs:121
model,
NormalizeMac(mac),
protocol,
First(raw, "brand") is { Length: > 0 } brand ? brand : "his");
}
public static string TranslateKey(string key) => key.Trim().ToUpperInvariant() switch
{
"KEY_ENTER" => "KEY_OK",
"KEY_RETURN" => "KEY_RETURNS",
"KEY_VOLUP" => "KEY_VOLUMEUP",
"KEY_VOLDOWN" => "KEY_VOLUMEDOWN",
"KEY_CHUP" => "KEY_CHANNELUP",
"KEY_CHDOWN" => "KEY_CHANNELDOWN",
"KEY_PLAYPAUSE" => "KEY_PLAY",
"KEY_FF" => "KEY_FORWARDS",
"KEY_REWIND" => "KEY_BACKWARDS",
var value when value.StartsWith("KEY_", StringComparison.Ordinal) => value,
_ => throw new ArgumentException("Invalid VIDAA remote key.", nameof(key)),
};
public static string Topic(string service, string clientId, string action)
=> $"/remoteapp/tv/{service}/{clientId}/actions/{action}";
/// <summary>
/// The token exchange is asked for on a <c>data</c> topic rather than through
/// <see cref="Topic"/>'s <c>actions</c> namespace.
/// </summary>
public static string TokenRequestTopic(string clientId)
=> $"/remoteapp/tv/platform_service/{clientId}/data/gettoken";
/// <summary>An empty refresh token asks for a first pair of tokens.</summary>
public static string TokenRequestPayload() => "{\"refreshtoken\":\"\"}";
public static string PictureSettingPayload(int menuId, int value)
{
if (menuId is < 1 or > 999)View on GitHub (pinned to 7a42f01d47)