i do something similar. 43inch 4k tv as monitor, windows laptop, windows pc, mac laptop connected via this kvm. main kb and macro kb plugged directly into kvm's mouse and keyboard slots, everything split out to the hub slot, currently this is a hotdoxv2 for typing and a preonic for key combos and shortcuts. preonic has been the mainstay shortcut board; i've had others for typing; dactyl manuform, sophle, obe, redox...
for my setup, NKRO must be OFF; kvm hates nkro being on. i think i had good kvm's before and didn't realized that nugget at the time.
macros for SL,SL,1 etc for switch. layers on the devices for mac/pc because of how i prefer my keys (others do ctrl/gui swap and like it just fine).
you might be able to combine the layer swap and switching in the macro but i haven't tried, i keep everything in via and vial now... btw, the boards MUST be directly connected to program with via,vial or qmk toolbox, then connect back to the kvm. usually after doing this (or a power outage) you must turn off and back on the kvm while connected to each system to get everything recognized again, but only when a hard power cycle or programming happens.... oddly i don't have to do it when turning off pc's or the kvm on purpose.
get good hdmi cables, it improves the signal.
i use usb a to a pig tail cables on the kvm and usb c pigtails on the boards so i'm not disconnecting and reconnecting cables right in the slots to minimize damage from my short attention span.
i tried some of the virtual switches and the cost and headache and security notices on work pc's made it too tedious for me (see: my short attention span).
good luck and keep this updated on your search and solution, i'm always open to changing everything at any time! ;D