Skip to content

Commit 765d067

Browse files
committed
[Update]v2.0.0
1 parent 852a0a7 commit 765d067

File tree

8 files changed

+295
-293
lines changed

8 files changed

+295
-293
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 C
3+
Copyright (c) 2019 celclow
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 98 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
Arduino を Switch コントローラーとして認識させます。
66

7+
**v2 系 は v1 系とは互換性がありません。**
8+
過去バージョンは[Release](https://github.com/celclow/SwitchControlLibrary/releases)ページよりダウンロードできます。
9+
710
## 使い方
811

912
VID=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
## ライセンス

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=SwitchControlLibrary
2-
version=1.0.0
2+
version=2.0.0
33
author=celclow
44
maintainer=celclow
55
sentence=
66
paragraph=
77
category=Device Control
8-
url=https://wearysite.wordpress.com/
8+
url=https://github.com/celclow/SwitchControlLibrary
99
architectures=*

src/CustomHID.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ CustomHID_::CustomHID_()
88

99
int CustomHID_::SendReport(const void *data, int len)
1010
{
11-
auto ret = USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
12-
return ret;
11+
auto ret = USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
12+
return ret;
1313
}
1414

1515
CustomHID_ &CustomHID()
1616
{
17-
static CustomHID_ obj;
18-
return obj;
17+
static CustomHID_ obj;
18+
return obj;
1919
}
2020

2121
#endif /* if defined(USBCON) */

src/CustomHID.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
#pragma once
2+
13
#include <HID.h>
24

35
#if defined(USBCON)
46

57
class CustomHID_ : public HID_
68
{
79
public:
8-
CustomHID_();
9-
int SendReport(const void *data, int len);
10+
CustomHID_();
11+
int SendReport(const void *data, int len);
1012
};
1113

1214
CustomHID_ &CustomHID();

0 commit comments

Comments
 (0)