Well, here in the present have prostheses controlled by monitoring electrical impulses in what's left of the limb the prosthesis is attached to. We have prostheses controlled by directly monitoring the brains of the people the limb is attached to (well, monkeys, but I'm pretty sure human testing is in the works). We have limbs that are smart enough to infer the action they should take from the orientation and pressure they're currently at (As per EDL's excellent answer).
But we're working in the future, right?
Humans have already shown that they can 'feel' and interact with even very simple electronics implanted into their skin. (The Cyborg 2.0 project being an example IIRC, I can't actually check for links right now). The human brain is a remarkably plastic organ. Give it enough time and it can adapt most signals into something useful/learn to send different signals to get the effect it's after. We're also making remarkable inroads into machines that can translate a set of arbitrary inputs into complex concepts into a set of arbitrary outputs (See Google Translate). Couple those two with whatever anti-rejection medical tech you've got going on to achieve a stable and medically safe bone graft and you've got not only a usable prosthetic-nerve interface, but one that is pretty easy to get used to!
It goes like this: Using your Future Tech (tm) you split out each nerve from the nerve bundle running down your limb of choice. Each of those strands (just get them as fine as you can, it'll work out) is then grafted to a bidirectional relay. These relays then act as inputs for the limb's processor.
The processor is initialised in 'learning' mode. Technicians installing the limb ask the graftee to try to perform a series of actions with their missing arm (time from injury may be important here). When doing so they also tell the processor what it should be learning to do. Hopefully the right nerves will light up like a Christmas tree (this is very similar to the way limbs are controlled by monitoring the brain, by the way) and they can be 'mapped' to the correct actions. Similarly the techs can send impulses back down the various clusters of nerves and ask what the sensations are. Map those correctly and voila: Your arm moves (almost) like you remember it doing and feels (almost) like it used to.
Then neuroplasticity comes into play. Over time your brain would learn to accept whatever crazy inputs and outputs it was given, it would just be really hard. The last step was basically just to make it easier for your brain to take over and 'relearn' exactly what signals do what and what inputs mean what. It won't be perfect to start with, but if your brain is learning the limb and the limb is learning your brain then you should expect functional convergence of thought/action to be really quite smooth.
Then the limb is basically just connected to exactly the nerves it used to be.
Now for the bit that matches your use case: Because you now have the mappings for input and output sensibly mapped you could theoretically use that processor to control the same kind of limb anywhere and at any scale. If you have a suitably plastic-brained person they could even learn to control a multitude of limbs from the same processor, and if there's information on how best to translate the bipedal leg mapping to a quadrupedal leg mapping then it can be used to minimise the amount of relearning your brain has to do.
Imagine a surgeon with prosthetic arms (for stability) putting on a VR headset and taking direct control of a laparoscopic surgical tool as though it's their own limb. If they know what 'hand gestures' they need to do to control the tool and the machine learning suite knows how best to translate the 'gesture' into an action with the surgical tool, soon enough the surgeon will stop thinking in terms of gestures and will just manipulate the tool directly.
Now: This approach runs into issues if the graftee has been missing the limb a long time or never had a limb to begin with. Then they won't have as much of a memory (not really a memory-memory, more like muscle memory) of the limb and the ends of the nerves will have helped up in such a way that they don't have the same I/O capacity, so the nerves will need to be pared back (future medicine again I'm afraid) and the process of learning the limb(s) will be a lot harder.
TLDR: Nerves go into future-medicine box. Future-medicine box does machine learning. Future-medicine box controls limb(s).
ADDENDUM: A lot of this relies on The Future, but an awful lot of the tech and procedures are either already real things or are plausible extensions of real things.