The Lua language is simple enough -- the hard part is the API DeSmuME provides -- I can't find a shred of documentation on it. How do they expect people to write scripts if they don't publish an API?
The most I can find is they say "look at FCEUX Lua" in the FAQ, so I can only assume it mirror's FCEUX's API, which is documented here:http://www.fceux.com/web/help/fceux.html?LuaScripting.html
But it can't possibly match exactly. Maybe this is something you should ask on the DeSmuME forums.
As for using a 360 gamepad -- I'm appauled that an emulator doesn't support that out of the box. Regardless, to accomplish that in Lua, you'll probably have to do the following:
1) Import a package that allows for gamepad reads
2) Register some kind of callback so the emu calls into your script every frame
3) In that callback function, poll the gamepad to see what buttons are being pressed, and send that information to the emu (I would assume the Lua API provides a way to do this ... in FCEUX you can do it with joypad.set() )