Skip to content

Commit 7bc1c5d

Browse files
committed
Swap names of Extension Port and Controller
Reverts 83f5222
1 parent fcb69b3 commit 7bc1c5d

File tree

12 files changed

+65
-65
lines changed

12 files changed

+65
-65
lines changed

examples/Any/DebugPrint/DebugPrint.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <NintendoExtensionCtrl.h>
2828

29-
ExtensionController controller;
29+
ExtensionPort controller;
3030

3131
void setup() {
3232
Serial.begin(115200);

examples/Any/IdentifyController/IdentifyController.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <NintendoExtensionCtrl.h>
2828

29-
ExtensionController controller;
29+
ExtensionPort controller;
3030

3131
void setup() {
3232
Serial.begin(115200);

examples/Any/MultipleTypes/MultipleTypes.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@
2626

2727
#include <NintendoExtensionCtrl.h>
2828

29-
ExtensionController controller; // Port for communicating with extension controllers
29+
ExtensionPort port; // Port for communicating with extension controllers
3030

31-
Nunchuk::Shared nchuk(controller); // Read Nunchuk formatted data from the port
32-
ClassicController::Shared classic(controller); // Read Classic Controller formatted data from the port
31+
Nunchuk::Shared nchuk(port); // Read Nunchuk formatted data from the port
32+
ClassicController::Shared classic(port); // Read Classic Controller formatted data from the port
3333

3434
void setup() {
3535
Serial.begin(115200);
36-
controller.begin();
36+
port.begin();
3737

38-
while (!controller.connect()) {
38+
while (!port.connect()) {
3939
Serial.println("No controller found!");
4040
delay(1000);
4141
}
4242
}
4343

4444
void loop() {
45-
boolean success = controller.update(); // Get new data from the controller
45+
boolean success = port.update(); // Get new data from the controller
4646

4747
if (success == true) { // We've got data!
48-
ExtensionType conType = controller.getControllerType();
48+
ExtensionType conType = port.getControllerType();
4949

5050
switch (conType) {
5151
case(ExtensionType::Nunchuk):

examples/Any/SpeedTest/SpeedTest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <NintendoExtensionCtrl.h>
2828

29-
ExtensionController controller; // Generic controller, 6 bytes
29+
ExtensionPort controller; // Generic controller port, 6 bytes
3030

3131
const long TestDuration = 1000; // Length of each test, in milliseconds
3232

extras/AddingControllers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ If you want to use an extension controller that is not currently supported by th
44
## Step #1: Creating The Class Framework
55
The first step in adding support for your controller is building it a class. The header (.h) and implementation (.cpp) files live within the `controllers` folder in the source directory. You'll need to create both of these files with the name of your controller.
66

7-
Controller classes live inside the library namespace and inherit from the `ExtensionPort` class, which contains methods for communicating with the controllers and manipulating the control surface data. This includes combining multi-byte data and extracting bits that correspond to button presses. To use this you'll need to include the "ExtensionController.h" header, which is in the `internal` source directory.
7+
Controller classes live inside the library namespace and inherit from the `ExtensionController` class, which contains methods for communicating with the controllers and manipulating the control surface data. This includes combining multi-byte data and extracting bits that correspond to button presses. To use this you'll need to include the "ExtensionController.h" header, which is in the `internal` source directory.
88

99
The class name for your controller is going to be the "Shared" version of the class, which uses a reference to port and control data that exists elsewhere - thus it has a `_Shared` suffix. Here is what the start of the `ClassicController_Shared` class looks like:
1010

1111
```C++
1212
#include "internal/ExtensionController.h"
1313

1414
namespace NintendoExtensionCtrl {
15-
class ClassicController_Shared : public ExtensionPort {
15+
class ClassicController_Shared : public ExtensionController {
1616
public:
1717
ClassicController_Shared(ExtensionData &dataRef) :
18-
ExtensionPort(dataRef, ExtensionType::ClassicController) {}
18+
ExtensionController(dataRef, ExtensionType::ClassicController) {}
1919

20-
ClassicController_Shared(ExtensionController &controller) :
20+
ClassicController_Shared(ExtensionPort &controller) :
2121
ClassicController_Shared(controller.getExtensionData()) {}
2222
```
2323

24-
Note how the constructors use a reference to an `ExtensionData` class *external* to the controller class itself. You can also see that the controller's identity is passed to the `ExtensionPort` class to limit what types of controllers can connect (more on that in a bit).
24+
Note how the constructors use a reference to an `ExtensionData` class *external* to the controller class itself. You can also see that the controller's identity is passed to the `ExtensionController` class to limit what types of controllers can connect (more on that in a bit).
2525

2626
## Step #2: Building Your Data Maps
2727
The next step is to add the data maps for your controller. These define where the data for each control input lies within in the data array.
@@ -72,7 +72,7 @@ The resulting bit from the control data is extracted and inverted, as extension
7272
```C++
7373
BitMap ButtonA = { 5, 4 };
7474
```
75-
Full definitions of these data types can be found in the [`NXC_DataMaps.h`](../src/internal/NXC_DataMaps.h) file. Methods for using them are defined in the `ExtensionPort` class definition ([`ExtensionController.h`](../src/internal/ExtensionController.h)).
75+
Full definitions of these data types can be found in the [`NXC_DataMaps.h`](../src/internal/NXC_DataMaps.h) file. Methods for using them are defined in the `ExtensionController` class definition ([`ExtensionController.h`](../src/internal/ExtensionController.h)).
7676

7777
---
7878

@@ -159,13 +159,13 @@ Once that's done, head back to your controller's header file and add that identi
159159

160160
```
161161
ClassicController_Shared(ExtensionData &dataRef) :
162-
ExtensionPort(dataRef, ExtensionType::ClassicController) {}
162+
ExtensionController(dataRef, ExtensionType::ClassicController) {}
163163
```
164164

165165
You will also need to edit the switch statement in the `IdentifyControllers` example to add your controller to the 'switch' statement.
166166

167167
## Step #6: Create the Combined Class
168-
The last step to get your controller working is to create a combined class that inherits from your `_Shared` class and bundles it with a set of extension port data to use. This creates an easy to use class for most users who are looking to get data from just one controller. Just copy this line, replacing all instances of `YourController` with your controller's name:
168+
The last step to get your controller working is to create a combined class that inherits from your `_Shared` class and bundles it with a set of extension data to use. This creates an easy to use class for most users who are looking to get data from just one controller. Just copy this line, replacing all instances of `YourController` with your controller's name:
169169

170170
```C++
171171
using YourController = NintendoExtensionCtrl::BuildControllerClass

src/controllers/ClassicController.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "internal/ExtensionController.h"
2727

2828
namespace NintendoExtensionCtrl {
29-
class ClassicController_Shared : public ExtensionPort {
29+
class ClassicController_Shared : public ExtensionController {
3030
public:
3131
struct Maps {
3232
constexpr static ByteMap LeftJoyX = ByteMap(0, 6, 0, 0);
@@ -59,10 +59,10 @@ namespace NintendoExtensionCtrl {
5959
};
6060

6161
ClassicController_Shared(ExtensionData &dataRef) :
62-
ExtensionPort(dataRef, ExtensionType::ClassicController) {}
62+
ExtensionController(dataRef, ExtensionType::ClassicController) {}
6363

64-
ClassicController_Shared(ExtensionController &controller) :
65-
ClassicController_Shared(controller.getExtensionData()) {}
64+
ClassicController_Shared(ExtensionPort &port) :
65+
ClassicController_Shared(port.getExtensionData()) {}
6666

6767
uint8_t leftJoyX() const; // 6 bits, 0-63
6868
uint8_t leftJoyY() const;

src/controllers/DJTurntable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ClassicController.h" // For joystick and +/- control maps
2929

3030
namespace NintendoExtensionCtrl {
31-
class DJTurntableController_Shared : public ExtensionPort {
31+
class DJTurntableController_Shared : public ExtensionController {
3232
public:
3333
struct Maps {
3434
constexpr static ByteMap JoyX = ClassicController_Shared::Maps::LeftJoyX;
@@ -56,10 +56,10 @@ namespace NintendoExtensionCtrl {
5656
};
5757

5858
DJTurntableController_Shared(ExtensionData& dataRef) :
59-
ExtensionPort(dataRef, ExtensionType::DJTurntableController), left(*this), right(*this) {}
59+
ExtensionController(dataRef, ExtensionType::DJTurntableController), left(*this), right(*this) {}
6060

61-
DJTurntableController_Shared(ExtensionController &controller) :
62-
DJTurntableController_Shared(controller.getExtensionData()) {}
61+
DJTurntableController_Shared(ExtensionPort &port) :
62+
DJTurntableController_Shared(port.getExtensionData()) {}
6363

6464
enum class TurntableConfig {
6565
BaseOnly,

src/controllers/DrumController.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ClassicController.h" // For joystick and +/- control maps
2929

3030
namespace NintendoExtensionCtrl {
31-
class DrumController_Shared : public ExtensionPort {
31+
class DrumController_Shared : public ExtensionController {
3232
public:
3333
struct Maps {
3434
constexpr static ByteMap JoyX = ClassicController_Shared::Maps::LeftJoyX;
@@ -52,10 +52,10 @@ namespace NintendoExtensionCtrl {
5252
};
5353

5454
DrumController_Shared(ExtensionData &dataRef) :
55-
ExtensionPort(dataRef, ExtensionType::DrumController) {}
55+
ExtensionController(dataRef, ExtensionType::DrumController) {}
5656

57-
DrumController_Shared(ExtensionController &controller) :
58-
DrumController_Shared(controller.getExtensionData()) {}
57+
DrumController_Shared(ExtensionPort &port) :
58+
DrumController_Shared(port.getExtensionData()) {}
5959

6060
enum VelocityID : uint8_t {
6161
None = 0x1F,

src/controllers/GuitarController.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ClassicController.h" // For joystick and +/- control maps
2929

3030
namespace NintendoExtensionCtrl {
31-
class GuitarController_Shared : public ExtensionPort {
31+
class GuitarController_Shared : public ExtensionController {
3232
public:
3333
struct Maps {
3434
constexpr static ByteMap JoyX = ClassicController_Shared::Maps::LeftJoyX;
@@ -51,10 +51,10 @@ namespace NintendoExtensionCtrl {
5151
};
5252

5353
GuitarController_Shared(ExtensionData &dataRef) :
54-
ExtensionPort(dataRef, ExtensionType::GuitarController) {}
54+
ExtensionController(dataRef, ExtensionType::GuitarController) {}
5555

56-
GuitarController_Shared(ExtensionController &controller) :
57-
GuitarController_Shared(controller.getExtensionData()) {}
56+
GuitarController_Shared(ExtensionPort &port) :
57+
GuitarController_Shared(port.getExtensionData()) {}
5858

5959
uint8_t joyX() const; // 6 bits, 0-63
6060
uint8_t joyY() const;

src/controllers/Nunchuk.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "internal/ExtensionController.h"
2727

2828
namespace NintendoExtensionCtrl {
29-
class Nunchuk_Shared : public ExtensionPort {
29+
class Nunchuk_Shared : public ExtensionController {
3030
public:
3131
struct Maps {
3232
constexpr static CtrlIndex JoyX = 0;
@@ -46,10 +46,10 @@ namespace NintendoExtensionCtrl {
4646
};
4747

4848
Nunchuk_Shared(ExtensionData &dataRef) :
49-
ExtensionPort(dataRef, ExtensionType::Nunchuk) {}
49+
ExtensionController(dataRef, ExtensionType::Nunchuk) {}
5050

51-
Nunchuk_Shared(ExtensionController &controller) :
52-
Nunchuk_Shared(controller.getExtensionData()) {}
51+
Nunchuk_Shared(ExtensionPort &port) :
52+
Nunchuk_Shared(port.getExtensionData()) {}
5353

5454
uint8_t joyX() const; // 8 bits, 0-255
5555
uint8_t joyY() const;

0 commit comments

Comments
 (0)