Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## [Unreleased]

### Added
- Tartarus V2 Pro thumbstick (#21): Analog mode / Key mode on the Thumbstick tab. Key mode turns
the stick into keys (WASD out of the box) and games get only those keys, no controller: the
keypad goes into 8-way mode and driver mode, as Synapse does, and sends the stick's position in
its own report. Unlike Synapse's 4-way and 8-way modes, forward can be at any angle, the zones
where two keys are held at once (W+A) have an adjustable width, from a clean 4-way to wide
diagonals, and the dead zone is set apart from the angle. A key stays down a few degrees past
its zone so it doesn't flicker, and keys are let go while the PC is locked. Analog mode makes
the stick a game controller again, with Synapse's Thumbstick Orientation (the keypad's own
quarter turn) if wanted; key mode isn't affected by it. Settings are kept per profile, also
while in analog mode. The tab shows the stick live on a dial, with "Forward = where the stick
points". Also `secbird stick`, `secbird stickturn`, `secbird stickmode` and `secbird devmode`.
- Tartarus V2 Pro keys (#21): the Keys tab draws the keypad as it is (rows of 6, 6, 6, 5 and 4,
numbered as printed, and the three thumb buttons and the stick press beside them), and
remapping works. The keypad keeps remaps in its own memory, so Secretarybird writes them as
Synapse does (keymap 1 of profile 1), byte for byte as seen in USB captures, and they work with
nothing running. In key mode the keypad ignores its own keymap (driver mode); the tray then does
the remaps itself, telling the keypad's keys from another keyboard's by the keypad's own report.
For now a key can be set to another single key on the normal layer; the top and bottom thumb
buttons can also go back to HyperShift and cycle up profile. HyperShift-layer remaps, shortcuts
and macros come later.
- `secbird listen [keys]`: a read-only recording of what a device sends, to work out what its
interfaces carry.

Tested on one keypad (firmware 1.2) without Synapse running. The commands, and the captures and
logs they come from, are in docs/tartarus-v2-pro.md.

## [0.5.1] - 2026-10-30

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Things Secretarybird does that Synapse won't:
- **Plain files.** Your settings are one `profiles.json`; back it up or copy it to another PC.
- **Share the lights.** Hand a device's RGB to another app and keep using Secretarybird for
everything else.
- **Thumbstick at any angle.** On the Tartarus V2 Pro, turn the stick into WASD with forward
wherever your thumb wants it and diagonals that hold two keys, at the width you choose.
- **Clean up after Razer.** [`secbird debloat`](#debloat) turns off Razer's background services,
and `debloat undo` puts them back.

Expand Down
2 changes: 1 addition & 1 deletion crates/secbird-core/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
{"pid":"02E1","name":"Blade 18 (2026)","kind":"laptop","txid":"FF","lighting":"standard","leds":[{"name":"backlight","id":5}],"matrix":{"rows":6,"cols":19},"source":"openrazer"},
{"pid":"02E3","name":"Reclusa X Mini 65%","kind":"keyboard","interface":2,"txid":"1F","polling":"high","lighting":"extended","leds":[{"name":"backlight","id":5}],"source":"user report (#53): txid 1F on interface 2, HyperPolling 00:C0, LEDs 0, 5; everything tried works; per-key layout not known"},
{"pid":"02EA","name":"Huntsman V3 HE TKL","kind":"keyboard","interface":3,"txid":"1F","polling":"high","lighting":"extended","leds":[{"name":"backlight","id":5}],"source":"user reports (#36, #50): txid 1F on interface 3, HyperPolling 00:C0, LEDs 0, 5; #50 names it the TKL; per-key layout not known"},
{"pid":"02EB","name":"Tartarus V2 Pro","kind":"keypad","txid":"1F","polling":"high","lighting":"extended","leds":[{"name":"backlight","id":5}],"source":"Synapse AvailableDevices.json (747); txid 1F, interface 3, HyperPolling 00:C0 and LEDs 0, 5 from #21; LED 0 left out (it is the all-LEDs id); per-key layout not known"},
{"pid":"02EB","name":"Tartarus V2 Pro","kind":"keypad","txid":"1F","polling":"high","thumbstick":true,"onboard_keymap":true,"lighting":"extended","leds":[{"name":"backlight","id":5}],"source":"Synapse AvailableDevices.json (747); txid 1F, interface 3, HyperPolling 00:C0 and LEDs 0, 5 from #21; LED 0 left out (it is the all-LEDs id); per-key layout not known; keys remapped like Synapse (02:37 then 02:0D), from a USB capture"},
{"pid":"0501","name":"Kraken 7.1","kind":"headset","lighting":"kraken","source":"openrazer"},
{"pid":"0504","name":"Kraken 7.1 Chroma","kind":"headset","lighting":"kraken","source":"openrazer"},
{"pid":"0506","name":"Kraken 7.1 (Alternate)","kind":"headset","lighting":"kraken","source":"openrazer"},
Expand Down
67 changes: 67 additions & 0 deletions crates/secbird-core/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,73 @@ fn check_lighting(dev: &Device, store: &mut Store) -> Result<()> {
Ok(())
}

/// Thumbstick as keys for the active profile (`None` turns it off). Turning it on puts the
/// keypad in driver mode and 8-way mode, so it sends the stick's position only to
/// Secretarybird; turning it off makes the stick a game controller again. The tray reads the
/// stick and presses the keys.
pub fn set_stick(dev: &Device, store: &mut Store, stick: Option<crate::stick::Stick>) -> Result<Option<crate::stick::Stick>> {
if !dev.spec.as_ref().is_some_and(|s| s.thumbstick) {
return Err(crate::error::Error::Unsupported(format!("{} has no thumbstick", dev.name())));
}
let stick = stick.map(crate::stick::Stick::checked).transpose()?;
// The analog orientation as it is now, kept before key mode changes it (below).
let analog_turn = dev.stick_rotated().ok();
let profile = store.for_device(dev).active_mut();
let was_on = profile.stick.is_some();
if stick.is_some() && !was_on && profile.stick_rotated.is_none() {
profile.stick_rotated = analog_turn;
}
let restore_turn = profile.stick_rotated;
// Off keeps the settings aside; on without settings of its own takes them back.
let stick = match stick {
Some(s) => Some(s),
None => {
if let Some(old) = profile.stick.take() {
profile.stick_off = Some(old);
}
None
}
};
if stick.is_some() {
profile.stick_off = None;
}
profile.stick = stick.clone();
store.save()?;
match (&stick, was_on) {
(Some(_), false) => {
dev.set_driver_mode()?;
dev.set_stick_mode(crate::stick::Mode::EightWay)?;
// The keypad turns the position it reports in key mode too: key mode reads it
// unturned and has its own Forward.
dev.set_stick_rotated(false)?;
}
(None, true) => {
dev.set_stick_mode(crate::stick::Mode::Analog)?;
// Back to normal mode, where the keypad's own key remaps work again.
dev.set_normal_mode()?;
if let Some(rotated) = restore_turn {
dev.set_stick_rotated(rotated)?;
}
}
_ => {}
}
Ok(stick)
}

/// Synapse's Thumbstick Orientation (the keypad's own quarter turn), saved to the active profile.
pub fn set_stick_rotated(dev: &Device, store: &mut Store, rotated: bool) -> Result<()> {
if !dev.spec.as_ref().is_some_and(|s| s.thumbstick) {
return Err(crate::error::Error::Unsupported(format!("{} has no thumbstick", dev.name())));
}
let profile = store.for_device(dev).active_mut();
// In key mode the keypad stays unturned; this is for when the stick is a controller again.
if profile.stick.is_none() {
dev.set_stick_rotated(rotated)?;
}
profile.stick_rotated = Some(rotated);
store.save()
}

/// Returns the DPI actually set, after rounding to the device's step.
pub fn set_dpi(dev: &Device, store: &mut Store, x: u16, y: u16) -> Result<(u16, u16)> {
let applied = dev.set_dpi(x, y)?;
Expand Down
107 changes: 99 additions & 8 deletions crates/secbird-core/src/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,36 @@ pub const KEYS: &[(u8, &str, &str, u8)] = &[
/// (the mouse button) stay apart.
const KEY_PREFIX: &str = "key-";

/// The Tartarus V2 Pro's thumb inputs: (key id, name, label, Razer key). The key id is what
/// 02:0D takes (seen in USB captures of Synapse setting each one to a key, #21); the Razer
/// key is what the keypad reports in report 04 in driver mode, where they type nothing.
/// Top to bottom as on Synapse's drawing, then the stick press.
pub const KEYPAD_THUMBS: &[(u8, &str, &str, u8)] = &[
(59, "thumb-top", "Top thumb button (HyperShift)", 0x01),
(218, "thumb-middle", "Middle thumb button", 0x67),
(217, "thumb-bottom", "Bottom thumb button", 0x68),
(219, "stick-press", "Stick press", 0x69),
];

/// What a key of a keypad that keeps remaps on board does out of the box, where Synapse was
/// seen writing it: the key's own usage, or for two thumb buttons their default function
/// (`0C 01 01` HyperShift, `07 01 04` cycle up profile, from a USB capture). The middle thumb
/// button (cycle down keymap) and the stick press (disabled) had nothing written, so `None`.
pub fn onboard_default(id: u8) -> Option<Action> {
match id {
59 => Some(Action::HyperShift),
217 => Some(Action::ProfileCycleUp),
_ => KEYS.iter().find(|k| k.0 == id).map(|k| Action::Key { modifiers: 0, usage: k.3 }),
}
}

/// A key's id from its name without the `key-` prefix (`capslock`, or `id57`).
pub fn key_id(name: &str) -> Option<u8> {
KEYS.iter().find(|k| k.1 == name).map(|k| k.0).or_else(|| name.strip_prefix("id")?.parse().ok())
KEYS.iter()
.find(|k| k.1 == name)
.map(|k| k.0)
.or_else(|| KEYPAD_THUMBS.iter().find(|k| k.1 == name).map(|k| k.0))
.or_else(|| name.strip_prefix("id")?.parse().ok())
}

/// A remappable input: a mouse button or a keyboard key. Each has its own id space.
Expand All @@ -225,7 +252,11 @@ impl Input {
match self {
Input::Button(id) => button_name(id),
Input::Key(id) => {
let name = KEYS.iter().find(|k| k.0 == id).map_or_else(|| format!("id{id}"), |k| k.1.to_string());
let name = KEYS
.iter()
.chain(KEYPAD_THUMBS)
.find(|k| k.0 == id)
.map_or_else(|| format!("id{id}"), |k| k.1.to_string());
format!("{KEY_PREFIX}{name}")
}
}
Expand All @@ -234,7 +265,9 @@ impl Input {
pub fn label(self) -> String {
match self {
Input::Button(id) => button_label(id),
Input::Key(id) => KEYS.iter().find(|k| k.0 == id).map_or_else(|| format!("Key {id}"), |k| k.2.to_string()),
Input::Key(id) => {
KEYS.iter().chain(KEYPAD_THUMBS).find(|k| k.0 == id).map_or_else(|| format!("Key {id}"), |k| k.2.to_string())
}
}
}

Expand Down Expand Up @@ -734,23 +767,74 @@ impl Device {
Ok(Action::decode(a[3], [a[5], a[6], a[7], a[8], a[9]]))
}

/// What a button or key does right now (the live slot).
/// Whether this key lives in an on-board keymap (Tartarus V2 Pro) rather than a live slot.
fn in_onboard_keymap(&self, input: Input) -> bool {
matches!(input, Input::Key(_)) && self.spec.as_ref().is_some_and(|s| s.onboard_keymap)
}

/// What a button or key does right now (the live slot, or profile 1 of a keypad that
/// keeps remaps on board).
pub fn input(&self, input: Input, layer: Layer) -> Result<Action> {
self.read_input(cmd::BUTTON_LIVE_SLOT, input, layer)
let slot = if self.in_onboard_keymap(input) { cmd::KEYMAP_PROFILE } else { cmd::BUTTON_LIVE_SLOT };
self.read_input(slot, input, layer)
}

/// What a button or key does in the active saved slot: Synapse's or the factory setting.
/// A keypad that keeps remaps on board has no separate saved copy: its keys go back to
/// what they type out of the box, as Synapse's "default" does.
pub fn saved_input(&self, input: Input, layer: Layer) -> Result<Action> {
if self.in_onboard_keymap(input) {
let Input::Key(id) = input else { unreachable!() };
if layer != Layer::Normal {
return Err(Error::Unsupported(format!("{} has no known default here", input.label())));
}
return onboard_default(id).ok_or_else(|| {
Error::Unsupported(format!(
"{} can't be put back to its default from here yet (Synapse wasn't seen doing it); set it to a key, or use Synapse",
input.label()
))
});
}
let slot = self.get(cmd::ACTIVE_SLOT, 1, &[]).map(|r| r.args()[0]).unwrap_or(1).max(1);
self.read_input(slot, input, layer)
}

/// Set a button or key in the live slot. Returns whether anything was sent: an
/// unchanged one is left alone.
/// Set a key the way Synapse does on a keypad that keeps remaps on board, byte for byte as
/// captured: `02:37 [01]`, then `02:0D` size 0A `[01, key, 00, 02, 02, 00, usage, 0, 0, 0]`.
/// Only what Synapse was seen sending: a single key on the normal layer.
fn set_onboard_key(&self, id: u8, layer: Layer, action: Action) -> Result<()> {
let known = KEYS.iter().chain(KEYPAD_THUMBS).any(|k| k.0 == id);
let allowed = match action {
Action::Key { modifiers: 0, .. } => known,
// The thumb buttons' defaults, as Synapse wrote them back.
other => onboard_default(id) == Some(other),
};
if !allowed {
return Err(Error::Unsupported(
"on this keypad a key can only be set to another single key for now (no shortcuts, macros or mouse actions)".into(),
));
}
if layer != Layer::Normal {
return Err(Error::Unsupported("HyperShift keys on this keypad can't be changed yet".into()));
}
let (function, data_size, data) = action.encode();
let mut args = vec![cmd::KEYMAP_PROFILE, id, layer as u8, function, data_size];
args.extend_from_slice(&data);
self.transact(cmd::OBM_KEYMAP, cmd::OBM_KEYMAP_SIZE, &[cmd::KEYMAP_ID])?;
self.transact(cmd::KEY, cmd::KEYMAP_KEY_SIZE, &args)?;
Ok(())
}

/// Set a button or key in the live slot (or a keypad's on-board keymap). Returns whether
/// anything was sent: an unchanged one is left alone.
pub fn set_input(&self, input: Input, layer: Layer, action: Action) -> Result<bool> {
if self.input(input, layer).ok() == Some(action) {
return Ok(false);
}
if let (true, Input::Key(id)) = (self.in_onboard_keymap(input), input) {
self.set_onboard_key(id, layer, action)?;
return Ok(true);
}
let (command, size, id) = input.command();
let (function, data_size, data) = action.encode();
let mut args = vec![cmd::BUTTON_LIVE_SLOT, id, layer as u8, function, data_size];
Expand All @@ -768,6 +852,9 @@ impl Device {
/// without any software ("Save to mouse"). A flash write: only on request, never on a
/// profile switch.
pub fn set_slot_input(&self, slot: u8, input: Input, layer: Layer, action: Action) -> Result<()> {
if self.in_onboard_keymap(input) {
return Err(Error::Unsupported("this keypad keeps its keys on board already".into()));
}
if !(1..=5).contains(&slot) {
return Err(Error::InvalidArg(format!("on-board slot {slot}: use 1 to 5")));
}
Expand Down Expand Up @@ -831,7 +918,11 @@ impl Device {
if self.input(Input::Key(31), Layer::Normal).is_err() {
return Vec::new();
}
KEYS.iter().filter_map(|k| self.input(Input::Key(k.0), Layer::Normal).ok().map(|a| (k.0, a))).collect()
let thumbs: &[(u8, &str, &str, u8)] = if self.spec.as_ref().is_some_and(|s| s.onboard_keymap) { KEYPAD_THUMBS } else { &[] };
KEYS.iter()
.chain(thumbs)
.filter_map(|k| self.input(Input::Key(k.0), Layer::Normal).ok().map(|a| (k.0, a)))
.collect()
}

/// Button ids the mouse says it has (Synapse's "Get Button ID list"), in [`BUTTONS`]
Expand Down
12 changes: 12 additions & 0 deletions crates/secbird-core/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ pub const BUTTON_IDS_SIZE: u8 = 0x50;
/// in software, so no keyboard has been seen to take it yet.
pub const KEY: Command = Command::new(0x02, 0x0D);
pub const KEY_SIZE: u8 = 0x50;
/// On keypads that keep remaps on board (Tartarus V2 Pro), Synapse writes a key with size
/// 0A, `[profile, key, layer, function, size, data0..data4]`, into the keymap chosen with
/// [`OBM_KEYMAP`]. Seen in a USB capture of Synapse remapping S to 2:
/// `02:37 [01]` then `02:0D [01 20 00 02 02 00 1F 00 00 00]`.
pub const KEYMAP_KEY_SIZE: u8 = 0x0A;
/// Synapse "Set OBM Keymap": `[keymap]`, the keymap later key writes go to. Synapse sends it
/// before every key write.
pub const OBM_KEYMAP: Command = Command::new(0x02, 0x37);
pub const OBM_KEYMAP_SIZE: u8 = 0x01;
/// The on-board profile and keymap Synapse writes remaps to: profile 1, keymap 1.
pub const KEYMAP_PROFILE: u8 = 1;
pub const KEYMAP_ID: u8 = 1;
/// The key ids a keyboard has (Synapse "Get Key Assignment List"): request `[slot, layer,
/// offset]`, reply `[slot, layer, ids...]`. GET only; what the request bytes mean is a guess.
pub const KEY_IDS: Command = Command::new(0x02, 0x8F);
Expand Down
9 changes: 9 additions & 0 deletions crates/secbird-core/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ pub struct DeviceSpec {
pub wireless: bool,
#[serde(default)]
pub onboard_profiles: u8,
/// Has a thumbstick that reads as a game controller in True Analog mode, which the
/// tray can turn into keys (see [`crate::stick`]).
#[serde(default)]
pub thumbstick: bool,
/// Keeps key remaps in an on-board profile's keymap instead of a live slot, the way
/// Synapse remaps the Tartarus V2 Pro: select keymap 1 (02:37), then set the key in
/// profile 1 (02:0D, size 0A). See [`crate::buttons`] and docs/tartarus-v2-pro.md.
#[serde(default)]
pub onboard_keymap: bool,
/// Where this entry's facts come from (e.g. "synapse-descriptor", "openrazer").
#[serde(default)]
pub source: String,
Expand Down
Loading