Skip to content

Commit

Permalink
fix MIDIUSB and adapt CompleteHID to PluggableHID
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm authored and cmaglie committed Jul 16, 2015
1 parent e1a0350 commit efd329b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 550 deletions.
24 changes: 13 additions & 11 deletions libraries/CompleteHID/CompleteHID.cpp
@@ -1,7 +1,6 @@
#if 1 //defined(USBCON)

#include "CompleteHID.h"
#include "HID.h"

#define HID_MOUSE_ABS_ENABLED

Expand Down Expand Up @@ -197,16 +196,19 @@ const u8 _hidReportDescriptor[] = {
#endif
};

size_t getsizeof_hidReportDescriptor() {
return sizeof(_hidReportDescriptor);
}

//================================================================================
//================================================================================
// Mouse

Mouse_::Mouse_(void) : _buttons(0)
{
static HID_Descriptor cb = {
.length = sizeof(_hidReportDescriptor),
.descriptor = _hidReportDescriptor,
};
static HIDDescriptorListNode node(&cb);
HID.AppendDescriptor(&node);
}

void Mouse_::begin(void)
Expand All @@ -232,7 +234,7 @@ void Mouse_::move(signed char x, signed char y, signed char wheel)
m[1] = x;
m[2] = y;
m[3] = wheel;
HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m));
HID.SendReport(HID_REPORTID_MOUSE,m,sizeof(m));
}

// X and Y have the range of 0 to 32767.
Expand Down Expand Up @@ -261,7 +263,7 @@ void Mouse_::moveAbsolute(uint16_t x, uint16_t y)
m[2] = MSB(x);
m[3] = LSB(y);
m[4] = MSB(y);
HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m));
HID.SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m));
}

void Mouse_::buttons(uint8_t b)
Expand Down Expand Up @@ -308,7 +310,7 @@ void Keyboard_::end(void)

void Keyboard_::sendReport(KeyReport* keys)
{
HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys));
HID.SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys));
}

extern
Expand Down Expand Up @@ -549,12 +551,12 @@ size_t Keyboard_::systemControl(uint8_t k)

m[0] = LSB(mask);
m[1] = MSB(mask);
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
HID.SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));

// these are all OSCs, so send a clear to make it possible to send it again later
m[0] = 0;
m[1] = 0;
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
HID.SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
return 1;
}
else
Expand All @@ -581,12 +583,12 @@ size_t Keyboard_::consumerControl(uint8_t k)

m[0] = LSB(mask);
m[1] = MSB(mask);
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
HID.SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));

// these are all OSCs, so send a clear to make it possible to send it again later
m[0] = 0;
m[1] = 0;
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
HID.SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
return 1;
}
else
Expand Down
26 changes: 14 additions & 12 deletions libraries/CompleteHID/CompleteHID.h
@@ -1,7 +1,7 @@
#ifndef COMPLETEHID_h
#define COMPLETEHID_h

#if defined(_USING_HID)
#if 0 //defined(_USING_HID)

#error "Can only attach one submodule to HID module"

Expand All @@ -12,6 +12,8 @@
#include "HID.h"
#include "HIDTables.h"

extern HID_ HID;

//================================================================================
//================================================================================
// Mouse
Expand Down Expand Up @@ -98,17 +100,17 @@ class Keyboard_ : public Print
Keyboard_(void);
void begin(void);
void end(void);
virtual size_t write(uint8_t k);
virtual size_t press(uint8_t k);
virtual size_t release(uint8_t k);
virtual size_t writeKeycode(uint8_t k);
virtual size_t pressKeycode(uint8_t k);
virtual size_t releaseKeycode(uint8_t k);
virtual size_t addKeycodeToReport(uint8_t k);
virtual size_t removeKeycodeFromReport(uint8_t k);
virtual void releaseAll(void);
virtual size_t systemControl(uint8_t k);
virtual size_t consumerControl(uint8_t k);
size_t write(uint8_t k);
size_t press(uint8_t k);
size_t release(uint8_t k);
size_t writeKeycode(uint8_t k);
size_t pressKeycode(uint8_t k);
size_t releaseKeycode(uint8_t k);
size_t addKeycodeToReport(uint8_t k);
size_t removeKeycodeFromReport(uint8_t k);
void releaseAll(void);
size_t systemControl(uint8_t k);
size_t consumerControl(uint8_t k);
};
extern Keyboard_ Keyboard;

Expand Down
2 changes: 1 addition & 1 deletion libraries/MIDIUSB/MIDIUSB.cpp
Expand Up @@ -44,7 +44,7 @@ int MIDI_GetInterface(uint8_t* interfaceNum)
interfaceNum[0] += 2; // uses 2
return USB_SendControl(0,&_midiInterface,sizeof(_midiInterface));
}
bool MIDI_Setup(Setup& setup, u8 i)
bool MIDI_Setup(USBSetup& setup, u8 i)
{
//Support requests here if needed. Typically these are optional
return false;
Expand Down
12 changes: 6 additions & 6 deletions libraries/MIDIUSB/MIDIUSB.h
Expand Up @@ -30,12 +30,12 @@ class MIDI_

int8_t begin();

virtual uint32_t available(void);
virtual void accept(void);
virtual midiEventPacket_t read(void);
virtual void flush(void);
virtual void sendMIDI(midiEventPacket_t event);
virtual size_t write(const uint8_t *buffer, size_t size);
uint32_t available(void);
void accept(void);
midiEventPacket_t read(void);
void flush(void);
void sendMIDI(midiEventPacket_t event);
size_t write(const uint8_t *buffer, size_t size);
operator bool();
};
extern MIDI_ MidiUSB;
Expand Down

0 comments on commit efd329b

Please sign in to comment.