Skip to content

Commit 6759e88

Browse files
author
Martino Facchin
committed
remove setupUSB weak hook and replace with global constructors
thanks @matthijskooijman
1 parent 18a2f2a commit 6759e88

File tree

7 files changed

+4
-31
lines changed

7 files changed

+4
-31
lines changed

Diff for: hardware/arduino/avr/cores/arduino/main.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int main(void)
3737
initVariant();
3838

3939
#if defined(USBCON)
40-
setupUSB();
4140
USBDevice.attach();
4241
#endif
4342

Diff for: libraries/HID/HID.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ bool WEAK HID_Setup(Setup& setup, u8 i)
111111
}
112112
}
113113

114-
// to be called by begin(), will trigger USB disconnection and reconnection
115-
int8_t HID_Plug(void)
114+
HID_::HID_(void)
116115
{
117116
static uint8_t endpointType[1];
118117

@@ -137,17 +136,10 @@ int8_t HID_Plug(void)
137136
D_HIDREPORT(getsizeof_hidReportDescriptor()),
138137
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
139138
};
140-
141-
return HID_ENDPOINT_INT;
142-
}
143-
144-
HID_::HID_(void)
145-
{
146139
}
147140

148141
int HID_::begin(void)
149142
{
150-
return HID_Plug();
151143
}
152144

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

Diff for: libraries/Keyboard/Keyboard.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ size_t getsizeof_hidReportDescriptor() {
200200
return sizeof(_hidReportDescriptor);
201201
}
202202

203-
void WEAK setupUSB() {
204-
HID.begin();
205-
}
206-
207203
uint8_t USBPutChar(uint8_t c);
208204

209205
// press() adds the specified key (printing, non-printing, or modifier)

Diff for: libraries/MIDIUSB/MIDIUSB.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ ring_bufferMIDI midi_rx_buffer = {{0,0,0,0 }, 0, 0};
3939

4040
static MIDIDescriptor _midiInterface;
4141

42-
void WEAK setupUSB() {
43-
MidiUSB.begin();
44-
}
45-
4642
int8_t WEAK MIDI_GetInterface(uint8_t* interfaceNum)
4743
{
4844
interfaceNum[0] += 2; // uses 2
@@ -171,9 +167,8 @@ void MIDI_::sendMIDI(midiEventPacket_t event)
171167
write(data, 4);
172168
}
173169

174-
int8_t MIDI_plug(void)
170+
MIDI_::MIDI_(void)
175171
{
176-
177172
static uint8_t endpointType[2];
178173

179174
endpointType[0] = EP_TYPE_BULK_OUT_MIDI; // MIDI_ENDPOINT_OUT
@@ -210,13 +205,10 @@ int8_t MIDI_plug(void)
210205
D_MIDI_JACK_EP(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN),USB_ENDPOINT_TYPE_BULK,512),
211206
D_MIDI_AC_JACK_EP (1, 3)
212207
};
213-
214-
return MIDI_ENDPOINT_IN;
215208
}
216209

217210
int8_t MIDI_::begin()
218211
{
219-
return MIDI_plug();
220212
}
221213

222214

Diff for: libraries/MIDIUSB/MIDIUSB.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class MIDI_
2626
// private:
2727
// RingBuffer *_midi_rx_buffer;
2828
public:
29+
MIDI_(void);
30+
2931
int8_t begin();
3032

3133
virtual uint32_t available(void);

Diff for: libraries/Mouse/Mouse.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ Mouse_ Mouse;
4545
//================================================================================
4646
// Mouse
4747

48-
void WEAK setupUSB() {
49-
HID.begin();
50-
}
51-
5248
Mouse_::Mouse_(void) : _buttons(0)
5349
{
5450
}

Diff for: libraries/MouseAndKeyboard/MouseAndKeyboard.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ size_t getsizeof_hidReportDescriptor() {
9191
return sizeof(_hidReportDescriptor);
9292
}
9393

94-
void WEAK setupUSB() {
95-
HID.begin();
96-
}
97-
9894
Mouse_ Mouse;
9995

10096
//================================================================================

0 commit comments

Comments
 (0)