Signed-off-by: Gergely Nagy <algernon@keyboard.io>
wip/rcm-stm32
Gergely Nagy 3 years ago
parent 1fafd8b5bb
commit d60784e6cf
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -23,7 +23,9 @@ namespace hid {
namespace rcmcomposite { namespace rcmcomposite {
USBHID RCMHID; USBHID RCMHID;
HIDKeyboard RCMBootKeyboard(RCMHID, 0);
HIDKeyboard RCMKeyboard(RCMHID); HIDKeyboard RCMKeyboard(RCMHID);
HIDConsumer RCMConsumer(RCMHID);
USBCompositeSerial CompositeSerial; USBCompositeSerial CompositeSerial;
} // namespace rcmcomposite } // namespace rcmcomposite

@ -31,8 +31,16 @@ namespace hid {
namespace rcmcomposite { namespace rcmcomposite {
extern USBHID RCMHID; extern USBHID RCMHID;
extern HIDKeyboard RCMKeyboard; extern HIDKeyboard RCMBootKeyboard;
extern HIDConsumer RCMConsumer;
extern USBCompositeSerial CompositeSerial; extern USBCompositeSerial CompositeSerial;
const uint8_t report_description_[] = {
HID_BOOT_KEYBOARD_REPORT_DESCRIPTOR(),
HID_KEYBOARD_REPORT_DESCRIPTOR(2),
HID_CONSUMER_REPORT_DESCRIPTOR(3)
};
} }
struct RCMCompositeProps: public BaseProps { struct RCMCompositeProps: public BaseProps {
@ -46,8 +54,12 @@ template <typename _Props>
class RCMComposite: public Base<_Props> { class RCMComposite: public Base<_Props> {
public: public:
void setup() { void setup() {
rcmcomposite::RCMHID.begin(rcmcomposite::CompositeSerial, HID_KEYBOARD); rcmcomposite::RCMHID.begin(rcmcomposite::CompositeSerial,
rcmcomposite::report_description_,
sizeof(rcmcomposite::report_description_));
while(!USBComposite); while(!USBComposite);
rcmcomposite::RCMBootKeyboard.begin();
} }
}; };

@ -27,8 +27,9 @@ namespace driver {
namespace hid { namespace hid {
namespace rcmcomposite { namespace rcmcomposite {
extern USBHID RCMHID; extern HIDKeyboard RCMBootKeyboard;
extern HIDKeyboard RCMKeyboard; extern HIDKeyboard RCMKeyboard;
extern HIDConsumer RCMConsumer;
class BootKeyboardWrapper { class BootKeyboardWrapper {
public: public:
@ -42,6 +43,56 @@ class BootKeyboardWrapper {
void setProtocol(uint8_t protocol) {} void setProtocol(uint8_t protocol) {}
void setDefaultProtocol(uint8_t protocol) {} void setDefaultProtocol(uint8_t protocol) {}
void sendReport() {
RCMBootKeyboard.sendReport();
}
void press(uint8_t code) {
RCMBootKeyboard.press(code);
}
void release(uint8_t code) {
RCMBootKeyboard.release(code);
}
void releaseAll() {
RCMBootKeyboard.releaseAll();
}
bool isKeyPressed(uint8_t code) {
return RCMBootKeyboard.isKeyPressed(code);
}
bool wasKeyPressed(uint8_t code) {
return RCMBootKeyboard.wasKeyPressed(code);
}
bool isModifierActive(uint8_t code) {
return RCMBootKeyboard.isModifierActive(code);
}
bool wasModifierActive(uint8_t code) {
return RCMBootKeyboard.wasModifierActive(code);
}
bool isAnyModifierActive() {
return RCMBootKeyboard.isAnyModifierActive();
}
bool wasAnyModifierActive() {
return RCMBootKeyboard.wasAnyModifierActive();
}
uint8_t getLeds() {
return RCMBootKeyboard.getLEDs();
}
};
class SixKROKeyboardWrapper {
public:
SixKROKeyboardWrapper() {}
void begin() {}
uint8_t getProtocol() {
return 1;
}
void setProtocol(uint8_t protocol) {}
void setDefaultProtocol(uint8_t protocol) {}
void sendReport() { void sendReport() {
RCMKeyboard.sendReport(); RCMKeyboard.sendReport();
} }
@ -73,7 +124,6 @@ class BootKeyboardWrapper {
} }
bool wasAnyModifierActive() { bool wasAnyModifierActive() {
return RCMKeyboard.wasAnyModifierActive(); return RCMKeyboard.wasAnyModifierActive();
return 0;
} }
uint8_t getLeds() { uint8_t getLeds() {
@ -81,8 +131,32 @@ class BootKeyboardWrapper {
} }
}; };
class ConsumerControlWrapper {
public:
ConsumerControlWrapper() {}
void begin() {
RCMConsumer.begin();
}
void sendReport() {
}
void releaseAll() {
RCMConsumer.release();
}
void press(uint16_t code) {
RCMConsumer.press(code);
}
void release(uint16_t code) {
RCMConsumer.release();
}
};
struct KeyboardProps: public base::KeyboardProps { struct KeyboardProps: public base::KeyboardProps {
typedef BootKeyboardWrapper BootKeyboard; typedef BootKeyboardWrapper BootKeyboard;
typedef SixKROKeyboardWrapper NKROKeyboard;
typedef ConsumerControlWrapper ConsumerControl;
}; };
template <typename _Props> template <typename _Props>

Loading…
Cancel
Save