From 675cbc6cb6aee5819ee80bdf555d05574f84de4e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 24 Jan 2017 22:52:27 +0100 Subject: [PATCH 01/59] Lifted out of KeyboardioFirmware This is the same Keyboardio-MouseKeys that lived in core KeyboardioFirmware up until this point. It has been lifted out, the same GPL-2 license file added, along with a README, and the URL in library.properties has been updated. Signed-off-by: Gergely Nagy --- COPYING | 339 +++++++++++++++++++++++++++++++++++ README.md | 5 + library.properties | 10 ++ src/Keyboardio-MouseKeys.cpp | 68 +++++++ src/Keyboardio-MouseKeys.h | 13 ++ src/MouseKeyDefs.h | 41 +++++ src/MouseWrapper.cpp | 120 +++++++++++++ src/MouseWrapper.h | 56 ++++++ 8 files changed, 652 insertions(+) create mode 100644 COPYING create mode 100644 README.md create mode 100644 library.properties create mode 100644 src/Keyboardio-MouseKeys.cpp create mode 100644 src/Keyboardio-MouseKeys.h create mode 100644 src/MouseKeyDefs.h create mode 100644 src/MouseWrapper.cpp create mode 100644 src/MouseWrapper.h diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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; either version 2 of the License, or + (at your option) any later version. + + 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, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 00000000..e06bd6c6 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Keyboardio-MouseKeys + +This is a plugin for [KeyboardioFirmware][fw], that adds support for mouse keys. + + [fw]: https://github.com/keyboardio/KeyboardioFirmware diff --git a/library.properties b/library.properties new file mode 100644 index 00000000..23cd518c --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=Keyboardio-MouseKeys +version=0.0.1 +author=Jesse Vincent +maintainer=Jesse Vincent +sentence=Mouse keys for Keyboardio boards. +paragraph=... +category=Communication +url=https://github.com/keyboardio/Keyboardio-MouseKeys +architectures=avr +dot_a_linkage=true \ No newline at end of file diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp new file mode 100644 index 00000000..aba457a0 --- /dev/null +++ b/src/Keyboardio-MouseKeys.cpp @@ -0,0 +1,68 @@ +#include + +#include "Keyboardio-MouseKeys.h" +#include "MouseWrapper.h" +#include "KeyboardioFirmware.h" + +static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) { + if (key_toggled_off(keyState)) { + if (mappedKey.keyCode & KEY_MOUSE_UP || mappedKey.keyCode & KEY_MOUSE_DOWN) { + MouseWrapper.mouseActiveForCyclesY=0; + } + if (mappedKey.keyCode & KEY_MOUSE_LEFT || mappedKey.keyCode & KEY_MOUSE_RIGHT) { + MouseWrapper.mouseActiveForCyclesX=0; + } + } + + if (!key_is_pressed(keyState)) + return; + + if (mappedKey.keyCode & KEY_MOUSE_UP) { + MouseWrapper.move(0,-1); + } else if (mappedKey.keyCode & KEY_MOUSE_DOWN) { + MouseWrapper.move(0,1); + } + + if (mappedKey.keyCode & KEY_MOUSE_LEFT) { + MouseWrapper.move(-1,0); + } else if (mappedKey.keyCode & KEY_MOUSE_RIGHT) { + MouseWrapper.move(1,0); + } +} + +static Key handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) { + if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) + return mappedKey; + + if (mappedKey.keyCode & KEY_MOUSE_BUTTON) { + uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; + + if (key_toggled_on(keyState)) { + MouseWrapper.press_button(button); + } else if (key_toggled_off(keyState)) { + MouseWrapper.release_button(button); + } + } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { + handle_mouse_key_event(mappedKey, keyState); + } else if (key_toggled_on(keyState)) { + if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { + // we don't pass in the left and up values because those are the + // default, "no-op" conditionals + MouseWrapper.warp( ((mappedKey.keyCode & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00) ); + } + } + + return Key_NoKey; +} + +MouseKeys_::MouseKeys_(void) { +} + +void +MouseKeys_::begin (void) { + event_handler_hook_add (handleMouseKeys); +} + +MouseKeys_ MouseKeys; diff --git a/src/Keyboardio-MouseKeys.h b/src/Keyboardio-MouseKeys.h new file mode 100644 index 00000000..da24ec57 --- /dev/null +++ b/src/Keyboardio-MouseKeys.h @@ -0,0 +1,13 @@ +#pragma once + +#include "KeyboardioFirmware.h" +#include "MouseKeyDefs.h" + +class MouseKeys_ : public KeyboardioPlugin { + public: + MouseKeys_ (void); + + virtual void begin(void) final; +}; + +extern MouseKeys_ MouseKeys; diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h new file mode 100644 index 00000000..b8479b27 --- /dev/null +++ b/src/MouseKeyDefs.h @@ -0,0 +1,41 @@ +#pragma once + +#define IS_MOUSE_KEY B00010000 + +// Synthetic, not internal +#define KEY_MOUSE_BTN_L 0x01 // Synthetic key +#define KEY_MOUSE_BTN_M 0x02 // Synthetic key +#define KEY_MOUSE_BTN_R 0x03 // Synthetic key + + +#define KEY_MOUSE_UP B0000001 +#define KEY_MOUSE_DOWN B0000010 +#define KEY_MOUSE_LEFT B0000100 +#define KEY_MOUSE_RIGHT B0001000 +#define KEY_MOUSE_BUTTON B0010000 +#define KEY_MOUSE_WARP B0100000 +#define KEY_MOUSE_WARP_END B1000000 + + +#define Key_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT } +#define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT } +#define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } +#define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } +#define Key_mouseWarpEnd (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_WARP_END} + + +#define Key_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_LEFT } +#define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP } +#define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_RIGHT } +#define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_LEFT } +#define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_RIGHT } +#define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } +#define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN } +#define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } +#define Key_mouseScrollUp +#define Key_mouseScrollDn +#define Key_mouseScrollL +#define Key_mouseScrollR +#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L } +#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M } +#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R } diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp new file mode 100644 index 00000000..8426f044 --- /dev/null +++ b/src/MouseWrapper.cpp @@ -0,0 +1,120 @@ + +// Mouse-related methods +// +// +#include "MouseWrapper.h" + + +MouseWrapper_::MouseWrapper_(void) { + Mouse.begin(); + AbsoluteMouse.begin(); +} + +void MouseWrapper_::press_button(uint8_t button) { + Mouse.press(button); + end_warping(); + +} + +void MouseWrapper_::release_button(uint8_t button) { + Mouse.release(button); +} + + +void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { + uint16_t x_center = left + width/2; + uint16_t y_center = top + height/2; + AbsoluteMouse.moveTo(x_center,y_center); +} + + + + + +void MouseWrapper_::begin_warping() { + section_left = WARP_ABS_LEFT; + section_top = WARP_ABS_TOP; + next_width = MAX_WARP_WIDTH; + next_height = MAX_WARP_HEIGHT; + is_warping = true; +} + +void MouseWrapper_::end_warping() { + is_warping= false; +} + +void MouseWrapper_::warp(uint8_t warp_cmd) { + if (is_warping == false) { + begin_warping(); + } + + + if ( warp_cmd & WARP_END) { + end_warping(); + return; + } + + + next_width = next_width / 2; + next_height = next_height/2; + + if (warp_cmd & WARP_UP) { +// Serial.print(" - up "); + } else if (warp_cmd & WARP_DOWN) { +// Serial.print(" - down "); + section_top = section_top + next_height; + } + + if (warp_cmd & WARP_LEFT) { + // Serial.print(" - left "); + } else if (warp_cmd & WARP_RIGHT) { + // Serial.print(" - right "); + section_left = section_left + next_width; + } + + warp_jump(section_left, section_top, next_height,next_width); + +} + + +// cubic wave function based on code from FastLED +uint8_t MouseWrapper_::acceleration(uint8_t cycles) { + uint8_t i = cycles; + + if( i & 0x80) { + i = 255 - i; + } + + i = i << 1; + + uint8_t ii = (i*i) >> 8; + uint8_t iii = (ii*i) >> 8; + + i = (( (3 * (uint16_t)(ii)) - ( 2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; + + if ( i > ACCELERATION_CEIL) { + i = ACCELERATION_CEIL; + } + return i; +} + + +void MouseWrapper_::move( int8_t x, int8_t y) { + int16_t moveX =0; + int16_t moveY = 0; + if (x != 0 ) { + if (mouseActiveForCyclesX < 255) { mouseActiveForCyclesX++;} + moveX = (x * acceleration(mouseActiveForCyclesX)); + } + if (y != 0) { + if (mouseActiveForCyclesY < 255) { mouseActiveForCyclesY++;} + moveY = (y * acceleration(mouseActiveForCyclesY)); + + } + + end_warping(); + Mouse.move(moveX, moveY, 0); + +} + +MouseWrapper_ MouseWrapper; diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h new file mode 100644 index 00000000..4e8b7fd6 --- /dev/null +++ b/src/MouseWrapper.h @@ -0,0 +1,56 @@ +#pragma once + +#include "Arduino.h" +#include "KeyboardioHID.h" + +// Warping commands + +#define WARP_END 1 +#define WARP_UP 2 +#define WARP_DOWN 4 +#define WARP_LEFT 8 +#define WARP_RIGHT 16 + + + +// apparently, the mac discards 15% of the value space for mouse movement. +// need to test this on other platforms + +#define MAX_WARP_WIDTH 32767 +#define MAX_WARP_HEIGHT 32767 + +#define WARP_ABS_TOP 0 +#define WARP_ABS_LEFT 0 + +// Mouse acceleration + +// we want the whole s curve, not just the bit +// that's usually above the x and y axes; +#define ACCELERATION_FLOOR 2 +#define ACCELERATION_CEIL 50 + + +class MouseWrapper_ { + public: + MouseWrapper_(void); + void move( int8_t x, int8_t y); + void warp(uint8_t warp_cmd); + void press_button(uint8_t button); + void release_button(uint8_t button); + uint8_t mouseActiveForCyclesX = 0; + uint8_t mouseActiveForCyclesY = 0; + + private: + uint16_t next_width = 0; + uint16_t next_height = 0; + uint16_t section_top = 0; + uint16_t section_left = 0; + boolean is_warping = false; + + uint8_t acceleration (uint8_t cycles); + void begin_warping(); + void end_warping(); + void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); + +}; +extern MouseWrapper_ MouseWrapper; From 6d2587f7afb05b0b12cec30bee3d930c5c55e377 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 25 Jan 2017 10:59:21 +0100 Subject: [PATCH 02/59] Adjust for the flags/keyCode swap Signed-off-by: Gergely Nagy --- src/MouseKeyDefs.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index b8479b27..237eef24 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -17,25 +17,25 @@ #define KEY_MOUSE_WARP_END B1000000 -#define Key_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT } -#define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT } -#define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } -#define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } -#define Key_mouseWarpEnd (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_WARP_END} - - -#define Key_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_LEFT } -#define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP } -#define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_RIGHT } -#define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_LEFT } -#define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_RIGHT } -#define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } -#define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN } -#define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } +#define Key_mouseWarpNW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpNE (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpSW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpSE (Key) { KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpEnd (Key) { KEY_MOUSE_WARP| KEY_MOUSE_WARP_END, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } + + +#define Key_mouseUpL (Key) { KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseUp (Key) { KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseUpR (Key) { KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseL (Key) { KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseR (Key) { KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseDnL (Key) { KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseDn (Key) { KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseDnR (Key) { KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseScrollUp #define Key_mouseScrollDn #define Key_mouseScrollL #define Key_mouseScrollR -#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L } -#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M } -#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R } +#define Key_mouseBtnL (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } +#define Key_mouseBtnM (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } +#define Key_mouseBtnR (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } From dcd8d8405e56d99fb8fe81323e460b255e44aad5 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 27 Jan 2017 23:01:26 +0100 Subject: [PATCH 03/59] Use the new, double-add protected hook functions Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index aba457a0..b3a2a7be 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -62,7 +62,7 @@ MouseKeys_::MouseKeys_(void) { void MouseKeys_::begin (void) { - event_handler_hook_add (handleMouseKeys); + event_handler_hook_use (handleMouseKeys); } MouseKeys_ MouseKeys; From c782eb727523565d57b2a874cb66e17c69ebf5b5 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 2 Feb 2017 09:18:54 +0100 Subject: [PATCH 04/59] Make diagonal mouse movement considerably smoother Instead of acting on mouse movement keys immediately in the event handler hook, just store them, and act on them during a loop hook. This has the effect of collecting all movement intents noticed in a full scan, and acting on them in one go, rather than acting individually. This makes diagonal movement (up & right keys pressed at the same time) a lot smoother, at the cost of a few ms of delay. The delay is not noticeable, and the smoothing would be a good trade anyway. No more jerky diagonal movements! Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index b3a2a7be..e8af08d7 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -4,6 +4,25 @@ #include "MouseWrapper.h" #include "KeyboardioFirmware.h" +static uint8_t mouseMoveIntent; + +static void loopHook(bool postClear) { + if (postClear) { + mouseMoveIntent = 0; + return; + } + + if (mouseMoveIntent & KEY_MOUSE_UP) + MouseWrapper.move(0, -1); + else if (mouseMoveIntent & KEY_MOUSE_DOWN) + MouseWrapper.move(0, 1); + + if (mouseMoveIntent & KEY_MOUSE_LEFT) + MouseWrapper.move(-1, 0); + else if (mouseMoveIntent & KEY_MOUSE_RIGHT) + MouseWrapper.move(1, 0); +} + static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) { if (key_toggled_off(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_UP || mappedKey.keyCode & KEY_MOUSE_DOWN) { @@ -17,17 +36,7 @@ static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) { if (!key_is_pressed(keyState)) return; - if (mappedKey.keyCode & KEY_MOUSE_UP) { - MouseWrapper.move(0,-1); - } else if (mappedKey.keyCode & KEY_MOUSE_DOWN) { - MouseWrapper.move(0,1); - } - - if (mappedKey.keyCode & KEY_MOUSE_LEFT) { - MouseWrapper.move(-1,0); - } else if (mappedKey.keyCode & KEY_MOUSE_RIGHT) { - MouseWrapper.move(1,0); - } + mouseMoveIntent |= mappedKey.keyCode; } static Key handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) { @@ -63,6 +72,7 @@ MouseKeys_::MouseKeys_(void) { void MouseKeys_::begin (void) { event_handler_hook_use (handleMouseKeys); + loop_hook_use (loopHook); } MouseKeys_ MouseKeys; From 41d57b598add3219bcfa87a756ae4e06ce1f9f15 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 2 Feb 2017 09:58:54 +0100 Subject: [PATCH 05/59] Use a single accel counter Instead of calculating separate acceleration for the x and y axes, use only a single one, that applies to both axes. Thus, holding mouse up, and then pressing and holding right will move the mouse cursor in a straight diagonal line, instead of a curve. Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 25 ++++++++++++------------- src/MouseWrapper.cpp | 12 ++++-------- src/MouseWrapper.h | 4 ++-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index e8af08d7..9a61e123 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -12,27 +12,26 @@ static void loopHook(bool postClear) { return; } + if (mouseMoveIntent == 0) { + MouseWrapper.mouseActiveForCycles = 0; + return; + } + + if (MouseWrapper.mouseActiveForCycles < 255) + MouseWrapper.mouseActiveForCycles++; + if (mouseMoveIntent & KEY_MOUSE_UP) - MouseWrapper.move(0, -1); + MouseWrapper.move(0, -1); else if (mouseMoveIntent & KEY_MOUSE_DOWN) - MouseWrapper.move(0, 1); + MouseWrapper.move(0, 1); if (mouseMoveIntent & KEY_MOUSE_LEFT) - MouseWrapper.move(-1, 0); + MouseWrapper.move(-1, 0); else if (mouseMoveIntent & KEY_MOUSE_RIGHT) - MouseWrapper.move(1, 0); + MouseWrapper.move(1, 0); } static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) { - if (key_toggled_off(keyState)) { - if (mappedKey.keyCode & KEY_MOUSE_UP || mappedKey.keyCode & KEY_MOUSE_DOWN) { - MouseWrapper.mouseActiveForCyclesY=0; - } - if (mappedKey.keyCode & KEY_MOUSE_LEFT || mappedKey.keyCode & KEY_MOUSE_RIGHT) { - MouseWrapper.mouseActiveForCyclesX=0; - } - } - if (!key_is_pressed(keyState)) return; diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 8426f044..a8e8eaaf 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -103,18 +103,14 @@ void MouseWrapper_::move( int8_t x, int8_t y) { int16_t moveX =0; int16_t moveY = 0; if (x != 0 ) { - if (mouseActiveForCyclesX < 255) { mouseActiveForCyclesX++;} - moveX = (x * acceleration(mouseActiveForCyclesX)); + moveX = (x * acceleration(mouseActiveForCycles)); } if (y != 0) { - if (mouseActiveForCyclesY < 255) { mouseActiveForCyclesY++;} - moveY = (y * acceleration(mouseActiveForCyclesY)); - + moveY = (y * acceleration(mouseActiveForCycles)); } - - end_warping(); - Mouse.move(moveX, moveY, 0); + end_warping(); + Mouse.move(moveX, moveY, 0); } MouseWrapper_ MouseWrapper; diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 4e8b7fd6..df2d98c8 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -37,8 +37,7 @@ class MouseWrapper_ { void warp(uint8_t warp_cmd); void press_button(uint8_t button); void release_button(uint8_t button); - uint8_t mouseActiveForCyclesX = 0; - uint8_t mouseActiveForCyclesY = 0; + uint8_t mouseActiveForCycles = 0; private: uint16_t next_width = 0; @@ -53,4 +52,5 @@ class MouseWrapper_ { void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); }; + extern MouseWrapper_ MouseWrapper; From ba1a8604a07f32359e56c0982b0f2b0d81ebc96c Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 2 Feb 2017 10:18:51 +0100 Subject: [PATCH 06/59] Some small code cleanups Move the hooks inside the `MouseKeys_` object, and drop the `handle_mouse_key_event` function, by inlining it into the event handler hook. Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 20 +++++++------------- src/Keyboardio-MouseKeys.h | 6 ++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index 9a61e123..4fb73917 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -4,9 +4,9 @@ #include "MouseWrapper.h" #include "KeyboardioFirmware.h" -static uint8_t mouseMoveIntent; +uint8_t MouseKeys_::mouseMoveIntent; -static void loopHook(bool postClear) { +void MouseKeys_::loopHook(bool postClear) { if (postClear) { mouseMoveIntent = 0; return; @@ -31,14 +31,7 @@ static void loopHook(bool postClear) { MouseWrapper.move(1, 0); } -static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) { - if (!key_is_pressed(keyState)) - return; - - mouseMoveIntent |= mappedKey.keyCode; -} - -static Key handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) { +Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) { if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) return mappedKey; @@ -51,7 +44,8 @@ static Key handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) MouseWrapper.release_button(button); } } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { - handle_mouse_key_event(mappedKey, keyState); + if (key_is_pressed(keyState)) + mouseMoveIntent |= mappedKey.keyCode; } else if (key_toggled_on(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { // we don't pass in the left and up values because those are the @@ -70,8 +64,8 @@ MouseKeys_::MouseKeys_(void) { void MouseKeys_::begin (void) { - event_handler_hook_use (handleMouseKeys); - loop_hook_use (loopHook); + event_handler_hook_use(eventHandlerHook); + loop_hook_use(loopHook); } MouseKeys_ MouseKeys; diff --git a/src/Keyboardio-MouseKeys.h b/src/Keyboardio-MouseKeys.h index da24ec57..17d47aa5 100644 --- a/src/Keyboardio-MouseKeys.h +++ b/src/Keyboardio-MouseKeys.h @@ -8,6 +8,12 @@ class MouseKeys_ : public KeyboardioPlugin { MouseKeys_ (void); virtual void begin(void) final; + + private: + static uint8_t mouseMoveIntent; + + static void loopHook(bool postClear); + static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); }; extern MouseKeys_ MouseKeys; From ce734dbd37dcca1936bf1c3f2f409bbf61f26086 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 2 Feb 2017 10:24:14 +0100 Subject: [PATCH 07/59] MouseWrapper: static-ification Mark most of the things static, to save a couple of bytes in program-space. Signed-off-by: Gergely Nagy --- src/MouseWrapper.cpp | 28 +++++++++++++--------------- src/MouseWrapper.h | 35 ++++++++++++++++------------------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index a8e8eaaf..fb58547e 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -4,6 +4,13 @@ // #include "MouseWrapper.h" +uint16_t MouseWrapper_::next_width; +uint16_t MouseWrapper_::next_height; +uint16_t MouseWrapper_::section_top; +uint16_t MouseWrapper_::section_left; +boolean MouseWrapper_::is_warping; + +uint8_t MouseWrapper_::mouseActiveForCycles; MouseWrapper_::MouseWrapper_(void) { Mouse.begin(); @@ -20,17 +27,12 @@ void MouseWrapper_::release_button(uint8_t button) { Mouse.release(button); } - void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { uint16_t x_center = left + width/2; uint16_t y_center = top + height/2; - AbsoluteMouse.moveTo(x_center,y_center); + AbsoluteMouse.moveTo(x_center, y_center); } - - - - void MouseWrapper_::begin_warping() { section_left = WARP_ABS_LEFT; section_top = WARP_ABS_TOP; @@ -48,14 +50,12 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { begin_warping(); } - - if ( warp_cmd & WARP_END) { + if (warp_cmd & WARP_END) { end_warping(); return; } - - next_width = next_width / 2; + next_width = next_width/2; next_height = next_height/2; if (warp_cmd & WARP_UP) { @@ -73,10 +73,8 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { } warp_jump(section_left, section_top, next_height,next_width); - } - // cubic wave function based on code from FastLED uint8_t MouseWrapper_::acceleration(uint8_t cycles) { uint8_t i = cycles; @@ -92,14 +90,14 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { i = (( (3 * (uint16_t)(ii)) - ( 2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; - if ( i > ACCELERATION_CEIL) { - i = ACCELERATION_CEIL; + if (i > ACCELERATION_CEIL) { + i = ACCELERATION_CEIL; } return i; } -void MouseWrapper_::move( int8_t x, int8_t y) { +void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX =0; int16_t moveY = 0; if (x != 0 ) { diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index df2d98c8..6c9fff10 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -11,8 +11,6 @@ #define WARP_LEFT 8 #define WARP_RIGHT 16 - - // apparently, the mac discards 15% of the value space for mouse movement. // need to test this on other platforms @@ -29,28 +27,27 @@ #define ACCELERATION_FLOOR 2 #define ACCELERATION_CEIL 50 - class MouseWrapper_ { public: MouseWrapper_(void); - void move( int8_t x, int8_t y); - void warp(uint8_t warp_cmd); - void press_button(uint8_t button); - void release_button(uint8_t button); - uint8_t mouseActiveForCycles = 0; - private: - uint16_t next_width = 0; - uint16_t next_height = 0; - uint16_t section_top = 0; - uint16_t section_left = 0; - boolean is_warping = false; - - uint8_t acceleration (uint8_t cycles); - void begin_warping(); - void end_warping(); - void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); + static void move(int8_t x, int8_t y); + static void warp(uint8_t warp_cmd); + static void press_button(uint8_t button); + static void release_button(uint8_t button); + static uint8_t mouseActiveForCycles; + private: + static uint16_t next_width; + static uint16_t next_height; + static uint16_t section_top; + static uint16_t section_left; + static boolean is_warping; + + static uint8_t acceleration(uint8_t cycles); + static void begin_warping(); + static void end_warping(); + static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); }; extern MouseWrapper_ MouseWrapper; From 34923f8f755409734f06c4c0ee516337146b144f Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 2 Feb 2017 23:17:34 +0100 Subject: [PATCH 08/59] Minor mouse movement optimalisation When acting on `moveIntent`, set up the direction first, and move the cursor only once, instead of twice (once for each axis). This makes the movement even smoother, and also saves us a few bytes of code. Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index 4fb73917..23a85a64 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -17,18 +17,22 @@ void MouseKeys_::loopHook(bool postClear) { return; } + int8_t moveX = 0, moveY = 0; + if (MouseWrapper.mouseActiveForCycles < 255) MouseWrapper.mouseActiveForCycles++; if (mouseMoveIntent & KEY_MOUSE_UP) - MouseWrapper.move(0, -1); + moveY = -1; else if (mouseMoveIntent & KEY_MOUSE_DOWN) - MouseWrapper.move(0, 1); + moveY = 1; if (mouseMoveIntent & KEY_MOUSE_LEFT) - MouseWrapper.move(-1, 0); + moveX = -1; else if (mouseMoveIntent & KEY_MOUSE_RIGHT) - MouseWrapper.move(1, 0); + moveX = 1; + + MouseWrapper.move(moveX, moveY); } Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) { From 05c80e632a75877804118515e0ba8f29afa1c292 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 9 Feb 2017 20:41:07 +0100 Subject: [PATCH 09/59] Implement a way to slow down the acceleration Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 10 ++++++++-- src/Keyboardio-MouseKeys.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index 23a85a64..702af5b6 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -5,6 +5,8 @@ #include "KeyboardioFirmware.h" uint8_t MouseKeys_::mouseMoveIntent; +uint8_t MouseKeys_::accelDelay; +uint8_t MouseKeys_::accelDelayCounter; void MouseKeys_::loopHook(bool postClear) { if (postClear) { @@ -19,8 +21,12 @@ void MouseKeys_::loopHook(bool postClear) { int8_t moveX = 0, moveY = 0; - if (MouseWrapper.mouseActiveForCycles < 255) - MouseWrapper.mouseActiveForCycles++; + if (accelDelayCounter == accelDelay) { + if (MouseWrapper.mouseActiveForCycles < 255) + MouseWrapper.mouseActiveForCycles++; + accelDelayCounter = 0; + } else + accelDelayCounter++; if (mouseMoveIntent & KEY_MOUSE_UP) moveY = -1; diff --git a/src/Keyboardio-MouseKeys.h b/src/Keyboardio-MouseKeys.h index 17d47aa5..ff42ea07 100644 --- a/src/Keyboardio-MouseKeys.h +++ b/src/Keyboardio-MouseKeys.h @@ -8,9 +8,11 @@ class MouseKeys_ : public KeyboardioPlugin { MouseKeys_ (void); virtual void begin(void) final; + static uint8_t accelDelay; private: static uint8_t mouseMoveIntent; + static uint8_t accelDelayCounter; static void loopHook(bool postClear); static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); From a33621e867585245436341086ec246b5a3fbf88e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 10 Feb 2017 11:38:53 +0100 Subject: [PATCH 10/59] Introducing the tuning knobs Instead of counting loops for the purpose of calculating acceleration, use timers and steps instead. This means that we can now tune how often the mouse moves (`speedDelay`), how much it moves when it does (`speed`), how fast acceleration is (`accelSpeed`), and how often we accelerate (`accelDelay`). By default, the movement speed is one, and there is no delay, while acceleration has an 50ms delay, and a speed of one. But all of these can be tuned at run-time: we can turn off acceleration completely, or slow down the mouse considerably - the possibilities are almost endless! Signed-off-by: Gergely Nagy --- src/Keyboardio-MouseKeys.cpp | 44 +++++++++++++++++++++++++----------- src/Keyboardio-MouseKeys.h | 9 ++++++-- src/MouseWrapper.cpp | 6 ++--- src/MouseWrapper.h | 2 +- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Keyboardio-MouseKeys.cpp index 702af5b6..7c05490d 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Keyboardio-MouseKeys.cpp @@ -5,8 +5,15 @@ #include "KeyboardioFirmware.h" uint8_t MouseKeys_::mouseMoveIntent; -uint8_t MouseKeys_::accelDelay; -uint8_t MouseKeys_::accelDelayCounter; + +uint8_t MouseKeys_::speed = 1; +uint16_t MouseKeys_::speedDelay = 0; + +uint8_t MouseKeys_::accelSpeed = 1; +uint16_t MouseKeys_::accelDelay = 50; + +uint32_t MouseKeys_::accelStartTime; +uint32_t MouseKeys_::startTime; void MouseKeys_::loopHook(bool postClear) { if (postClear) { @@ -15,28 +22,33 @@ void MouseKeys_::loopHook(bool postClear) { } if (mouseMoveIntent == 0) { - MouseWrapper.mouseActiveForCycles = 0; + MouseWrapper.accelStep = 0; + startTime = 0; + accelStartTime = 0; return; } + if ((millis() - startTime) < speedDelay) + return; + + startTime = millis(); + int8_t moveX = 0, moveY = 0; - if (accelDelayCounter == accelDelay) { - if (MouseWrapper.mouseActiveForCycles < 255) - MouseWrapper.mouseActiveForCycles++; - accelDelayCounter = 0; - } else - accelDelayCounter++; + if ((millis() - accelStartTime) >= (accelDelay * MouseWrapper.accelStep)) { + if (MouseWrapper.accelStep < 255 - accelSpeed) + MouseWrapper.accelStep += accelSpeed; + } if (mouseMoveIntent & KEY_MOUSE_UP) - moveY = -1; + moveY = -speed; else if (mouseMoveIntent & KEY_MOUSE_DOWN) - moveY = 1; + moveY = speed; if (mouseMoveIntent & KEY_MOUSE_LEFT) - moveX = -1; + moveX = -speed; else if (mouseMoveIntent & KEY_MOUSE_RIGHT) - moveX = 1; + moveX = speed; MouseWrapper.move(moveX, moveY); } @@ -54,6 +66,12 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS MouseWrapper.release_button(button); } } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { + if (key_toggled_on(keyState)) { + if (!startTime) + startTime = millis(); + if (!accelStartTime) + accelStartTime = millis(); + } if (key_is_pressed(keyState)) mouseMoveIntent |= mappedKey.keyCode; } else if (key_toggled_on(keyState)) { diff --git a/src/Keyboardio-MouseKeys.h b/src/Keyboardio-MouseKeys.h index ff42ea07..7bc805ed 100644 --- a/src/Keyboardio-MouseKeys.h +++ b/src/Keyboardio-MouseKeys.h @@ -8,11 +8,16 @@ class MouseKeys_ : public KeyboardioPlugin { MouseKeys_ (void); virtual void begin(void) final; - static uint8_t accelDelay; + + static uint8_t speed; + static uint16_t speedDelay; + static uint8_t accelSpeed; + static uint16_t accelDelay; private: static uint8_t mouseMoveIntent; - static uint8_t accelDelayCounter; + static uint32_t startTime; + static uint32_t accelStartTime; static void loopHook(bool postClear); static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index fb58547e..553a5356 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -10,7 +10,7 @@ uint16_t MouseWrapper_::section_top; uint16_t MouseWrapper_::section_left; boolean MouseWrapper_::is_warping; -uint8_t MouseWrapper_::mouseActiveForCycles; +uint8_t MouseWrapper_::accelStep; MouseWrapper_::MouseWrapper_(void) { Mouse.begin(); @@ -101,10 +101,10 @@ void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX =0; int16_t moveY = 0; if (x != 0 ) { - moveX = (x * acceleration(mouseActiveForCycles)); + moveX = (x * acceleration(accelStep)); } if (y != 0) { - moveY = (y * acceleration(mouseActiveForCycles)); + moveY = (y * acceleration(accelStep)); } end_warping(); diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 6c9fff10..fc2f8126 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -35,7 +35,7 @@ class MouseWrapper_ { static void warp(uint8_t warp_cmd); static void press_button(uint8_t button); static void release_button(uint8_t button); - static uint8_t mouseActiveForCycles; + static uint8_t accelStep; private: static uint16_t next_width; From 4ec2c5888a56567f4d69192d7fb960d8b42d756a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 11 Feb 2017 23:40:23 +0100 Subject: [PATCH 11/59] The Big Rename Renamed the library to Kaleidoscope-MouseKeys, and followed up with other renames. Signed-off-by: Gergely Nagy --- README.md | 6 +++--- library.properties | 6 +++--- ...{Keyboardio-MouseKeys.cpp => Kaleidoscope-MouseKeys.cpp} | 4 ++-- src/{Keyboardio-MouseKeys.h => Kaleidoscope-MouseKeys.h} | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) rename src/{Keyboardio-MouseKeys.cpp => Kaleidoscope-MouseKeys.cpp} (97%) rename src/{Keyboardio-MouseKeys.h => Kaleidoscope-MouseKeys.h} (86%) diff --git a/README.md b/README.md index e06bd6c6..ce8ad7e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Keyboardio-MouseKeys +# Kaleidoscope-MouseKeys -This is a plugin for [KeyboardioFirmware][fw], that adds support for mouse keys. +This is a plugin for [Kaleidoscope][fw], that adds support for mouse keys. - [fw]: https://github.com/keyboardio/KeyboardioFirmware + [fw]: https://github.com/keyboardio/Kaleidoscope diff --git a/library.properties b/library.properties index 23cd518c..d4df7f02 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ -name=Keyboardio-MouseKeys +name=Kaleidoscope-MouseKeys version=0.0.1 author=Jesse Vincent maintainer=Jesse Vincent -sentence=Mouse keys for Keyboardio boards. +sentence=Mouse keys for Kaleidoscope. paragraph=... category=Communication -url=https://github.com/keyboardio/Keyboardio-MouseKeys +url=https://github.com/keyboardio/Kaleidoscope-MouseKeys architectures=avr dot_a_linkage=true \ No newline at end of file diff --git a/src/Keyboardio-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp similarity index 97% rename from src/Keyboardio-MouseKeys.cpp rename to src/Kaleidoscope-MouseKeys.cpp index 7c05490d..17d80f02 100644 --- a/src/Keyboardio-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -1,8 +1,8 @@ #include -#include "Keyboardio-MouseKeys.h" +#include "Kaleidoscope-MouseKeys.h" #include "MouseWrapper.h" -#include "KeyboardioFirmware.h" +#include "Kaleidoscope.h" uint8_t MouseKeys_::mouseMoveIntent; diff --git a/src/Keyboardio-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h similarity index 86% rename from src/Keyboardio-MouseKeys.h rename to src/Kaleidoscope-MouseKeys.h index 7bc805ed..f303d077 100644 --- a/src/Keyboardio-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -1,9 +1,9 @@ #pragma once -#include "KeyboardioFirmware.h" +#include "Kaleidoscope.h" #include "MouseKeyDefs.h" -class MouseKeys_ : public KeyboardioPlugin { +class MouseKeys_ : public KaleidoscopePlugin { public: MouseKeys_ (void); From 3d0903af411243033f54f9932c81c6301a8cdaf9 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 21 Feb 2017 12:58:57 +0100 Subject: [PATCH 12/59] Improved timer handling Instead of calculating time deltas every time we want to check a timeout, calculate the projected end ahead of time. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 22 ++++++++++------------ src/Kaleidoscope-MouseKeys.h | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 17d80f02..9538e299 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -12,8 +12,8 @@ uint16_t MouseKeys_::speedDelay = 0; uint8_t MouseKeys_::accelSpeed = 1; uint16_t MouseKeys_::accelDelay = 50; -uint32_t MouseKeys_::accelStartTime; -uint32_t MouseKeys_::startTime; +uint32_t MouseKeys_::accelEndTime; +uint32_t MouseKeys_::endTime; void MouseKeys_::loopHook(bool postClear) { if (postClear) { @@ -23,19 +23,19 @@ void MouseKeys_::loopHook(bool postClear) { if (mouseMoveIntent == 0) { MouseWrapper.accelStep = 0; - startTime = 0; - accelStartTime = 0; + endTime = 0; + accelEndTime = 0; return; } - if ((millis() - startTime) < speedDelay) - return; + if (millis() < endTime) + return; - startTime = millis(); + endTime = millis() + speedDelay; int8_t moveX = 0, moveY = 0; - if ((millis() - accelStartTime) >= (accelDelay * MouseWrapper.accelStep)) { + if (millis() >= accelEndTime) { if (MouseWrapper.accelStep < 255 - accelSpeed) MouseWrapper.accelStep += accelSpeed; } @@ -67,10 +67,8 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS } } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { if (key_toggled_on(keyState)) { - if (!startTime) - startTime = millis(); - if (!accelStartTime) - accelStartTime = millis(); + endTime = millis() + speedDelay; + accelEndTime = millis() + accelDelay; } if (key_is_pressed(keyState)) mouseMoveIntent |= mappedKey.keyCode; diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index f303d077..e94d5ea9 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -16,8 +16,8 @@ class MouseKeys_ : public KaleidoscopePlugin { private: static uint8_t mouseMoveIntent; - static uint32_t startTime; - static uint32_t accelStartTime; + static uint32_t endTime; + static uint32_t accelEndTime; static void loopHook(bool postClear); static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); From dbbc80190af5474e435889d739d3917cd6d4c9f9 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 10 Mar 2017 22:56:30 +0100 Subject: [PATCH 13/59] Reuse the button bit for WARP_END WARP + Button makes no sense together, so reuse the _BUTTON bit for _WARP_END. This will allow us to use the free'd up bit for something else. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 2 +- src/MouseKeyDefs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 9538e299..50b4203f 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -57,7 +57,7 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) return mappedKey; - if (mappedKey.keyCode & KEY_MOUSE_BUTTON) { + if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; if (key_toggled_on(keyState)) { diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 237eef24..de4d82c0 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -14,7 +14,7 @@ #define KEY_MOUSE_RIGHT B0001000 #define KEY_MOUSE_BUTTON B0010000 #define KEY_MOUSE_WARP B0100000 -#define KEY_MOUSE_WARP_END B1000000 +#define KEY_MOUSE_WARP_END B0010000 #define Key_mouseWarpNW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } From a3cca30e1f90ef0640b3a797efef9a1202a7082d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 10 Mar 2017 22:58:13 +0100 Subject: [PATCH 14/59] Implement mouse wheel support With these changes, the vertical scrolling of the mouse wheel is now properly supported. It has no acceleration, because the wheel doesn't have one either. It has a delay, however, which I tried to tune to a reasonable speed. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 26 ++++++++++++++++++++++++-- src/Kaleidoscope-MouseKeys.h | 4 ++++ src/MouseKeyDefs.h | 5 +++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 50b4203f..d330c051 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -12,8 +12,24 @@ uint16_t MouseKeys_::speedDelay = 0; uint8_t MouseKeys_::accelSpeed = 1; uint16_t MouseKeys_::accelDelay = 50; +uint8_t MouseKeys_::wheelSpeed = 1; +uint16_t MouseKeys_::wheelDelay = 50; + uint32_t MouseKeys_::accelEndTime; uint32_t MouseKeys_::endTime; +uint32_t MouseKeys_::wheelEndTime; + +void MouseKeys_::scrollWheel(uint8_t keyCode) { + if (millis() < wheelEndTime) + return; + + wheelEndTime = millis() + wheelDelay; + + if (keyCode & KEY_MOUSE_UP) + Mouse.move(0, 0, wheelSpeed); + else if (keyCode & KEY_MOUSE_DOWN) + Mouse.move(0, 0, -wheelSpeed); +} void MouseKeys_::loopHook(bool postClear) { if (postClear) { @@ -69,9 +85,15 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS if (key_toggled_on(keyState)) { endTime = millis() + speedDelay; accelEndTime = millis() + accelDelay; + wheelEndTime = 0; + } + if (key_is_pressed(keyState)) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + scrollWheel (mappedKey.keyCode); + } + else + mouseMoveIntent |= mappedKey.keyCode; } - if (key_is_pressed(keyState)) - mouseMoveIntent |= mappedKey.keyCode; } else if (key_toggled_on(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { // we don't pass in the left and up values because those are the diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index e94d5ea9..4b309cd7 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -13,12 +13,16 @@ class MouseKeys_ : public KaleidoscopePlugin { static uint16_t speedDelay; static uint8_t accelSpeed; static uint16_t accelDelay; + static uint8_t wheelSpeed; + static uint16_t wheelDelay; private: static uint8_t mouseMoveIntent; static uint32_t endTime; static uint32_t accelEndTime; + static uint32_t wheelEndTime; + static void scrollWheel(uint8_t keyCode); static void loopHook(bool postClear); static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); }; diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index de4d82c0..4b998dc0 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -15,6 +15,7 @@ #define KEY_MOUSE_BUTTON B0010000 #define KEY_MOUSE_WARP B0100000 #define KEY_MOUSE_WARP_END B0010000 +#define KEY_MOUSE_WHEEL B1000000 #define Key_mouseWarpNW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } @@ -32,8 +33,8 @@ #define Key_mouseDnL (Key) { KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseDn (Key) { KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseDnR (Key) { KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } -#define Key_mouseScrollUp -#define Key_mouseScrollDn +#define Key_mouseScrollUp (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseScrollDn (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseScrollL #define Key_mouseScrollR #define Key_mouseBtnL (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } From 8786adbc84740afce66a9c6a9d6f1598376763eb Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 3 Jun 2017 22:47:24 -0700 Subject: [PATCH 15/59] astyle with current project style guidelines --- src/Kaleidoscope-MouseKeys.cpp | 139 ++++++++++++++++----------------- src/Kaleidoscope-MouseKeys.h | 32 ++++---- src/MouseWrapper.cpp | 114 +++++++++++++-------------- src/MouseWrapper.h | 40 +++++----- 4 files changed, 162 insertions(+), 163 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index d330c051..2f4f6926 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -20,100 +20,99 @@ uint32_t MouseKeys_::endTime; uint32_t MouseKeys_::wheelEndTime; void MouseKeys_::scrollWheel(uint8_t keyCode) { - if (millis() < wheelEndTime) - return; + if (millis() < wheelEndTime) + return; - wheelEndTime = millis() + wheelDelay; + wheelEndTime = millis() + wheelDelay; - if (keyCode & KEY_MOUSE_UP) - Mouse.move(0, 0, wheelSpeed); - else if (keyCode & KEY_MOUSE_DOWN) - Mouse.move(0, 0, -wheelSpeed); + if (keyCode & KEY_MOUSE_UP) + Mouse.move(0, 0, wheelSpeed); + else if (keyCode & KEY_MOUSE_DOWN) + Mouse.move(0, 0, -wheelSpeed); } void MouseKeys_::loopHook(bool postClear) { - if (postClear) { - mouseMoveIntent = 0; - return; - } + if (postClear) { + mouseMoveIntent = 0; + return; + } - if (mouseMoveIntent == 0) { - MouseWrapper.accelStep = 0; - endTime = 0; - accelEndTime = 0; - return; - } + if (mouseMoveIntent == 0) { + MouseWrapper.accelStep = 0; + endTime = 0; + accelEndTime = 0; + return; + } - if (millis() < endTime) - return; + if (millis() < endTime) + return; - endTime = millis() + speedDelay; + endTime = millis() + speedDelay; - int8_t moveX = 0, moveY = 0; + int8_t moveX = 0, moveY = 0; - if (millis() >= accelEndTime) { - if (MouseWrapper.accelStep < 255 - accelSpeed) - MouseWrapper.accelStep += accelSpeed; - } + if (millis() >= accelEndTime) { + if (MouseWrapper.accelStep < 255 - accelSpeed) + MouseWrapper.accelStep += accelSpeed; + } - if (mouseMoveIntent & KEY_MOUSE_UP) - moveY = -speed; - else if (mouseMoveIntent & KEY_MOUSE_DOWN) - moveY = speed; + if (mouseMoveIntent & KEY_MOUSE_UP) + moveY = -speed; + else if (mouseMoveIntent & KEY_MOUSE_DOWN) + moveY = speed; - if (mouseMoveIntent & KEY_MOUSE_LEFT) - moveX = -speed; - else if (mouseMoveIntent & KEY_MOUSE_RIGHT) - moveX = speed; + if (mouseMoveIntent & KEY_MOUSE_LEFT) + moveX = -speed; + else if (mouseMoveIntent & KEY_MOUSE_RIGHT) + moveX = speed; - MouseWrapper.move(moveX, moveY); + MouseWrapper.move(moveX, moveY); } Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) { - if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) - return mappedKey; - - if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { - uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; - - if (key_toggled_on(keyState)) { - MouseWrapper.press_button(button); - } else if (key_toggled_off(keyState)) { - MouseWrapper.release_button(button); - } - } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { - if (key_toggled_on(keyState)) { - endTime = millis() + speedDelay; - accelEndTime = millis() + accelDelay; - wheelEndTime = 0; - } - if (key_is_pressed(keyState)) { - if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { - scrollWheel (mappedKey.keyCode); - } - else - mouseMoveIntent |= mappedKey.keyCode; - } - } else if (key_toggled_on(keyState)) { - if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { - // we don't pass in the left and up values because those are the - // default, "no-op" conditionals - MouseWrapper.warp( ((mappedKey.keyCode & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) | - ((mappedKey.keyCode & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) | - ((mappedKey.keyCode & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00) ); - } + if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) + return mappedKey; + + if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { + uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; + + if (key_toggled_on(keyState)) { + MouseWrapper.press_button(button); + } else if (key_toggled_off(keyState)) { + MouseWrapper.release_button(button); + } + } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { + if (key_toggled_on(keyState)) { + endTime = millis() + speedDelay; + accelEndTime = millis() + accelDelay; + wheelEndTime = 0; + } + if (key_is_pressed(keyState)) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + scrollWheel(mappedKey.keyCode); + } else + mouseMoveIntent |= mappedKey.keyCode; + } + } else if (key_toggled_on(keyState)) { + if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { + // we don't pass in the left and up values because those are the + // default, "no-op" conditionals + MouseWrapper.warp(((mappedKey.keyCode & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00)); } + } - return Key_NoKey; + return Key_NoKey; } MouseKeys_::MouseKeys_(void) { } void -MouseKeys_::begin (void) { - event_handler_hook_use(eventHandlerHook); - loop_hook_use(loopHook); +MouseKeys_::begin(void) { + event_handler_hook_use(eventHandlerHook); + loop_hook_use(loopHook); } MouseKeys_ MouseKeys; diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 4b309cd7..ee71fb0d 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -4,27 +4,27 @@ #include "MouseKeyDefs.h" class MouseKeys_ : public KaleidoscopePlugin { - public: - MouseKeys_ (void); + public: + MouseKeys_(void); - virtual void begin(void) final; + virtual void begin(void) final; - static uint8_t speed; - static uint16_t speedDelay; - static uint8_t accelSpeed; - static uint16_t accelDelay; - static uint8_t wheelSpeed; - static uint16_t wheelDelay; + static uint8_t speed; + static uint16_t speedDelay; + static uint8_t accelSpeed; + static uint16_t accelDelay; + static uint8_t wheelSpeed; + static uint16_t wheelDelay; private: - static uint8_t mouseMoveIntent; - static uint32_t endTime; - static uint32_t accelEndTime; - static uint32_t wheelEndTime; + static uint8_t mouseMoveIntent; + static uint32_t endTime; + static uint32_t accelEndTime; + static uint32_t wheelEndTime; - static void scrollWheel(uint8_t keyCode); - static void loopHook(bool postClear); - static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); + static void scrollWheel(uint8_t keyCode); + static void loopHook(bool postClear); + static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); }; extern MouseKeys_ MouseKeys; diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 553a5356..b6495cc7 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -13,102 +13,102 @@ boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; MouseWrapper_::MouseWrapper_(void) { - Mouse.begin(); - AbsoluteMouse.begin(); + Mouse.begin(); + AbsoluteMouse.begin(); } void MouseWrapper_::press_button(uint8_t button) { - Mouse.press(button); - end_warping(); + Mouse.press(button); + end_warping(); } void MouseWrapper_::release_button(uint8_t button) { - Mouse.release(button); + Mouse.release(button); } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { - uint16_t x_center = left + width/2; - uint16_t y_center = top + height/2; - AbsoluteMouse.moveTo(x_center, y_center); + uint16_t x_center = left + width/2; + uint16_t y_center = top + height/2; + AbsoluteMouse.moveTo(x_center, y_center); } void MouseWrapper_::begin_warping() { - section_left = WARP_ABS_LEFT; - section_top = WARP_ABS_TOP; - next_width = MAX_WARP_WIDTH; - next_height = MAX_WARP_HEIGHT; - is_warping = true; + section_left = WARP_ABS_LEFT; + section_top = WARP_ABS_TOP; + next_width = MAX_WARP_WIDTH; + next_height = MAX_WARP_HEIGHT; + is_warping = true; } void MouseWrapper_::end_warping() { - is_warping= false; + is_warping= false; } void MouseWrapper_::warp(uint8_t warp_cmd) { - if (is_warping == false) { - begin_warping(); - } + if (is_warping == false) { + begin_warping(); + } - if (warp_cmd & WARP_END) { - end_warping(); - return; - } + if (warp_cmd & WARP_END) { + end_warping(); + return; + } - next_width = next_width/2; - next_height = next_height/2; + next_width = next_width/2; + next_height = next_height/2; - if (warp_cmd & WARP_UP) { + if (warp_cmd & WARP_UP) { // Serial.print(" - up "); - } else if (warp_cmd & WARP_DOWN) { + } else if (warp_cmd & WARP_DOWN) { // Serial.print(" - down "); - section_top = section_top + next_height; - } + section_top = section_top + next_height; + } - if (warp_cmd & WARP_LEFT) { - // Serial.print(" - left "); - } else if (warp_cmd & WARP_RIGHT) { - // Serial.print(" - right "); - section_left = section_left + next_width; - } + if (warp_cmd & WARP_LEFT) { + // Serial.print(" - left "); + } else if (warp_cmd & WARP_RIGHT) { + // Serial.print(" - right "); + section_left = section_left + next_width; + } - warp_jump(section_left, section_top, next_height,next_width); + warp_jump(section_left, section_top, next_height,next_width); } // cubic wave function based on code from FastLED uint8_t MouseWrapper_::acceleration(uint8_t cycles) { - uint8_t i = cycles; + uint8_t i = cycles; - if( i & 0x80) { - i = 255 - i; - } + if (i & 0x80) { + i = 255 - i; + } - i = i << 1; + i = i << 1; - uint8_t ii = (i*i) >> 8; - uint8_t iii = (ii*i) >> 8; + uint8_t ii = (i*i) >> 8; + uint8_t iii = (ii*i) >> 8; - i = (( (3 * (uint16_t)(ii)) - ( 2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; + i = (((3 * (uint16_t)(ii)) - (2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; - if (i > ACCELERATION_CEIL) { - i = ACCELERATION_CEIL; - } - return i; + if (i > ACCELERATION_CEIL) { + i = ACCELERATION_CEIL; + } + return i; } void MouseWrapper_::move(int8_t x, int8_t y) { - int16_t moveX =0; - int16_t moveY = 0; - if (x != 0 ) { - moveX = (x * acceleration(accelStep)); - } - if (y != 0) { - moveY = (y * acceleration(accelStep)); - } - - end_warping(); - Mouse.move(moveX, moveY, 0); + int16_t moveX =0; + int16_t moveY = 0; + if (x != 0) { + moveX = (x * acceleration(accelStep)); + } + if (y != 0) { + moveY = (y * acceleration(accelStep)); + } + + end_warping(); + Mouse.move(moveX, moveY, 0); } MouseWrapper_ MouseWrapper; diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index fc2f8126..4bb82b1a 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -28,26 +28,26 @@ #define ACCELERATION_CEIL 50 class MouseWrapper_ { - public: - MouseWrapper_(void); - - static void move(int8_t x, int8_t y); - static void warp(uint8_t warp_cmd); - static void press_button(uint8_t button); - static void release_button(uint8_t button); - static uint8_t accelStep; - - private: - static uint16_t next_width; - static uint16_t next_height; - static uint16_t section_top; - static uint16_t section_left; - static boolean is_warping; - - static uint8_t acceleration(uint8_t cycles); - static void begin_warping(); - static void end_warping(); - static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); + public: + MouseWrapper_(void); + + static void move(int8_t x, int8_t y); + static void warp(uint8_t warp_cmd); + static void press_button(uint8_t button); + static void release_button(uint8_t button); + static uint8_t accelStep; + + private: + static uint16_t next_width; + static uint16_t next_height; + static uint16_t section_top; + static uint16_t section_left; + static boolean is_warping; + + static uint8_t acceleration(uint8_t cycles); + static void begin_warping(); + static void end_warping(); + static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); }; extern MouseWrapper_ MouseWrapper; From 20b52f91bfedb3afbe6672f9bbc800d1d3f9235b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 3 Jun 2017 23:20:44 -0700 Subject: [PATCH 16/59] Add build infrastructure --- .travis.yml | 21 +++++++++++++++++++++ Makefile | 12 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .travis.yml create mode 100644 Makefile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e7030acf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +dist: trusty +sudo: false +os: + - linux +install: + - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Arduino-Boards hardware/keyboardio/avr +script: + - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware +notifications: + irc: + channels: + - "chat.freenode.net#keyboardio" + use_notice: true + skip_join: true + template: + - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" + email: + on_success: change + on_failure: change +cache: + ccache: true diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..9ce0c4a9 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +# This stub makefile for a Kaleidoscope plugin pulls in +# all targets from the Kaleidoscope-Plugin library + +MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build +UNAME_S := $(shell uname -s) + +BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware +ifeq ($(UNAME_S),Darwin) +BOARD_HARDWARE_PATH ?= $(HOME)/Library/Arduino/hardware +endif + +include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/*.mk From 78b3739a4edc15ecc2f44273697a2c25704d7f65 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 3 Jun 2017 23:41:43 -0700 Subject: [PATCH 17/59] partially satisfying the cpplint complaints --- src/Kaleidoscope-MouseKeys.cpp | 3 ++- src/MouseKeyDefs.h | 8 ++++---- src/MouseWrapper.cpp | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 2f4f6926..7a6017b6 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -90,8 +90,9 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS if (key_is_pressed(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { scrollWheel(mappedKey.keyCode); - } else + } else { mouseMoveIntent |= mappedKey.keyCode; + } } } else if (key_toggled_on(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 4b998dc0..83ca84d3 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -1,11 +1,11 @@ #pragma once -#define IS_MOUSE_KEY B00010000 +#define IS_MOUSE_KEY B00010000 // Synthetic, not internal -#define KEY_MOUSE_BTN_L 0x01 // Synthetic key -#define KEY_MOUSE_BTN_M 0x02 // Synthetic key -#define KEY_MOUSE_BTN_R 0x03 // Synthetic key +#define KEY_MOUSE_BTN_L 0x01 // Synthetic key +#define KEY_MOUSE_BTN_M 0x02 // Synthetic key +#define KEY_MOUSE_BTN_R 0x03 // Synthetic key #define KEY_MOUSE_UP B0000001 diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index b6495cc7..2e09a600 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -20,7 +20,6 @@ MouseWrapper_::MouseWrapper_(void) { void MouseWrapper_::press_button(uint8_t button) { Mouse.press(button); end_warping(); - } void MouseWrapper_::release_button(uint8_t button) { From 5de9053fd27cbda060cc611603d64d5aa02bde35 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 3 Jun 2017 23:42:34 -0700 Subject: [PATCH 18/59] Make cpplint happy --- src/Kaleidoscope-MouseKeys.h | 2 +- src/MouseWrapper.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index ee71fb0d..255a0888 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -7,7 +7,7 @@ class MouseKeys_ : public KaleidoscopePlugin { public: MouseKeys_(void); - virtual void begin(void) final; + void begin(void) final; static uint8_t speed; static uint16_t speedDelay; diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 2e09a600..5aa522b6 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -27,8 +27,8 @@ void MouseWrapper_::release_button(uint8_t button) { } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { - uint16_t x_center = left + width/2; - uint16_t y_center = top + height/2; + uint16_t x_center = left + width / 2; + uint16_t y_center = top + height / 2; AbsoluteMouse.moveTo(x_center, y_center); } @@ -41,7 +41,7 @@ void MouseWrapper_::begin_warping() { } void MouseWrapper_::end_warping() { - is_warping= false; + is_warping = false; } void MouseWrapper_::warp(uint8_t warp_cmd) { @@ -54,8 +54,8 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { return; } - next_width = next_width/2; - next_height = next_height/2; + next_width = next_width / 2; + next_height = next_height / 2; if (warp_cmd & WARP_UP) { // Serial.print(" - up "); @@ -71,7 +71,7 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { section_left = section_left + next_width; } - warp_jump(section_left, section_top, next_height,next_width); + warp_jump(section_left, section_top, next_height, next_width); } // cubic wave function based on code from FastLED @@ -84,8 +84,8 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { i = i << 1; - uint8_t ii = (i*i) >> 8; - uint8_t iii = (ii*i) >> 8; + uint8_t ii = (i * i) >> 8; + uint8_t iii = (ii * i) >> 8; i = (((3 * (uint16_t)(ii)) - (2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; @@ -97,7 +97,7 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { void MouseWrapper_::move(int8_t x, int8_t y) { - int16_t moveX =0; + int16_t moveX = 0; int16_t moveY = 0; if (x != 0) { moveX = (x * acceleration(accelStep)); From ab9127d8ea606dd997ffea5d9c4ebc663bc8a715 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 16 Jun 2017 15:24:40 +0200 Subject: [PATCH 19/59] Fill out the paragraph= property in library.properties Signed-off-by: Gergely Nagy --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index d4df7f02..37481310 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=0.0.1 author=Jesse Vincent maintainer=Jesse Vincent sentence=Mouse keys for Kaleidoscope. -paragraph=... +paragraph=Simulate a mouse with keys on a regular keyboard. category=Communication url=https://github.com/keyboardio/Kaleidoscope-MouseKeys architectures=avr From 964b6d2d4a4ac59d8a2b6421bfccffb07c0c814f Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 16 Jun 2017 16:14:42 +0200 Subject: [PATCH 20/59] README.md: Document the keys provided Signed-off-by: Gergely Nagy --- README.md | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce8ad7e8..bc883b29 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,139 @@ # Kaleidoscope-MouseKeys -This is a plugin for [Kaleidoscope][fw], that adds support for mouse keys. +![status][st:stable] [![Build Status][travis:image]][travis:status] - [fw]: https://github.com/keyboardio/Kaleidoscope + [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys.svg?branch=master + [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys + + [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 + [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 + [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 + +Have you ever wanted to control the mouse cursor from the comfort of your +keyboard? With this plugin, you can. While it may not replace the mouse in all +situations, there are plenty of cases where one will not have to lift their +hands off the keyboard just to nudge the mouse cursor away a little. + +Of course, there are a lot more one can do with the plugin than to nudge the +cursor! Mouse keys are provided for all four *and* diagonal movement; mouse +buttons; and a unique warping mechanism too. And not only these: the speed of +the cursor, the mouse wheel, and that of acceleration can all be configured to +match one's desired behaviour. + +## Using the plugin + +To use the plugin, simply include the header, make sure the `MouseKeys` object +is properly used, and place mouse keys on your keymap. It is best illustrated +with an example: + +```c++ +#include +#include + +// Somewhere in the keymap: +Key_mouseUp, Key_mouseDn, Key_mouseL, Key_mouseR, +Key_mouseBtnL, Key_mouseBtnR + +void setup() { + Kaleidoscope.use(&MouseKeys); + + Kaleidoscope.setup (); +} +``` + +## Keys provided by the plugin + +The plugin provides a number of keys one can put on the keymap, that allow +control of the mouse. They can be divided into a few groups: + +### Cursor movement + +The simplest set of keys are the mouse cursor movement keys. These move the +cursor one direction or the other, with speed and acceleration factored in. When +a mouse cursor movement key is held down, it will move `.speed` pixels each +`.speedDelay` milliseconds without acceleration. But when `.accelSpeed` is +non-zero (and it is not zero by default), the speed will increase by +`.accelSpeed` every `.accelDelay` milliseconds. Thus, unless configured +otherwise, holding a direction will move that way at increasing speed. + +One can hold more than one key down at the same time, and the cursor will move +towards a direction that is the combination of the keys held. For example, +holding the "mouse up" and "mouse right" keys together will move the cursor +diagonally up and right. + +The cursor movement keys are as follows: + +* `Key_mouseUp`, `Key_mouseDn`, `Key_mouseL`, `Key_mouseR`: Move the cursor up, + down, left, or right, respectively. +* `Key_mouseUpL`, `Key_mouseUpR`, `Key_mouseDnL`, `Key_mouseDnR`: Move the + cursor up-left, up-right, down-left, down-right, respectively. + +### Scroll wheel + +Controlling the scroll wheel is similarly simple. It does not have acceleration, +but one can control the speed with the `.wheelSpeed` and `.wheelDelay` +properties (see below). + +* `Key_mouseScrollUp`, `Key_mouseScrollDn`: Scroll the mouse wheel up or down, + respectively. + +### Buttons + +Buttons are even simpler than movement: there is no movement speed, nor +acceleration involved. One just presses them. + +* `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`: The left, middle, and right + mouse buttons, respectively. + +### Warping + +Warping is one of the most interesting features of the plugin, and is a feature +unique to Kaleidoscope, as far as we can tell. The warping keys position the +mouse cursor within a quadrant of the screen on first press, and any subsequent +taps will warp within the previously selected quadrant. For example, pressing +the north-west warp key twice will first jump to the middle of the north-west +quadrant of your screen, then select the north-west quadrant of that, and jump +to the middle of it. + +To stop warping, use any other mouse key, or hit the "warp end" key. + +This features works out of the box on Windows and OSX. On Linux, a patch exists, +but has not been finalised and merged yet. + +The warping keys are the following: + +* `Key_mouseWarpNW`, `Key_mouseWarpNE`, `Key_mouseWarpSW`, `Key_mouseWarpSE`: + Warp towards the north-west, north-east, south-west, or south-east quadrants, + respectively. +* `Key_mouseWarpEnd`: End the warping sequence, resetting it to the default + state. Using any of the warping keys after this will start from the whole + screen again. + +## Plugin methods + +The plugin provides a `MouseKeys` object, with the following methods and +properties available: + +### `.speed` and `.speedDelay` + +> These two control the speed of the mouse cursor, when a movement key is held. +> The former, `.speed`, controls the amount of pixels the cursor moves, when it +> has to move, and defaults to 1. The latter, `.speedDelay` is the amount of +> time - in milliseconds - to wait between two movements, and defaults to 0, no +> delay. + +### `.accelSpeed` and `.accelDelay` + +> These two properties control the speed of acceleration. The former, +> `.accelSpeed`, controls how much the speed shall be increased at each step, +> while the second, `.accelDelay`, controls how often (in milliseconds) +> acceleration should be applied. +> +> They default to 1 pixel and 50 milliseconds, respectively. + +### `.wheelSpeed` and `.wheelDelay` + +> The last two properties supported by the plugin control the mouse wheel +> scrolling speed. The former, `.wheelSpeed`, controls the amount of ticks the +> wheel shall scroll, and defaults to 1. The second, `.wheelDelay`, controls the +> delay between two scroll events, and defaults to 50 milliseconds. From 0808057864307ffdf02867eb8eac8edd30a26b57 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 17 Jun 2017 07:56:33 +0200 Subject: [PATCH 21/59] Documentation clarification Fixes #4. Signed-off-by: Gergely Nagy --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bc883b29..a0f82910 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ match one's desired behaviour. ## Using the plugin -To use the plugin, simply include the header, make sure the `MouseKeys` object -is properly used, and place mouse keys on your keymap. It is best illustrated -with an example: +To use the plugin, simply include the header in your Sketch, tell the firmware +to use the `MouseKeys` object, and place mouse keys on your keymap. It is best +illustrated with an example: ```c++ #include @@ -52,7 +52,8 @@ The simplest set of keys are the mouse cursor movement keys. These move the cursor one direction or the other, with speed and acceleration factored in. When a mouse cursor movement key is held down, it will move `.speed` pixels each `.speedDelay` milliseconds without acceleration. But when `.accelSpeed` is -non-zero (and it is not zero by default), the speed will increase by +non-zero (and it is not zero by default, +see [below](#accelspeed-and-acceldelay)), the speed will increase by `.accelSpeed` every `.accelDelay` milliseconds. Thus, unless configured otherwise, holding a direction will move that way at increasing speed. From 2d7388e42fee27f16e6e2382a6495509d559eaa1 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 24 Jul 2017 13:49:10 -0700 Subject: [PATCH 22/59] Update to 'new' keyswitch state API --- src/Kaleidoscope-MouseKeys.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 7a6017b6..5f49678c 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -76,25 +76,25 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; - if (key_toggled_on(keyState)) { + if (keyToggledOn(keyState)) { MouseWrapper.press_button(button); - } else if (key_toggled_off(keyState)) { + } else if (keyToggledOff(keyState)) { MouseWrapper.release_button(button); } } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) { - if (key_toggled_on(keyState)) { + if (keyToggledOn(keyState)) { endTime = millis() + speedDelay; accelEndTime = millis() + accelDelay; wheelEndTime = 0; } - if (key_is_pressed(keyState)) { + if (keyIsPressed(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { scrollWheel(mappedKey.keyCode); } else { mouseMoveIntent |= mappedKey.keyCode; } } - } else if (key_toggled_on(keyState)) { + } else if (keyToggledOn(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { // we don't pass in the left and up values because those are the // default, "no-op" conditionals From 2c08dd867bf1ed059528996c1d2e324d807fb571 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 24 Jul 2017 15:56:34 -0700 Subject: [PATCH 23/59] camelCasing press_button to pressButton --- src/Kaleidoscope-MouseKeys.cpp | 2 +- src/MouseWrapper.cpp | 2 +- src/MouseWrapper.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 5f49678c..4b7041b2 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -77,7 +77,7 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; if (keyToggledOn(keyState)) { - MouseWrapper.press_button(button); + MouseWrapper.pressButton(button); } else if (keyToggledOff(keyState)) { MouseWrapper.release_button(button); } diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 5aa522b6..697def1d 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -17,7 +17,7 @@ MouseWrapper_::MouseWrapper_(void) { AbsoluteMouse.begin(); } -void MouseWrapper_::press_button(uint8_t button) { +void MouseWrapper_::pressButton(uint8_t button) { Mouse.press(button); end_warping(); } diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 4bb82b1a..86079b52 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -33,7 +33,7 @@ class MouseWrapper_ { static void move(int8_t x, int8_t y); static void warp(uint8_t warp_cmd); - static void press_button(uint8_t button); + static void pressButton(uint8_t button); static void release_button(uint8_t button); static uint8_t accelStep; From b87014c544e2f4f2f7ee3905d1c5becb637e54c1 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 25 Jul 2017 11:09:58 -0700 Subject: [PATCH 24/59] Port to the new HID facade --- src/Kaleidoscope-MouseKeys.cpp | 4 ++-- src/MouseWrapper.cpp | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 4b7041b2..927d2e9d 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -26,9 +26,9 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) { wheelEndTime = millis() + wheelDelay; if (keyCode & KEY_MOUSE_UP) - Mouse.move(0, 0, wheelSpeed); + kaleidoscope::hid::moveMouse(0, 0, wheelSpeed); else if (keyCode & KEY_MOUSE_DOWN) - Mouse.move(0, 0, -wheelSpeed); + kaleidoscope::hid::moveMouse(0, 0, -wheelSpeed); } void MouseKeys_::loopHook(bool postClear) { diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 697def1d..a0b7e993 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -3,6 +3,7 @@ // // #include "MouseWrapper.h" +#include "kaleidoscope/hid.h" uint16_t MouseWrapper_::next_width; uint16_t MouseWrapper_::next_height; @@ -13,23 +14,23 @@ boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; MouseWrapper_::MouseWrapper_(void) { - Mouse.begin(); - AbsoluteMouse.begin(); + kaleidoscope::hid::initializeMouse(); + kaleidoscope::hid::initializeAbsoluteMouse(); } void MouseWrapper_::pressButton(uint8_t button) { - Mouse.press(button); + kaleidoscope::hid::pressMouseButtons(button); end_warping(); } void MouseWrapper_::release_button(uint8_t button) { - Mouse.release(button); + kaleidoscope::hid::releaseMouseButtons(button); } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { uint16_t x_center = left + width / 2; uint16_t y_center = top + height / 2; - AbsoluteMouse.moveTo(x_center, y_center); + kaleidoscope::hid::moveAbsoluteMouseTo(x_center, y_center, 0); } void MouseWrapper_::begin_warping() { @@ -107,7 +108,7 @@ void MouseWrapper_::move(int8_t x, int8_t y) { } end_warping(); - Mouse.move(moveX, moveY, 0); + kaleidoscope::hid::moveMouse(moveX, moveY, 0); } MouseWrapper_ MouseWrapper; From b19fd73f1ff0df8a2f96be78a1cddff1fdc3ccd4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 25 Jul 2017 11:20:28 -0700 Subject: [PATCH 25/59] astyle --- src/MouseWrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index a0b7e993..4da39c0a 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -14,17 +14,17 @@ boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; MouseWrapper_::MouseWrapper_(void) { - kaleidoscope::hid::initializeMouse(); - kaleidoscope::hid::initializeAbsoluteMouse(); + kaleidoscope::hid::initializeMouse(); + kaleidoscope::hid::initializeAbsoluteMouse(); } void MouseWrapper_::pressButton(uint8_t button) { - kaleidoscope::hid::pressMouseButtons(button); + kaleidoscope::hid::pressMouseButtons(button); end_warping(); } void MouseWrapper_::release_button(uint8_t button) { - kaleidoscope::hid::releaseMouseButtons(button); + kaleidoscope::hid::releaseMouseButtons(button); } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { From 5f3b3486ed8cccb6c9830b6ba0607b7768aca999 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 25 Jul 2017 15:52:17 -0700 Subject: [PATCH 26/59] Update Makefile to fix OS X build --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9ce0c4a9..2b04143a 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,10 @@ MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build UNAME_S := $(shell uname -s) -BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware ifeq ($(UNAME_S),Darwin) -BOARD_HARDWARE_PATH ?= $(HOME)/Library/Arduino/hardware +BOARD_HARDWARE_PATH ?= $(HOME)/Documents/Arduino/hardware +else +BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware endif -include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/*.mk +include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/rules.mk From ef47dc54479102985532711f4478e936efd35715 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 26 Jul 2017 20:31:55 -0700 Subject: [PATCH 27/59] switch mouse button constants to those defined in the HID library. This is a leakage from the KeyboardioHID library --- src/MouseKeyDefs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 83ca84d3..0485db12 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -3,9 +3,9 @@ #define IS_MOUSE_KEY B00010000 // Synthetic, not internal -#define KEY_MOUSE_BTN_L 0x01 // Synthetic key -#define KEY_MOUSE_BTN_M 0x02 // Synthetic key -#define KEY_MOUSE_BTN_R 0x03 // Synthetic key +#define KEY_MOUSE_BTN_L MOUSE_LEFT // Synthetic key +#define KEY_MOUSE_BTN_M MOUSE_MIDDLE // Synthetic key +#define KEY_MOUSE_BTN_R MOUSE_RIGHT // Synthetic key #define KEY_MOUSE_UP B0000001 From 5e79b16923f38c55d13726c6921d88dc87be0a19 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 26 Jul 2017 20:33:32 -0700 Subject: [PATCH 28/59] switch around our constants so we have more room for mouse buttons in the bit vector --- src/MouseKeyDefs.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 0485db12..9f5bdbc9 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -12,10 +12,11 @@ #define KEY_MOUSE_DOWN B0000010 #define KEY_MOUSE_LEFT B0000100 #define KEY_MOUSE_RIGHT B0001000 -#define KEY_MOUSE_BUTTON B0010000 +#define KEY_MOUSE_WHEEL B0010000 #define KEY_MOUSE_WARP B0100000 -#define KEY_MOUSE_WARP_END B0010000 -#define KEY_MOUSE_WHEEL B1000000 +#define KEY_MOUSE_WARP_END B1000000 +// all buttons end warp. also, we're out of bits +#define KEY_MOUSE_BUTTON B1000000 #define Key_mouseWarpNW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } From 65fee12dad3504c28c10148bcd357faa09c0b357 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 28 Jul 2017 17:12:43 +0200 Subject: [PATCH 29/59] Move Mouse & AbsoluteMouse initialization to MouseWrapper.begin To avoid issues with static initialization order, move the Mouse & AbsoluteMouse initialization from the MouseWrapper constructor to MouseWrapper.begin, which will be called from MouseKeys.begin. Thus, user code does not need to change. This fixes keyboardio/Kaleidoscope#140. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 1 + src/MouseWrapper.cpp | 3 +++ src/MouseWrapper.h | 1 + 3 files changed, 5 insertions(+) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 927d2e9d..70572429 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -112,6 +112,7 @@ MouseKeys_::MouseKeys_(void) { void MouseKeys_::begin(void) { + MouseWrapper.begin(); event_handler_hook_use(eventHandlerHook); loop_hook_use(loopHook); } diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 4da39c0a..f5aec4c3 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -14,6 +14,9 @@ boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; MouseWrapper_::MouseWrapper_(void) { +} + +void MouseWrapper_::begin(void) { kaleidoscope::hid::initializeMouse(); kaleidoscope::hid::initializeAbsoluteMouse(); } diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 86079b52..b1c0cefa 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -31,6 +31,7 @@ class MouseWrapper_ { public: MouseWrapper_(void); + static void begin(void); static void move(int8_t x, int8_t y); static void warp(uint8_t warp_cmd); static void pressButton(uint8_t button); From 5f4ee21790c56d0e8d65556698c4c00b927b5a24 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Mon, 7 Aug 2017 16:24:24 -0600 Subject: [PATCH 30/59] Upgraded mouse acceleration. Uses mickeys (1/16th subpixel units) now instead of pixels. Much smoother! Added "speedLimit" config var to set maximum cursor speed. Ensured default values are sane. --- src/Kaleidoscope-MouseKeys.cpp | 4 ++-- src/MouseWrapper.cpp | 38 ++++++++++++++++++++-------------- src/MouseWrapper.h | 6 +----- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 70572429..b3e5b733 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -7,10 +7,10 @@ uint8_t MouseKeys_::mouseMoveIntent; uint8_t MouseKeys_::speed = 1; -uint16_t MouseKeys_::speedDelay = 0; +uint16_t MouseKeys_::speedDelay = 1; uint8_t MouseKeys_::accelSpeed = 1; -uint16_t MouseKeys_::accelDelay = 50; +uint16_t MouseKeys_::accelDelay = 64; uint8_t MouseKeys_::wheelSpeed = 1; uint16_t MouseKeys_::wheelDelay = 50; diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index f5aec4c3..15c6a8c6 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -12,6 +12,7 @@ uint16_t MouseWrapper_::section_left; boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; +uint8_t MouseWrapper_::speedLimit = 127; MouseWrapper_::MouseWrapper_(void) { } @@ -79,23 +80,20 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { } // cubic wave function based on code from FastLED +// produces a shape similar to a sine curve from 0 to 255 +// (slow growth at 0, fast growth in the middle, slow growth at 255) +// http://www.wolframalpha.com/input/?i=((3((x)**2)%2F256)+-+((2((x)(x)(x%2F256))%2F256)))+%2B+1 uint8_t MouseWrapper_::acceleration(uint8_t cycles) { - uint8_t i = cycles; + uint16_t i = cycles; - if (i & 0x80) { - i = 255 - i; - } - - i = i << 1; + uint16_t ii = (i * i) >> 8; + uint16_t iii = (ii * i) >> 8; - uint8_t ii = (i * i) >> 8; - uint8_t iii = (ii * i) >> 8; + i = ((3 * ii) - (2 * iii)) + 1; - i = (((3 * (uint16_t)(ii)) - (2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR; + // Just in case (may go up to 256 at peak) + if (i > 255) i = 255; - if (i > ACCELERATION_CEIL) { - i = ACCELERATION_CEIL; - } return i; } @@ -103,15 +101,25 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX = 0; int16_t moveY = 0; + static int8_t remainderX = 0; + static int8_t remainderY = 0; if (x != 0) { - moveX = (x * acceleration(accelStep)); + moveX = remainderX + (x * acceleration(accelStep)); + if (moveX > (int16_t)speedLimit) moveX = speedLimit; + else if (moveX < -(int16_t)speedLimit) moveX = -speedLimit; } if (y != 0) { - moveY = (y * acceleration(accelStep)); + moveY = remainderY + (y * acceleration(accelStep)); + if (moveY > (int16_t)speedLimit) moveY = speedLimit; + else if (moveY < -(int16_t)speedLimit) moveY = -speedLimit; } end_warping(); - kaleidoscope::hid::moveMouse(moveX, moveY, 0); + // move by whole pixels, not subpixels + kaleidoscope::hid::moveMouse(moveX>>4, moveY>>4, 0); + // save leftover subpixel movements for later + remainderX = moveX & 0x0f; + remainderY = moveY & 0x0f; } MouseWrapper_ MouseWrapper; diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index b1c0cefa..99a9adbd 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -22,11 +22,6 @@ // Mouse acceleration -// we want the whole s curve, not just the bit -// that's usually above the x and y axes; -#define ACCELERATION_FLOOR 2 -#define ACCELERATION_CEIL 50 - class MouseWrapper_ { public: MouseWrapper_(void); @@ -37,6 +32,7 @@ class MouseWrapper_ { static void pressButton(uint8_t button); static void release_button(uint8_t button); static uint8_t accelStep; + static uint8_t speedLimit; private: static uint16_t next_width; From ff95f30ade92a6614b1c831ad3f6f4ec45e17807 Mon Sep 17 00:00:00 2001 From: Selene Scriven Date: Mon, 7 Aug 2017 18:27:23 -0600 Subject: [PATCH 31/59] Fix style issue pointed out by travis --- src/MouseWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 15c6a8c6..9476a237 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -116,7 +116,7 @@ void MouseWrapper_::move(int8_t x, int8_t y) { end_warping(); // move by whole pixels, not subpixels - kaleidoscope::hid::moveMouse(moveX>>4, moveY>>4, 0); + kaleidoscope::hid::moveMouse(moveX >> 4, moveY >> 4, 0); // save leftover subpixel movements for later remainderX = moveX & 0x0f; remainderY = moveY & 0x0f; From b249c505057795498bced9659513ead7ef653b5a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 17 Aug 2017 12:29:53 +0200 Subject: [PATCH 32/59] Stop using deprecated interfaces Use `Kaleidoscope.useEventHandlerHook` and `Kaleidoscope.useLoopHook` instead of the deprecated `event_handler_hook_use` and `loop_hook_use` interfaces. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index b3e5b733..778e3eb6 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -113,8 +113,8 @@ MouseKeys_::MouseKeys_(void) { void MouseKeys_::begin(void) { MouseWrapper.begin(); - event_handler_hook_use(eventHandlerHook); - loop_hook_use(loopHook); + Kaleidoscope.useEventHandlerHook(eventHandlerHook); + Kaleidoscope.useLoopHook(loopHook); } MouseKeys_ MouseKeys; From 4b3aa0127a398cda596a4307bfb47b4c7c8bc758 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 21 Aug 2017 22:24:54 -0700 Subject: [PATCH 33/59] Update Makefile with OSX fixes and new paths --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2b04143a..8f830f44 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ # This stub makefile for a Kaleidoscope plugin pulls in # all targets from the Kaleidoscope-Plugin library -MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) -BOARD_HARDWARE_PATH ?= $(HOME)/Documents/Arduino/hardware +SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino/ else -BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware +SKETCHBOOK_DIR ?= $(HOME)/Arduino endif -include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/rules.mk +BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware +KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/ +include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk From c2a51487c6d0a9fb918bb6f4db443d538f7fcff5 Mon Sep 17 00:00:00 2001 From: Craig Disselkoen Date: Sat, 21 Oct 2017 21:39:12 -0700 Subject: [PATCH 34/59] Remove no-longer-used KeyboardioHID.h include --- src/MouseWrapper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 99a9adbd..732d2af7 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -1,7 +1,6 @@ #pragma once #include "Arduino.h" -#include "KeyboardioHID.h" // Warping commands From df72fb710f972f1e6e25aa6f9dfbe0e12be90f61 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 24 Nov 2017 23:23:15 +0100 Subject: [PATCH 35/59] Fix mouse keys getting occasionally stuck Instead of discrete press & release tracking, press the mousekey when the physical key is pressed, and like `Keyboard`, send & clear the report once per cycle, instead on every action. This fixes #10. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 778e3eb6..a417f667 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -33,6 +33,8 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) { void MouseKeys_::loopHook(bool postClear) { if (postClear) { + kaleidoscope::hid::sendMouseReport(); + kaleidoscope::hid::releaseAllMouseButtons(); mouseMoveIntent = 0; return; } @@ -76,7 +78,7 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; - if (keyToggledOn(keyState)) { + if (keyIsPressed(keyState)) { MouseWrapper.pressButton(button); } else if (keyToggledOff(keyState)) { MouseWrapper.release_button(button); From 3005d9534e53757d5b00d04e46d5ce8753f4d224 Mon Sep 17 00:00:00 2001 From: SjB Date: Thu, 30 Nov 2017 11:09:13 -0500 Subject: [PATCH 36/59] Horizontal Mouse Scrolling Support in Kaleidoscope-Mousekeys using the new moveMouse function in kaleidoscope::hid we can have horizontal mouse scrolling. --- README.md | 4 +++- src/Kaleidoscope-MouseKeys.cpp | 4 ++++ src/MouseKeyDefs.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a0f82910..466609c4 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,9 @@ properties (see below). * `Key_mouseScrollUp`, `Key_mouseScrollDn`: Scroll the mouse wheel up or down, respectively. - +* `Key_mouseScrollL`, `Key_mouseScrollR`: Scroll the mouse wheel left or right, + respectively. + ### Buttons Buttons are even simpler than movement: there is no movement speed, nor diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 778e3eb6..88e26cb4 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -29,6 +29,10 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) { kaleidoscope::hid::moveMouse(0, 0, wheelSpeed); else if (keyCode & KEY_MOUSE_DOWN) kaleidoscope::hid::moveMouse(0, 0, -wheelSpeed); + else if (keyCode & KEY_MOUSE_LEFT) + kaleidoscope::hid::moveMouse(0, 0, 0, -wheelSpeed); + else if (keyCode & KEY_MOUSE_RIGHT) + kaleidoscope::hid::moveMouse(0, 0, 0, wheelSpeed); } void MouseKeys_::loopHook(bool postClear) { diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 9f5bdbc9..2a10af25 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -36,8 +36,8 @@ #define Key_mouseDnR (Key) { KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseScrollUp (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseScrollDn (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } -#define Key_mouseScrollL -#define Key_mouseScrollR +#define Key_mouseScrollL (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseScrollR (Key) { KEY_MOUSE_WHEEL | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseBtnL (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } #define Key_mouseBtnM (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } #define Key_mouseBtnR (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } From 468c2443a543a9f24251a7ab544a0f3d2f134efd Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 27 Mar 2018 12:22:21 +0200 Subject: [PATCH 37/59] README.md: Drop the note about OS compatibility Since we switched to using a separate node for the absolute mouse, it works with all three major operating systems. For that reason, the note about OS compatibility is incorrect, and with this patch, we drop it. Reported by @noseglasses, thanks! Signed-off-by: Gergely Nagy --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 466609c4..379813cb 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Key_mouseBtnL, Key_mouseBtnR void setup() { Kaleidoscope.use(&MouseKeys); - + Kaleidoscope.setup (); } ``` @@ -79,7 +79,7 @@ properties (see below). respectively. * `Key_mouseScrollL`, `Key_mouseScrollR`: Scroll the mouse wheel left or right, respectively. - + ### Buttons Buttons are even simpler than movement: there is no movement speed, nor @@ -100,9 +100,6 @@ to the middle of it. To stop warping, use any other mouse key, or hit the "warp end" key. -This features works out of the box on Windows and OSX. On Linux, a patch exists, -but has not been finalised and merged yet. - The warping keys are the following: * `Key_mouseWarpNW`, `Key_mouseWarpNE`, `Key_mouseWarpSW`, `Key_mouseWarpSE`: From b370681111efce35838ef962d1ea187ed90b2157 Mon Sep 17 00:00:00 2001 From: Cy Rossignol Date: Mon, 2 Apr 2018 05:10:44 +0100 Subject: [PATCH 38/59] Fix warping while dragging the mouse Before this change, we couldn't use the full functionality of the plugin's warp feature to drag an item (by holding down a mouse button key). The plugin would reset the warp state during each scan cycle, so we could only warp the pointer to a cell in the top-level grid. This fix enables warping repeatedly into sub-cells while holding a mouse button. --- src/Kaleidoscope-MouseKeys.cpp | 6 ++++++ src/MouseWrapper.cpp | 8 +++++++- src/MouseWrapper.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 4455dde4..2e7de67e 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -83,6 +83,12 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; if (keyIsPressed(keyState)) { + // Reset warp state on initial mouse button key-down only so we can use + // warp keys to drag-and-drop: + if (keyToggledOn(keyState)) { + MouseWrapper.reset_warping(); + } + MouseWrapper.pressButton(button); } else if (keyToggledOff(keyState)) { MouseWrapper.release_button(button); diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 9476a237..54b361f3 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -24,11 +24,11 @@ void MouseWrapper_::begin(void) { void MouseWrapper_::pressButton(uint8_t button) { kaleidoscope::hid::pressMouseButtons(button); - end_warping(); } void MouseWrapper_::release_button(uint8_t button) { kaleidoscope::hid::releaseMouseButtons(button); + end_warping(); } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { @@ -49,6 +49,12 @@ void MouseWrapper_::end_warping() { is_warping = false; } +void MouseWrapper_::reset_warping() { + if (is_warping == true) { + begin_warping(); + } +} + void MouseWrapper_::warp(uint8_t warp_cmd) { if (is_warping == false) { begin_warping(); diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 732d2af7..e16b7733 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -28,6 +28,7 @@ class MouseWrapper_ { static void begin(void); static void move(int8_t x, int8_t y); static void warp(uint8_t warp_cmd); + static void reset_warping(); static void pressButton(uint8_t button); static void release_button(uint8_t button); static uint8_t accelStep; From a407aa29b0a381e9ced9c3aa1afa9515c9e56c11 Mon Sep 17 00:00:00 2001 From: Cy Rossignol Date: Sun, 1 Apr 2018 00:58:48 +0100 Subject: [PATCH 39/59] Add an optional 9-sector-grid warp size This warp mode is similar to the navigation provided by some speech recognition software. A 9-cell grid may provide more precision and efficiency than the existing 4-cell warp mode. This adds some extra key definitions to support the additional sectors and enables a user to switch the grid size: MouseKeys.setWarpGridSize(MOUSE_WARP_GRID_3X3); Signed-off-by: Cy Rossignol --- README.md | 123 +++++++++++++++++++++++++++++++-- src/Kaleidoscope-MouseKeys.cpp | 8 ++- src/Kaleidoscope-MouseKeys.h | 3 + src/MouseKeyDefs.h | 5 ++ src/MouseWarpModes.h | 10 +++ src/MouseWrapper.cpp | 33 +++++---- src/MouseWrapper.h | 2 + 7 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 src/MouseWarpModes.h diff --git a/README.md b/README.md index 379813cb..d4ee37a4 100644 --- a/README.md +++ b/README.md @@ -88,19 +88,65 @@ acceleration involved. One just presses them. * `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`: The left, middle, and right mouse buttons, respectively. -### Warping +## Warping Warping is one of the most interesting features of the plugin, and is a feature unique to Kaleidoscope, as far as we can tell. The warping keys position the -mouse cursor within a quadrant of the screen on first press, and any subsequent -taps will warp within the previously selected quadrant. For example, pressing -the north-west warp key twice will first jump to the middle of the north-west -quadrant of your screen, then select the north-west quadrant of that, and jump -to the middle of it. +mouse cursor within a sector of the screen on first press, and any subsequent +taps will warp within the previously selected sector. For example, pressing the +north-west warp key twice will first jump to the middle of the north-west +sector of your screen, then select the north-west sector of that, and jump to +the middle of it. To stop warping, use any other mouse key, or hit the "warp end" key. -The warping keys are the following: +### Warp grid size + +The warp grid size determines how MouseKeys partitions the screen to select the +next position to jump to when pressing a warp key. The plugin provides two grid +sizes to choose from: a *2x2* grid that splits the screen into quadrants, and a +*3x3* grid with nine cells similar to a navigation feature included with some +speech recognition software. By default, the plugin splits the screen into the +2x2 grid. + +To change the warp grid size, call the plugin's `setWarpGridSize()` method: + +```c++ +MouseKeys.setWarpGridSize(MOUSE_WARP_GRID_3X3); +``` + +#### 2x2 grid + +As described above, MouseKeys warps the pointer using a grid model that reflects +locations on the screen. By default, the plugin uses a 2x2 grid. To understand +how warping works, examine this diagram of a screen split into that 2x2 grid: + + +-----------------------+-----------------------+ + | | | | + | G | tab | | + | | | | + |-----------+-----------| tab | + | | | | + | B | esc | | + | | | | + +-----------------------+-----------------------+ + | | | + | | | + | | | + | B | esc | + | | | + | | | + | | | + +-----------------------+-----------------------+ + +Each quadrant is labed with a key that, when pressed, moves the mouse pointer +to the center of that quadrant. With this layout, pressing G warps +the pointer to the top-left quadant. Then, the plugin "zooms" into that sector +with a smaller grid so that the next warp key pressed jumps the pointer more +precisely within the sector. In this case, if we press esc next, +the pointer warps to the bottom-right corner within that quadrant. + +The warping keys for the 2x2 grid are the following: * `Key_mouseWarpNW`, `Key_mouseWarpNE`, `Key_mouseWarpSW`, `Key_mouseWarpSE`: Warp towards the north-west, north-east, south-west, or south-east quadrants, @@ -109,6 +155,64 @@ The warping keys are the following: state. Using any of the warping keys after this will start from the whole screen again. +#### 3x3 grid + +A 3x3 warp grid assigns a key to each of nine sectors of the screen. The next +diagram shows a screen with a key label that warps to each sector. As we can +see, pressing W warps the pointer into the top-left sector, and +pressing V warps to the bottom-right corner within that sector: + + +-----------------+-----------------+-----------------+ + | W | E | R | | | + |-----+-----+-----| | | + | S | D | F | E | R | + |-----+-----+-----| | | + | X | C | V | | | + +-----------------+-----------------+-----------------+ + | | | | + | | | | + | S | D | F | + | | | | + | | | | + +-----------------+-----------------+-----------------+ + | | | | + | | | | + | X | C | V | + | | | | + | | | | + +-----------------+-----------------+-----------------+ + +To use a 3x3 warp grid, we may need to remap some keys. A suggested warp key +mapping is shown below on the left side of a keyboard with a QWERTY layout: + + W | E | R T A - End Warping (Key_mouseWarpEnd) + ---+---+--- W - Warp NW Sector (Key_mouseWarpNW) + A S | D | F G E - Warp N Sector (Key_mouseWarpN) + ---+---+--- R - Warp NE Sector (Key_mouseWarpNE) + X | C | V B S - Warp E Sector (Key_mouseWarpE) + D - Warp/Zoom Center (Key_mouseWarpIn) + F - Warp W Sector (Key_mouseWarpW) + K - Warp SE Sector (Key_mouseWarpSE) + C - Warp S Sector (Key_mouseWarpS) + V - Warp SW Sector (Key_mouseWarpSW) + T - Right Click (Key_mouseBtnR) + G - Left Click (Key_mouseBtnL) + B - Middle Click (Key_mouseBtnM) + +This example layout replaces the default directional mouse keys and sets the +warp keys in a comfortable position for a warp-only configuration. Of course, +a Kaleidoscope user may retain the directional keys and map the warp keys +elsewhere according to his or her liking. + +A 3x3 warp grid layout contains all of the keys from the 2x2 grid layout with +the following additions: + +* `Key_mouseWarpN`, `Key_mouseWarpE`, `Key_mouseWarpS`, `Key_mouseWarpW`: + Warp towards the north, east, south, and west sectors, respectively. +* `Key_mouseWarpIn`: Warp to the center sector of the grid. The plugin will + continue to "zoom" into center of the current cell with each consecutive + press of this key. + ## Plugin methods The plugin provides a `MouseKeys` object, with the following methods and @@ -137,3 +241,8 @@ properties available: > scrolling speed. The former, `.wheelSpeed`, controls the amount of ticks the > wheel shall scroll, and defaults to 1. The second, `.wheelDelay`, controls the > delay between two scroll events, and defaults to 50 milliseconds. + +### `.setWarpGridSize` + +> This method changes the size of the grid used for [warping](#warping). The +> following are valid sizes: `MOUSE_WARP_GRID_2X2`, `MOUSE_WARP_GRID_3X3` diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 4455dde4..6da6090b 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -19,6 +19,10 @@ uint32_t MouseKeys_::accelEndTime; uint32_t MouseKeys_::endTime; uint32_t MouseKeys_::wheelEndTime; +void MouseKeys_::setWarpGridSize(uint8_t grid_size) { + MouseWrapper.warp_grid_size = grid_size; +} + void MouseKeys_::scrollWheel(uint8_t keyCode) { if (millis() < wheelEndTime) return; @@ -102,10 +106,10 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS } } else if (keyToggledOn(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { - // we don't pass in the left and up values because those are the - // default, "no-op" conditionals MouseWrapper.warp(((mappedKey.keyCode & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_UP) ? WARP_UP : 0x00) | ((mappedKey.keyCode & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) | + ((mappedKey.keyCode & KEY_MOUSE_LEFT) ? WARP_LEFT : 0x00) | ((mappedKey.keyCode & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00)); } } diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 255a0888..78dbabe2 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -2,6 +2,7 @@ #include "Kaleidoscope.h" #include "MouseKeyDefs.h" +#include "MouseWarpModes.h" class MouseKeys_ : public KaleidoscopePlugin { public: @@ -16,6 +17,8 @@ class MouseKeys_ : public KaleidoscopePlugin { static uint8_t wheelSpeed; static uint16_t wheelDelay; + static void setWarpGridSize(uint8_t grid_size); + private: static uint8_t mouseMoveIntent; static uint32_t endTime; diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 2a10af25..5f66a5d4 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -20,8 +20,13 @@ #define Key_mouseWarpNW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpN (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseWarpNE (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpIn (Key) { KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpE (Key) { KEY_MOUSE_WARP| KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseWarpSW (Key) { KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } +#define Key_mouseWarpS (Key) { KEY_MOUSE_WARP| KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseWarpSE (Key) { KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } #define Key_mouseWarpEnd (Key) { KEY_MOUSE_WARP| KEY_MOUSE_WARP_END, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY } diff --git a/src/MouseWarpModes.h b/src/MouseWarpModes.h new file mode 100644 index 00000000..6f2b28a4 --- /dev/null +++ b/src/MouseWarpModes.h @@ -0,0 +1,10 @@ +#pragma once + +// Warp modes determine how the plugin jumps the mouse pointer to a screen +// location when pressing a warp key. + + +// Grid Based - the constant represents the number of cells in a row or column: + +#define MOUSE_WARP_GRID_2X2 2 +#define MOUSE_WARP_GRID_3X3 3 diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 9476a237..100367bb 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -5,6 +5,7 @@ #include "MouseWrapper.h" #include "kaleidoscope/hid.h" +uint8_t MouseWrapper_::warp_grid_size = MOUSE_WARP_GRID_2X2; uint16_t MouseWrapper_::next_width; uint16_t MouseWrapper_::next_height; uint16_t MouseWrapper_::section_top; @@ -59,21 +60,29 @@ void MouseWrapper_::warp(uint8_t warp_cmd) { return; } - next_width = next_width / 2; - next_height = next_height / 2; + next_width /= warp_grid_size; + next_height /= warp_grid_size; - if (warp_cmd & WARP_UP) { -// Serial.print(" - up "); - } else if (warp_cmd & WARP_DOWN) { -// Serial.print(" - down "); - section_top = section_top + next_height; + // WARP_UP + WARP_DOWN means "zoom in" to center sector + if (warp_cmd & WARP_UP && warp_cmd & WARP_DOWN) { + section_left += next_width; + section_top += next_height; + + warp_jump(section_left, section_top, next_height, next_width); + + return; + } + + if (warp_cmd & WARP_DOWN) { + section_top += next_height * (warp_grid_size - 1); + } else if (!(warp_cmd & WARP_UP)) { + section_top += next_height; } - if (warp_cmd & WARP_LEFT) { - // Serial.print(" - left "); - } else if (warp_cmd & WARP_RIGHT) { - // Serial.print(" - right "); - section_left = section_left + next_width; + if (warp_cmd & WARP_RIGHT) { + section_left += next_width * (warp_grid_size - 1); + } else if (!(warp_cmd & WARP_LEFT)) { + section_left += next_width; } warp_jump(section_left, section_top, next_height, next_width); diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 732d2af7..8c6ee04f 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -1,6 +1,7 @@ #pragma once #include "Arduino.h" +#include "MouseWarpModes.h" // Warping commands @@ -32,6 +33,7 @@ class MouseWrapper_ { static void release_button(uint8_t button); static uint8_t accelStep; static uint8_t speedLimit; + static uint8_t warp_grid_size; private: static uint16_t next_width; From b18465033ebfe9eda2900960490e8c84cfdccc2b Mon Sep 17 00:00:00 2001 From: Ryan Anderson Date: Mon, 23 Apr 2018 11:33:33 +0100 Subject: [PATCH 40/59] Reset the acceleration timer each time it expires. Without this, once the timeout expires the first time, every time through the loop triggers acceleration, which rapidly becomes excessive. --- src/Kaleidoscope-MouseKeys.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 6da6090b..859dc669 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -62,8 +62,10 @@ void MouseKeys_::loopHook(bool postClear) { int8_t moveX = 0, moveY = 0; if (millis() >= accelEndTime) { - if (MouseWrapper.accelStep < 255 - accelSpeed) + if (MouseWrapper.accelStep < 255 - accelSpeed) { MouseWrapper.accelStep += accelSpeed; + } + accelEndTime = millis() + accelDelay; } if (mouseMoveIntent & KEY_MOUSE_UP) From 0bd171137114f350fb968f2b9cf96ef5f670939a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 13 May 2018 10:24:21 +0200 Subject: [PATCH 41/59] Updated to use the new plugin APIs Signed-off-by: Gergely Nagy --- README.md | 28 ++++++++-------- src/Kaleidoscope-MouseKeys.cpp | 59 +++++++++++++++++++++++----------- src/Kaleidoscope-MouseKeys.h | 20 ++++++++---- 3 files changed, 69 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index d4ee37a4..47a8df8f 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ illustrated with an example: Key_mouseUp, Key_mouseDn, Key_mouseL, Key_mouseR, Key_mouseBtnL, Key_mouseBtnR -void setup() { - Kaleidoscope.use(&MouseKeys); +KALEIDOSCOPE_INIT_PLUGINS(MouseKeys); +void setup() { Kaleidoscope.setup (); } ``` @@ -121,15 +121,15 @@ As described above, MouseKeys warps the pointer using a grid model that reflects locations on the screen. By default, the plugin uses a 2x2 grid. To understand how warping works, examine this diagram of a screen split into that 2x2 grid: - +-----------------------+-----------------------+ + +-----------------------|-----------------------+ | | | | | G | tab | | | | | | - |-----------+-----------| tab | + |-----------|-----------| tab | | | | | | B | esc | | | | | | - +-----------------------+-----------------------+ + +-----------------------|-----------------------+ | | | | | | | | | @@ -137,7 +137,7 @@ how warping works, examine this diagram of a screen split into that 2x2 grid: | | | | | | | | | - +-----------------------+-----------------------+ + +-----------------------|-----------------------+ Each quadrant is labed with a key that, when pressed, moves the mouse pointer to the center of that quadrant. With this layout, pressing G warps @@ -162,33 +162,33 @@ diagram shows a screen with a key label that warps to each sector. As we can see, pressing W warps the pointer into the top-left sector, and pressing V warps to the bottom-right corner within that sector: - +-----------------+-----------------+-----------------+ + +-----------------|-----------------|-----------------+ | W | E | R | | | - |-----+-----+-----| | | + |-----|-----|-----| | | | S | D | F | E | R | - |-----+-----+-----| | | + |-----|-----|-----| | | | X | C | V | | | - +-----------------+-----------------+-----------------+ + +-----------------|-----------------|-----------------+ | | | | | | | | | S | D | F | | | | | | | | | - +-----------------+-----------------+-----------------+ + +-----------------|-----------------|-----------------+ | | | | | | | | | X | C | V | | | | | | | | | - +-----------------+-----------------+-----------------+ + +-----------------|-----------------|-----------------+ To use a 3x3 warp grid, we may need to remap some keys. A suggested warp key mapping is shown below on the left side of a keyboard with a QWERTY layout: W | E | R T A - End Warping (Key_mouseWarpEnd) - ---+---+--- W - Warp NW Sector (Key_mouseWarpNW) + ---|---|--- W - Warp NW Sector (Key_mouseWarpNW) A S | D | F G E - Warp N Sector (Key_mouseWarpN) - ---+---+--- R - Warp NE Sector (Key_mouseWarpNE) + ---|---|--- R - Warp NE Sector (Key_mouseWarpNE) X | C | V B S - Warp E Sector (Key_mouseWarpE) D - Warp/Zoom Center (Key_mouseWarpIn) F - Warp W Sector (Key_mouseWarpW) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 0bfb7aa9..7e643201 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -39,23 +39,24 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) { kaleidoscope::hid::moveMouse(0, 0, 0, wheelSpeed); } -void MouseKeys_::loopHook(bool postClear) { - if (postClear) { - kaleidoscope::hid::sendMouseReport(); - kaleidoscope::hid::releaseAllMouseButtons(); - mouseMoveIntent = 0; - return; - } +kaleidoscope::EventHandlerResult MouseKeys_::afterEachCycle() { + kaleidoscope::hid::sendMouseReport(); + kaleidoscope::hid::releaseAllMouseButtons(); + mouseMoveIntent = 0; + return kaleidoscope::EventHandlerResult::OK; +} + +kaleidoscope::EventHandlerResult MouseKeys_::beforeReportingState() { if (mouseMoveIntent == 0) { MouseWrapper.accelStep = 0; endTime = 0; accelEndTime = 0; - return; + return kaleidoscope::EventHandlerResult::OK; } if (millis() < endTime) - return; + return kaleidoscope::EventHandlerResult::OK; endTime = millis() + speedDelay; @@ -79,11 +80,13 @@ void MouseKeys_::loopHook(bool postClear) { moveX = speed; MouseWrapper.move(moveX, moveY); + + return kaleidoscope::EventHandlerResult::OK; } -Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) { +kaleidoscope::EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState) { if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) - return mappedKey; + return kaleidoscope::EventHandlerResult::OK; if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; @@ -122,17 +125,37 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS } } - return Key_NoKey; + return kaleidoscope::EventHandlerResult::EVENT_CONSUMED; } -MouseKeys_::MouseKeys_(void) { +kaleidoscope::EventHandlerResult MouseKeys_::onSetup(void) { + MouseWrapper.begin(); + + return kaleidoscope::EventHandlerResult::OK; } -void -MouseKeys_::begin(void) { - MouseWrapper.begin(); - Kaleidoscope.useEventHandlerHook(eventHandlerHook); - Kaleidoscope.useLoopHook(loopHook); +// Legacy V1 API +#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API +void MouseKeys_::begin() { + onSetup(); + Kaleidoscope.useEventHandlerHook(legacyEventHandler); + Kaleidoscope.useLoopHook(legacyLoopHook); +} + +Key MouseKeys_::legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state) { + kaleidoscope::EventHandlerResult r = MouseKeys.onKeyswitchEvent(mapped_key, row, col, key_state); + if (r == kaleidoscope::EventHandlerResult::OK) + return mapped_key; + return Key_NoKey; +} + +void MouseKeys_::legacyLoopHook(bool is_post_clear) { + if (is_post_clear) { + MouseKeys.afterEachCycle(); + } else { + MouseKeys.beforeReportingState(); + } } +#endif MouseKeys_ MouseKeys; diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 78dbabe2..3b23ddff 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -4,11 +4,9 @@ #include "MouseKeyDefs.h" #include "MouseWarpModes.h" -class MouseKeys_ : public KaleidoscopePlugin { +class MouseKeys_ : public kaleidoscope::Plugin { public: - MouseKeys_(void); - - void begin(void) final; + MouseKeys_(void) {} static uint8_t speed; static uint16_t speedDelay; @@ -19,6 +17,18 @@ class MouseKeys_ : public KaleidoscopePlugin { static void setWarpGridSize(uint8_t grid_size); + kaleidoscope::EventHandlerResult onSetup(); + kaleidoscope::EventHandlerResult beforeReportingState(); + kaleidoscope::EventHandlerResult afterEachCycle(); + kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState); + +#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API + protected: + void begin(); + static Key legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state); + static void legacyLoopHook(bool is_post_clear); +#endif + private: static uint8_t mouseMoveIntent; static uint32_t endTime; @@ -26,8 +36,6 @@ class MouseKeys_ : public KaleidoscopePlugin { static uint32_t wheelEndTime; static void scrollWheel(uint8_t keyCode); - static void loopHook(bool postClear); - static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); }; extern MouseKeys_ MouseKeys; From 69a8288d5d650d4b982da68c52f92c5a66a95bf1 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Sun, 3 Jun 2018 17:54:21 -0400 Subject: [PATCH 42/59] Apply correct diagonal movement speeds Previously, diagonal movements were not reduced in the two axes, resulting in movement that was too quick. This commit divides diagonal movements by sqrt(2) / 2 to correct the movement speed. The net result is that diagonal movement should feel smoother and speed more as expected. --- src/MouseWrapper.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index cca78610..604d897c 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -112,19 +112,34 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { return i; } +static int8_t roundAwayFromZero(float value) { + if (value < 0.0f) { + return static_cast(value - 0.5f); + } + + return static_cast(value + 0.5f); +} void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX = 0; int16_t moveY = 0; static int8_t remainderX = 0; static int8_t remainderY = 0; + static const float HALF_SQRT_2 = 0.7071f; + + boolean isDiagonal = (x != 0 && y != 0); + if (x != 0) { + if (isDiagonal) x = roundAwayFromZero(HALF_SQRT_2 * x); moveX = remainderX + (x * acceleration(accelStep)); + if (moveX > (int16_t)speedLimit) moveX = speedLimit; else if (moveX < -(int16_t)speedLimit) moveX = -speedLimit; } if (y != 0) { + if (isDiagonal) y = roundAwayFromZero(HALF_SQRT_2 * y); moveY = remainderY + (y * acceleration(accelStep)); + if (moveY > (int16_t)speedLimit) moveY = speedLimit; else if (moveY < -(int16_t)speedLimit) moveY = -speedLimit; } From 3805b53cadfb2f7fa870b6bbfa39f64d27098043 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Sun, 3 Jun 2018 18:10:24 -0400 Subject: [PATCH 43/59] Clean up implementation --- src/MouseWrapper.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 604d897c..06403449 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -127,19 +127,18 @@ void MouseWrapper_::move(int8_t x, int8_t y) { static int8_t remainderY = 0; static const float HALF_SQRT_2 = 0.7071f; - boolean isDiagonal = (x != 0 && y != 0); + if (x != 0 && y != 0) { + x = roundAwayFromZero(HALF_SQRT_2 * x); + y = roundAwayFromZero(HALF_SQRT_2 * y); + } if (x != 0) { - if (isDiagonal) x = roundAwayFromZero(HALF_SQRT_2 * x); moveX = remainderX + (x * acceleration(accelStep)); - if (moveX > (int16_t)speedLimit) moveX = speedLimit; else if (moveX < -(int16_t)speedLimit) moveX = -speedLimit; } if (y != 0) { - if (isDiagonal) y = roundAwayFromZero(HALF_SQRT_2 * y); moveY = remainderY + (y * acceleration(accelStep)); - if (moveY > (int16_t)speedLimit) moveY = speedLimit; else if (moveY < -(int16_t)speedLimit) moveY = -speedLimit; } From 04112de29701267ec045ca29a7ef31946caad5f5 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Mon, 4 Jun 2018 01:55:13 -0400 Subject: [PATCH 44/59] Approximate sqrt(2)/2 with ints to avoid floats --- src/MouseWrapper.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 06403449..082b1fde 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -112,24 +112,19 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { return i; } -static int8_t roundAwayFromZero(float value) { - if (value < 0.0f) { - return static_cast(value - 0.5f); - } - - return static_cast(value + 0.5f); -} - void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX = 0; int16_t moveY = 0; static int8_t remainderX = 0; static int8_t remainderY = 0; - static const float HALF_SQRT_2 = 0.7071f; if (x != 0 && y != 0) { - x = roundAwayFromZero(HALF_SQRT_2 * x); - y = roundAwayFromZero(HALF_SQRT_2 * y); + // 99 / 140 closely approximates sqrt(2) / 2. + int8_t adjusted_x = x * 99 / 140; + int8_t adjusted_y = y * 99 / 140; + + x = (adjusted_x == 0 ? x : adjusted_x); + y = (adjusted_y == 0 ? y : adjusted_y); } if (x != 0) { From 77acd347e8b84c873f5748ad811f51cd65d69a65 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Mon, 4 Jun 2018 17:43:58 -0400 Subject: [PATCH 45/59] Address possible overflow, adhere to style The multiplication by 99 can overflow an int8_t depending on whether the expression is coerced to a regular-sized int (based on the 99 literal). Just to be safe, perform a cast to int16_t in case the coercion does not happen. --- src/MouseWrapper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 082b1fde..8ca6e150 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -119,12 +119,13 @@ void MouseWrapper_::move(int8_t x, int8_t y) { static int8_t remainderY = 0; if (x != 0 && y != 0) { - // 99 / 140 closely approximates sqrt(2) / 2. - int8_t adjusted_x = x * 99 / 140; - int8_t adjusted_y = y * 99 / 140; + // 99 / 140 closely approximates sqrt(2) / 2. Since integer division + // truncates towards zero we do not need to worry about truncation errors. + int8_t adjustedX = (int16_t)x * 99 / 140; + int8_t adjustedY = (int16_t)y * 99 / 140; - x = (adjusted_x == 0 ? x : adjusted_x); - y = (adjusted_y == 0 ? y : adjusted_y); + if (adjustedX != 0) x = adjustedX; + if (adjustedY != 0) y = adjustedY; } if (x != 0) { From c45e7d1c1d5da0d5c78eb7a8d4c81968814dfdb6 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Sat, 9 Jun 2018 17:14:47 -0400 Subject: [PATCH 46/59] Fix diagonal speed limit and remainder calculation --- src/MouseWrapper.cpp | 37 ++++++++++++++++++++++++------------- src/MouseWrapper.h | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 8ca6e150..2c3af984 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -14,6 +14,7 @@ boolean MouseWrapper_::is_warping; uint8_t MouseWrapper_::accelStep; uint8_t MouseWrapper_::speedLimit = 127; +uint8_t MouseWrapper_::subpixelsPerPixel = 16; MouseWrapper_::MouseWrapper_(void) { } @@ -112,39 +113,49 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { return i; } +// Get the diagonalized version of a value, i.e. value * sqrt(2) / 2. If the +// value ends up being zero, return the original value instead. +static int16_t diagonalize(int16_t value) { + // 99 / 140 closely approximates sqrt(2) / 2. Since integer division + // truncates towards zero we do not need to worry about truncation errors. + int16_t diagonalValue = value * 99 / 140; + return (diagonalValue == 0 ? value : diagonalValue); +} + void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX = 0; int16_t moveY = 0; static int8_t remainderX = 0; static int8_t remainderY = 0; + int16_t effectiveSpeedLimit = speedLimit; if (x != 0 && y != 0) { - // 99 / 140 closely approximates sqrt(2) / 2. Since integer division - // truncates towards zero we do not need to worry about truncation errors. - int8_t adjustedX = (int16_t)x * 99 / 140; - int8_t adjustedY = (int16_t)y * 99 / 140; + // For diagonal movements, we apply a diagonalized speed limit. The + // effective speed limit is set based on whether we are moving diagonally. + effectiveSpeedLimit = diagonalize(effectiveSpeedLimit); - if (adjustedX != 0) x = adjustedX; - if (adjustedY != 0) y = adjustedY; + x = diagonalize(x); + y = diagonalize(y); } if (x != 0) { moveX = remainderX + (x * acceleration(accelStep)); - if (moveX > (int16_t)speedLimit) moveX = speedLimit; - else if (moveX < -(int16_t)speedLimit) moveX = -speedLimit; + if (moveX > effectiveSpeedLimit) moveX = effectiveSpeedLimit; + else if (moveX < -effectiveSpeedLimit) moveX = -effectiveSpeedLimit; } + if (y != 0) { moveY = remainderY + (y * acceleration(accelStep)); - if (moveY > (int16_t)speedLimit) moveY = speedLimit; - else if (moveY < -(int16_t)speedLimit) moveY = -speedLimit; + if (moveY > effectiveSpeedLimit) moveY = effectiveSpeedLimit; + else if (moveY < -effectiveSpeedLimit) moveY = -effectiveSpeedLimit; } end_warping(); // move by whole pixels, not subpixels - kaleidoscope::hid::moveMouse(moveX >> 4, moveY >> 4, 0); + kaleidoscope::hid::moveMouse(moveX / subpixelsPerPixel, moveY / subpixelsPerPixel, 0); // save leftover subpixel movements for later - remainderX = moveX & 0x0f; - remainderY = moveY & 0x0f; + remainderX = moveX - moveX / subpixelsPerPixel * subpixelsPerPixel; + remainderY = moveY - moveY / subpixelsPerPixel * subpixelsPerPixel; } MouseWrapper_ MouseWrapper; diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 3bb467fc..b07c8b5e 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -34,6 +34,7 @@ class MouseWrapper_ { static void release_button(uint8_t button); static uint8_t accelStep; static uint8_t speedLimit; + static uint8_t subpixelsPerPixel; static uint8_t warp_grid_size; private: From 7eabe867a4834cd2fa49257104c5b40c608e9b0d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 29 Jul 2018 21:07:18 +0200 Subject: [PATCH 47/59] Stop moving into a given direction when releasing a mouse key While we do clear the report every cycle, similar to how key release events are explicitly removed from the report, mouse movements should get removed too. This makes it possible to use them in macros reliably, without surprising results (an extra report sent at the end of the macro). Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 7e643201..cafd7ede 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -114,6 +114,34 @@ kaleidoscope::EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, by } else { mouseMoveIntent |= mappedKey.keyCode; } + } else if (keyToggledOff(keyState)) { + /* If a mouse key toggles off, we want to explicitly stop moving (or + * scrolling) in that direction. We want to do this to support use-cases + * where we send multiple reports per cycle (such as macros), and can't + * rely on the main loop clearing the report for us. We do not want to + * clear the whole report either, because we want any other mouse keys + * to still have their desired effect. Therefore, we selectively stop + * movement or scrolling. */ + mouseMoveIntent &= ~mappedKey.keyCode; + bool x = false, y = false, vWheel = false, hWheel = false; + + if (mappedKey.keyCode & KEY_MOUSE_UP || + mappedKey.keyCode & KEY_MOUSE_DOWN) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + vWheel = true; + } else { + y = true; + } + } else if (mappedKey.keyCode & KEY_MOUSE_LEFT || + mappedKey.keyCode & KEY_MOUSE_RIGHT) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + hWheel = true; + } else { + x = true; + } + } + + kaleidoscope::hid::stopMouse(x, y, vWheel, hWheel); } } else if (keyToggledOn(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { From 8ec69c8fbacd81f7e53659138bf7a4af1cc905b8 Mon Sep 17 00:00:00 2001 From: Daniele Tamino Date: Mon, 6 Aug 2018 21:20:21 -0700 Subject: [PATCH 48/59] Add setSpeedLimit API --- README.md | 6 ++++++ src/Kaleidoscope-MouseKeys.cpp | 4 ++++ src/Kaleidoscope-MouseKeys.h | 1 + 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 47a8df8f..a990d9d3 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,12 @@ properties available: > wheel shall scroll, and defaults to 1. The second, `.wheelDelay`, controls the > delay between two scroll events, and defaults to 50 milliseconds. +### `.setSpeedLimit` + +> This method sets the maximum speed after which acceleration stops. +> The default is 127, and the minimum value is 16 (things will not work +> properly below 16). + ### `.setWarpGridSize` > This method changes the size of the grid used for [warping](#warping). The diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index cafd7ede..e67e38de 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -23,6 +23,10 @@ void MouseKeys_::setWarpGridSize(uint8_t grid_size) { MouseWrapper.warp_grid_size = grid_size; } +void MouseKeys_::setSpeedLimit(uint8_t speed_limit) { + MouseWrapper.speedLimit = speed_limit; +} + void MouseKeys_::scrollWheel(uint8_t keyCode) { if (millis() < wheelEndTime) return; diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 3b23ddff..756e6385 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -16,6 +16,7 @@ class MouseKeys_ : public kaleidoscope::Plugin { static uint16_t wheelDelay; static void setWarpGridSize(uint8_t grid_size); + static void setSpeedLimit(uint8_t speed_limit); kaleidoscope::EventHandlerResult onSetup(); kaleidoscope::EventHandlerResult beforeReportingState(); From d7abd066c66ea5adb2ef77d94a49b9b11121254f Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 14 Aug 2018 16:56:29 -0700 Subject: [PATCH 49/59] astyle --- src/Kaleidoscope-MouseKeys.cpp | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index e67e38de..b3bf86d3 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -119,33 +119,33 @@ kaleidoscope::EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, by mouseMoveIntent |= mappedKey.keyCode; } } else if (keyToggledOff(keyState)) { - /* If a mouse key toggles off, we want to explicitly stop moving (or - * scrolling) in that direction. We want to do this to support use-cases - * where we send multiple reports per cycle (such as macros), and can't - * rely on the main loop clearing the report for us. We do not want to - * clear the whole report either, because we want any other mouse keys - * to still have their desired effect. Therefore, we selectively stop - * movement or scrolling. */ - mouseMoveIntent &= ~mappedKey.keyCode; - bool x = false, y = false, vWheel = false, hWheel = false; - - if (mappedKey.keyCode & KEY_MOUSE_UP || - mappedKey.keyCode & KEY_MOUSE_DOWN) { - if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { - vWheel = true; - } else { - y = true; - } - } else if (mappedKey.keyCode & KEY_MOUSE_LEFT || - mappedKey.keyCode & KEY_MOUSE_RIGHT) { - if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { - hWheel = true; - } else { - x = true; - } + /* If a mouse key toggles off, we want to explicitly stop moving (or + * scrolling) in that direction. We want to do this to support use-cases + * where we send multiple reports per cycle (such as macros), and can't + * rely on the main loop clearing the report for us. We do not want to + * clear the whole report either, because we want any other mouse keys + * to still have their desired effect. Therefore, we selectively stop + * movement or scrolling. */ + mouseMoveIntent &= ~mappedKey.keyCode; + bool x = false, y = false, vWheel = false, hWheel = false; + + if (mappedKey.keyCode & KEY_MOUSE_UP || + mappedKey.keyCode & KEY_MOUSE_DOWN) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + vWheel = true; + } else { + y = true; } + } else if (mappedKey.keyCode & KEY_MOUSE_LEFT || + mappedKey.keyCode & KEY_MOUSE_RIGHT) { + if (mappedKey.keyCode & KEY_MOUSE_WHEEL) { + hWheel = true; + } else { + x = true; + } + } - kaleidoscope::hid::stopMouse(x, y, vWheel, hWheel); + kaleidoscope::hid::stopMouse(x, y, vWheel, hWheel); } } else if (keyToggledOn(keyState)) { if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { From 256c7a729a555bc21448f4609f7f6d7bb7706fe6 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 20 Aug 2018 23:20:30 +0200 Subject: [PATCH 50/59] Drop the V1 plugin API compatibility code Signed-off-by: Gergely Nagy --- src/Kaleidoscope-MouseKeys.cpp | 24 ------------------------ src/Kaleidoscope-MouseKeys.h | 7 ------- 2 files changed, 31 deletions(-) diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index b3bf86d3..054a5d9f 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -166,28 +166,4 @@ kaleidoscope::EventHandlerResult MouseKeys_::onSetup(void) { return kaleidoscope::EventHandlerResult::OK; } -// Legacy V1 API -#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API -void MouseKeys_::begin() { - onSetup(); - Kaleidoscope.useEventHandlerHook(legacyEventHandler); - Kaleidoscope.useLoopHook(legacyLoopHook); -} - -Key MouseKeys_::legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state) { - kaleidoscope::EventHandlerResult r = MouseKeys.onKeyswitchEvent(mapped_key, row, col, key_state); - if (r == kaleidoscope::EventHandlerResult::OK) - return mapped_key; - return Key_NoKey; -} - -void MouseKeys_::legacyLoopHook(bool is_post_clear) { - if (is_post_clear) { - MouseKeys.afterEachCycle(); - } else { - MouseKeys.beforeReportingState(); - } -} -#endif - MouseKeys_ MouseKeys; diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 756e6385..5d01af4e 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -23,13 +23,6 @@ class MouseKeys_ : public kaleidoscope::Plugin { kaleidoscope::EventHandlerResult afterEachCycle(); kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState); -#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API - protected: - void begin(); - static Key legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state); - static void legacyLoopHook(bool is_post_clear); -#endif - private: static uint8_t mouseMoveIntent; static uint32_t endTime; From d76932810451cf2f470f7b204527c4290db36f7b Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 23 Aug 2018 22:10:01 +0200 Subject: [PATCH 51/59] Relicense under GPLv3 (only), and add headers. Signed-off-by: Gergely Nagy --- COPYING | 899 ++++++++++++++++++++++----------- src/Kaleidoscope-MouseKeys.cpp | 16 + src/Kaleidoscope-MouseKeys.h | 16 + src/MouseKeyDefs.h | 16 + src/MouseWarpModes.h | 16 + src/MouseWrapper.cpp | 16 + src/MouseWrapper.h | 16 + 7 files changed, 713 insertions(+), 282 deletions(-) diff --git a/COPYING b/COPYING index d159169d..94a9ed02 100644 --- a/COPYING +++ b/COPYING @@ -1,281 +1,622 @@ GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. END OF TERMS AND CONDITIONS @@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) - This program is free software; you can redistribute it and/or modify + 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; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -303,37 +644,31 @@ the "copyright" line and a pointer to where the full notice is found. 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + You should have received a copy of the GNU General Public License + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 054a5d9f..a59cfd22 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + #include #include "Kaleidoscope-MouseKeys.h" diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index 5d01af4e..bc6615da 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + #pragma once #include "Kaleidoscope.h" diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index 5f66a5d4..de649a4b 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + #pragma once #define IS_MOUSE_KEY B00010000 diff --git a/src/MouseWarpModes.h b/src/MouseWarpModes.h index 6f2b28a4..a81355ac 100644 --- a/src/MouseWarpModes.h +++ b/src/MouseWarpModes.h @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + #pragma once // Warp modes determine how the plugin jumps the mouse pointer to a screen diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 2c3af984..ec5b1a29 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + // Mouse-related methods // diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index b07c8b5e..b85b950f 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -1,3 +1,19 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + #pragma once #include "Arduino.h" From 8d6fcb7c03c2f20fa6965f82669408d77e388822 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 23 Aug 2018 22:10:21 +0200 Subject: [PATCH 52/59] Add CONTRIBUTING.md Copied from Kaleidoscope, as it is applicable here too. Signed-off-by: Gergely Nagy --- CONTRIBUTING.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c490e3ce --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Developer Certificate of Origin + +All contributions must include acceptance of the DCO: + +``` +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` + +## Sign your work + +To accept the DCO, please add this line to each commit message with your name +and email address (`git commit -s` will do this for you): + + Signed-off-by: Jane Example From f248ea31563487a8361c9098ccf7f4ef48c4adc3 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 4 Sep 2018 18:24:02 -0700 Subject: [PATCH 53/59] Update travis.yml to point to new bundle repo --- .travis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7030acf..e3e64f77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,15 @@ dist: trusty sudo: false os: - linux +addons: + apt: + packages: + - shellcheck install: - - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Arduino-Boards hardware/keyboardio/avr + - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio hardware/keyboardio script: - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware + - shellcheck bin/kaleidoscope-builder notifications: irc: channels: @@ -13,7 +18,7 @@ notifications: use_notice: true skip_join: true template: - - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" + - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" email: on_success: change on_failure: change From bb58eee9b880e632a9b24e3bc4cc43c02f95adb5 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 4 Sep 2018 18:42:30 -0700 Subject: [PATCH 54/59] shellcheck should only be run in the Kaleidoscope repo --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3e64f77..23d30ccc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,10 @@ dist: trusty sudo: false os: - linux -addons: - apt: - packages: - - shellcheck install: - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio hardware/keyboardio script: - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware - - shellcheck bin/kaleidoscope-builder notifications: irc: channels: From a180a6784d17fc9a0f46004ac9cd2ffaee20ac7b Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 2 Oct 2018 16:18:39 +0200 Subject: [PATCH 55/59] Add prev/next mouse buttons KeyboardioHID already supports these keys, so lets expose them! Fixes #28. Signed-off-by: Gergely Nagy --- README.md | 5 +++-- src/MouseKeyDefs.h | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a990d9d3..a2d3ae6f 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,9 @@ properties (see below). Buttons are even simpler than movement: there is no movement speed, nor acceleration involved. One just presses them. -* `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`: The left, middle, and right - mouse buttons, respectively. +* `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`, `Key_mouseBtnP`, + `Key_mouseBtnN`: The left, middle, right, previous, and next mouse buttons, + respectively. ## Warping diff --git a/src/MouseKeyDefs.h b/src/MouseKeyDefs.h index de649a4b..a6e8c6b7 100644 --- a/src/MouseKeyDefs.h +++ b/src/MouseKeyDefs.h @@ -22,7 +22,8 @@ #define KEY_MOUSE_BTN_L MOUSE_LEFT // Synthetic key #define KEY_MOUSE_BTN_M MOUSE_MIDDLE // Synthetic key #define KEY_MOUSE_BTN_R MOUSE_RIGHT // Synthetic key - +#define KEY_MOUSE_BTN_P MOUSE_PREV +#define KEY_MOUSE_BTN_N MOUSE_NEXT #define KEY_MOUSE_UP B0000001 #define KEY_MOUSE_DOWN B0000010 @@ -62,3 +63,5 @@ #define Key_mouseBtnL (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } #define Key_mouseBtnM (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } #define Key_mouseBtnR (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } +#define Key_mouseBtnP (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_P, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } +#define Key_mouseBtnN (Key) { KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_N, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY } From b71ab5f1b3ea61c8a10871cc8d0ad9c9515fd5ca Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 10 Oct 2018 06:52:05 +0200 Subject: [PATCH 56/59] README.md & Travis cleanup Remove the IRC notifications from Travis (we're not using IRC anymore), and the stable/experimental badge from README.md (because they aren't being kept up to date). Signed-off-by: Gergely Nagy --- .travis.yml | 7 ------- README.md | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 23d30ccc..49b8c498 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,6 @@ install: script: - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware notifications: - irc: - channels: - - "chat.freenode.net#keyboardio" - use_notice: true - skip_join: true - template: - - "%{repository_name}/%{branch} %{commit} by %{author}: %{commit_subject} %{build_url} %{message}" email: on_success: change on_failure: change diff --git a/README.md b/README.md index a2d3ae6f..610ad246 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ # Kaleidoscope-MouseKeys -![status][st:stable] [![Build Status][travis:image]][travis:status] +[![Build Status][travis:image]][travis:status] [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys - [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 - [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 - [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 - Have you ever wanted to control the mouse cursor from the comfort of your keyboard? With this plugin, you can. While it may not replace the mouse in all situations, there are plenty of cases where one will not have to lift their From 0683faeb79fb590e0556286f869fc884964f8961 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 14 Oct 2018 12:43:26 +0200 Subject: [PATCH 57/59] Rearrange the file layout in preparation of becoming a monorepo Move the documentation to `doc/plugin/MouseKeys.md`, sources under `src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of merging plugins into a single monorepo. Signed-off-by: Gergely Nagy --- README.md | 245 +---------------- doc/plugin/MouseKeys.md | 246 ++++++++++++++++++ src/Kaleidoscope-MouseKeys.h | 34 +-- src/MouseWrapper.h | 52 +--- src/{ => kaleidoscope/plugin}/MouseKeyDefs.h | 0 .../plugin/MouseKeys.cpp} | 30 ++- src/kaleidoscope/plugin/MouseKeys.h | 55 ++++ .../plugin}/MouseWarpModes.h | 0 .../plugin}/MouseWrapper.cpp | 7 +- src/kaleidoscope/plugin/MouseWrapper.h | 74 ++++++ 10 files changed, 403 insertions(+), 340 deletions(-) create mode 100644 doc/plugin/MouseKeys.md rename src/{ => kaleidoscope/plugin}/MouseKeyDefs.h (100%) rename src/{Kaleidoscope-MouseKeys.cpp => kaleidoscope/plugin/MouseKeys.cpp} (88%) create mode 100644 src/kaleidoscope/plugin/MouseKeys.h rename src/{ => kaleidoscope/plugin}/MouseWarpModes.h (100%) rename src/{ => kaleidoscope/plugin}/MouseWrapper.cpp (98%) create mode 100644 src/kaleidoscope/plugin/MouseWrapper.h diff --git a/README.md b/README.md index 610ad246..842a8b11 100644 --- a/README.md +++ b/README.md @@ -5,247 +5,4 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys -Have you ever wanted to control the mouse cursor from the comfort of your -keyboard? With this plugin, you can. While it may not replace the mouse in all -situations, there are plenty of cases where one will not have to lift their -hands off the keyboard just to nudge the mouse cursor away a little. - -Of course, there are a lot more one can do with the plugin than to nudge the -cursor! Mouse keys are provided for all four *and* diagonal movement; mouse -buttons; and a unique warping mechanism too. And not only these: the speed of -the cursor, the mouse wheel, and that of acceleration can all be configured to -match one's desired behaviour. - -## Using the plugin - -To use the plugin, simply include the header in your Sketch, tell the firmware -to use the `MouseKeys` object, and place mouse keys on your keymap. It is best -illustrated with an example: - -```c++ -#include -#include - -// Somewhere in the keymap: -Key_mouseUp, Key_mouseDn, Key_mouseL, Key_mouseR, -Key_mouseBtnL, Key_mouseBtnR - -KALEIDOSCOPE_INIT_PLUGINS(MouseKeys); - -void setup() { - Kaleidoscope.setup (); -} -``` - -## Keys provided by the plugin - -The plugin provides a number of keys one can put on the keymap, that allow -control of the mouse. They can be divided into a few groups: - -### Cursor movement - -The simplest set of keys are the mouse cursor movement keys. These move the -cursor one direction or the other, with speed and acceleration factored in. When -a mouse cursor movement key is held down, it will move `.speed` pixels each -`.speedDelay` milliseconds without acceleration. But when `.accelSpeed` is -non-zero (and it is not zero by default, -see [below](#accelspeed-and-acceldelay)), the speed will increase by -`.accelSpeed` every `.accelDelay` milliseconds. Thus, unless configured -otherwise, holding a direction will move that way at increasing speed. - -One can hold more than one key down at the same time, and the cursor will move -towards a direction that is the combination of the keys held. For example, -holding the "mouse up" and "mouse right" keys together will move the cursor -diagonally up and right. - -The cursor movement keys are as follows: - -* `Key_mouseUp`, `Key_mouseDn`, `Key_mouseL`, `Key_mouseR`: Move the cursor up, - down, left, or right, respectively. -* `Key_mouseUpL`, `Key_mouseUpR`, `Key_mouseDnL`, `Key_mouseDnR`: Move the - cursor up-left, up-right, down-left, down-right, respectively. - -### Scroll wheel - -Controlling the scroll wheel is similarly simple. It does not have acceleration, -but one can control the speed with the `.wheelSpeed` and `.wheelDelay` -properties (see below). - -* `Key_mouseScrollUp`, `Key_mouseScrollDn`: Scroll the mouse wheel up or down, - respectively. -* `Key_mouseScrollL`, `Key_mouseScrollR`: Scroll the mouse wheel left or right, - respectively. - -### Buttons - -Buttons are even simpler than movement: there is no movement speed, nor -acceleration involved. One just presses them. - -* `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`, `Key_mouseBtnP`, - `Key_mouseBtnN`: The left, middle, right, previous, and next mouse buttons, - respectively. - -## Warping - -Warping is one of the most interesting features of the plugin, and is a feature -unique to Kaleidoscope, as far as we can tell. The warping keys position the -mouse cursor within a sector of the screen on first press, and any subsequent -taps will warp within the previously selected sector. For example, pressing the -north-west warp key twice will first jump to the middle of the north-west -sector of your screen, then select the north-west sector of that, and jump to -the middle of it. - -To stop warping, use any other mouse key, or hit the "warp end" key. - -### Warp grid size - -The warp grid size determines how MouseKeys partitions the screen to select the -next position to jump to when pressing a warp key. The plugin provides two grid -sizes to choose from: a *2x2* grid that splits the screen into quadrants, and a -*3x3* grid with nine cells similar to a navigation feature included with some -speech recognition software. By default, the plugin splits the screen into the -2x2 grid. - -To change the warp grid size, call the plugin's `setWarpGridSize()` method: - -```c++ -MouseKeys.setWarpGridSize(MOUSE_WARP_GRID_3X3); -``` - -#### 2x2 grid - -As described above, MouseKeys warps the pointer using a grid model that reflects -locations on the screen. By default, the plugin uses a 2x2 grid. To understand -how warping works, examine this diagram of a screen split into that 2x2 grid: - - +-----------------------|-----------------------+ - | | | | - | G | tab | | - | | | | - |-----------|-----------| tab | - | | | | - | B | esc | | - | | | | - +-----------------------|-----------------------+ - | | | - | | | - | | | - | B | esc | - | | | - | | | - | | | - +-----------------------|-----------------------+ - -Each quadrant is labed with a key that, when pressed, moves the mouse pointer -to the center of that quadrant. With this layout, pressing G warps -the pointer to the top-left quadant. Then, the plugin "zooms" into that sector -with a smaller grid so that the next warp key pressed jumps the pointer more -precisely within the sector. In this case, if we press esc next, -the pointer warps to the bottom-right corner within that quadrant. - -The warping keys for the 2x2 grid are the following: - -* `Key_mouseWarpNW`, `Key_mouseWarpNE`, `Key_mouseWarpSW`, `Key_mouseWarpSE`: - Warp towards the north-west, north-east, south-west, or south-east quadrants, - respectively. -* `Key_mouseWarpEnd`: End the warping sequence, resetting it to the default - state. Using any of the warping keys after this will start from the whole - screen again. - -#### 3x3 grid - -A 3x3 warp grid assigns a key to each of nine sectors of the screen. The next -diagram shows a screen with a key label that warps to each sector. As we can -see, pressing W warps the pointer into the top-left sector, and -pressing V warps to the bottom-right corner within that sector: - - +-----------------|-----------------|-----------------+ - | W | E | R | | | - |-----|-----|-----| | | - | S | D | F | E | R | - |-----|-----|-----| | | - | X | C | V | | | - +-----------------|-----------------|-----------------+ - | | | | - | | | | - | S | D | F | - | | | | - | | | | - +-----------------|-----------------|-----------------+ - | | | | - | | | | - | X | C | V | - | | | | - | | | | - +-----------------|-----------------|-----------------+ - -To use a 3x3 warp grid, we may need to remap some keys. A suggested warp key -mapping is shown below on the left side of a keyboard with a QWERTY layout: - - W | E | R T A - End Warping (Key_mouseWarpEnd) - ---|---|--- W - Warp NW Sector (Key_mouseWarpNW) - A S | D | F G E - Warp N Sector (Key_mouseWarpN) - ---|---|--- R - Warp NE Sector (Key_mouseWarpNE) - X | C | V B S - Warp E Sector (Key_mouseWarpE) - D - Warp/Zoom Center (Key_mouseWarpIn) - F - Warp W Sector (Key_mouseWarpW) - K - Warp SE Sector (Key_mouseWarpSE) - C - Warp S Sector (Key_mouseWarpS) - V - Warp SW Sector (Key_mouseWarpSW) - T - Right Click (Key_mouseBtnR) - G - Left Click (Key_mouseBtnL) - B - Middle Click (Key_mouseBtnM) - -This example layout replaces the default directional mouse keys and sets the -warp keys in a comfortable position for a warp-only configuration. Of course, -a Kaleidoscope user may retain the directional keys and map the warp keys -elsewhere according to his or her liking. - -A 3x3 warp grid layout contains all of the keys from the 2x2 grid layout with -the following additions: - -* `Key_mouseWarpN`, `Key_mouseWarpE`, `Key_mouseWarpS`, `Key_mouseWarpW`: - Warp towards the north, east, south, and west sectors, respectively. -* `Key_mouseWarpIn`: Warp to the center sector of the grid. The plugin will - continue to "zoom" into center of the current cell with each consecutive - press of this key. - -## Plugin methods - -The plugin provides a `MouseKeys` object, with the following methods and -properties available: - -### `.speed` and `.speedDelay` - -> These two control the speed of the mouse cursor, when a movement key is held. -> The former, `.speed`, controls the amount of pixels the cursor moves, when it -> has to move, and defaults to 1. The latter, `.speedDelay` is the amount of -> time - in milliseconds - to wait between two movements, and defaults to 0, no -> delay. - -### `.accelSpeed` and `.accelDelay` - -> These two properties control the speed of acceleration. The former, -> `.accelSpeed`, controls how much the speed shall be increased at each step, -> while the second, `.accelDelay`, controls how often (in milliseconds) -> acceleration should be applied. -> -> They default to 1 pixel and 50 milliseconds, respectively. - -### `.wheelSpeed` and `.wheelDelay` - -> The last two properties supported by the plugin control the mouse wheel -> scrolling speed. The former, `.wheelSpeed`, controls the amount of ticks the -> wheel shall scroll, and defaults to 1. The second, `.wheelDelay`, controls the -> delay between two scroll events, and defaults to 50 milliseconds. - -### `.setSpeedLimit` - -> This method sets the maximum speed after which acceleration stops. -> The default is 127, and the minimum value is 16 (things will not work -> properly below 16). - -### `.setWarpGridSize` - -> This method changes the size of the grid used for [warping](#warping). The -> following are valid sizes: `MOUSE_WARP_GRID_2X2`, `MOUSE_WARP_GRID_3X3` +See [doc/plugin/MouseKeys.md](doc/plugin/MouseKeys.md) for documentation. diff --git a/doc/plugin/MouseKeys.md b/doc/plugin/MouseKeys.md new file mode 100644 index 00000000..a095a726 --- /dev/null +++ b/doc/plugin/MouseKeys.md @@ -0,0 +1,246 @@ +# Kaleidoscope-MouseKeys + +Have you ever wanted to control the mouse cursor from the comfort of your +keyboard? With this plugin, you can. While it may not replace the mouse in all +situations, there are plenty of cases where one will not have to lift their +hands off the keyboard just to nudge the mouse cursor away a little. + +Of course, there are a lot more one can do with the plugin than to nudge the +cursor! Mouse keys are provided for all four *and* diagonal movement; mouse +buttons; and a unique warping mechanism too. And not only these: the speed of +the cursor, the mouse wheel, and that of acceleration can all be configured to +match one's desired behaviour. + +## Using the plugin + +To use the plugin, simply include the header in your Sketch, tell the firmware +to use the `MouseKeys` object, and place mouse keys on your keymap. It is best +illustrated with an example: + +```c++ +#include +#include + +// Somewhere in the keymap: +Key_mouseUp, Key_mouseDn, Key_mouseL, Key_mouseR, +Key_mouseBtnL, Key_mouseBtnR + +KALEIDOSCOPE_INIT_PLUGINS(MouseKeys); + +void setup() { + Kaleidoscope.setup (); +} +``` + +## Keys provided by the plugin + +The plugin provides a number of keys one can put on the keymap, that allow +control of the mouse. They can be divided into a few groups: + +### Cursor movement + +The simplest set of keys are the mouse cursor movement keys. These move the +cursor one direction or the other, with speed and acceleration factored in. When +a mouse cursor movement key is held down, it will move `.speed` pixels each +`.speedDelay` milliseconds without acceleration. But when `.accelSpeed` is +non-zero (and it is not zero by default, +see [below](#accelspeed-and-acceldelay)), the speed will increase by +`.accelSpeed` every `.accelDelay` milliseconds. Thus, unless configured +otherwise, holding a direction will move that way at increasing speed. + +One can hold more than one key down at the same time, and the cursor will move +towards a direction that is the combination of the keys held. For example, +holding the "mouse up" and "mouse right" keys together will move the cursor +diagonally up and right. + +The cursor movement keys are as follows: + +* `Key_mouseUp`, `Key_mouseDn`, `Key_mouseL`, `Key_mouseR`: Move the cursor up, + down, left, or right, respectively. +* `Key_mouseUpL`, `Key_mouseUpR`, `Key_mouseDnL`, `Key_mouseDnR`: Move the + cursor up-left, up-right, down-left, down-right, respectively. + +### Scroll wheel + +Controlling the scroll wheel is similarly simple. It does not have acceleration, +but one can control the speed with the `.wheelSpeed` and `.wheelDelay` +properties (see below). + +* `Key_mouseScrollUp`, `Key_mouseScrollDn`: Scroll the mouse wheel up or down, + respectively. +* `Key_mouseScrollL`, `Key_mouseScrollR`: Scroll the mouse wheel left or right, + respectively. + +### Buttons + +Buttons are even simpler than movement: there is no movement speed, nor +acceleration involved. One just presses them. + +* `Key_mouseBtnL`, `Key_mouseBtnM`, `Key_mouseBtnR`, `Key_mouseBtnP`, + `Key_mouseBtnN`: The left, middle, right, previous, and next mouse buttons, + respectively. + +## Warping + +Warping is one of the most interesting features of the plugin, and is a feature +unique to Kaleidoscope, as far as we can tell. The warping keys position the +mouse cursor within a sector of the screen on first press, and any subsequent +taps will warp within the previously selected sector. For example, pressing the +north-west warp key twice will first jump to the middle of the north-west +sector of your screen, then select the north-west sector of that, and jump to +the middle of it. + +To stop warping, use any other mouse key, or hit the "warp end" key. + +### Warp grid size + +The warp grid size determines how MouseKeys partitions the screen to select the +next position to jump to when pressing a warp key. The plugin provides two grid +sizes to choose from: a *2x2* grid that splits the screen into quadrants, and a +*3x3* grid with nine cells similar to a navigation feature included with some +speech recognition software. By default, the plugin splits the screen into the +2x2 grid. + +To change the warp grid size, call the plugin's `setWarpGridSize()` method: + +```c++ +MouseKeys.setWarpGridSize(MOUSE_WARP_GRID_3X3); +``` + +#### 2x2 grid + +As described above, MouseKeys warps the pointer using a grid model that reflects +locations on the screen. By default, the plugin uses a 2x2 grid. To understand +how warping works, examine this diagram of a screen split into that 2x2 grid: + + +-----------------------|-----------------------+ + | | | | + | G | tab | | + | | | | + |-----------|-----------| tab | + | | | | + | B | esc | | + | | | | + +-----------------------|-----------------------+ + | | | + | | | + | | | + | B | esc | + | | | + | | | + | | | + +-----------------------|-----------------------+ + +Each quadrant is labed with a key that, when pressed, moves the mouse pointer +to the center of that quadrant. With this layout, pressing G warps +the pointer to the top-left quadant. Then, the plugin "zooms" into that sector +with a smaller grid so that the next warp key pressed jumps the pointer more +precisely within the sector. In this case, if we press esc next, +the pointer warps to the bottom-right corner within that quadrant. + +The warping keys for the 2x2 grid are the following: + +* `Key_mouseWarpNW`, `Key_mouseWarpNE`, `Key_mouseWarpSW`, `Key_mouseWarpSE`: + Warp towards the north-west, north-east, south-west, or south-east quadrants, + respectively. +* `Key_mouseWarpEnd`: End the warping sequence, resetting it to the default + state. Using any of the warping keys after this will start from the whole + screen again. + +#### 3x3 grid + +A 3x3 warp grid assigns a key to each of nine sectors of the screen. The next +diagram shows a screen with a key label that warps to each sector. As we can +see, pressing W warps the pointer into the top-left sector, and +pressing V warps to the bottom-right corner within that sector: + + +-----------------|-----------------|-----------------+ + | W | E | R | | | + |-----|-----|-----| | | + | S | D | F | E | R | + |-----|-----|-----| | | + | X | C | V | | | + +-----------------|-----------------|-----------------+ + | | | | + | | | | + | S | D | F | + | | | | + | | | | + +-----------------|-----------------|-----------------+ + | | | | + | | | | + | X | C | V | + | | | | + | | | | + +-----------------|-----------------|-----------------+ + +To use a 3x3 warp grid, we may need to remap some keys. A suggested warp key +mapping is shown below on the left side of a keyboard with a QWERTY layout: + + W | E | R T A - End Warping (Key_mouseWarpEnd) + ---|---|--- W - Warp NW Sector (Key_mouseWarpNW) + A S | D | F G E - Warp N Sector (Key_mouseWarpN) + ---|---|--- R - Warp NE Sector (Key_mouseWarpNE) + X | C | V B S - Warp E Sector (Key_mouseWarpE) + D - Warp/Zoom Center (Key_mouseWarpIn) + F - Warp W Sector (Key_mouseWarpW) + K - Warp SE Sector (Key_mouseWarpSE) + C - Warp S Sector (Key_mouseWarpS) + V - Warp SW Sector (Key_mouseWarpSW) + T - Right Click (Key_mouseBtnR) + G - Left Click (Key_mouseBtnL) + B - Middle Click (Key_mouseBtnM) + +This example layout replaces the default directional mouse keys and sets the +warp keys in a comfortable position for a warp-only configuration. Of course, +a Kaleidoscope user may retain the directional keys and map the warp keys +elsewhere according to his or her liking. + +A 3x3 warp grid layout contains all of the keys from the 2x2 grid layout with +the following additions: + +* `Key_mouseWarpN`, `Key_mouseWarpE`, `Key_mouseWarpS`, `Key_mouseWarpW`: + Warp towards the north, east, south, and west sectors, respectively. +* `Key_mouseWarpIn`: Warp to the center sector of the grid. The plugin will + continue to "zoom" into center of the current cell with each consecutive + press of this key. + +## Plugin methods + +The plugin provides a `MouseKeys` object, with the following methods and +properties available: + +### `.speed` and `.speedDelay` + +> These two control the speed of the mouse cursor, when a movement key is held. +> The former, `.speed`, controls the amount of pixels the cursor moves, when it +> has to move, and defaults to 1. The latter, `.speedDelay` is the amount of +> time - in milliseconds - to wait between two movements, and defaults to 0, no +> delay. + +### `.accelSpeed` and `.accelDelay` + +> These two properties control the speed of acceleration. The former, +> `.accelSpeed`, controls how much the speed shall be increased at each step, +> while the second, `.accelDelay`, controls how often (in milliseconds) +> acceleration should be applied. +> +> They default to 1 pixel and 50 milliseconds, respectively. + +### `.wheelSpeed` and `.wheelDelay` + +> The last two properties supported by the plugin control the mouse wheel +> scrolling speed. The former, `.wheelSpeed`, controls the amount of ticks the +> wheel shall scroll, and defaults to 1. The second, `.wheelDelay`, controls the +> delay between two scroll events, and defaults to 50 milliseconds. + +### `.setSpeedLimit` + +> This method sets the maximum speed after which acceleration stops. +> The default is 127, and the minimum value is 16 (things will not work +> properly below 16). + +### `.setWarpGridSize` + +> This method changes the size of the grid used for [warping](#warping). The +> following are valid sizes: `MOUSE_WARP_GRID_2X2`, `MOUSE_WARP_GRID_3X3` diff --git a/src/Kaleidoscope-MouseKeys.h b/src/Kaleidoscope-MouseKeys.h index bc6615da..b948baea 100644 --- a/src/Kaleidoscope-MouseKeys.h +++ b/src/Kaleidoscope-MouseKeys.h @@ -16,36 +16,4 @@ #pragma once -#include "Kaleidoscope.h" -#include "MouseKeyDefs.h" -#include "MouseWarpModes.h" - -class MouseKeys_ : public kaleidoscope::Plugin { - public: - MouseKeys_(void) {} - - static uint8_t speed; - static uint16_t speedDelay; - static uint8_t accelSpeed; - static uint16_t accelDelay; - static uint8_t wheelSpeed; - static uint16_t wheelDelay; - - static void setWarpGridSize(uint8_t grid_size); - static void setSpeedLimit(uint8_t speed_limit); - - kaleidoscope::EventHandlerResult onSetup(); - kaleidoscope::EventHandlerResult beforeReportingState(); - kaleidoscope::EventHandlerResult afterEachCycle(); - kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState); - - private: - static uint8_t mouseMoveIntent; - static uint32_t endTime; - static uint32_t accelEndTime; - static uint32_t wheelEndTime; - - static void scrollWheel(uint8_t keyCode); -}; - -extern MouseKeys_ MouseKeys; +#include "kaleidoscope/plugin/MouseKeys.h" diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index b85b950f..7f6e39e8 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -16,54 +16,6 @@ #pragma once -#include "Arduino.h" -#include "MouseWarpModes.h" +#warning Please migrate to including "kaleidoscope/plugin/MouseWrapper.h" instead of "MouseWrapper.h", or even consider dropping the include, because will pull the right header in anyway. -// Warping commands - -#define WARP_END 1 -#define WARP_UP 2 -#define WARP_DOWN 4 -#define WARP_LEFT 8 -#define WARP_RIGHT 16 - -// apparently, the mac discards 15% of the value space for mouse movement. -// need to test this on other platforms - -#define MAX_WARP_WIDTH 32767 -#define MAX_WARP_HEIGHT 32767 - -#define WARP_ABS_TOP 0 -#define WARP_ABS_LEFT 0 - -// Mouse acceleration - -class MouseWrapper_ { - public: - MouseWrapper_(void); - - static void begin(void); - static void move(int8_t x, int8_t y); - static void warp(uint8_t warp_cmd); - static void reset_warping(); - static void pressButton(uint8_t button); - static void release_button(uint8_t button); - static uint8_t accelStep; - static uint8_t speedLimit; - static uint8_t subpixelsPerPixel; - static uint8_t warp_grid_size; - - private: - static uint16_t next_width; - static uint16_t next_height; - static uint16_t section_top; - static uint16_t section_left; - static boolean is_warping; - - static uint8_t acceleration(uint8_t cycles); - static void begin_warping(); - static void end_warping(); - static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); -}; - -extern MouseWrapper_ MouseWrapper; +#include "kaleidoscope/plugin/MouseWrapper.h" diff --git a/src/MouseKeyDefs.h b/src/kaleidoscope/plugin/MouseKeyDefs.h similarity index 100% rename from src/MouseKeyDefs.h rename to src/kaleidoscope/plugin/MouseKeyDefs.h diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/kaleidoscope/plugin/MouseKeys.cpp similarity index 88% rename from src/Kaleidoscope-MouseKeys.cpp rename to src/kaleidoscope/plugin/MouseKeys.cpp index a59cfd22..80612198 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/kaleidoscope/plugin/MouseKeys.cpp @@ -20,6 +20,9 @@ #include "MouseWrapper.h" #include "Kaleidoscope.h" +namespace kaleidoscope { +namespace plugin { + uint8_t MouseKeys_::mouseMoveIntent; uint8_t MouseKeys_::speed = 1; @@ -59,24 +62,24 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) { kaleidoscope::hid::moveMouse(0, 0, 0, wheelSpeed); } -kaleidoscope::EventHandlerResult MouseKeys_::afterEachCycle() { +EventHandlerResult MouseKeys_::afterEachCycle() { kaleidoscope::hid::sendMouseReport(); kaleidoscope::hid::releaseAllMouseButtons(); mouseMoveIntent = 0; - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; } -kaleidoscope::EventHandlerResult MouseKeys_::beforeReportingState() { +EventHandlerResult MouseKeys_::beforeReportingState() { if (mouseMoveIntent == 0) { MouseWrapper.accelStep = 0; endTime = 0; accelEndTime = 0; - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; } if (millis() < endTime) - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; endTime = millis() + speedDelay; @@ -101,12 +104,12 @@ kaleidoscope::EventHandlerResult MouseKeys_::beforeReportingState() { MouseWrapper.move(moveX, moveY); - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; } -kaleidoscope::EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState) { +EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState) { if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY)) - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; if (mappedKey.keyCode & KEY_MOUSE_BUTTON && !(mappedKey.keyCode & KEY_MOUSE_WARP)) { uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; @@ -173,13 +176,16 @@ kaleidoscope::EventHandlerResult MouseKeys_::onKeyswitchEvent(Key &mappedKey, by } } - return kaleidoscope::EventHandlerResult::EVENT_CONSUMED; + return EventHandlerResult::EVENT_CONSUMED; } -kaleidoscope::EventHandlerResult MouseKeys_::onSetup(void) { +EventHandlerResult MouseKeys_::onSetup(void) { MouseWrapper.begin(); - return kaleidoscope::EventHandlerResult::OK; + return EventHandlerResult::OK; +} + +} } -MouseKeys_ MouseKeys; +kaleidoscope::plugin::MouseKeys_ MouseKeys; diff --git a/src/kaleidoscope/plugin/MouseKeys.h b/src/kaleidoscope/plugin/MouseKeys.h new file mode 100644 index 00000000..8b958cba --- /dev/null +++ b/src/kaleidoscope/plugin/MouseKeys.h @@ -0,0 +1,55 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + +#pragma once + +#include "Kaleidoscope.h" +#include "MouseKeyDefs.h" +#include "MouseWarpModes.h" + +namespace kaleidoscope { +namespace plugin { +class MouseKeys_ : public kaleidoscope::Plugin { + public: + MouseKeys_(void) {} + + static uint8_t speed; + static uint16_t speedDelay; + static uint8_t accelSpeed; + static uint16_t accelDelay; + static uint8_t wheelSpeed; + static uint16_t wheelDelay; + + static void setWarpGridSize(uint8_t grid_size); + static void setSpeedLimit(uint8_t speed_limit); + + EventHandlerResult onSetup(); + EventHandlerResult beforeReportingState(); + EventHandlerResult afterEachCycle(); + EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState); + + private: + static uint8_t mouseMoveIntent; + static uint32_t endTime; + static uint32_t accelEndTime; + static uint32_t wheelEndTime; + + static void scrollWheel(uint8_t keyCode); +}; +} +} + +extern kaleidoscope::plugin::MouseKeys_ MouseKeys; diff --git a/src/MouseWarpModes.h b/src/kaleidoscope/plugin/MouseWarpModes.h similarity index 100% rename from src/MouseWarpModes.h rename to src/kaleidoscope/plugin/MouseWarpModes.h diff --git a/src/MouseWrapper.cpp b/src/kaleidoscope/plugin/MouseWrapper.cpp similarity index 98% rename from src/MouseWrapper.cpp rename to src/kaleidoscope/plugin/MouseWrapper.cpp index ec5b1a29..ac6db7f9 100644 --- a/src/MouseWrapper.cpp +++ b/src/kaleidoscope/plugin/MouseWrapper.cpp @@ -21,6 +21,9 @@ #include "MouseWrapper.h" #include "kaleidoscope/hid.h" +namespace kaleidoscope { +namespace plugin { + uint8_t MouseWrapper_::warp_grid_size = MOUSE_WARP_GRID_2X2; uint16_t MouseWrapper_::next_width; uint16_t MouseWrapper_::next_height; @@ -173,5 +176,7 @@ void MouseWrapper_::move(int8_t x, int8_t y) { remainderX = moveX - moveX / subpixelsPerPixel * subpixelsPerPixel; remainderY = moveY - moveY / subpixelsPerPixel * subpixelsPerPixel; } +} +} -MouseWrapper_ MouseWrapper; +kaleidoscope::plugin::MouseWrapper_ MouseWrapper; diff --git a/src/kaleidoscope/plugin/MouseWrapper.h b/src/kaleidoscope/plugin/MouseWrapper.h new file mode 100644 index 00000000..e5938a18 --- /dev/null +++ b/src/kaleidoscope/plugin/MouseWrapper.h @@ -0,0 +1,74 @@ +/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. + * Copyright (C) 2017-2018 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 . + */ + +#pragma once + +#include "Arduino.h" +#include "MouseWarpModes.h" + +// Warping commands + +#define WARP_END 1 +#define WARP_UP 2 +#define WARP_DOWN 4 +#define WARP_LEFT 8 +#define WARP_RIGHT 16 + +// apparently, the mac discards 15% of the value space for mouse movement. +// need to test this on other platforms + +#define MAX_WARP_WIDTH 32767 +#define MAX_WARP_HEIGHT 32767 + +#define WARP_ABS_TOP 0 +#define WARP_ABS_LEFT 0 + +// Mouse acceleration + +namespace kaleidoscope { +namespace plugin { + +class MouseWrapper_ { + public: + MouseWrapper_(void); + + static void begin(void); + static void move(int8_t x, int8_t y); + static void warp(uint8_t warp_cmd); + static void reset_warping(); + static void pressButton(uint8_t button); + static void release_button(uint8_t button); + static uint8_t accelStep; + static uint8_t speedLimit; + static uint8_t subpixelsPerPixel; + static uint8_t warp_grid_size; + + private: + static uint16_t next_width; + static uint16_t next_height; + static uint16_t section_top; + static uint16_t section_left; + static boolean is_warping; + + static uint8_t acceleration(uint8_t cycles); + static void begin_warping(); + static void end_warping(); + static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); +}; +} +} + +extern kaleidoscope::plugin::MouseWrapper_ MouseWrapper; From cdb5087ec965bb3830b2c4d86ef8b97f31b1779a Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 14 Oct 2018 12:43:26 +0200 Subject: [PATCH 58/59] Remove files we do not need in the monorepo Signed-off-by: Gergely Nagy --- .travis.yml | 14 - CONTRIBUTING.md | 50 ---- COPYING | 674 --------------------------------------------- Makefile | 14 - README.md | 8 - library.properties | 10 - 6 files changed, 770 deletions(-) delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 COPYING delete mode 100644 Makefile delete mode 100644 README.md delete mode 100644 library.properties diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 49b8c498..00000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -dist: trusty -sudo: false -os: - - linux -install: - - git clone --depth 1 --recurse-submodules https://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio hardware/keyboardio -script: - - make travis-test BOARD_HARDWARE_PATH=$(pwd)/hardware -notifications: - email: - on_success: change - on_failure: change -cache: - ccache: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c490e3ce..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,50 +0,0 @@ -# Developer Certificate of Origin - -All contributions must include acceptance of the DCO: - -``` -Developer Certificate of Origin -Version 1.1 - -Copyright (C) 2004, 2006 The Linux Foundation and its contributors. -1 Letterman Drive -Suite D4700 -San Francisco, CA, 94129 - -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. - - -Developer's Certificate of Origin 1.1 - -By making a contribution to this project, I certify that: - -(a) The contribution was created in whole or in part by me and I - have the right to submit it under the open source license - indicated in the file; or - -(b) The contribution is based upon previous work that, to the best - of my knowledge, is covered under an appropriate open source - license and I have the right under that license to submit that - work with modifications, whether created in whole or in part - by me, under the same open source license (unless I am - permitted to submit under a different license), as indicated - in the file; or - -(c) The contribution was provided directly to me by some other - person who certified (a), (b) or (c) and I have not modified - it. - -(d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with - this project or the open source license(s) involved. -``` - -## Sign your work - -To accept the DCO, please add this line to each commit message with your name -and email address (`git commit -s` will do this for you): - - Signed-off-by: Jane Example diff --git a/COPYING b/COPYING deleted file mode 100644 index 94a9ed02..00000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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, either version 3 of the License, or - (at your option) any later version. - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Makefile b/Makefile deleted file mode 100644 index 8f830f44..00000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# This stub makefile for a Kaleidoscope plugin pulls in -# all targets from the Kaleidoscope-Plugin library - -UNAME_S := $(shell uname -s) - -ifeq ($(UNAME_S),Darwin) -SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino/ -else -SKETCHBOOK_DIR ?= $(HOME)/Arduino -endif - -BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware -KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/ -include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk diff --git a/README.md b/README.md deleted file mode 100644 index 842a8b11..00000000 --- a/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Kaleidoscope-MouseKeys - -[![Build Status][travis:image]][travis:status] - - [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys.svg?branch=master - [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MouseKeys - -See [doc/plugin/MouseKeys.md](doc/plugin/MouseKeys.md) for documentation. diff --git a/library.properties b/library.properties deleted file mode 100644 index 37481310..00000000 --- a/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=Kaleidoscope-MouseKeys -version=0.0.1 -author=Jesse Vincent -maintainer=Jesse Vincent -sentence=Mouse keys for Kaleidoscope. -paragraph=Simulate a mouse with keys on a regular keyboard. -category=Communication -url=https://github.com/keyboardio/Kaleidoscope-MouseKeys -architectures=avr -dot_a_linkage=true \ No newline at end of file From 4f2ca9f58fc82af8377cea0197b788c039acd20c Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 15 Oct 2018 23:55:20 +0200 Subject: [PATCH 59/59] Further source code rearrangement Move auxiliary files to `src/kaleidoscope/plugin/MouseKeys` to not pollute the `kaleidoscope/plugin` directory with headers not meant to be included directly. Signed-off-by: Gergely Nagy --- src/MouseWrapper.h | 4 ++-- src/kaleidoscope/plugin/MouseKeys.cpp | 3 +-- src/kaleidoscope/plugin/MouseKeys.h | 5 +++-- src/kaleidoscope/plugin/{ => MouseKeys}/MouseKeyDefs.h | 0 src/kaleidoscope/plugin/{ => MouseKeys}/MouseWarpModes.h | 0 src/kaleidoscope/plugin/{ => MouseKeys}/MouseWrapper.cpp | 2 +- src/kaleidoscope/plugin/{ => MouseKeys}/MouseWrapper.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename src/kaleidoscope/plugin/{ => MouseKeys}/MouseKeyDefs.h (100%) rename src/kaleidoscope/plugin/{ => MouseKeys}/MouseWarpModes.h (100%) rename src/kaleidoscope/plugin/{ => MouseKeys}/MouseWrapper.cpp (98%) rename src/kaleidoscope/plugin/{ => MouseKeys}/MouseWrapper.h (97%) diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 7f6e39e8..ad127ce7 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -16,6 +16,6 @@ #pragma once -#warning Please migrate to including "kaleidoscope/plugin/MouseWrapper.h" instead of "MouseWrapper.h", or even consider dropping the include, because will pull the right header in anyway. +#warning The "MouseWrapper.h" header is deprecated, the same functionality is included by default when using . It can be safely removed. -#include "kaleidoscope/plugin/MouseWrapper.h" +#include "kaleidoscope/plugin/MouseKeys/MouseWrapper.h" diff --git a/src/kaleidoscope/plugin/MouseKeys.cpp b/src/kaleidoscope/plugin/MouseKeys.cpp index 80612198..52fbe618 100644 --- a/src/kaleidoscope/plugin/MouseKeys.cpp +++ b/src/kaleidoscope/plugin/MouseKeys.cpp @@ -16,9 +16,8 @@ #include -#include "Kaleidoscope-MouseKeys.h" -#include "MouseWrapper.h" #include "Kaleidoscope.h" +#include "Kaleidoscope-MouseKeys.h" namespace kaleidoscope { namespace plugin { diff --git a/src/kaleidoscope/plugin/MouseKeys.h b/src/kaleidoscope/plugin/MouseKeys.h index 8b958cba..71ba3fd4 100644 --- a/src/kaleidoscope/plugin/MouseKeys.h +++ b/src/kaleidoscope/plugin/MouseKeys.h @@ -17,8 +17,9 @@ #pragma once #include "Kaleidoscope.h" -#include "MouseKeyDefs.h" -#include "MouseWarpModes.h" +#include "kaleidoscope/plugin/MouseKeys/MouseKeyDefs.h" +#include "kaleidoscope/plugin/MouseKeys/MouseWarpModes.h" +#include "kaleidoscope/plugin/MouseKeys/MouseWrapper.h" namespace kaleidoscope { namespace plugin { diff --git a/src/kaleidoscope/plugin/MouseKeyDefs.h b/src/kaleidoscope/plugin/MouseKeys/MouseKeyDefs.h similarity index 100% rename from src/kaleidoscope/plugin/MouseKeyDefs.h rename to src/kaleidoscope/plugin/MouseKeys/MouseKeyDefs.h diff --git a/src/kaleidoscope/plugin/MouseWarpModes.h b/src/kaleidoscope/plugin/MouseKeys/MouseWarpModes.h similarity index 100% rename from src/kaleidoscope/plugin/MouseWarpModes.h rename to src/kaleidoscope/plugin/MouseKeys/MouseWarpModes.h diff --git a/src/kaleidoscope/plugin/MouseWrapper.cpp b/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp similarity index 98% rename from src/kaleidoscope/plugin/MouseWrapper.cpp rename to src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp index ac6db7f9..b52fb2c1 100644 --- a/src/kaleidoscope/plugin/MouseWrapper.cpp +++ b/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp @@ -18,7 +18,7 @@ // Mouse-related methods // // -#include "MouseWrapper.h" +#include "kaleidoscope/plugin/MouseKeys/MouseWrapper.h" #include "kaleidoscope/hid.h" namespace kaleidoscope { diff --git a/src/kaleidoscope/plugin/MouseWrapper.h b/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.h similarity index 97% rename from src/kaleidoscope/plugin/MouseWrapper.h rename to src/kaleidoscope/plugin/MouseKeys/MouseWrapper.h index e5938a18..c2641771 100644 --- a/src/kaleidoscope/plugin/MouseWrapper.h +++ b/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.h @@ -17,7 +17,7 @@ #pragma once #include "Arduino.h" -#include "MouseWarpModes.h" +#include "kaleidoscope/plugin/MouseKeys/MouseWarpModes.h" // Warping commands