parent
72d4ac8124
commit
9ebab0fb52
@ -0,0 +1 @@
|
|||||||
|
# Pointer
|
@ -0,0 +1,7 @@
|
|||||||
|
name=Kaleidoscope-Pointer
|
||||||
|
version=0.0.0
|
||||||
|
sentence=Pointing device support for Kaleidoscope
|
||||||
|
maintainer=Kaleidoscope's Developers <jesse@keyboard.io>
|
||||||
|
url=https://github.com/keyboardio/Kaleidoscope
|
||||||
|
author=Keyboardio
|
||||||
|
paragraph=
|
@ -0,0 +1,19 @@
|
|||||||
|
/* 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 "kaleidoscope/plugin/Pointer.h"
|
@ -0,0 +1,64 @@
|
|||||||
|
/* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "kaleidoscope/Runtime.h"
|
||||||
|
#include "Kaleidoscope-FocusSerial.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Event Handlers
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
EventHandlerResult Pointer::onNameQuery() {
|
||||||
|
return ::Focus.sendName(F("Pointer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
EventHandlerResult Pointer::onSetup(void) {
|
||||||
|
kaleidoscope::Runtime.hid().mouse().setup();
|
||||||
|
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
EventHandlerResult Pointer::afterEachCycle() {
|
||||||
|
Runtime.hid().mouse().sendReport();
|
||||||
|
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
EventHandlerResult Pointer::onPointerSensorEvent(PointerEvent &event) {
|
||||||
|
if (event.key != POINTER_MOTION && event.key != POINTER_SCROLL)
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
if (event.key == POINTER_MOTION) {
|
||||||
|
Runtime.hid().mouse().move(event.x, event.y, 0, 0);
|
||||||
|
} else if (event.key == POINTER_SCROLL) {
|
||||||
|
Runtime.hid().mouse().move(0, 0, event.v, event.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EventHandlerResult::EVENT_CONSUMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
kaleidoscope::plugin::Pointer Pointer;
|
@ -0,0 +1,37 @@
|
|||||||
|
// -*- 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 "kaleidoscope/Runtime.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
class Pointer: public kaleidoscope::Plugin {
|
||||||
|
public:
|
||||||
|
Pointer() {}
|
||||||
|
|
||||||
|
EventHandlerResult onSetup();
|
||||||
|
EventHandlerResult onNameQuery();
|
||||||
|
EventHandlerResult onPointerSensorEvent(PointerEvent &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern kaleidoscope::plugin::Pointer Pointer;
|
@ -0,0 +1,23 @@
|
|||||||
|
/* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kaleidoscope/PointerEvent.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
|
||||||
|
PointerEventId PointerEvent::last_id_ = 0;
|
||||||
|
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,68 @@
|
|||||||
|
/* 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 <stdint.h> // for uint8_t, int8_t
|
||||||
|
|
||||||
|
#include "kaleidoscope/key_defs.h" // for Key, Key_NoKey
|
||||||
|
#include "kaleidoscope/KeyAddr.h" // for KeyAddr
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
|
||||||
|
typedef int8_t PointerEventId;
|
||||||
|
|
||||||
|
struct PointerEvent {
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor for plugin use when regenerating an event with specific ID:
|
||||||
|
PointerEvent(KeyAddr addr, int8_t x, int8_t y, int8_t h, int8_t v,
|
||||||
|
Key key = Key_NoKey, PointerEventId id = last_id_)
|
||||||
|
: addr(addr), x(x), y(y), h(h), v(v), key(key), id_(id) {}
|
||||||
|
|
||||||
|
PointerEventEvent() : id_(last_id_) {}
|
||||||
|
|
||||||
|
// For use by sensor creating a new event from a physical sensor event.
|
||||||
|
static PointerEvent next(KeyAddr addr, int8_t x, int8_t y, int8_t h, int8_t v) {
|
||||||
|
return PointerEvent(addr, x, y, h, v, Key_NoKey, ++last_id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
PointerEventId id() const {
|
||||||
|
return id_;
|
||||||
|
}
|
||||||
|
void swapId(PointerEvent &other) {
|
||||||
|
PointerEventId tmp_id = id_;
|
||||||
|
id_ = other.id_;
|
||||||
|
other.id_ = tmp_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyAddr addr = KeyAddr::none();
|
||||||
|
int8_t x = 0;
|
||||||
|
int8_t y = 0;
|
||||||
|
int8_t h = 0;
|
||||||
|
int8_t v = 0;
|
||||||
|
Key key = Key_NoKey;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// serial number of the event:
|
||||||
|
static PointerEventId last_id_;
|
||||||
|
PointerEventId id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
typedef kaleidoscope::PointerEventId PointerEventId;
|
||||||
|
typedef kaleidoscope::PointerEvent PointerEvent;
|
Loading…
Reference in new issue