This npm package is a react component that displays the nintendo switch pro controller on the screen and changes the color of each button with an argument.
npm install react-nintendo-switch-procon-renderer
- The available inputs are "a", "b", "x", "y", "up", "right", "down", "left", "r", "l", "zr", "zl", "plus", "minus", "home", "cap".
- on a click butotn
- handleButtonClick(button: Button)
import { Procon, buttons } from "react-nintendo-switch-procon-renderer";
export default function App() {
const handleButtonClick = (button: Button) => {
console.log(button);
}
return (
<>
<Procon pressedButtons={[]} handleButtonClick={handleButtonClick} />
<hr />
<Procon pressedButtons={["zr", "up"]} />
<hr />
<Procon pressedButtons={buttons} />
</>
)
}
- yarn
- yarn build
- cd sample && yarn server
- yarn release-build
- npm publish
- left stick, right stickの押し込み反映
- スティックの傾きの反映
- do npm publish by github action