Repository navigation
Mac: Keyboard and mouse controls for Tears of the Kingdom - #330
Open
sujitv19196 wants to merge 1 commit into
Open
sujitv19196 wants to merge 1 commit into
sujitv19196 wants to merge 1 commit into
Conversation
sujitv19196
marked this pull request as draft
October 26, 2026 19:41
sujitv19196
force-pushed
the
totk-keyboard-mouse
branch
from
October 26, 2026 23:14
5e4ec52 to
44a401b
Compare
sujitv19196
marked this pull request as ready for review
October 26, 2026 23:28
sujitv19196
force-pushed
the
totk-keyboard-mouse
branch
from
October 28, 2026 04:53
4ca1776 to
c1e4e0d
Compare
ltrdpper
pushed a commit
to ltrdpper/BananaNative
that referenced
this pull request
Nov 16, 2026
…per-frame budget' (seedds#330) from 1982tito/BananaNative:prune-budget into android
… Mac DM_KBM=1 turns on keyboard and mouse controls for Tears of the Kingdom 1.4.3 on the Mac: the mouse turns the camera by angle (Chase, Aiming, LockOn and Ultrahand, SpecialPower and Recall), moves objects held by Ultrahand, and the keyboard takes a PC layout (quick menus on 1-4 and the scroll wheel, the ability wheel pointed with the mouse, bow and throw toggles on F and G, Ascend's aiming on the mouse buttons). Without DM_KBM the game and every other game run as before. The feature lives in files of its own: - dm/host/front_kbm_mac.m / .h: the layout and the mouse camera's host half (its state page block, settings and build gate); front_mac.m calls it through four one-line hooks, and the Makefile takes front_*_mac.m by wildcard. - dm/games/0100F2C0115B6000/kbm_patches.py: the camera stubs, with their state at +0x800 in the frame step state page, clear of the frame step's own fields; patches.py runs them from a 1.4.3 FRAME_STEP entry beside the same frame step stub the matched rule places. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sujitv19196
force-pushed
the
totk-keyboard-mouse
branch
from
November 17, 2026 13:53
c1e4e0d to
e3986bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keyboard and mouse controls for Tears of the Kingdom on the Mac
The Mac front end mapped the keyboard onto a controller layout and had no mouse camera, which makes Tears of the Kingdom hard to play without a controller. This PR adds keyboard and mouse controls in which the mouse turns the camera by angle instead of pretending to be the right stick. They are opt in (
DM_KBM=1): most players use a controller, so the game still starts with the classic keys.It is one commit on top of current main, so it can also be cherry-picked onto other forks of the repo:
git cherry-pick <sha>.Minimal and kept to its own files
The feature lives almost entirely in three new files. It touches shared code only through a few one-line hooks, so it stays easy to rebase and to carry on other branches.
dm/host/front_kbm_mac.m/.hDM_KBM/DM_MOUSE_SENS/DM_MOUSE_INVERT_Ysettings and the build gate. It installs its own event monitor for clicks, the scroll wheel and modifier keys.dm/games/0100F2C0115B6000/kbm_patches.pydm/host/front_mac.mkbm_start,kbm_inputinpush,kbm_keyinon_key,kbm_release). Nothing is renamed:kbm_starttakes pointers to the front end's own key state.dm/host/MakefileSRC += $(sort $(wildcard front_*_mac.m)), on its own line, so a new front end file does not touch theSRCline.dm/games/0100F2C0115B6000/patches.pyFRAME_STEPentry that runs the existing frame step stub and then the mouse camera.docs/env_switches.tsvdocs/agents/game-patches.mddm/tools/docs_patches.py). If it conflicts, re-run the script rather than merging by hand.Compared with the earlier version of this PR,
loader.c,dm.h,hle.h,patch_nso.pyandnso_asm.pyare no longer changed:loader.candhle.hare now static infront_kbm_mac.m.MOUSE_CAMERAfixup, itsmodule_tfield and thepatch_nso.pyplumbing are gone. The host gates on the build ID through the existingdm_main_build(), as AGENTS.md describes for host code tied to fixed addresses.BC,CBZW,LDRS,STRS,STRW) live inkbm_patches.py. They can move tonso_asm.pyif a second user appears.How the mouse camera works
kbm_patches.py,mouse_stub). At that point, a stub:+0x800in the frame step state page. That keeps it clear of the frame step's own fields at the start of the page: main now uses+0x40for dynamic resolution and+0x48..+0x98for the screen shape, which the earlier version of this PR would have overlapped.277178b7…). There the frame step comes from aFRAME_STEPentry that calls the samestub()at the six functions' 1.4.3 addresses, whereMATCH_FRAME_STEPfinds them. Every other build keeps the matched frame step alone.kbm_patches.pycomment list every address and field.The layout
DM_KBM=1(for example a line in~/Library/Application Support/nxnative/0100F2C0115B6000/env.txt) turns the keyboard and mouse controls on. Without it, the game starts with the classic keys, as before. A click in the window captures the mouse, and ⌘Tab releases it.DM_KBM=1turns the controls on.DM_MOUSE_SENSsets the sensitivity (degrees per count, 0.1 by default).DM_MOUSE_INVERT_Y=1inverts the vertical axis. All three are listed indocs/env_switches.tsv.The default and other games are unchanged
DM_KBM=1: Tears of the Kingdom plays as on main. The stubs are in, but with a sensitivity of 0 they run only the instruction they replaced.DM_KBM=1. Every other game keeps the classic keys and the mouse as the touchscreen._macsuffix keeps the files out of the iOS build.Checked
dmhostbuilds for Tears of the Kingdom with no new warnings.dm/ios/tools/compile_check.pypasses (265 files).test_patches,test_docsandtest_env_switchespass.+0x800. It has not been played in game again yet.🤖 Generated with Claude Code