do not renumber explicitly numbered enums

In general, if an enum has been explicitly numbered, it means
that there are crates that depend on the actual number assigned,
and changing them will break other crates.

This is done to allow for cross-compatibility reasons, for
example, going to a C FFI or to the standard library, where
we can't simply refer to a Rust crate to import the symbolic
enums and have the compiler figure out a consistent numbering
method.

Thus even though it's a bit "ugly", please assign only unused
numbers to new enums, and when old enums are retired, do not
re-use the number.
This commit is contained in:
bunnie 2022-06-14 01:23:48 +08:00
parent d7eb53664e
commit 9760910991

View file

@ -61,28 +61,28 @@ pub(crate) enum Opcode {
RegisterRawListener = 3,
/// request for updates for *when* keyboard is pressed
RegisterKeyObserver = 4,
RegisterKeyObserver = 12,
/// set repeat delay, rate; both in ms
SetRepeat = 5, //(u32, u32),
SetRepeat = 4, //(u32, u32),
/// set chording interval (how long to wait for all keydowns to happen before interpreting as a chord), in ms (for braille keyboards)
SetChordInterval = 6, //(u32),
SetChordInterval = 5, //(u32),
/// used by host mode emulation and debug UART to inject keys
InjectKey = 7, //(char),
InjectKey = 6, //(char),
/// used by the interrupt handler to transfer results to the main loop
HandlerTrigger = 8,
HandlerTrigger = 7,
/// used to turn keyboard vibrate on and off
Vibe = 9,
Vibe = 8,
/// a blocking key listener - blocks until a key is hit
BlockingKeyListener = 10,
BlockingKeyListener = 9,
/// Suspend/resume callback
SuspendResume = 11,
SuspendResume = 10,
}
// this structure is used to register a keyboard listener. Currently, we only accept