44
55Arduino を Switch コントローラーとして認識させます。
66
7+ ** v2 系 は v1 系とは互換性がありません。**
8+ 過去バージョンは[ Release] ( https://github.com/celclow/SwitchControlLibrary/releases ) ページよりダウンロードできます。
9+
710## 使い方
811
912VID=0x0f0d, PID=0x0092 へ変更してボードへ書き込んでください。
@@ -13,42 +16,112 @@ VID=0x0f0d, PID=0x0092 へ変更してボードへ書き込んでください。
1316
1417## 操作方法
1518
16- メソッドの定義は ` SwitchControlLibrary.h ` を参照。
17-
1819- ボタンを押す
1920
20- ```
21- // Aボタンを押す
22- SwitchControlLibrary().PressButtonA();
23- ```
21+ - ` pressButton(uint8_t button) `
22+
23+ ```
24+ SwitchControlLibrary().pressButton(Button::A); // Aボタンを押す
25+ SwitchControlLibrary().pressButton(Button::B); // Bボタンを押す
26+ ```
27+
28+ - `releaseButton(uint8_t button)`
29+
30+ ```
31+ SwitchControlLibrary().releaseButton(Button::A); // Aボタンを離す
32+ SwitchControlLibrary().releaseButton(Button::B); // Bボタンを離す
33+ ```
34+
35+ - `Button` 定義一覧
36+
37+ ```
38+ Button::Y
39+ Button::B
40+ Button::A
41+ Button::X
42+ Button::L
43+ Button::R
44+ Button::ZL
45+ Button::ZR
46+ Button::MINUS
47+ Button::PLUS
48+ Button::LCLICK
49+ Button::RCLICK
50+ Button::HOME
51+ Button::CAPTURE
52+ ```
2453
25- - ボタンを離す
54+ - ハット
2655
27- ```
28- // Aボタンを離す
29- SwitchControlLibrary().ReleaseButtonA();
30- ```
56+ - `moveHat(uint8_t hat)`
3157
32- - ハット
58+ ```
59+ SwitchControlLibrary().moveHat(Hat::UP); // ハットは上
60+ SwitchControlLibrary().moveHat(Hat::RIGHT); // ハットは右
61+ ```
3362
34- Hat の定義は ` SwitchControlLibrary.h ` を参照。
63+ - `Hat` 定義一覧
3564
36- ```
37- // ハットを左へ
38- SwitchControlLibrary().MoveHat(Hat::LEFT);
39- ```
65+ ```
66+ Hat::UP
67+ Hat::UP_RIGHT
68+ Hat::RIGHT
69+ Hat::DOWN_RIGHT
70+ Hat::DOWN
71+ Hat::DOWN_LEFT
72+ Hat::LEFT
73+ Hat::UP_LEFT
74+ Hat::NEUTRAL
75+ ```
4076
41- * スティック
77+ - `pressHat(uint8_t hat_button)` `releaseHat(uint8_t hat_button)`
4278
43- Stick の定義は ` SwitchControlLibrary.h ` を参照。
79+ ```
80+ SwitchControlLibrary().pressHat(HatButton::UP) // ハットは上
81+ SwitchControlLibrary().pressHat(HatButton::RIGHT) // ハットは右上
82+ SwitchControlLibrary().releaseHat(HatButton::UP) // ハットは右
83+ SwitchControlLibrary().releaseHat(HatButton::RIGHT) // ハットはニュートラル
84+ ```
4485
45- ```
46- // MoveLeftStick(uint8_t lx, uint8_t ly);
47- // lx x軸座標(0〜255)
48- // ly y軸座標(0〜255)
86+ - `HatButton` 定義一覧
4987
50- // 左スティックを左へ(数値の場合)
51- SwitchControlLibrary().MoveLeftStick(0, 128);
88+ ```
89+ HatButton::UP
90+ HatButton::RIGHT
91+ HatButton::DOWN
92+ HatButton::LEFT
93+ ```
94+
95+ - スティック
96+
97+ - `moveLeftStick(uint8_t lx, uint8_t ly)` `moveRightStick(uint8_t rx, uint8_t ry)`
98+
99+ - `lx` `ly` `rx` `ry` には、0〜255 の値を指定します。
100+
101+ ```
102+ SwitchControlLibrary().moveLeftStick(0, 128) // 左スティックは左
103+ SwitchControlLibrary().moveLeftStick(128, 128) // 左スティックはニュートラル
104+ SwitchControlLibrary().moveLeftStick(255, 128) // 左スティックは右
105+ SwitchControlLibrary().moveLeftStick(Stick::MIN, Stick::NEUTRAL) // 左スティックは左
106+ SwitchControlLibrary().moveLeftStick(Stick::MAX, Stick::NEUTRAL) // 左スティックは右
107+ ```
108+
109+ - `Stick` 定義一覧
110+
111+ ```
112+ Stick::MIN
113+ Stick::NEUTRAL
114+ Stick::MAX
115+ ```
116+
117+ - `sendReport()`
118+
119+ `sendReport()` を実行したタイミングでキーが送信されます。
120+
121+ ```
122+ SwitchControlLibrary().pressButton(Button::A); // ニュートラル
123+ SwitchControlLibrary().pressButton(Button::B); // ニュートラル
124+ SwitchControlLibrary().sendReport() // A、Bボタンが同時に送信される
52125 ```
53126
54127## ライセンス
0 commit comments