Outstanding! You've uncovered Rob McCooper's patented Explosive Hat technique! Use to toss your hat, then use again to detonate it. Better back off to a safe distance first!
The Explosive Hat Technique, called Mine in-game, is an attainable power-up within Sly Cooper and the Thievius Raccoonus, which was perfected by one of Sly Cooper's ancestors, Rob McCooper. It is the sixth move obtained from a vault.
Equipping the mine and pressing will cause Sly to take off his hat and throw it on the ground, then pull a new hat from his backpack and place it on his head. Pressing again will cause Sly to tap the end of his cane on the ground, making the hat explode, damaging anyone in the explosion radius. The radius is large enough that Sly must move back from the hat after it is laid, or he will be damaged by it.