From a91ba5a9d7ced85277ad60f1dbf381192f5c5ed8 Mon Sep 17 00:00:00 2001 From: sanine Date: Thu, 19 Oct 2023 20:12:24 -0500 Subject: update --- 12key-arduino/ModeMouse.h | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 12key-arduino/ModeMouse.h (limited to '12key-arduino/ModeMouse.h') diff --git a/12key-arduino/ModeMouse.h b/12key-arduino/ModeMouse.h new file mode 100644 index 0000000..c68a70c --- /dev/null +++ b/12key-arduino/ModeMouse.h @@ -0,0 +1,81 @@ +#pragma once + +#include +#include "Mode.h" + + +#define STEP_SIZE 3 + +#define MOVE_KEYS (KEY_2 | KEY_4 | KEY_6 | KEY_8 | KEY_3 | KEY_9) +#define CLICK_KEYS (KEY_1 | KEY_7) + + +class ModeMouse : public Mode { + public: + MouseMode() { + m_setStep = false; + m_step = 2; + } + + + void reset() {} + + + Mode * update(unsigned int keys) { + if (keys & KEY_STAR) return Mode::modes[0]; + + if (keys & KEY_HASH) { + if (!m_setStep) { + m_setStep = true; + m_step = 1; + } + else { + m_step *= 2; + } + return NULL; + } + + m_setStep = false; + + if (keys & MOVE_KEYS) + move(keys); + else if (keys & CLICK_KEYS) + click(keys); + + return NULL; + } + + + void move(unsigned int keys) { + /* movement */ + if (keys & KEY_2) { + for (int i=0; i