Where is motor skill function located within the brain? Does the neural activity that correlates with motor skill function tend to be focused near or far from the outer surface of the brain, or both? And what about perception?

My deeper curiosity being: I'd conjecture that the first is either near the surface or both, given the ability of technology now to read input directly from the brain in order to move virtual objects.
Most brain-machine interfaces involving movement would be based on activity in primary motor cortex, which, as you said, is near the surface. Right next to that are is primary somatosensory cortex, which is the first cortical area where touch information is processed. It is also near the surface. Most of the neocortex is going to be near the surface, with some parts (gyri) closer than others (sulci).

The primary reason that there is more progress being made with reading from the brain as opposed to sending information to the brain is that we have very little understanding of how information is stored and processed in the brain, the language of the brain. What we do know is that we can record neural activity and feed it into some type of machine learning algorithm which then can interpret this activity to some degree. Note that the output of these models is usually very limited and their performance is far from perfect.

Going the other way is a lot more difficult, because we would need to be able to speak the language of the brain. You might think that you could just reverse the models somehow, but it's not that simple. The good news is that all of this research (brain machine interfaces, as well as all of the other basic science work being done) is slowly moving towards a better understanding of how the brain works to a level where we will someday be able to speak the language. I wouldn't be surprised if, in less than 10 years, we will be seeing neural implants being tested that communicate bidirectionally with the brain.