wip: mouse stuff

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

@ -26,6 +26,7 @@ USBHID RCMHID;
HIDKeyboard RCMBootKeyboard(RCMHID, 0);
HIDKeyboard RCMKeyboard(RCMHID);
HIDConsumer RCMConsumer(RCMHID);
HIDMouse RCMMouse(RCMHID);
USBCompositeSerial CompositeSerial;
} // namespace rcmcomposite

@ -23,7 +23,7 @@
#include "kaleidoscope/driver/hid/Base.h"
#include "rcmcomposite/Keyboard.h"
//#include "rcmcomposite/Mouse.h"
#include "rcmcomposite/Mouse.h"
namespace kaleidoscope {
namespace driver {
@ -38,7 +38,8 @@ extern USBCompositeSerial CompositeSerial;
const uint8_t report_description_[] = {
HID_BOOT_KEYBOARD_REPORT_DESCRIPTOR(),
HID_KEYBOARD_REPORT_DESCRIPTOR(2),
HID_CONSUMER_REPORT_DESCRIPTOR(3)
HID_CONSUMER_REPORT_DESCRIPTOR(3),
HID_MOUSE_REPORT_DESCRIPTOR(4)
};
}
@ -46,8 +47,8 @@ const uint8_t report_description_[] = {
struct RCMCompositeProps: public BaseProps {
typedef rcmcomposite::KeyboardProps KeyboardProps;
typedef rcmcomposite::Keyboard<KeyboardProps> Keyboard;
// typedef rcmcomposite::MouseProps MouseProps;
// typedef rcmcomposite::Mouse<MouseProps> Mouse;
typedef rcmcomposite::MouseProps MouseProps;
typedef rcmcomposite::Mouse<MouseProps> Mouse;
};
template <typename _Props>

@ -0,0 +1,81 @@
// -*- mode: c++ -*-
/* Kaleidoscope - Firmware for computer input devices
* Copyright (C) 2021 Keyboard.io, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Arduino.h>
#include <USBComposite.h>
#include "kaleidoscope/driver/hid/base/Mouse.h"
namespace kaleidoscope {
namespace driver {
namespace hid {
namespace rcmcomposite {
extern HIDMouse RCMMouse;
/*
* We are wrapping `Mouse` here, instead of directly using the class in
* `MouseProps` below. We do this, because this lets the linker optimize this
* whole thing out if it is unused. It can do that because instantiating `Mouse`
* is in a separate compilation unit.
*
* While it would have been cleaner and shorter to instantiate them here, and
* drop the global objects, that prevents optimizing them out, and that's a cost
* we do not want to pay.
*/
class MouseWrapper {
public:
MouseWrapper() {}
void begin() {}
void sendReport() {
RCMMouse.sendReport();
}
void move(int8_t x, int8_t y, int8_t vWheel, int8_t hWheel) {
RCMMouse.move(x, y, vWheel);
}
void stop(bool x, bool y, bool vWheel = false, bool hWheel = false) {
RCMMouse.stop(x, y, vWheel);
}
void releaseAll() {
RCMMouse.releaseAll();
}
void press(uint8_t buttons) {
RCMMouse.press(buttons);
}
void release(uint8_t buttons) {
RCMMouse.release(buttons);
}
void click(uint8_t buttons) {
RCMMouse.click(buttons);
}
};
struct MouseProps: public base::MouseProps {
typedef MouseWrapper Mouse;
};
template <typename _Props>
class Mouse: public base::Mouse<_Props> {};
}
}
}
}
Loading…
Cancel
Save