aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-06-04 00:10:47 -0400
committerJack Humbert <jack.humb@gmail.com>2016-06-04 00:10:47 -0400
commitb36e532b5e0eef219f33075e6e60b68d104484ee (patch)
tree6979225bc1c87f339b358945ec2558c396da4530 /doc
parent189a3b02fb7b43c6bc28271ee0c0bf9eb16810bf (diff)
downloadqmk_firmware-b36e532b5e0eef219f33075e6e60b68d104484ee.tar.gz
qmk_firmware-b36e532b5e0eef219f33075e6e60b68d104484ee.zip
cleans up folder structure
* consolidates docs * deletes converter/ * updates .md references (most)
Diffstat (limited to 'doc')
-rw-r--r--doc/BUILD_GUIDE.md60
-rw-r--r--doc/COPYING.GPLv2339
-rw-r--r--doc/COPYING.GPLv3674
-rwxr-xr-xdoc/CYGWIN_GUIDE.md352
-rw-r--r--doc/FUSE.txt40
-rw-r--r--doc/HAND_WIRE.md321
-rw-r--r--doc/PCB_GUIDE.md151
-rw-r--r--doc/POWER.txt62
-rw-r--r--doc/TMK_README.md243
-rw-r--r--doc/USB_NKRO.txt160
-rw-r--r--doc/VAGRANT_GUIDE.md26
-rw-r--r--doc/build_old.md187
-rw-r--r--doc/keycode.txt261
-rw-r--r--doc/keymap.md599
-rw-r--r--doc/other_projects.md62
15 files changed, 3537 insertions, 0 deletions
diff --git a/doc/BUILD_GUIDE.md b/doc/BUILD_GUIDE.md
new file mode 100644
index 000000000..089d63834
--- /dev/null
+++ b/doc/BUILD_GUIDE.md
@@ -0,0 +1,60 @@
1# Build Guide
2
3## Build Environment Setup
4
5### Windows (Vista and later)
61. If you have ever installed WinAVR, uninstall it.
72. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**.
83. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location.
94. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer.
105. Double-click on the 1-setup-path-win batch script to run it. You'll need to accept a User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up.
116. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete!
127. Future build commands should be run from the standard Windows command prompt, which you can find by searching for "command prompt" from the start menu or start screen. Ignore the "MHV AVR Shell".
13
14### Mac
15If you're using [homebrew,](http://brew.sh/) you can use the following commands:
16
17 brew tap osx-cross/avr
18 brew install avr-libc
19 brew install dfu-programmer
20
21This is the recommended method. If you don't have homebrew, [install it!](http://brew.sh/) It's very much worth it for anyone who works in the command line.
22
23You can also try these instructions:
24
251. Install Xcode from the App Store.
262. Install the Command Line Tools from `Xcode->Preferences->Downloads`.
273. Install [DFU-Programmer][dfu-prog].
28
29### Linux
30Install AVR GCC, AVR libc, and dfu-progammer with your favorite package manager.
31
32Debian/Ubuntu example:
33
34 sudo apt-get update
35 sudo apt-get install gcc-avr avr-libc dfu-programmer
36
37### Vagrant
38If you have any problems building the firmware, you can try using a tool called Vagrant. It will set up a virtual computer with a known configuration that's ready-to-go for firmware building. OLKB does NOT host the files for this virtual computer. Details on how to set up Vagrant are in the [VAGRANT_GUIDE file](VAGRANT_GUIDE.md).
39
40## Verify Your Installation
411. If you haven't already, obtain this repository ([https://github.com/jackhumbert/qmk_firmware](https://github.com/jackhumbert/qmk_firmware)). You can either download it as a zip file and extract it, or clone it using the command line tool git or the Github Desktop application.
422. Open up a terminal or command prompt and navigate to the qmk_firmware folder using the `cd` command. The command prompt will typically open to your home directory. If, for example, you cloned the repository to your Documents folder, then you would type `cd Documents/qmk_firmware`. If you extracted the file from a zip, then it may be named `qmk_firmware-master` instead.
433. To confirm that you're in the correct location, you can display the contents of your current folder using the `dir` command on Windows, or the `ls` command on Linux or Mac. You should see several files, including `README.md` and a `quantum` folder. From here, you need to navigate to the appropriate folder under `keyboard/`. For example, if you're building for a Planck, run `cd keyboard/planck`.
444. Once you're in the correct keyboard-specific folder, run the `make` command. This should output a lot of information about the build process.
45
46## Customizing, Building, and Deploying Your Firmware
47
48Note: Some keyboard folders have non-standard organizations, and may not even support specifying alternate keymaps. Until these get reorganized, you will need to edit their default keymaps directly.
49
501. Running the `make` command from your keyboard's folder will generate a .hex file based on the default keymap. All keymaps for a particular keyboard live in the `keymaps` folder in that keyboard's folder. To create your own keymap, duplicate the folder `keymaps/default`, and rename it with your name, for example `jack`. Or, if you don't care about the ability to share your keymap with the community via GitHub, you can just modify the default keymap itself. Details on how to program keymap files can be found in other guides.
512. To build a keymap other than the default, type `KEYMAP=<name>` after `make`. So if I've named my keymap `jack`, the full command would be `make KEYMAP=jack`.
523. How you deploy the firmware will depend on whether you are using a PCB or a Teensy. In both cases, you'll need to put the keyboard in bootloader mode, either by pressing a button on the PCB/Teensy or pressing the key with the `RESET` keycode. Then, if you're using a PCB, just run `make KEYMAP=<name> dfu` to both build and deploy the firmware. If you're using a Teensy, you'll probably need to take the <keyboardname>.hex file that make produces in the keyboard's folder, and deploy it using the [Teensy Loader.](https://www.pjrc.com/teensy/loader.html)
53
54## Helpful Tips
551. On Linux or OS X, you can run `sleep 5; make KEYMAP=<name> dfu` to delay building/deploying the firmware until for 5 seconds, giving you a chance to put the firmware into bootloader mode. You can change the 5 to any number of seconds.
56
57## Troubleshooting
581. Try running `make clean` if the make command fails.
59
60 WIP
diff --git a/doc/COPYING.GPLv2 b/doc/COPYING.GPLv2
new file mode 100644
index 000000000..d159169d1
--- /dev/null
+++ b/doc/COPYING.GPLv2
@@ -0,0 +1,339 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Lesser General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License along
307 with this program; if not, write to the Free Software Foundation, Inc.,
308 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
310Also add information on how to contact you by electronic and paper mail.
311
312If the program is interactive, make it output a short notice like this
313when it starts in an interactive mode:
314
315 Gnomovision version 69, Copyright (C) year name of author
316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 This is free software, and you are welcome to redistribute it
318 under certain conditions; type `show c' for details.
319
320The hypothetical commands `show w' and `show c' should show the appropriate
321parts of the General Public License. Of course, the commands you use may
322be called something other than `show w' and `show c'; they could even be
323mouse-clicks or menu items--whatever suits your program.
324
325You should also get your employer (if you work as a programmer) or your
326school, if any, to sign a "copyright disclaimer" for the program, if
327necessary. Here is a sample; alter the names:
328
329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
332 <signature of Ty Coon>, 1 April 1989
333 Ty Coon, President of Vice
334
335This General Public License does not permit incorporating your program into
336proprietary programs. If your program is a subroutine library, you may
337consider it more useful to permit linking proprietary applications with the
338library. If this is what you want to do, use the GNU Lesser General
339Public License instead of this License.
diff --git a/doc/COPYING.GPLv3 b/doc/COPYING.GPLv3
new file mode 100644
index 000000000..94a9ed024
--- /dev/null
+++ b/doc/COPYING.GPLv3
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14to take away your freedom to share and change the works. By contrast,
15the GNU General Public License is intended to guarantee your freedom to
16share and change all versions of a program--to make sure it remains free
17software for all its users. We, the Free Software Foundation, use the
18GNU General Public License for most of our software; it applies also to
19any other work released this way by its authors. You can apply it to
20your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23price. Our General Public Licenses are designed to make sure that you
24have the freedom to distribute copies of free software (and charge for
25them if you wish), that you receive source code or can get it if you
26want it, that you can change the software or use pieces of it in new
27free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30these rights or asking you to surrender the rights. Therefore, you have
31certain responsibilities if you distribute copies of the software, or if
32you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35gratis or for a fee, you must pass on to the recipients the same
36freedoms that you received. You must make sure that they, too, receive
37or can get the source code. And you must show them these terms so they
38know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41(1) assert copyright on the software, and (2) offer you this License
42giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45that there is no warranty for this free software. For both users' and
46authors' sake, the GPL requires that modified versions be marked as
47changed, so that their problems will not be attributed erroneously to
48authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51modified versions of the software inside them, although the manufacturer
52can do so. This is fundamentally incompatible with the aim of
53protecting users' freedom to change the software. The systematic
54pattern of such abuse occurs in the area of products for individuals to
55use, which is precisely where it is most unacceptable. Therefore, we
56have designed this version of the GPL to prohibit the practice for those
57products. If such problems arise substantially in other domains, we
58stand ready to extend this provision to those domains in future versions
59of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62States should not allow patents to restrict development and use of
63software on general-purpose computers, but in those that do, we wish to
64avoid the special danger that patents applied to a free program could
65make it effectively proprietary. To prevent this, the GPL assures that
66patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81License. Each licensee is addressed as "you". "Licensees" and
82"recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85in a fashion requiring copyright permission, other than the making of an
86exact copy. The resulting work is called a "modified version" of the
87earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93permission, would make you directly or secondarily liable for
94infringement under applicable copyright law, except executing it on a
95computer or modifying a private copy. Propagation includes copying,
96distribution (with or without modification), making available to the
97public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100parties to make or receive copies. Mere interaction with a user through
101a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104to the extent that it includes a convenient and prominently visible
105feature that (1) displays an appropriate copyright notice, and (2)
106tells the user that there is no warranty for the work (except to the
107extent that warranties are provided), that licensees may convey the
108work under this License, and how to view a copy of this License. If
109the interface presents a list of user commands or options, such as a
110menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115for making modifications to it. "Object code" means any non-source
116form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119standard defined by a recognized standards body, or, in the case of
120interfaces specified for a particular programming language, one that
121is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124than the work as a whole, that (a) is included in the normal form of
125packaging a Major Component, but which is not part of that Major
126Component, and (b) serves only to enable use of the work with that
127Major Component, or to implement a Standard Interface for which an
128implementation is available to the public in source code form. A
129"Major Component", in this context, means a major essential component
130(kernel, window system, and so on) of the specific operating system
131(if any) on which the executable work runs, or a compiler used to
132produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135the source code needed to generate, install, and (for an executable
136work) run the object code and to modify the work, including scripts to
137control those activities. However, it does not include the work's
138System Libraries, or general-purpose tools or generally available free
139programs which are used unmodified in performing those activities but
140which are not part of the work. For example, Corresponding Source
141includes interface definition files associated with source files for
142the work, and the source code for shared libraries and dynamically
143linked subprograms that the work is specifically designed to require,
144such as by intimate data communication or control flow between those
145subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148can regenerate automatically from other parts of the Corresponding
149Source.
150
151 The Corresponding Source for a work in source code form is that
152same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157copyright on the Program, and are irrevocable provided the stated
158conditions are met. This License explicitly affirms your unlimited
159permission to run the unmodified Program. The output from running a
160covered work is covered by this License only if the output, given its
161content, constitutes a covered work. This License acknowledges your
162rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/doc/CYGWIN_GUIDE.md b/doc/CYGWIN_GUIDE.md
new file mode 100755
index 000000000..ac13e745d
--- /dev/null
+++ b/doc/CYGWIN_GUIDE.md
@@ -0,0 +1,352 @@
1#Planck Advanced (but not too advanced) `cygwin` Users Guide
2If you are a user of the [cygwin environment](https://cygwin.com) in Windows and want the freedom to use the latest tools available, then this is the guide for you. If compiling your own copy of the latest and greatest Gnu C Compiler makes you super happy, then this is the guide for you. If the command line make you smile, then this is the guide for you.
3
4This guide was written step by step as I went through the process on a `Windows 10` `x86_64` and a `Windows 7` `amd k10` based system. This should be generally applicable to to any `Windows` environment with `cygwin`.
5
6#####Do not skip steps. Do not move past a step until the previous step finishes successfully.
7
8Based on [avr-libc installation guide](http://www.nongnu.org/avr-libc/user-manual/install_tools.html)
9
10##Get the Required Packages
11Download the `cygwin` setup ([x86_64](https://cygwin.com/setup-x86_64.exe)) and install the default system plus the following if they are not already selected:
12- devel/git
13- devel/gcc-core
14- devel/gcc-g++
15- devel/flex
16- devel/bison
17- devel/make
18- devel/texinfo
19- devel/gettext-devel
20- devel/automake
21- devel/autoconfig
22- devel/libtool
23- text/gettext
24- libs/libgcc1
25- interpreters/m4
26- web/wget
27- archive/unzip
28
29The following sources will be required:
30- [gmp](https://gmplib.org/) (6.1.0)
31- [mpfr](http://www.mpfr.org/) (3.1.4)
32- [mpc](http://www.multiprecision.org/) (1.0.3)
33- [binutils](https://www.sourceware.org/binutils/) (2.26)
34- [gcc](https://gcc.gnu.org/) (5.3.0)
35- [avr-libc](http://www.nongnu.org/avr-libc/) (2.0.0)
36
37The `dfu-programmer` will be required to flash the new firmware
38- [dfu-programmer](https://dfu-programmer.github.io/) (0.7.2)
39
40The set of commands below will create a directory (`~/local/avr`) for the sources you compile to be installed on the machine and a directory (`~/src`) for these source files to be stored. The commands then download the sources of the needed packages and unpack them. Note: the expand commands are different depending on if the packages are offered as a `bz2` or `gz` archive
41```
42$ mkdir ~/local
43$ mkdir ~/local/avr
44$ mkdir ~/src
45$ cd ~/src
46$ wget https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2
47$ wget http://www.mpfr.org/mpfr-3.1.4/mpfr-3.1.4.tar.bz2
48$ wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
49$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.gz
50$ wget http://mirror0.babylon.network/gcc/releases/gcc-5.3.0/gcc-5.3.0.tar.gz
51$ wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-2.0.0.tar.bz2
52$ tar -xjf gmp-6.1.0.tar.bz2
53$ tar -xjf mpfr-3.1.4.tar.bz2
54$ tar -zxf mpc-1.0.3.tar.gz
55$ tar -zxf binutils-2.26.tar.gz
56$ tar -zxf gcc-5.3.0.tar.gz
57$ tar -xjf avr-libc-2.0.0.tar.bz2
58```
59
60##Setup the Build Environment
61These commands will set up the install directory and the `PATH` variable, which will allow you to access your installed packages. Note: if you close the `cygwin` terminal window, you will need to rerun these commands, they are not permanent.
62```
63$ PREFIX=$HOME/local/avr
64$ export PREFIX
65$ PATH=/usr/local/bin:/usr/local/lib:/usr/local/include:/bin:/lib:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS
66$ PATH=$PATH:$PREFIX/bin:$PREFIX/lib
67$ export PATH
68```
69
70##The `gcc` Required Math Library Packages
71The following packages are required to be complied and installed in order to compile `gcc`. They are not sufficiently available through the `cygwin` package system, so we have to make them ourselves. They must be complied in this order because each one depends on the previous. Verfiy that for each package, `make check` returns all passing and no fails.
72
73###Build and Install `gmp`
74```
75$ cd ~/src/gmp-6.1.0
76$ ./configure --enable-static --disable-shared
77$ make
78$ make check
79$ make install
80```
81
82###Build and Install `mpfr`
83```
84$ cd ~/src/mpfr-3.1.4
85$ ./configure --with-gmp-build=../gmp-6.1.0 --enable-static --disable-shared
86$ make
87$ make check
88$ make install
89```
90
91###Build and Install `mpc`
92```
93$ cd ~/src/mpc-1.0.3
94$ ./configure --with-gmp=/usr/local --with-mpfr=/usr/local --enable-static --disable-shared
95$ make
96$ make check
97$ make install
98```
99
100##OPTIONAL Part
101You can build and install a brand new `gcc` or you can use the one supplied by `cygwin`. This will take about 4-5 hours to compile (It is a "native build", so it does the entire build **3 times**. This takes a long while).
102
103###Build and Install `gcc` for Your Machine
104```
105$ cd ~/src/gcc-5.3.0
106$ mkdir obj-local
107$ cd obj-local
108$ ../configure --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-static --disable-shared
109$ make
110$ make install
111```
112##End OPTIONAL Part
113
114###Build and Install `binutils` for Your Machine
115```
116$ cd ~/src/binutils-2.26
117$ mkdir obj-local
118$ cd obj-local
119$ ../configure
120$ make
121$ make install
122```
123
124##Buliding `binutils`, `gcc`, and `avr-libc` for the AVR system
125Now we can make the critical stuff for compiling our firmware: `binutils`, `gcc`, and `avr-libc` for the AVR architecture. These allow us to build and manipulate the firmware for the keyboard.
126
127###Build `binutils` for AVR
128If you plan to build and install `avr-gdb` also, use the `gdb` install at the end of this guide as it also builds the `binutils`
129```
130$ cd ~/src/binutils-2.26
131$ mkdir obj-avr
132$ cd obj-avr
133$ ../configure --prefix=$PREFIX --target=avr --disable-nls
134$ make
135$ make install
136```
137
138###Build `gcc` for AVR
139```
140$ cd ~/src/gcc-5.3.0
141$ mkdir obj-avr
142$ cd obj-avr
143$ ../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-static --disable-shared --disable-nls --disable-libssp --with-dwarf2
144$ make
145$ make install
146```
147
148###Build `avr-libc` for AVR
149For building the `avr-libc`, we have to specify the host build system. In my case it is `x86_64-unknown-cygwin`. You can look for build system type in the `gcc` configure notes for the proper `--build` specification to pass when you configure `avr-libc`.
150```
151$ cd ~/src/avr-libc-2.0.0
152$ ./configure --prefix=$PREFIX --build=x86_64-unknown-cygwin --host=avr
153$ make
154$ make install
155```
156
157##Building 'dfu-programmer' for flashing the firmware via USB and installing the drivers
158We can either build our own, or use the precomplied binaries. The precompiled binaries don't play well with `cygwin` so it is better to build them ourselves. The procedure for the precompiled binaries is included at the end of this guide.
159
160### Build and Install the `libusb`
161The `dfu-programmer` requires `libusb` so that it can interact with the USB system. These repos must be bootstrapped in order to create an appropriate `./configure` and `Makefile` for your system.
162```
163$ cd ~/src
164$ git clone https://github.com/libusb/libusb.git
165$ cd libusb
166$ ./bootstrap.sh
167$ ./configure
168$ make
169$ make install
170```
171
172### Build and Install the `dfu-programmer`
173```
174$ cd ~/src
175$ git clone https://github.com/dfu-programmer/dfu-programmer.git
176$ cd dfu-programmer
177$ ./bootstrap.sh
178$ ./configure
179$ make
180$ make install
181```
182
183Verify the installation with:
184```
185$ which dfu-programmer
186/usr/local/bin/dfu-programmer
187
188$ dfu-programmer
189dfu-programmer 0.7.2
190https://github.com/dfu-programmer/dfu-programmer
191Type 'dfu-programmer --help' for a list of commands
192 'dfu-programmer --targets' to list supported target devices
193```
194If you are not getting the above result, you will not be able to flash the firmware!
195
196###Install the USB drivers
197The drivers are included in the windows binary version of [`dfu-programmer` 0.7.2](http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip).
198```
199$ cd ~/src
200$ wget http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip
201$ unzip dfu-programmer-win-0.7.2.zip -d dfu-programmer-win-0.7.2
202```
203
204or
205
206The official drivers are found in [Atmel's `FLIP` installer](http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe). Download and then install `FLIP`. Upon installation, the drivers will be found in `C:\Program Files (x86)\Atmel\Flip 3.4.7\usb`.
207
208Then, from an **administrator-privileged** `Windows` terminal, run the following command (adjust the path for username, etc. as necessary) and accept the prompt that pops up:
209```
210C:\> pnputil -i -a C:\cygwin64\home\Kevin\src\dfu-programmer-win-0.7.2\dfu-prog-usb-1.2.2\atmel_usb_dfu.inf
211or
212C:\> pnputil -i -a "C:\Program Files (x86)\Atmel\Flip 3.4.7\usb\atmel_usb_dfu.inf"
213```
214
215This should be the result:
216```
217Microsoft PnP Utility
218
219Processing inf : atmel_usb_dfu.inf
220Successfully installed the driver on a device on the system.
221Driver package added successfully.
222Published name : oem104.inf
223
224
225Total attempted: 1
226Number successfully imported: 1
227```
228
229Alternatively, the `Windows` driver can be installed when prompted by `Windows` when the keyboard is attached. Do not let `Windows` search for a driver; specify the path to search for a driver and point it to the `atmel_usb_dfu.inf` file.
230
231##Building and Flashing the Planck firmware!
232If you did everything else right. This part should be a snap! Grab the latest sources from `github`, make the Plank firmware, then flash it.
233
234###Build Planck and Load the Firmware
235```
236$ cd ~/src
237$ git clone https://github.com/jackhumbert/qmk_firmware.git
238$ cd qmk_firmware/keyboard/planck
239$ make
240```
241
242Make sure there are no errors. You should end up with this or something similar:
243```
244Creating load file for Flash: planck.hex
245avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature planck.elf planck.hex
246
247Creating load file for EEPROM: planck.eep
248avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
249--change-section-lma .eeprom=0 --no-change-warnings -O ihex planck.elf planck.eep || exit 0
250
251Creating Extended Listing: planck.lss
252avr-objdump -h -S -z planck.elf > planck.lss
253
254Creating Symbol Table: planck.sym
255avr-nm -n planck.elf > planck.sym
256
257Size after:
258 text data bss dec hex filename
259 18602 82 155 18839 4997 planck.elf
260
261-------- end --------
262```
263
264If you do not get the above, you **did not** build the firmware, and you will have nothing to flash. If you have the fresh clone from `github`, it was probably something gone wrong in this install process, go check and see what didn't work and threw errors or what steps you might have missed.
265
266But if everything went OK, you are ready to flash! Press the reset button on the bottom of the Planck, wait two seconds, then:
267```
268$ make dfu
269```
270.
271.
272.
273profit!!!
274
275
276
277
278
279##extra bits...
280
281###Installing Precompiled `dfu-programmer` Binaries (not recommended for `cygwin`)
282To install the `dfu-programmer` from the binaries, we must get if from [the `dfu-programmer` website](https://dfu-programmer.github.io/) ([0.7.2](http://iweb.dl.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip)).
283
284Copy this file into your `cygwin` home\src directory. (For me, it is `C:\cygwin64\home\Kevin\src`), extract the files, move `dfu-programmer.exe` to `~/local/avr/bin`. Most obnoxiously, the `libusb0_x86.dll` and `libusb0.sys` need to be moved from `./dfu-prog-usb-1.2.2/x86/` to a directory in the `Windows` `PATH` and the `cygwin` `PATH`. This is because the `dfu-programmer` binary is `mingw` based, not `cygwin` based, so the `dlls` do not cooperate. I achieved acceptable pathing by moving the files to `C:\cygwin64\home\Kevin\local\avr\bin` Then, in a `WINDOWS` command prompt running (Adjusting your path for username, etc. as needed):
285```
286C:\> set PATH=%PATH%;C:\cygwin64\home\Kevin\local\avr\bin
287```
288
289Then, rename `libusb0_x86.dll` to `libusb0.dll`.
290
291You can tell that you were successful by trying to execute 'dfu-programmer' from the 'cygwin' prompt:
292```
293$ which dfu-programmer
294/home/Kevin/local/avr/bin/dfu-programmer
295
296$ dfu-programmer
297dfu-programmer 0.7.2
298https://github.com/dfu-programmer/dfu-programmer
299Type 'dfu-programmer --help' for a list of commands
300 'dfu-programmer --targets' to list supported target devices
301```
302
303If you are not getting the above result, you will not be able to flash the firmware!
304- Try making sure your `PATH` variables are set correctly for both `Windows` and `cygwin`.
305- Make sure the `dll` is named correctly.
306- Do not extract it with `cygwin`'s `unzip` as it does not set the executable permission. If you did it anyway, do `chmod +x dfu-programmer.exe`.
307- Still have problems? Try building it instead.
308
309
310##Debugging Tools
311
312These tools are for debugging your firmware, etc. before flashing. Theoretically, it can save your memory from wearing out. However, these tool do not work 100% for the Planck firmware.
313
314### `gdb` for AVR
315`gdb` has a simulator for AVR but it does not support all instructions (like WDT), so it immediately crashes when running the Planck firmware (because `lufa.c` disables the WDT in the first few lines of execution). But it can still be useful in debugging example code and test cases, if you know how to use it.
316
317```
318$ cd ~/src
319$ git clone git://sourceware.org/git/binutils-gdb.git
320$ cd binutils-gdb
321$ mkdir obj-avr
322$ cd obj-avr
323$ ../configure --prefix=$PREFIX --target=avr --build=x86_64-unknown-cygwin --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --disable-nls --enable-static
324$ make
325$ make install
326```
327
328### `simulavr`
329`simulavr` is an AVR simulator. It runs the complied AVR elfs. `simulavr` does not support the `atmega32u4` device... it does `atmega32` but that is not good enough for the firmware (no PORTE and other things), so you cannot run the Planck firmware. I use it to simulate ideas I have for features in separate test projects.
330
331This one is a major pain in the butt because it has a lot of dependencies and it is buggy. I will do my best to explain it but... it was hard to figure out. A few things need to be changed in the 'Makefile' to make it work in `cygwin`.
332
333
334```
335$ cd ~/src
336$ git clone https://github.com/Traumflug/simulavr.git
337$ cd simulavr
338$ ./bootstrap
339$ ./configure --prefix=$PREFIX --enable-static --disable-tcl --disable-doxygen-doc
340```
341 Edit `src/Makefile.am` now so that `-no-undefined` is included (I did this by removing the SYS_MINGW conditional surrounding `libsim_la_LDFLAGS += -no-undefined` and `libsimulavr_la_LDFLAGS += -no-undefined \ libsimulavr_la_LIBADD += $(TCL_LIB)`. Also, `$(EXEEXT)` is added after `kbdgentables` in two places.
342
343```
344$ make
345$ make install
346```
347
348
349TODO:
350- git repos for all sources
351- command line magic for cygwin setup
352- better options for `dfu-drivers`
diff --git a/doc/FUSE.txt b/doc/FUSE.txt
new file mode 100644
index 000000000..40055e5ab
--- /dev/null
+++ b/doc/FUSE.txt
@@ -0,0 +1,40 @@
1ATMega168P Fuse/Lock Bits
2=========================
3This configuration is from usbasploader's Makefile.
4
5 HFUSE 0xD6
6 LFUSE 0xDF
7 EFUSE 0x00
8 LOCK 0x3F(intact)
9
10#---------------------------------------------------------------------
11# ATMega168P
12#---------------------------------------------------------------------
13# Fuse extended byte:
14# 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
15# \+/
16# +------- BOOTSZ (00 = 2k bytes)
17# Fuse high byte:
18# 0xd6 = 1 1 0 1 0 1 1 0
19# ^ ^ ^ ^ ^ \-+-/
20# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
21# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
22# | | | +-------------- WDTON (if 0: watchdog always on)
23# | | +---------------- SPIEN (allow serial programming)
24# | +------------------ DWEN (debug wire enable)
25# +-------------------- RSTDISBL (reset pin is enabled)
26# Fuse low byte:
27# 0xdf = 1 1 0 1 1 1 1 1
28# ^ ^ \ / \--+--/
29# | | | +------- CKSEL 3..0 (external >8M crystal)
30# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
31# | +------------------ CKOUT (if 0: Clock output enabled)
32# +-------------------- CKDIV8 (if 0: divide by 8)
33
34
35# Lock Bits
36# 0x3f = - - 1 1 1 1 1 1
37# \ / \-/ \-/
38# | | +----- LB 2..1 (No memory lock features enabled)
39# | +--------- BLB0 2..1 (No restrictions for SPM or LPM accessing the Application section)
40# +--------------- BLB1 2..1 (No restrictions for SPM or LPM accessing the Boot Loader section)
diff --git a/doc/HAND_WIRE.md b/doc/HAND_WIRE.md
new file mode 100644
index 000000000..0b7367eda
--- /dev/null
+++ b/doc/HAND_WIRE.md
@@ -0,0 +1,321 @@
1# Quantum Hand-wiring Guide
2
3Parts list:
4* *x* keyswitches (MX, Matias, Gateron, etc)
5* *x* diodes
6* Keyboard plate (metal, plastic, cardboard, etc)
7* Wire (strained for wiring to the Teensy, anything for the rows/columns)
8* Soldering iron set at 600ºF or 315ºC (if temperature-controlled)
9* Resin-cored solder (leaded or lead-free)
10* Adequate ventilation/a fan
11* Tweezers (optional)
12* Wire cutters/snippers
13
14## How the matrix works (why we need diodes)
15
16The microcontroller (in this case, the Teensy 2.0) will be setup up via the firmware to send a logical 1 to the columns, one at a time, and read from the rows, all at once - this process is called matrix scanning. The matrix is a bunch of open switches that, by default, don't allow any current to pass through - the firmware will read this as no keys being pressed. As soon as you press one key down, the logical 1 that was coming from the column the keyswitch is attached to gets passed through the switch and to the corresponding row - check out the following 2x2 example:
17
18 Column 0 being scanned Column 1 being scanned
19 x x
20 col0 col1 col0 col1
21 | | | |
22 row0 ---(key0)---(key1) row0 ---(key0)---(key1)
23 | | | |
24 row1 ---(key2)---(key3) row1 ---(key2)---(key3)
25
26The `x` represents that the column/row associated has a value of 1, or is HIGH. Here, we see that no keys are being pressed, so no rows get an `x`. For one keyswitch, keep in mind that one side of the contacts is connected to its row, and the other, its column.
27
28When we press `key0`, `col0` gets connected to `row0`, so the values that the firmware receives for that row is `0b01` (the `0b` here means that this is a bit value, meaning all of the following digits are bits - 0 or 1 - and represent the keys in that column). We'll use this notation to show when a keyswitch has been pressed, to show that the column and row are being connected:
29
30 Column 0 being scanned Column 1 being scanned
31 x x
32 col0 col1 col0 col1
33 | | | |
34 x row0 ---(-+-0)---(key1) row0 ---(-+-0)---(key1)
35 | | | |
36 row1 ---(key2)---(key3) row1 ---(key2)---(key3)
37
38We can now see that `row0` has an `x`, so has the value of 1. As a whole, the data the firmware receives when `key0` is pressed is
39
40 col0: 0b01
41 col1: 0b00
42 │└row0
43 └row1
44
45A problem arises when you start pressing more than one key at a time. Looking at our matrix again, it should become pretty obvious:
46
47 Column 0 being scanned Column 1 being scanned
48 x x
49 col0 col1 col0 col1
50 | | | |
51 x row0 ---(-+-0)---(-+-1) x row0 ---(-+-0)---(-+-1)
52 | | | |
53 x row1 ---(key2)---(-+-3) x row1 ---(key2)---(-+-3)
54
55 Remember that this ^ is still connected to row1
56
57The data we get from that is:
58
59 col0: 0b11
60 col1: 0b11
61 │└row0
62 └row1
63
64Which isn't accurate, since we only have 3 keys pressed down, not all 4. This behavior is called ghosting, and only happens in odd scenarios like this, but can be much more common on a bigger keyboard. The way we can get around this is by placing a diode after the keyswitch, but before it connects to its row. A diode only allows current to pass through one way, which will protect our other columns/rows from being activated in the previous example. We'll represent a dioded matrix like this;
65
66 Column 0 being scanned Column 1 being scanned
67 x x
68 col0 col1 col0 col1
69 │ │ | │
70 (key0) (key1) (key0) (key1)
71 ! │ ! │ ! | ! │
72 row0 ─────┴────────┘ │ row0 ─────┴────────┘ │
73 │ │ | │
74 (key2) (key3) (key2) (key3)
75 ! ! ! !
76 row1 ─────┴────────┘ row1 ─────┴────────┘
77
78In practical applications, the black line of the diode will be placed facing the row, and away from the keyswitch - the `!` in this case is the diode, where the gap represents the black line. A good way to remember this is to think of this symbol: `>|`
79
80Now when we press the three keys, invoking what would be a ghosting scenario:
81
82 Column 0 being scanned Column 1 being scanned
83 x x
84 col0 col1 col0 col1
85 │ │ │ │
86 (┌─┤0) (┌─┤1) (┌─┤0) (┌─┤1)
87 ! │ ! │ ! │ ! │
88 x row0 ─────┴────────┘ │ x row0 ─────┴────────┘ │
89 │ │ │ │
90 (key2) (┌─┘3) (key2) (┌─┘3)
91 ! ! ! !
92 row1 ─────┴────────┘ x row1 ─────┴────────┘
93
94Things act as they should! Which will get us the following data:
95
96 col0: 0b01
97 col1: 0b11
98 │└row0
99 └row1
100
101The firmware can then use this correct data to detect what it should do, and eventually, what signals it needs to send to the OS.
102
103## The actual hand-wiring
104
105### Getting things in place
106
107When starting this, you should have all of your stabilisers and keyswitches already installed (and optionally keycaps). If you're using a Cherry-type stabiliser (plate-mounted only, obviously), you'll need to install that before your keyswitches. If you're using Costar ones, you can installed them afterwards.
108
109To make things easier on yourself, make sure all of the keyswitches are oriented the same way (if they can be - not all layouts support this). Despite this, it's important to remember that the contacts on the keyswitches are completely symmetrical. We'll be using the keyswitch's left side contact for wiring the rows, and the right side one for wiring the columns.
110
111Get your soldering iron heated-up and collect the rest of the materials from the part list at the beginning of the guide. Place your keyboard so that the bottoms of the keyswitches are accessible - it may be a good idea to place it on a cloth to protect your keyswitches/keycaps.
112
113Before continuing, plan out where you're going to place your Teensy. If you're working with a board that has a large (6.25u) spacebar, it may be a good idea to place it in-between switches against the plate. Otherwise, you may want to trim some of the leads on the keyswitches where you plan on putting it - this will make it a little harder to solder the wire/diodes, but give you more room to place the Teensy.
114
115### Preparing the diodes
116
117It's a little easier to solder the diodes in place if you bend them at a 90º angle immediately after the black line - this will help to make sure you put them on the right way (direction matters), and in the correct position. The diodes will look like this when bent (with longer leads):
118
119 ┌─────┬─┐
120 ───┤ │ ├─┐
121 └─────┴─┘ │
122
123
124We'll be using the long lead at the bent end to connect it to the elbow (bent part) of the next diode, creating the row.
125
126### Soldering the diodes
127
128Starting at the top-left switch, place the diode (with tweezers if you have them) on the switch so that the diode itself is vertically aligned, and the black line is facing toward you. The straight end of the diode should be touching the left contact on the switch, and the bent end should be facing to the right and resting on the switch there, like this:
129
130 │o
131 ┌┴┐ o
132 │ │ O
133 ├─┤
134 └┬┘
135 └─────────────
136
137Letting the diode rest, grab your solder, and touch both it and the soldering iron to the left contact at the same time - the rosin in the solder should make it easy for the solder to flow over both the diode and the keyswitch contact. The diode may move a little, and if it does, carefully position it back it place by grabbing the bent end of the diode - the other end will become hot very quickly. If you find that it's moving too much, using needle-nose pliers of some sort may help to keep the diode still when soldering.
138
139The smoke that the rosin releases is harmful, so be careful not to breath it or get it in your eyes/face.
140
141After soldering things in place, it may be helpful to blow on the joint to push the smoke away from your face, and cool the solder quicker. You should see the solder develop a matte (not shiney) surface as it solidifies. Keep in mind that it will still be very hot afterwards, and will take a couple minutes to be cool to touch. Blow on it will accelerate this process.
142
143When the first diode is complete, the next one will need to be soldered to both the keyswitch, and the previous diode at the new elbow. That will look something like this:
144
145 │o │o
146 ┌┴┐ o ┌┴┐ o
147 │ │ O │ │ O
148 ├─┤ ├─┤
149 └┬┘ └┬┘
150 └────────────────┴─────────────
151
152After completing a row, use the wire cutters to trim the excess wire from the tops of the diodes, and from the right side on the final switch. This process will need to completed for each row you have.
153
154When all of the diodes are completely soldered, it's a good idea to quickly inspect each one to ensure that your solder joints are solid and sturdy - repairing things after this is possible, but more difficult.
155
156### Soldering the columns
157
158You'll have some options in the next process - it's a good idea to insulate the column wires (since the diodes aren't), but if you're careful enough, you can use exposed wires for the columns - it's not recommended, though. If you're using single-cored wire, stripping the plastic off of the whole wire and feeding it back on is probably the best option, but can be difficult depending on the size and materials. You'll want to leave parts of the wire exposed where you're going to be solder it onto the keyswitch.
159
160If you're using stranded wire, it's probably easiest to just use a lot of small wires to connect each keyswitch along the column. It's possible to use one and melt through the insulation, but this isn't recommended, will produce even more harmful fumes, and can ruin your soldering iron.
161
162Before beginning to solder, it helps to have your wire pre-bent (if using single-cored), or at least have an idea of how you're going to route the column (especially if you're making a staggered board). Where you go in particular doesn't matter too much, as we'll be basing our keymap definitions on how it was wired - just make sure every key in a particular row is in a unique column, and that they're in order from left to right.
163
164If you're not using any insulation, you can try to keep the column wires elevated, and solder them near the tips of the keyswitch contacts - if the wires are sturdy enough, they won't short out to the row wiring an diodes.
165
166### Wiring things to the Teensy
167
168Now that the matrix itself is complete, it's time to connect what you've done to the Teensy. You'll be needing the number of pins equal to your number of columns + your number of rows. There are some pins on the Teensy that are special, like D6 (the LED on the chip), or some of the UART, SPI, I2C, or PWM channels, but only avoid those if you're planning something in addition to a keyboard. If you're unsure about wanting to add something later, you should have enough pins in total to avoid a couple.
169
170The pins you'll absolutely have to avoid are: GND, VCC, AREF, and RST - all the others are usable and accessible in the firmware.
171
172Place the Teensy where you plan to put it - you'll have to cut wires to length in the next step, and you'll want to make sure they reach.
173
174Starting with the first column on the right side, measure out how much wire you'll need to connect it to the first pin on the Teensy - it helps to pick a side that you'll be able to work down, to keep the wires from overlapping too much. It may help to leave a little bit of slack so things aren't too tight. Cut the piece of wire, and solder it to the Teensy, and then the column - you can solder it anywhere along the column, but it may be easiest at the keyswitch. Just be sure the wire doesn't separate from the keyswitch when soldering.
175
176As you move from column to column, it'll be helpful to write the locations of the pins down. We'll use this data to setup the matrix in the future.
177
178When you're done with the columns, start with the rows in the same process, from top to bottom, and write them all down. Again, you can solder anywhere along the row, as long as it's after the diode - soldering before the diode (on the keyswitch side) will cause that row not to work.
179
180As you move along, be sure that the Teensy is staying in place - recutting and soldering the wires is a pain!
181
182### Getting some basic firmware set-up
183
184From here, you should have a working keyboard with the correct firmware. Before we attach the Teensy permanently to the keyboard, let's quickly get some firmware loaded onto the Teensy so we can test each keyswitch.
185
186To start out, download [the firmware](https://github.com/jackhumbert/qmk_firmware/) - we'll be using my (Jack's) fork of TMK called QMK/Quantum. We'll be doing a lot from the Terminal/command prompt, so get that open, along with a decent text editor like [Sublime Text](http://www.sublimetext.com/).
187
188The first thing we're going to do is create a new project using the script in the root directory of the firmware. In your terminal, run this command with `<project_name>` replaced by the name of your project - it'll need to be different from any other project in the `keyboard/` folder:
189
190 ./new_project.sh <project_name>
191
192You'll want to navigate to the `keyboard/<project_name>/` folder by typing, like the print-out from the script specifies:
193
194 cd keyboard/<project_name>
195
196#### config.h
197
198The first thing you're going to want to modify is the `config.h` file. Find `MATRIX_ROWS` and `MATRIX_COLS` and them to match the dimensions of your keyboard's matrix.
199
200Farther down are `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`. Change their definitions to match how you wired up your matrix (looking from the top of the keyboard, the rows run top-to-bottom and the columns run left-to-right). Likewise, change the definition of `UNUSED_PINS` to match the pins you did not use (this will save power).
201
202#### \<project_name\>.h
203
204The next file you'll want to look at is `<project_name>.h`. You're going to want to rewrite the `KEYMAP` definition - the format and syntax here is extremely important, so pay attention to how things are setup. The first half of the definition are considered the arguments - this is the format that you'll be following in your keymap later on, so you'll want to have as many k*xy* variables here as you do keys. The second half is the part that the firmware actually looks at, and will contain gaps depending on how you wired your matrix.
205
206We'll dive into how this will work with the following example. Say we have a keyboard like this:
207
208 ┌───┬───┬───┐
209 │ │ │ │
210 ├───┴─┬─┴───┤
211 │ │ │
212 └─────┴─────┘
213
214This can be described by saying the top row is 3 1u keys, and the bottom row is 2 1.5u keys. The difference between the two rows is important, because the bottom row has an unused column spot (3 v 2). Let's say that this is how we wired the columns:
215
216 ┌───┬───┬───┐
217 │ ┋ │ ┋ │ ┋ │
218 ├─┋─┴─┬─┴─┋─┤
219 │ ┋ │ ┋ │
220 └─────┴─────┘
221
222The middle column is unused on the bottom row in this example. Our `KEYMAP` definition would look like this:
223
224 #define KEYMAP( \
225 k00, k01, k02, \
226 k10, k11, \
227 ) \
228 { \
229 { k00, k01, k02 }, \
230 { k10, KC_NO, k11 }, \
231 }
232
233Notice how the top half is spaced to resemble our physical layout - this helps us understand which keys are associated with which columns. The bottom half uses the keycode `KC_NO` where there is no keyswitch wired in. It's easiest to keep the bottom half aligned in a grid to help us make sense of how the firmware actually sees the wiring.
234
235Let's say that instead, we wired our keyboard like this (a fair thing to do):
236
237 ┌───┬───┬───┐
238 │ ┋ │ ┋│ ┋ │
239 ├─┋─┴─┬┋┴───┤
240 │ ┋ │┋ │
241 └─────┴─────┘
242
243This would require our `KEYMAP` definition to look like this:
244
245 #define KEYMAP( \
246 k00, k01, k02, \
247 k10, k11, \
248 ) \
249 { \
250 { k00, k01, k02 }, \
251 { k10, k11, KC_NO }, \
252 }
253
254Notice how the `k11` and `KC_NO` switched places to represent the wiring, and the unused final column on the bottom row. Sometimes it'll make more sense to put a keyswitch on a particular column, but in the end, it won't matter, as long as all of them are accounted for. You can use this process to write out the `KEYMAP` for your entire keyboard - be sure to remember that your keyboard is actually backwards when looking at the underside of it.
255
256#### keymaps/default.c
257
258This is the actual keymap for your keyboard, and the main place you'll make changes as you perfect your layout. `default.c` is the file that gets pull by default when typing `make`, but you can make other files as well, and specify them by typing `make KEYMAP=<variant>`, which will pull `keymaps/<variant>.c`.
259
260The basis of a keymap is its layers - by default, layer 0 is active. You can activate other layers, the highest of which will be referenced first. Let's start with our base layer.
261
262Using our previous example, let's say we want to create the following layout:
263
264 ┌───┬───┬───┐
265 │ A │ 1 │ H │
266 ├───┴─┬─┴───┤
267 │ TAB │ SPC │
268 └─────┴─────┘
269
270This can be accomplished by using the following `keymaps` definition:
271
272 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
273 [0] = KEYMAP( /* Base */
274 KC_A, KC_1, KC_H, \
275 KC_TAB, KC_SPC \
276 ),
277 };
278
279Note that the layout of the keycodes is similar to the physical layout of our keyboard - this make it much easier to see what's going on. A lot of the keycodes should be fairly obvious, but for a full list of them, check out [tmk_code/doc/keycode.txt](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keycode.txt) - there are also a lot of aliases to condense your keymap file.
280
281It's also important to use the `KEYMAP` function we defined earlier - this is what allows the firmware to associate our intended readable keymap with the actual wiring.
282
283#### Compiling your firmware
284
285After you've written out your entire keymap, you're ready to get the firmware compiled and onto your Teensy. Before compiling, you'll need to get your [development environment set-up](https://github.com/jackhumbert/qmk_firmware/blob/master/keyboard/planck/PCB_GUIDE.md#setting-up-the-environment) - you can skip the dfu-programmer instructions, but you'll need to download and install the [Teensy Loader](https://www.pjrc.com/teensy/loader.html) to get the firmware on your Teensy.
286
287Once everything is installed, running `make` in the terminal should get you some output, and eventually a `<project_name>.hex` file in that folder. If you're having trouble with this step, see the end of the guide for the trouble-shooting section.
288
289Once you have your `<project_name>.hex` file, open up the Teensy loader application, and click the file icon. From here, navigate to your `QMK/keyboard/<project_name>/` folder, and select the `<project_name>.hex` file. Plug in your keyboard and press the button on the Teensy - you should see the LED on the device turn off once you do. The Teensy Loader app will change a little, and the buttons should be clickable - click the download button (down arrow), and then the reset button (right arrow), and your keyboard should be ready to go!
290
291#### Testing your firmware
292
293Carefully flip your keyboard over, open up a new text document, and try typing - you should get the characters that you put into your keymap. Test each key, and note the ones that aren't working. Here's a quick trouble-shooting guide for non-working keys:
294
2950. Flip the keyboard back over and short the keyswitch's contacts with a piece wire - this will eliminate the possibility of the keyswitch being bad and needing to be replaced.
2961. Check the solder points on the keyswitch - these need to be plump and whole. If you touch it with a moderate amount of force and it comes apart, it's not strong enough.
2972. Check the solder joints on the diode - if the diode is loose, part of your row may register, while the other may not.
2983. Check the solder joints on the columns - if your column wiring is loose, part or all of the column may not work.
2994. Check the solder joints on both sides of the wires going to/from the Teensy - the wires need to be fully soldered and connect to both sides.
3005. Check the <project_name>.h file for errors and incorrectly placed `KC_NO`s - if you're unsure where they should be, instead duplicate a k*xy* variable.
3016. Check to make sure you actually compiled the firmware and flashed the Teensy correctly. Unless you got error messages in the terminal, or a pop-up during flashing, you probably did everything correctly.
302
303If you've done all of these things, keep in mind that sometimes you might have had multiple things affecting the keyswitch, so it doesn't hurt to test the keyswitch by shorting it out at the end.
304
305#### Securing the Teensy, finishing your hardware, getting fancier firmware
306
307Now that you have a working board, it's time to get things in their permanent positions. I've often used liberal amounts of hot glue to secure and insulate things, so if that's your style, start spreading that stuff like butter. Otherwise, double-sided tape is always an elegant solution, and electrical tape is a distant second. Due to the nature of these builds, a lot of this part is up to you and how you planned (or didn't plan) things out.
308
309There are a lot of possibilities inside the firmware - check out the [README](https://github.com/jackhumbert/qmk_firmware/blob/master/README.md) for a full feature list, and dive into the different project (Planck, Ergodox EZ, etc) to see how people use all of them. You can always stop by [the OLKB subreddit for help!](http://reddit.com/r/olkb)
310
311## Trouble-shooting compiling
312
313### Windows
314
315#### fork: Resource temporarily unavailable
316
317http://www.avrfreaks.net/forum/windows-81-compilation-error
318
319### Mac
320
321### Linux
diff --git a/doc/PCB_GUIDE.md b/doc/PCB_GUIDE.md
new file mode 100644
index 000000000..b36d8fb64
--- /dev/null
+++ b/doc/PCB_GUIDE.md
@@ -0,0 +1,151 @@
1# Planck Firmware Guide
2
3## Setting up the environment
4
5### Windows
61. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**.
72. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location.
83. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer.
94. Right-click on the 1-setup-path-win batch script, select "Run as administrator", and accept the User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up.
105. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete!
11
12
13### Mac
14
15If you're using homebrew, you can use the following commands:
16
17 brew tap osx-cross/avr
18 brew install avr-libc
19 brew install dfu-programmer
20
21Otherwise, these instructions will work:
22
231. Install Xcode from the App Store.
242. Install the Command Line Tools from `Xcode->Preferences->Downloads`.
253. Install [DFU-Programmer][dfu-prog].
26
27### Linux
281. Install AVR GCC with your favorite package manager.
292. Install [DFU-Programmer][dfu-prog].
30
31Note that, since it will be directly accessing USB hardware, the
32`dfu-programmer` program needs to be run as root.
33
34## Verify Your Installation
351. Clone the following repository: https://github.com/jackhumbert/qmk_firmware
362. Open a Terminal and `cd` into `qmk_firmware/keyboard/planck`
373. Run `make`. This should output a lot of information about the build process.
38
39## Using the built-in functions
40
41Here is a list of some of the functions available from the command line:
42
43* `make clean`: clean the environment - may be required in-between builds
44* `make`: compile the code
45* `make KEYMAP=<keymap>`: compile with the extended keymap file `extended_keymaps/extended_keymap_<keymap>.c`
46* `make dfu`: build and flash the layout to the PCB
47* `make dfu-force`: build and force-flash the layout to the PCB (may be require for first flash)
48
49Generally, the instructions to flash the PCB are as follows:
50
511. Make changes to the appropriate keymap file
522. Save the file
533. `make clean`
544. Press the reset button on the PCB/press the key with the `RESET` keycode
555. `make <arguments> dfu` - use the necessary `KEYMAP=<keymap>` and/or `COMMON=true` arguments here.
56
57## Troubleshooting
58If you see something like this
59
60 0 [main] sh 13384 sync_with_child: child 9716(0x178) died before initialization with status code 0xC0000142
61 440 [main] sh 13384 sync_with_child: *** child state waiting for longjmp
62 /usr/bin/sh: fork: Resource temporarily unavailable
63
64after running 'make' on Windows than you are encountering a very popular issue with WinAVR on Windows 8.1 and 10.
65You can easily fix this problem by replacing msys-1.0.dll in WinAVR/utils/bin with [this one](http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip).
66Restart your system and everything should work fine!
67
68
69If you see this
70
71 dfu-programmer atmega32u4 erase
72 process_begin: CreateProcess(NULL, dfu-programmer atmega32u4 erase, ...) failed.
73 make (e=2): The system cannot find the file specified.
74 make: *** [dfu] Error 2
75
76when trying to 'make dfu' on Windows you need to copy the dfu-programmer.exe to qmk_firmware/keyboard/planck.
77
78
79## Quantum MK Firmware
80
81### Keymap
82
83Unlike the other keymaps, prefixing the keycodes with `KC_` is required. A full list of the keycodes is available [here](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keycode.txt). For the keycodes available only in the extended keymap, see this [header file](https://github.com/jackhumbert/qmk_firmware/blob/master/quantum/keymap_common.h).
84
85You can use modifiers with keycodes like this:
86
87 LCTL(KC_C)
88
89Which will generate Ctrl+c. These are daisy-chainable, meaning you can do things like:
90
91 LCTL(LALT(KC_C))
92
93That will generate Ctrl+Alt+c. The entire list of these functions is here:
94
95* `LCTL()`: Left control
96* `LSFT()` / `S()`: Left shift
97* `LALT()`: Left alt/opt
98* `LGUI()`: Left win/cmd
99* `RCTL()`: Right control
100* `RSFT()`: Right shift
101* `RALT()`: Right alt/opt
102* `RGUI()`: Right win/cmd
103
104`S(KC_1)`-like entries are useful in writing keymaps for the Planck.
105
106### Other keycodes
107
108A number of other keycodes have been added that you may find useful:
109
110* `CM_<key>`: the Colemak equivalent of a key (in place of `KC_<key>`), when using Colemak in software (`CM_O` generates `KC_SCLN`)
111* `RESET`: jump to bootloader for flashing (same as press the reset button)
112* `BL_STEP`: step through the backlight brightnesses
113* `BL_<0-15>`: set backlight brightness to 0-15
114* `BL_DEC`: lower the backlight brightness
115* `BL_INC`: raise the backlight brightness
116* `BL_TOGG`: toggle the backlight on/off
117
118### Function layers
119
120The extended keymap extends the number of function layers from 32 to the near-infinite value of 256. Rather than using `FN<num>` notation (still available, but limited to `FN0`-`FN31`), you can use the `FUNC(<num>)` notation. `F(<num>)` is a shortcut for this.
121
122The function actions are unchanged, and you can see the full list of them [here](https://github.com/jackhumbert/tmk_keyboard/blob/master/common/action_code.h). They are explained in detail [here](https://github.com/jackhumbert/tmk_keyboard/blob/master/doc/keymap.md#2-action).
123
124### Macros
125
126Macros have been setup in the `keymaps/keymap_default.c` file so that you can use `M(<num>)` to access a macro in the `action_get_macro` section on your keymap. The switch/case structure you see here is required, and is setup for `M(0)` - you'll need to copy and paste the code to look like this (e.g. to support `M(3)`):
127
128 switch(id) {
129 case 0:
130 return MACRODOWN(TYPE(KC_A), END);
131 break;
132 case 1:
133 return MACRODOWN(TYPE(KC_B), END);
134 break;
135 case 2:
136 return MACRODOWN(TYPE(KC_C), END);
137 break;
138 case 3:
139 return MACRODOWN(TYPE(KC_D), END);
140 break;
141 }
142 return MACRO_NONE;
143
144`MACRODOWN()` is a shortcut for `(record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)` which tells the macro to execute when the key is pressed. Without this, the macro will be executed on both the down and up stroke.
145
146[cygwin]: https://www.cygwin.com/
147[mingw]: http://www.mingw.org/
148[mhv]: https://infernoembedded.com/products/avr-tools
149[winavr]: http://winavr.sourceforge.net/
150[crosspack]: http://www.obdev.at/products/crosspack/index.html
151[dfu-prog]: http://dfu-programmer.sourceforge.net/
diff --git a/doc/POWER.txt b/doc/POWER.txt
new file mode 100644
index 000000000..0abbbe48e
--- /dev/null
+++ b/doc/POWER.txt
@@ -0,0 +1,62 @@
1Time to Sleep
2=============
3USB suspend no activity on USB line for 3ms
4No Interaction no user interaction
5 matrix has no change
6 matrix has no switch on
7
8
9AVR Power Management
10====================
11
12V-USB suspend
13 USB suspend
14 http://vusb.wikidot.com/examples
15
16MCUSR MCU Status Register
17 WDRF Watchdog Reset Flag
18 BORF
19 EXTRF
20 PORF Power-on Reset Flag
21
22SMCR Sleep Mode Control Register
23 SE Sleep Enable
24 SM2:0
25 #define set_sleep_mode(mode) \
26 #define SLEEP_MODE_IDLE (0)
27 #define SLEEP_MODE_ADC _BV(SM0)
28 #define SLEEP_MODE_PWR_DOWN _BV(SM1)
29 #define SLEEP_MODE_PWR_SAVE (_BV(SM0) | _BV(SM1))
30 #define SLEEP_MODE_STANDBY (_BV(SM1) | _BV(SM2))
31 #define SLEEP_MODE_EXT_STANDBY (_BV(SM0) | _BV(SM1) | _BV(SM2))
32
33
34ACSR Analog Comparator Control and Status Register
35 To disable Analog Comparator
36 ACSR = 0x80;
37 or
38 ACSR &= ~_BV(ACIE);
39 ACSR |= _BV(ACD);
40
41 ACD: Analog Comparator Disable
42 When this bit is written logic one, the power to the Analog Comparator is
43 switched off. This bit can be set at any time to turn off the Analog
44 Comparator. This will reduce power consumption in Active and Idle mode.
45 When changing the ACD bit, the Analog Comparator Interrupt must be disabled
46 by clearing the ACIE bit in ACSR. Otherwise an interrupt can occur when
47 the bit is changed.
48
49DIDR1 Digital Input Disable Register 1
50 AIN1D
51 AIN0D
52 When this bit is written logic one, the digital input buffer on the AIN1/0 pin is disabled. The corresponding PIN Register bit will always read as zero when this bit is set. When an analog signal is applied to the AIN1/0 pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the digital input buffer.
53
54
55PRR Power Reduction Register
56 PRTWI
57 PRTIM2
58 PRTIM0
59 PRTIM1
60 PRSPI
61 PRUSART0
62 PRADC
diff --git a/doc/TMK_README.md b/doc/TMK_README.md
new file mode 100644
index 000000000..36ef84ac6
--- /dev/null
+++ b/doc/TMK_README.md
@@ -0,0 +1,243 @@
1# TMK Documenation
2
3Features
4--------
5These features can be used in your keyboard.
6
7* Multi-layer Keymap - Multiple keyboard layouts with layer switching
8* Mouse key - Mouse control with keyboard
9* System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up
10* Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc
11* USB NKRO - 120 keys(+ 8 modifiers) simultaneously
12* PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device
13* Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols
14* User Function - Customizable function of key with writing code
15* Macro - Very primitive at this time
16* Keyboard Tricks - Oneshot modifier and modifier with tapping feature
17* Debug Console - Messages for debug and interaction with firmware
18* Virtual DIP Switch - Configurations stored EEPROM(Boot Magic)
19* Locking CapsLock - Mechanical switch support for CapsLock
20* Breathing Sleep LED - Sleep indicator with charm during USB suspend
21* Backlight - Control backlight levels
22
23
24
25Projects
26--------
27You can find some keyboard specific projects under `converter` and `keyboard` directory.
28
29## Main projects
30
31### OLKB products
32* [planck](keyboard/planck/) - [Planck] Ortholinear 40% keyboard
33* [preonic](keyboard/preonic/) - [Preonic] Ortholinear 50% keyboard
34* [atomic](keyboard/atomic/) - [Atomic] Ortholinear 60% keyboard
35
36### Ergodox EZ
37* [ergodox_ez](keyboard/ergodox_ez) - [Ergodox_EZ] Assembled split keyboard
38
39## Other projects
40
41### converter
42* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2]
43* [adb_usb](converter/adb_usb/) - [ADB keyboard to USB][GH_adb]
44* [m0110_usb](converter/m0110_usb) - [Macintosh 128K/512K/Plus keyboard to USB][GH_m0110]
45* [terminal_usb](converter/terminal_usb/) - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal]
46* [news_usb](converter/news_usb/) - [Sony NEWS keyboard to USB][GH_news]
47* [x68k_usb](converter/x68k_usb/) - [Sharp X68000 keyboard to USB][GH_x68k]
48* [sun_usb](converter/sun_usb/) - [Sun] to USB(type4, 5 and 3?)
49* [pc98_usb](converter/pc98_usb/) - [PC98] to USB
50* [usb_usb](converter/usb_usb/) - USB to USB(experimental)
51* [ascii_usb](converter/ascii_usb/) - ASCII(Serial console terminal) to USB
52* [ibm4704_usb](converter/ibm4704_usb) - [IBM 4704 keyboard Converter][GH_ibm4704]
53
54### keyboard
55* [hhkb](keyboard/hhkb/) - [Happy Hacking Keyboard pro][GH_hhkb] hasu's main board
56* [gh60](keyboard/gh60/) - [GH60] DIY 60% keyboard [prototype][GH60_proto] hasu's second board
57* [hbkb](keyboard/hbkb/) - [Happy Buckling spring keyboard][GH_hbkb](IBM Model M 60% mod)
58* [hid_liber](keyboard/hid_liber/) - [HID liberation][HID_liber] controller (by alaricljs)
59* [phantom](keyboard/phantom/) - [Phantom] keyboard (by Tranquilite)
60* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung)
61* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired]
62* [KMAC](keyboard/kmac/) - Korean custom keyboard
63* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard
64* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity]
65* [NerD](keyboard/nerd/) - Korean custom keyboard
66* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller
67* [Lightpad](keyboard/lightpad) - Korean custom keypad
68* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
69
70### Extenal projects using tmk_keyboard
71* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org]
72* [mcdox][mcdox_tmk] - [mcdox][mcdox]
73
74
75[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
76[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
77[GH_ps2]: http://geekhack.org/showwiki.php?title=Island:14618
78[GH_adb]: http://geekhack.org/showwiki.php?title=Island:14290
79[GH_hhkb_bt]: http://geekhack.org/showwiki.php?title=Island:20851
80[GH_m0110]: http://geekhack.org/showwiki.php?title=Island:24965
81[GH_news]: http://geekhack.org/showwiki.php?title=Island:25759
82[GH_terminal]: http://geekhack.org/showwiki.php?title=Island:27272
83[GH_x68k]: http://geekhack.org/showwiki.php?title=Island:29060
84[GH_hbkb]: http://geekhack.org/showwiki.php?title=Island:29483
85[GH_ibm4704]: http://geekhack.org/index.php?topic=54706.0
86[HID_liber]: http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions
87[Phantom]: http://geekhack.org/index.php?topic=26742
88[GH60]: http://geekhack.org/index.php?topic=34959
89[GH60_proto]: http://geekhack.org/index.php?topic=37570.0
90[PC98]: http://en.wikipedia.org/wiki/NEC_PC-9801
91[Sun]: http://en.wikipedia.org/wiki/Sun-3
92[IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS
93[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit
94[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid
95[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/
96[ergodox_org]: http://ergodox.org/
97[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox
98[mcdox]: https://github.com/DavidMcEwan/mcdox
99[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox
100[Planck]: http://olkb.co/planck
101[Preonic]: http://olkb.co/preonic
102[Atomic]: http://olkb.co/atomic
103[Ergodox_EZ]: https://www.indiegogo.com/projects/ergodox-ez-an-incredible-mechanical-keyboard
104
105
106License
107-------
108**GPLv2** or later. Some protocol files are under **Modified BSD License**.
109
110Third party libraries like LUFA, PJRC and V-USB have their own license respectively.
111
112
113
114Build Firmware and Program Controller
115-------------------------------------
116See [doc/build.md](tmk_core/doc/build.md), or the README in the particular keyboard/* folder.
117
118
119
120Change your keymap
121------------------
122See [doc/keymap.md](tmk_core/doc/keymap.md).
123
124
125
126Magic Commands
127--------------
128To see help press `Magic` + `H`.
129
130`Magic` key combination is `LShift` + `RShift` in many project, but `Power` key on ADB converter.
131`Magic` keybind can be vary on each project, check `config.h` in project directory.
132
133Following commands can be also executed with `Magic` + key. In console mode `Magic` keybind is not needed.
134
135 ----- Command Help -----
136 c: enter console mode
137 d: toggle debug enable
138 x: toggle matrix debug
139 k: toggle keyboard debug
140 m: toggle mouse debug
141 v: print device version & info
142 t: print timer count
143 s: print status
144 e: print eeprom config
145 n: toggle NKRO
146 0/F10: switch to Layer0
147 1/F1: switch to Layer1
148 2/F2: switch to Layer2
149 3/F3: switch to Layer3
150 4/F4: switch to Layer4
151 PScr: power down/remote wake-up
152 Caps: Lock Keyboard(Child Proof)
153 Paus: jump to bootloader
154
155
156
157Boot Magic Configuration - Virtual DIP Switch
158---------------------------------------------
159Boot Magic are executed during boot up time. Press Magic key below then plug in keyboard cable.
160Note that you must use keys of **Layer 0** as Magic keys. These settings are stored in EEPROM so that retain your configure over power cycles.
161
162To avoid configuring accidentally additive salt key `KC_SPACE` also needs to be pressed along with the following configuration keys. The salt key is configurable in `config.h`. See [tmk_core/common/bootmagic.h](tmk_core/common/bootmagic.h).
163
164#### General
165- Skip reading EEPROM to start with default configuration(`ESC`)
166- Clear configuration stored in EEPROM to reset configuration(`Backspace`)
167
168#### Bootloader
169- Kick up Bootloader(`B`)
170
171#### Debug
172- Debug enable(`D`)
173- Debug matrix enable(`D`+`X`)
174- Debug keyboard enable(`D`+`K`)
175- Debug mouse enable(`D`+`M`)
176
177#### Keymap
178- Swap Control and CapsLock(`Left Control`)
179- Change CapsLock to Control(`Caps Lock`)
180- Swap LeftAlt and Gui(`Left Alt`)
181- Swap RightAlt and Gui(`Right Alt`)
182- Disable Gui(`Left Gui`)
183- Swap Grave and Escape(`Grave`)
184- Swap BackSlash and BackSpace(`Back Slash`)
185- Enable NKRO on boot(`N`)
186
187#### Default Layer
188- Set Default Layer to 0(`0`)
189- Set Default Layer to 1(`1`)
190- Set Default Layer to 2(`2`)
191- Set Default Layer to 3(`3`)
192- Set Default Layer to 4(`4`)
193- Set Default Layer to 5(`5`)
194- Set Default Layer to 6(`6`)
195- Set Default Layer to 7(`7`)
196
197
198
199Mechanical Locking support
200--------------------------
201This feature makes it possible for you to use mechanical locking switch for `CapsLock`, `NumLock`
202or `ScrollLock`. To enable this feature define these macros in `config.h` and use `KC_LCAP`, `KC_LN
203UM` or `KC_LSCR` in keymap for locking key instead of normal `KC_CAPS`, `KC_NLCK` or `KC_SLCK`. Res
204ync option tries to keep switch state consistent with keyboard LED state.
205
206 #define LOCKING_SUPPORT_ENABLE
207 #define LOCKING_RESYNC_ENABLE
208
209
210
211Start Your Own Project
212-----------------------
213**TBD**
214
215
216
217Debugging
218--------
219Use PJRC's `hid_listen` to see debug messages. You can use the tool for debug even if firmware use LUFA stack.
220
221You can use xprintf() to display debug info on `hid_listen`, see `tmk_core/common/xprintf.h`.
222
223
224
225Files and Directories
226-------------------
227### Top
228* tmk_core/ - core library
229* keyboard/ - keyboard projects
230* converter/ - protocol converter projects
231* doc/ - documents
232
233
234
235Coding Style
236-------------
237- Doesn't use Tab to indent, use 4-spaces instead.
238
239
240
241Other Keyboard Firmware Projects
242------------------
243You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](tmk_core/doc/other_projects.md).
diff --git a/doc/USB_NKRO.txt b/doc/USB_NKRO.txt
new file mode 100644
index 000000000..d9f1d1229
--- /dev/null
+++ b/doc/USB_NKRO.txt
@@ -0,0 +1,160 @@
1USB NKRO MEMO
2=============
32010/12/09
4
5
6References
7----------
8USB - boot mode, NKRO, compatibility, etc...
9 http://geekhack.org/showthread.php?t=13162
10NKey Rollover - Overview, Testing Methodology, and Results
11 http://geekhack.org/showwiki.php?title=NKey+Rollover+-+Overview+Testing+Methodology+and+Results
12dfj's NKRO(2010/06)
13 http://geekhack.org/showpost.php?p=191195&postcount=251
14 http://geekhack.org/showthread.php?p=204389#post204389
15
16
17Terminology
18---------
19NKRO
20ghost
21matrix
22mechanical with diodes
23membrane
24
25
26OS Support Status
27-----------------
28USB NKRO is possible *without* a custom driver.
29At least following OS's supports.
30 Windows7 64bit
31 WindowsXP
32 Windows2000 SP4
33 Ubuntu10.4(Linux 2.6)
34 MacOSX(To be tested)
35
36
37Custom Driver for USB NKRO
38--------------------------
39NOT NEEDED
40at least when using following report formats on Windows, Linux or MacOSX.
41
42
43USB NKRO methods
44----------------
451. Virtual keyboards
46 Keyboard can increase its KRO by using virtual keyboards with Standard or Extended report.
47 If the keyboard has 2 virtual keyboard with Standard report(6KRO), it gets 12KRO.
48 Using this method means the keyboard is a composite device.
49
502. Extended report
51 It needs large report size for this method to achieve NKRO.
52 If a keyboard has 101keys, it needs 103byte report. It seems to be inefficient.
53
543. Bitmap report
55 If the keyboard has less than 128keys, 16byte report will be enough for NKRO.
56 The 16byte report seems to be reasonable cost to get NKRO.
57
58
59Report Format
60-------------
61Other report formats than followings are possible, though these format are typical one.
62
631. Standard 8bytes
64 modifiers(bitmap) 1byte
65 reserved 1byte(not used)
66 keys(array) 1byte*6
67Standard report can send 6keys plus 8modifiers simultaneously.
68Standard report is used by most keyboards in the marketplace.
69Standard report is identical to boot protocol report.
70Standard report is hard to suffer from compatibility problems.
71
722. Extended standard 16,32,64bytes
73 modifiers(bitmap) 1byte
74 reserved 1byte(not used)
75 keys(array) 1byte*(14,32,62)
76Extended report can send N-keys by using N+2bytes.
77Extended report is expected to be compatible with boot protocol.
78
793. Bitmap 16,32,64bytes
80 keys(bitmap) (16,32)bytes
81Bitmap report can send at most 128keys by 16bytes and 256keys by 32bytes.
82Bitmap report can achieve USB NKRO efficiently in terms of report size.
83Bitmap report needs a deliberation for boot protocol implementation.
84Bitmap report descriptor sample:
85 0x05, 0x01, // Usage Page (Generic Desktop),
86 0x09, 0x06, // Usage (Keyboard),
87 0xA1, 0x01, // Collection (Application),
88 // bitmap of modifiers
89 0x75, 0x01, // Report Size (1),
90 0x95, 0x08, // Report Count (8),
91 0x05, 0x07, // Usage Page (Key Codes),
92 0x19, 0xE0, // Usage Minimum (224),
93 0x29, 0xE7, // Usage Maximum (231),
94 0x15, 0x00, // Logical Minimum (0),
95 0x25, 0x01, // Logical Maximum (1),
96 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte
97 // LED output report
98 0x95, 0x05, // Report Count (5),
99 0x75, 0x01, // Report Size (1),
100 0x05, 0x08, // Usage Page (LEDs),
101 0x19, 0x01, // Usage Minimum (1),
102 0x29, 0x05, // Usage Maximum (5),
103 0x91, 0x02, // Output (Data, Variable, Absolute),
104 0x95, 0x01, // Report Count (1),
105 0x75, 0x03, // Report Size (3),
106 0x91, 0x03, // Output (Constant),
107 // bitmap of keys
108 0x95, (REPORT_BYTES-1)*8, // Report Count (),
109 0x75, 0x01, // Report Size (1),
110 0x15, 0x00, // Logical Minimum (0),
111 0x25, 0x01, // Logical Maximum(1),
112 0x05, 0x07, // Usage Page (Key Codes),
113 0x19, 0x00, // Usage Minimum (0),
114 0x29, (REPORT_BYTES-1)*8-1, // Usage Maximum (),
115 0x81, 0x02, // Input (Data, Variable, Absolute),
116 0xc0 // End Collection
117where REPORT_BYTES is a report size in bytes.
118
119
120Considerations
121--------------
122Compatibility
123 boot protocol
124 minor/old system
125 Some BIOS doesn't send SET_PROTOCOL request, a keyboard can't switch to boot protocol mode.
126 This may cause a problem on a keyboard which uses other report than Standard.
127Reactivity
128 USB polling time
129 OS/Driver processing time
130
131
132Windows Problem
133---------------
1341. Windows accepts only 6keys in case of Standard report.
135 It should be able to send 6keys plus 8modifiers.
1362. Windows accepts only 10keys in case of 16bytes Extended report.
137 It should be able to send 14keys plus 8modifiers.
1383. Windows accepts only 18keys in case of 32bytes Extended report.
139 It should be able to send 30keys plus 8modifiers.
140If keys are pressed in excess of the number, wrong keys are registered on Windows.
141
142This problem will be reportedly fixed soon.(2010/12/05)
143 http://forums.anandtech.com/showpost.php?p=30873364&postcount=17
144
145
146Tools for testing NKRO
147----------------------
148Browser App:
149http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx
150http://random.xem.us/rollover.html
151
152Windows:
153AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643
154
155Linux:
156xkeycaps
157xev
158showkeys
159
160EOF
diff --git a/doc/VAGRANT_GUIDE.md b/doc/VAGRANT_GUIDE.md
new file mode 100644
index 000000000..2127347d9
--- /dev/null
+++ b/doc/VAGRANT_GUIDE.md
@@ -0,0 +1,26 @@
1# Quick Start Directions
2
3This project includes a Vagrantfile that will allow you to build a new firmware for your keyboard very easily without major changes to your primary operating system. This also ensures that when you clone the project and perform a build, you have the exact same environment as anyone else using the Vagrantfile to build. This makes it much easier for people to help you troubleshoot any issues you encounter.
4
5## Requirements
6
7Using the `/util/Vagrantfile` in this repository requires you have [Vagrant](http://www.vagrantup.com/) as well as [VirtualBox](https://www.virtualbox.org/) (or [VMware Workstation](https://www.vmware.com/products/workstation) and [Vagrant VMware plugin](http://www.vagrantup.com/vmware) but the (paid) VMware plugin requires a licensed copy of VMware Workstation/Fusion).
8
9*COMPATIBILITY NOTICE* Certain versions of Virtualbox 5 appear to have an incompatibility with the Virtualbox extensions installed in the boxes in this Vagrantfile. If you encounter any issues with the /vagrant mount not succeeding, please upgrade your version of Virtualbox to at least 5.0.12.
10
11Other than having Vagrant and Virtualbox installed and possibly a restart of your computer afterwards, you can simple run a 'vagrant up' anywhere inside the folder where you checked out this project and it will start a Linux virtual machine that contains all the tools required to build this project. There is a post Vagrant startup hint that will get you off on the right foot, otherwise you can also reference the build documentation below.
12
13Build Firmware and Program Controller
14-------------------------------------
15See [/doc/BUIDE_GUIDE.md](/doc/BUILD_GUIDE.md), or the README in the particular keyboard/* folder.
16
17Change your keymap
18------------------
19See [/doc/keymap.md](/doc/keymap.md).
20
21## Flashing the firmware
22
23The "easy" way to flash the firmware is using a tool from your host OS like the Teensy programming app. [ErgoDox EZ](/keyboard/ergodox_ez/readme.md) gives a great example.
24
25If you want to program via the command line you can uncomment the ['modifyvm'] lines in the Vagrantfile to enable the USB passthrough into Linux and then program using the command line tools like dfu-util/dfu-programmer or you can install the Teensy CLI version.
26 \ No newline at end of file
diff --git a/doc/build_old.md b/doc/build_old.md
new file mode 100644
index 000000000..5c2d57d02
--- /dev/null
+++ b/doc/build_old.md
@@ -0,0 +1,187 @@
1Build Firmware and Program Controller
2=====================================
3
4## This guide may be out-dated - use doc/BUILD_GUIDE.md instead
5
6Download and Install
7--------------------
8### 1. Install Tools
9
101. **Toolchain** On Windows install [MHV AVR Tools][mhv] for AVR GCC compiler and [Cygwin][cygwin](or [MinGW][mingw]) for shell terminal. On Mac you can use [CrossPack][crosspack]. On Linux you can install AVR GCC (and avr-libc) with your favorite package manager or run the avr_setup.sh script in the root of this repository.
11
122. **Programmer** On Windows install [Atmel FLIP][flip]. On Mac and Linux install [dfu-programmer][dfu-prog].
13
143. **Driver** On Windows you start DFU bootloader on the chip first time you will see 'Found New Hardware Wizard' to install driver. If you install device driver properly you can find chip name like 'ATmega32U4' under 'LibUSB-Win32 Devices' tree on 'Device Manager'. If not you shall need to update its driver on 'Device Manager'. You will find the driver in `FLIP` install directory like: C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\. In case of `dfu-programmer` use its driver.
15
16If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader].
17
18
19### 2. Download source
20You can find firmware source at github:
21
22- <https://github.com/tmk/tmk_keyboard>
23
24If you are familiar with `Git` tools you are recommended to use it but you can also download zip archive from:
25
26- <https://github.com/tmk/tmk_keyboard/archive/master.zip>
27
28
29Build firmware
30--------------
31### 1. Open terminal
32Open terminal window to get access to commands. Use Cygwin(or MingGW) `shell terminal` in Windows or `Terminal.app` on Mac OSX. In Windows press `Windows` key and `R` then enter `cmd` in 'Run command' dialog showing up.
33
34### 2. Change directory
35Move to project directory in the firmware source.
36
37 cd tmk_keyboard/{'keyboard' or 'converter'}/<project>
38
39### 3. Make
40Build firmware using GNU `make` command. You'll see `<project>_<variant>.hex` file in that directory unless something unexpected occurs in build process.
41
42
43 make -f Makefile.<variant> clean
44 make -f Makefile.<variant>
45
46
47
48
49Program Controller
50------------------
51Now you have **hex** file to program on current directory. This **hex** is only needed to program your controller, other files are used for development and you may leave and forget them.
52
53### 1. Start bootloader
54How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual.
55
56### 2. Program with DFU bootloader
57Stock AVR USB chip including ATmega32U4 has DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. Open source command line tool `dfu-programmer` also supports AVR chips, it runs on Linux, Mac OSX and even Windows.
58
59To program AVR chip with DFU bootloader use `FLIP` or `dfu-programmer`.
60If you have a proper program command in `Makefile` just type this.
61
62`FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below.
63To use command line tool run this command. Note that you need to set PATH variable properly.
64
65 $ make -f Makefile.<variant> flip
66
67Or to program with `dfu-programmer` run:
68
69 $ make -f Makefile.<variant> dfu
70
71#### FLIP GUI tutorial
721. On menu bar click Device -> Select, then. `ATmega32u4`.
732. On menu bar click Settings -> Communication -> USB, then click 'Open' button on 'USB Port Connection' dialog.
74At this point you'll see grey-outed widgets on the app get colored and ready.
75
763. On menu bar click File -> Load HEX File, then select your firmware hex file on File Selector dialog.
774. On 'Operations Flow' panel click 'Run' button to load the firmware binary to the chip. Note that you should keep 'Erase', 'Blank Check', 'Program' and 'Verify' check boxes selected.
785. Re-plug USB cord or click 'Start Application' button to restart your controller.
79Done.
80
81See also these instructions if you need.
82
83- <http://code.google.com/p/micropendous/wiki/LoadingFirmwareWithFLIP>
84- <http://www.atmel.com/Images/doc7769.pdf>
85
86
87### 3. Program with Teensy Loader
88If you have PJRC Teensy see instruction of `Teensy Loader`.
89
90- <http://www.pjrc.com/teensy/loader.html>
91
92Or use this command if you have command line version of Teensy Loader installed.
93
94 $ make -f Makefile.<variant> teensy
95
96
97### 4. Program with Other programmer
98You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or USBasp. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile.
99
100 $ make -f Makefile.<variant> program
101
102
103[cygwin]: https://www.cygwin.com/
104[mingw]: http://www.mingw.org/
105[mhv]: https://infernoembedded.com/products/avr-tools
106[winavr]: http://winavr.sourceforge.net/
107[crosspack]: http://www.obdev.at/products/crosspack/index.html
108[flip]: http://www.atmel.com/tools/FLIP.aspx
109[dfu-prog]: http://dfu-programmer.sourceforge.net/
110[teensy-loader]:http://www.pjrc.com/teensy/loader.html
111
112
113
114Makefile Options
115----------------
116### 1. MCU and Frequency.
117
118 MCU = atmega32u4 # Teensy 2.0
119 #MCU = at90usb1286 # Teensy++ 2.0
120 F_CPU = 16000000
121
122Set your MCU and its clock in Hz.
123
124 # Boot Section Size in *bytes*
125 # Teensy halfKay 512
126 # Atmel DFU loader 4096
127 # LUFA bootloader 4096
128 OPT_DEFS += -DBOOTLOADER_SIZE=4096
129
130If you are using PJRC Teensy use `512` for `BOOTLOADER_SIZE`, otherwise use `4096` unless you are sure.
131
132### 2. Features
133Optional. Note that ***comment out*** with `#` to disable them.
134
135 BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
136 MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
137 EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
138 CONSOLE_ENABLE = yes # Console for debug(+400)
139 COMMAND_ENABLE = yes # Commands for debug and configuration
140 SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
141 #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
142 #BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
143
144### 3. Programmer
145Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`.
146
147 # avrdude with AVRISPmkII
148 PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex
149
150 # avrdude with USBaspLoader
151 PROGRAM_CMD = avrdude -p $(MCU) -c usbasp -U flash:w:$(TARGET).hex
152
153 # avrdude with arduino
154 PROGRAM_CMD = avrdude -p $(MCU) -c arduino -P COM1 -b 57600 -U flash:w:$(TARGET).hex
155
156
157
158Config.h Options
159----------------
160### 1. Magic command key combination
161
162 #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)))
163
164### 2. Mechanical Locking Support for CapsLock
165
166 /* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */
167 #define CAPSLOCK_LOCKING_ENABLE
168 /* Locking CapsLock re-synchronize hack */
169 #define CAPSLOCK_LOCKING_RESYNC_ENABLE
170
171### 3. Disable Debug and Print
172
173 /* disable debug print */
174 #define NO_DEBUG
175
176 /* disable print */
177 #define NO_PRINT
178
179### 4. Disable Action Features
180
181 #define NO_ACTION_LAYER
182 #define NO_ACTION_TAPPING
183 #define NO_ACTION_ONESHOT
184 #define NO_ACTION_MACRO
185 #define NO_ACTION_FUNCTION
186
187***TBD***
diff --git a/doc/keycode.txt b/doc/keycode.txt
new file mode 100644
index 000000000..44d7e27cd
--- /dev/null
+++ b/doc/keycode.txt
@@ -0,0 +1,261 @@
1Keycode Symbol Table
2====================
3Keycodes are defined in `common/keycode.h`.
4Range of 00-A4 and E0-E7 are identical with HID Usage:
5<http://www.usb.org/developers/devclass_docs/Hut1_11.pdf>
6Virtual keycodes are defined out of above range to support special actions.
7
8
9Keycode Symbol Short name Description
10--------------------------------------------------------------------------------
11KC_NO 00 Reserved (no event indicated)
12KC_ROLL_OVER 01 Keyboard ErrorRollOver
13KC_POST_FAIL 02 Keyboard POSTFail
14KC_UNDEFINED 03 Keyboard ErrorUndefined
15KC_A 04 Keyboard a and A
16KC_B 05 Keyboard b and B
17KC_C 06 Keyboard c and C
18KC_D 07 Keyboard d and D
19KC_E 08 Keyboard e and E
20KC_F 09 Keyboard f and F
21KC_G 0A Keyboard g and G
22KC_H 0B Keyboard h and H
23KC_I 0C Keyboard i and I
24KC_J 0D Keyboard j and J
25KC_K 0E Keyboard k and K
26KC_L 0F Keyboard l and L
27KC_M 10 Keyboard m and M
28KC_N 11 Keyboard n and N
29KC_O 12 Keyboard o and O
30KC_P 13 Keyboard p and P
31KC_Q 14 Keyboard q and Q
32KC_R 15 Keyboard r and R
33KC_S 16 Keyboard s and S
34KC_T 17 Keyboard t and T
35KC_U 18 Keyboard u and U
36KC_V 19 Keyboard v and V
37KC_W 1A Keyboard w and W
38KC_X 1B Keyboard x and X
39KC_Y 1C Keyboard y and Y
40KC_Z 1D Keyboard z and Z
41KC_1 1E Keyboard 1 and !
42KC_2 1F Keyboard 2 and @
43KC_3 20 Keyboard 3 and #
44KC_4 21 Keyboard 4 and $
45KC_5 22 Keyboard 5 and %
46KC_6 23 Keyboard 6 and ^
47KC_7 24 Keyboard 7 and &
48KC_8 25 Keyboard 8 and *
49KC_9 26 Keyboard 9 and (
50KC_0 27 Keyboard 0 and )
51KC_ENTER KC_ENT 28 Keyboard Return (ENTER)
52KC_ESCAPE KC_ESC 29 Keyboard ESCAPE
53KC_BSPACE KC_BSPC 2A Keyboard DELETE (Backspace)
54KC_TAB 2B Keyboard Tab
55KC_SPACE KC_SPC 2C Keyboard Spacebar
56KC_MINUS KC_MINS 2D Keyboard - and (underscore)
57KC_EQUAL KC_EQL 2E Keyboard = and +
58KC_LBRACKET KC_LBRC 2F Keyboard [ and {
59KC_RBRACKET KC_RBRC 30 Keyboard ] and }
60KC_BSLASH KC_BSLS 31 Keyboard \ and |
61KC_NONUS_HASH KC_NUHS 32 Keyboard Non-US # and ~
62KC_SCOLON KC_SCLN 33 Keyboard ; and :
63KC_QUOTE KC_QUOT 34 Keyboard ‘ and “
64KC_GRAVE KC_GRV 35 Keyboard Grave Accent and Tilde
65KC_COMMA KC_COMM 36 Keyboard, and <
66KC_DOT 37 Keyboard . and >
67KC_SLASH KC_SLSH 38 Keyboard / and ?
68KC_CAPSLOCK KC_CAPS 39 Keyboard Caps Lock
69KC_F1 3A Keyboard F1
70KC_F2 3B Keyboard F2
71KC_F3 3C Keyboard F3
72KC_F4 3D Keyboard F4
73KC_F5 3E Keyboard F5
74KC_F6 3F Keyboard F6
75KC_F7 40 Keyboard F7
76KC_F8 41 Keyboard F8
77KC_F9 42 Keyboard F9
78KC_F10 43 Keyboard F10
79KC_F11 44 Keyboard F11
80KC_F12 45 Keyboard F12
81KC_PSCREEN KC_PSCR 46 Keyboard PrintScreen1
82KC_SCKLOCK KC_SLCK 47 Keyboard Scroll Lock11
83KC_PAUSE KC_PAUS 48 Keyboard Pause1
84KC_INSERT KC_INS 49 Keyboard Insert1
85KC_HOME 4A Keyboard Home1
86KC_PGUP 4B Keyboard PageUp1
87KC_DELETE KC_DELETE 4C Keyboard Delete Forward
88KC_END 4D Keyboard End1
89KC_PGDOWN KC_PGDN 4E Keyboard PageDown1
90KC_RIGHT KC_RGHT 4F Keyboard RightArrow1
91KC_LEFT 50 Keyboard LeftArrow1
92KC_DOWN 51 Keyboard DownArrow1
93KC_UP 52 Keyboard UpArrow1
94KC_NUMLOCK KC_NLCK 53 Keypad Num Lock and Clear11
95KC_KP_SLASH KC_PSLS 54 Keypad /1
96KC_KP_ASTERISK KC_PAST 55 Keypad *
97KC_KP_MINUS KC_PMNS 56 Keypad -
98KC_KP_PLUS KC_PPLS 57 Keypad +
99KC_KP_ENTER KC_PENT 58 Keypad ENTER5
100KC_KP_1 KC_P1 59 Keypad 1 and End
101KC_KP_2 KC_P2 5A Keypad 2 and Down Arrow
102KC_KP_3 KC_P3 5B Keypad 3 and PageDn
103KC_KP_4 KC_P4 5C Keypad 4 and Left Arrow
104KC_KP_5 KC_P5 5D Keypad 5
105KC_KP_6 KC_P6 5E Keypad 6 and Right Arrow
106KC_KP_7 KC_P7 5F Keypad 7 and Home
107KC_KP_8 KC_P8 60 Keypad 8 and Up Arrow
108KC_KP_9 KC_P9 61 Keypad 9 and PageUp
109KC_KP_0 KC_P0 62 Keypad 0 and Insert
110KC_KP_DOT KC_PDOT 63 Keypad . and Delete
111KC_NONUS_BSLASH KC_NUBS 64 Keyboard Non-US \ and |
112KC_APPLICATION KC_APP 65 Keyboard Application10
113KC_POWER 66 Keyboard Power9
114KC_KP_EQUAL KC_PEQL 67 Keypad =
115KC_F13 68 Keyboard F13
116KC_F14 69 Keyboard F14
117KC_F15 6A Keyboard F15
118KC_F16 6B Keyboard F16
119KC_F17 6C Keyboard F17
120KC_F18 6D Keyboard F18
121KC_F19 6E Keyboard F19
122KC_F20 6F Keyboard F20
123KC_F21 70 Keyboard F21
124KC_F22 71 Keyboard F22
125KC_F23 72 Keyboard F23
126KC_F24 73 Keyboard F24
127KC_EXECUTE 74 Keyboard Execute
128KC_HELP 75 Keyboard Help
129KC_MENU 76 Keyboard Menu
130KC_SELECT 77 Keyboard Select
131KC_STOP 78 Keyboard Stop
132KC_AGAIN 79 Keyboard Again
133KC_UNDO 7A Keyboard Undo
134KC_CUT 7B Keyboard Cut
135KC_COPY 7C Keyboard Copy
136KC_PASTE 7D Keyboard Paste
137KC_FIND 7E Keyboard Find
138KC__MUTE 7F Keyboard Mute
139KC__VOLUP 80 Keyboard Volume Up
140KC__VOLDOWN 81 Keyboard Volume Down
141KC_LOCKING_CAPS 82 Keyboard Locking Caps Lock12
142KC_LOCKING_NUM 83 Keyboard Locking Num Lock12
143KC_LOCKING_SCROLL 84 Keyboard Locking Scroll Lock12
144KC_KP_COMMA KC_PCMM 85 Keypad Comma27
145KC_KP_EQUAL_AS400 86 Keypad Equal Sign29
146KC_INT1 KC_RO 87 Keyboard International115,28
147KC_INT2 KC_KANA 88 Keyboard International216
148KC_INT3 KC_JYEN 89 Keyboard International317
149KC_INT4 KC_HENK 8A Keyboard International418
150KC_INT5 KC_MHEN 8B Keyboard International519
151KC_INT6 8C Keyboard International620
152KC_INT7 8D Keyboard International721
153KC_INT8 8E Keyboard International822
154KC_INT9 8F Keyboard International922
155KC_LANG1 90 Keyboard LANG125
156KC_LANG2 91 Keyboard LANG226
157KC_LANG3 92 Keyboard LANG330
158KC_LANG4 93 Keyboard LANG431
159KC_LANG5 94 Keyboard LANG532
160KC_LANG6 95 Keyboard LANG68
161KC_LANG7 96 Keyboard LANG78
162KC_LANG8 97 Keyboard LANG88
163KC_LANG9 98 Keyboard LANG98
164KC_ALT_ERASE 99 Keyboard Alternate Erase7
165KC_SYSREQ 9A Keyboard SysReq/Attention1
166KC_CANCEL 9B Keyboard Cancel
167KC_CLEAR 9C Keyboard Clear
168KC_PRIOR 9D Keyboard Prior
169KC_RETURN 9E Keyboard Return
170KC_SEPARATOR 9F Keyboard Separator
171KC_OUT A0 Keyboard Out
172KC_OPER A1 Keyboard Oper
173KC_CLEAR_AGAIN A2 Keyboard Clear/Again
174KC_CRSEL A3 Keyboard CrSel/Props
175KC_EXSEL A4 Keyboard ExSel
176/* Modifiers */
177KC_LCTRL KC_LCTL E0 Keyboard LeftControl
178KC_LSHIFT KC_LSFT E1 Keyboard LeftShift
179KC_LALT E2 Keyboard LeftAlt
180KC_LGUI E3 Keyboard Left GUI(Windows/Apple/Meta key)
181KC_RCTRL KC_RCTL E4 Keyboard RightControl
182KC_RSHIFT KC_RSFT E5 Keyboard RightShift
183KC_RALT E6 Keyboard RightAlt
184KC_RGUI E7 Keyboard Right GUI(Windows/Apple/Meta key)
185
186/*
187 * Virtual keycodes
188 */
189/* System Control */
190KC_SYSTEM_POWER KC_PWR System Power Down
191KC_SYSTEM_SLEEP KC_SLEP System Sleep
192KC_SYSTEM_WAKE KC_WAKE System Wake
193/* Consumer Page */
194KC_AUDIO_MUTE KC_MUTE
195KC_AUDIO_VOL_UP KC_VOLU
196KC_AUDIO_VOL_DOWN KC_VOLD
197KC_MEDIA_NEXT_TRACK KC_MNXT
198KC_MEDIA_PREV_TRACK KC_MPRV
199KC_MEDIA_STOP KC_MSTP
200KC_MEDIA_PLAY_PAUSE KC_MPLY
201KC_MEDIA_SELECT KC_MSEL
202KC_MAIL KC_MAIL
203KC_CALCULATOR KC_CALC
204KC_MY_COMPUTER KC_MYCM
205KC_WWW_SEARCH KC_WSCH
206KC_WWW_HOME KC_WHOM
207KC_WWW_BACK KC_WBAK
208KC_WWW_FORWARD KC_WFWD
209KC_WWW_STOP KC_WSTP
210KC_WWW_REFRESH KC_WREF
211KC_WWW_FAVORITES KC_WFAV
212/* Mousekey */
213KC_MS_UP KC_MS_U Mouse Cursor Up
214KC_MS_DOWN KC_MS_D Mouse Cursor Down
215KC_MS_LEFT KC_MS_L Mouse Cursor Left
216KC_MS_RIGHT KC_MS_R Mouse Cursor Right
217KC_MS_BTN1 KC_BTN1 Mouse Button 1
218KC_MS_BTN2 KC_BTN2 Mouse Button 2
219KC_MS_BTN3 KC_BTN3 Mouse Button 3
220KC_MS_BTN4 KC_BTN4 Mouse Button 4
221KC_MS_BTN5 KC_BTN5 Mouse Button 5
222KC_MS_WH_UP KC_WH_U Mouse Wheel Up
223KC_MS_WH_DOWN KC_WH_D Mouse Wheel Down
224KC_MS_WH_LEFT KC_WH_L Mouse Wheel Left
225KC_MS_WH_RIGHT KC_WH_R Mouse Wheel Right
226KC_MS_ACCEL0 KC_ACL0 Mouse Acceleration 0
227KC_MS_ACCEL1 KC_ACL1 Mouse Acceleration 1
228KC_MS_ACCEL2 KC_ACL2 Mouse Acceleration 2
229/* Fn key */
230KC_FN0
231KC_FN1
232KC_FN2
233KC_FN3
234KC_FN4
235KC_FN5
236KC_FN6
237KC_FN7
238KC_FN8
239KC_FN9
240KC_FN10
241KC_FN11
242KC_FN12
243KC_FN13
244KC_FN14
245KC_FN15
246KC_FN16
247KC_FN17
248KC_FN18
249KC_FN19
250KC_FN20
251KC_FN21
252KC_FN22
253KC_FN23
254KC_FN24
255KC_FN25
256KC_FN26
257KC_FN27
258KC_FN28
259KC_FN29
260KC_FN30
261KC_FN31
diff --git a/doc/keymap.md b/doc/keymap.md
new file mode 100644
index 000000000..4d42fbe5c
--- /dev/null
+++ b/doc/keymap.md
@@ -0,0 +1,599 @@
1Keymap framework - how to define your keymap
2============================================
3***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.***
4
5## 0. Keymap and layers
6**Keymap** is comprised of multiple layers of key layout, you can define **32 layers** at most.
7**Layer** is an array of **keycodes** to define **actions** for each physical keys.
8respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence.
9
10 Keymap: 32 Layers Layer: Keycode matrix
11 ----------------- ---------------------
12 stack of layers array_of_keycode[row][column]
13 ____________ precedence _______________________
14 / / | high / ESC / F1 / F2 / F3 ....
15 31 /___________// | /-----/-----/-----/-----
16 30 /___________// | / TAB / Q / W / E ....
17 29 /___________/ | /-----/-----/-----/-----
18 : _:_:_:_:_:__ | : /LCtrl/ A / S / D ....
19 : / : : : : : / | : / : : : :
20 2 /___________// | 2 `--------------------------
21 1 /___________// | 1 `--------------------------
22 0 /___________/ V low 0 `--------------------------
23
24
25
26### 0.1 Keymap status
27Keymap has its state in two parameters:
28**`default_layer`** indicates a base keymap layer(0-31) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit.
29
30Keymap layer '0' is usually `default_layer` and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in `config.h`.
31To change `default_layer` will be useful when you switch key layout completely, say you want Colmak instead of Qwerty.
32
33 Initial state of Keymap Change base layout
34 ----------------------- ------------------
35
36 31 31
37 30 30
38 29 29
39 : :
40 : : ____________
41 2 ____________ 2 / /
42 1 / / ,->1 /___________/
43 ,->0 /___________/ | 0
44 | |
45 `--- default_layer = 0 `--- default_layer = 1
46 layer_state = 0x00000001 layer_state = 0x00000002
47
48On the other hand, you shall change `layer_state` to overlay base layer with some layers for feature such as navigation keys, function key(F1-F12), media keys or special actions.
49
50 Overlay feature layer
51 --------------------- bit|status
52 ____________ ---+------
53 31 / / 31 | 0
54 30 /___________// -----> 30 | 1
55 29 /___________/ -----> 29 | 1
56 : : | :
57 : ____________ : | :
58 2 / / 2 | 0
59 ,->1 /___________/ -----> 1 | 1
60 | 0 0 | 0
61 | +
62 `--- default_layer = 1 |
63 layer_state = 0x60000002 <-'
64
65
66
67### 0.2 Layer Precedence and Transparency
68Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred.
69
70You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
71Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead.
72See example below.
73
74
75### 0.3 Keymap Example
76Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array.
77
78This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard.
79This example has three layers, 'Qwerty' as base layer, 'Cursor' and 'Mousekey'.
80In this example,
81
82 `Fn0` is a **momentary layer switching** key, you can use keys on Cursor layer while holding the key.
83
84 `Fn1` is a momentary layer switching key with tapping feature, you can get semicolon **';'** with taping the key and switch layers while holding the key. The word **'tap'** or **'tapping'** mean to press and release a key quickly.
85
86 `Fn2` is a **toggle layer switch** key, you can stay switched layer after releasing the key unlike momentary switching.
87
88You can find other keymap definitions in file `keymap.c` located on project directories.
89
90 static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
91 /* 0: Qwerty
92 * ,-----------------------------------------------------------.
93 * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
94 * |-----------------------------------------------------------|
95 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
96 * |-----------------------------------------------------------|
97 * |Contro| A| S| D| F| G| H| J| K| L|Fn1| '|Enter |
98 * |-----------------------------------------------------------|
99 * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
100 * `-----------------------------------------------------------'
101 * |Gui|Alt |Space |Alt |Fn2|
102 * `-------------------------------------------'
103 */
104 KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
105 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
106 LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT,ENT, \
107 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
108 LGUI,LALT, SPC, RALT,FN2),
109 /* 1: Cursor(HHKB mode)
110 * ,-----------------------------------------------------------.
111 * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
112 * |-----------------------------------------------------------|
113 * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
114 * |-----------------------------------------------------------|
115 * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
116 * |-----------------------------------------------------------|
117 * |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
118 * `-----------------------------------------------------------'
119 * |Gui |Alt |Space |Alt |Gui|
120 * `--------------------------------------------'
121 */
122 KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
123 CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,BSPC, \
124 LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
125 LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
126 LGUI,LALT, SPC, RALT,RGUI),
127 /* 2: Mousekey
128 * ,-----------------------------------------------------------.
129 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
130 * |-----------------------------------------------------------|
131 * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
132 * |-----------------------------------------------------------|
133 * |Contro| | | | | |McL|McD|McU|McR| | |Return |
134 * |-----------------------------------------------------------|
135 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
136 * `-----------------------------------------------------------'
137 * |Gui |Alt |Mb1 |Alt | |
138 * `--------------------------------------------'
139 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
140 */
141 KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
142 TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,BSPC, \
143 LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
144 LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,TRNS, \
145 LGUI,LALT, BTN1, RALT,TRNS),
146 };
147
148 static const uint16_t PROGMEM fn_actions[] = {
149 ACTION_LAYER_MOMENTARY(1), // FN0
150 ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN1
151 ACTION_LAYER_TOGGLE(2), // FN2
152 };
153
154
155
156
157## 1. Keycode
158See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to indicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media control keys, System control keys and Mousekeys.
159
160 ***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`.
161
162### 1.0 Other key
163- `KC_NO` for no action
164- `KC_TRNS` for layer transparency (See above)
165
166### 1.1 Normal key
167- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key
168- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT`
169- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS`
170- `KC_UP`, `KC_DOWN`, `KC_RGHT`, `KC_LEFT`, `KC_PGUP`, `KC_PGDN`, `KC_HOME`, `KC_END`
171- `KC_CAPS`, `KC_NLCK`, `KC_SLCK`, `KC_PSCR`, `KC_PAUS`, `KC_APP`, `KC_F1` to `KC_F24`
172- `KC_P1` to `KC_P0`, `KC_PDOT`, `KC_PCMM`, `KC_PSLS`, `KC_PAST`, `KC_PMNS`, `KC_PPLS`, `KC_PEQL`, `KC_PENT` for keypad.
173
174### 1.2 Modifier
175There are 8 modifiers which has discrimination between left and right.
176
177- `KC_LCTL` and `KC_RCTL` for Control
178- `KC_LSFT` and `KC_RSFT` for Shift
179- `KC_LALT` and `KC_RALT` for Alt
180- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac
181
182### 1.3 Mousekey
183- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor
184- `KC_WH_U`, `KC_WH_D`, `KC_WH_L`, `KC_WH_R` for mouse wheel
185- `KC_BTN1`, `KC_BTN2`, `KC_BTN3`, `KC_BTN4`, `KC_BTN5` for mouse buttons
186
187### 1.4 System & Media key
188- `KC_PWR`, `KC_SLEP`, `KC_WAKE` for Power, Sleep, Wake
189- `KC_MUTE`, `KC_VOLU`, `KC_VOLD` for audio volume control
190- `KC_MNXT`, `KC_MPRV`, `KC_MSTP`, `KC_MPLY`, `KC_MSEL` for media control
191- `KC_MAIL`, `KC_CALC`, `KC_MYCM` for application launch
192- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation
193
194### 1.5 Fn key
195`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.***
196
197### 1.6 Keycode Table
198 See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.
199
200 In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions.
201[HID_usage]: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
202
203
204
205## 2. Action
206See [`common/action_code.h`](../common/action_code.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping.
207
208Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using just keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes.
209
210***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.***
211
212
213### 2.1 Key Action
214This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release.
215
216#### Parameters
217+ **mods**: { ` MOD_LCTL`, ` MOD_LSFT`, ` MOD_LALT`, ` MOD_LGUI`,
218 ` MOD_RCTL`, ` MOD_RSFT`, ` MOD_RALT`, ` MOD_RGUI` }
219+ **key**: keycode
220
221
222#### 2.1.1 Normal key and Modifier
223***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead.
224
225You can define these actions on *'A'* key and *'left shift'* modifier with:
226
227 ACTION_KEY(KC_A)
228 ACTION_KEY(KC_LSFT)
229
230#### 2.1.2 Modified key
231This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes.
232
233Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows.
234
235 ACTION_MODS_KEY(MOD_LSFT, KC_1)
236 ACTION_MODS_KEY(MOD_LALT, KC_TAB)
237
238Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro.
239
240 ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB)
241
242#### 2.1.3 Multiple Modifiers
243Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`.
244
245 ACTION_MODS(MOD_ALT | MOD_LSFT)
246
247#### 2.1.3 Modifier with Tap key([Dual role][dual_role])
248Works as a modifier key while holding, but registers a key on tap(press and release quickly).
249
250
251 ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)
252
253
254
255### 2.2 Layer Action
256These actions operate layers of keymap.
257
258#### Parameters
259You can specify a **target layer** of action and **when the action is executed**. Some actions take a **bit value** for bitwise operation.
260
261
262+ **layer**: `0`-`31`
263+ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` }
264+ **bits**: 4-bit value and 1-bit mask bit
265
266
267#### 2.2.1 Default Layer
268Default Layer is a layer which always is valid and referred to when actions is not defined on other overlay layers.
269
270This sets Default Layer to given parameter `layer` and activate it.
271
272 ACTION_DEFAULT_LAYER_SET(layer)
273
274
275#### 2.2.2 Momentary
276Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released.
277
278 ACTION_LAYER_MOMENTARY(layer)
279
280
281#### 2.2.3 Toggle Switch
282Turns on `layer` with first type(press and release) and turns off with next.
283
284 ACTION_LAYER_TOGGLE(layer)
285
286
287#### 2.2.4 Momentary Switch with tap key
288Turns on `layer` momentary while holding, but registers key on tap(press and release quickly).
289
290 ACTION_LAYER_TAP_KEY(layer, key)
291
292
293#### 2.2.5 Momentary Switch with tap toggle
294Turns on `layer` momentary while holding and toggles it with serial taps.
295
296 ACTION_LAYER_TAP_TOGGLE(layer)
297
298
299#### 2.2.6 Invert state of layer
300Inverts current state of `layer`. If the layer is on it becomes off with this action.
301
302 ACTION_LAYER_INVERT(layer, on)
303
304
305#### 2.2.7 Turn On layer
306Turns on layer state.
307
308 ACTION_LAYER_ON(layer, on)
309
310Turns on layer state on press and turns off on release.
311
312 ACTION_LAYER_ON_OFF(layer)
313
314
315#### 2.2.8 Turn Off layer
316Turns off layer state.
317
318 ACTION_LAYER_OFF(layer, on)
319
320Turns off layer state on press and activates on release.
321
322 ACTION_LAYER_OFF_ON(layer)
323
324
325#### 2.2.9 Set layer
326Turn on layer only.
327`layer_state = (1<<layer) [layer: 0-31]`
328
329 ACTION_LAYER_SET(layer, on)
330
331Turns on layer only and clear all layer on release..
332
333 ACTION_LAYER_SET_CLEAR(layer)
334
335
336#### 2.2.10 Bitwise operation
337
338**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed.
339
340 ACTION_LAYER_BIT_AND(part, bits, on)
341 ACTION_LAYER_BIT_OR(part, bits, on)
342 ACTION_LAYER_BIT_XOR(part, bits, on)
343 ACTION_LAYER_BIT_SET(part, bits, on)
344
345These actions works with parameters as following code.
346
347 uint8_t shift = part*4;
348 uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
349 uint32_t layer_state = layer_state <bitop> ((bits<<shift)|mask);
350
351
352Default Layer also has bitwise operations, they are executed when key is released.
353
354 ACTION_DEFAULT_LAYER_BIT_AND(part, bits)
355 ACTION_DEFAULT_LAYER_BIT_OR(part, bits)
356 ACTION_DEFAULT_LAYER_BIT_XOR(part, bits)
357 ACTION_DEFAULT_LAYER_BIT_SET(part, bits)
358
359
360
361### 2.3 Macro action
362***TBD***
363
364`Macro` action indicates complex key strokes.
365
366 MACRO( D(LSHIFT), D(D), END )
367 MACRO( U(D), U(LSHIFT), END )
368 MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )
369
370#### 2.3.1 Macro Commands
371- **I()** change interval of stroke.
372- **D()** press key
373- **U()** release key
374- **T()** type key(press and release)
375- **W()** wait
376- **END** end mark
377
378#### 2.3.2 Examples
379
380***TODO: sample implementation***
381See `keyboard/hhkb/keymap.c` for sample.
382
383
384
385### 2.4 Function action
386***TBD***
387
388There are two type of action, normal `Function` and tappable `Function`.
389These actions call user defined function with `id`, `opt`, and key event information as arguments.
390
391#### 2.4.1 Function
392To define normal `Function` action in keymap use this.
393
394 ACTION_FUNCTION(id, opt)
395
396#### 2.4.2 Function with tap
397To define tappable `Function` action in keymap use this.
398
399 ACTION_FUNCTION_TAP(id, opt)
400
401#### 2.4.3 Implement user function
402`Function` actions can be defined freely with C by user in callback function:
403
404 void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt)
405
406This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Function `id` can be 0-255 and `opt` can be 0-15.
407
408 `keyrecord_t` is comprised of key event and tap count. `keyevent_t` indicates which and when key is pressed or released. From `tap_count` you can know tap state, 0 means no tap. These information will be used in user function to decide how action of key is performed.
409
410 typedef struct {
411 keyevent_t event;
412 uint8_t tap_count;
413 } keyrecord_t;
414
415 typedef struct {
416 key_t key;
417 bool pressed;
418 uint16_t time;
419 } keyevent_t;
420
421 typedef struct {
422 uint8_t col;
423 uint8_t row;
424 } key_t;
425
426***TODO: sample implementation***
427See `keyboard/hhkb/keymap.c` for sample.
428
429
430
431### 2.5 Backlight Action
432These actions control the backlight.
433
434#### 2.5.1 Change backlight level
435Increase backlight level.
436
437 ACTION_BACKLIGHT_INCREASE()
438
439Decrease backlight level.
440
441 ACTION_BACKLIGHT_DECREASE()
442
443Step through backlight levels.
444
445 ACTION_BACKLIGHT_STEP()
446
447Turn a specific backlight level on or off.
448
449 ACTION_BACKLIGHT_LEVEL(1)
450
451#### 2.5.2 Turn on / off backlight
452Turn the backlight on and off without changing level.
453
454 ACTION_BACKLIGHT_TOGGLE()
455
456
457
458## 3. Layer switching Example
459There are some ways to switch layer with 'Layer' actions.
460
461### 3.1 Momentary switching
462Momentary switching changes layer only while holding Fn key.
463
464This action makes 'Layer 1' active(valid) on key press event and inactive on release event. Namely you can overlay a layer on lower layers or default layer temporarily with this action.
465
466 ACTION_LAYER_MOMENTARY(1)
467
468
469Note that after switching on press the actions on destination layer(Layer 1) are performed.
470***Thus you shall need to place an action to go back on destination layer***, or you will be stuck in destination layer without way to get back. Usually you need to place same action or 'KC_TRNS` on destination layer to get back.
471
472
473### 3.2 Toggle switching
474Toggle switching performed after releasing a key. With this action you can keep staying on the destination layer until you type the key again to return.
475
476This performs toggle switching action of 'Layer 2'.
477
478 ACTION_LAYER_TOGGLE(2)
479
480
481
482### 3.3 Momentary switching with Tap key
483These actions switch a layer only while holding a key but register the key on tap. **Tap** means to press and release a key quickly.
484
485 ACTION_LAYER_TAP_KEY(2, KC_SCLN)
486
487With this you can place a layer switching action on normal key like ';' without losing its original key register function. This action allows you to have layer switching action without necessity of a dedicated key. It means you can have it even on home row of keyboard.
488
489
490
491### 3.4 Momentary switching with Tap Toggle
492This switches layer only while holding a key but toggle layer with several taps. **Tap** means to press and release key quickly.
493
494 ACTION_LAYER_TAP_TOGGLE(1)
495
496Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by default.
497
498
499
500### 3.5 Momentary switching with Modifiers
501This registers modifier key(s) simultaneously with layer switching.
502
503 ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
504
505
506
507## 4. Tapping
508Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.
509
510### 4.1 Tap Key
511This is a feature to assign normal key action and modifier including layer switching to just same one physical key. This is a kind of [Dual role key][dual_role]. It works as modifier when holding the key but registers normal key when tapping.
512
513Modifier with tap key:
514
515 ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV)
516
517Layer switching with tap key:
518
519 ACTION_LAYER_TAP_KEY(2, KC_SCLN)
520
521[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys
522
523
524### 4.2 Tap Toggle
525This is a feature to assign both toggle layer and momentary switch layer action to just same one physical key. It works as momentary layer switch when holding a key but toggle switch with several taps.
526
527 ACTION_LAYER_TAP_TOGGLE(1)
528
529
530### 4.3 Oneshot Modifier
531This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping. The behavior of oneshot modifiers is similar to the [sticky keys](https://en.wikipedia.org/wiki/StickyKeys) functionality found in most operating systems.
532
533 ACTION_MODS_ONESHOT(MOD_LSFT)
534
535Oneshot layer key:
536
537 ACTION_LAYER_ONESHOT(MY_LAYER)
538
539Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can release Shift before 't' is pressed down.
540
541Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined.
542
543Most implementations of sticky keys allow you to lock a modifier by double tapping the modifier. The layer then remains locked untill the modifier is tapped again. To enable this behaviour for oneshot modifiers set `ONESHOT_TAP_TOGGLE` to the number taps required. The feature is disabled if `ONESHOT_TAP_TOGGLE<2` or not defined.
544
545
546### 4.4 Tap Toggle Mods
547Similar to layer tap toggle, this works as a momentary modifier when holding, but toggles on with several taps. A single tap will 'unstick' the modifier again.
548
549 ACTION_MODS_TAP_TOGGLE(MOD_LSFT)
550
551
552
553
554## 5. Legacy Keymap
555This was used in prior version and still works due to legacy support code in `common/keymap.c`. Legacy keymap doesn't support many of features that new keymap offers. ***It is not recommended to use Legacy Keymap for new project.***
556
557To enable Legacy Keymap support define this macro in `config.h`.
558
559 #define USE_LEGACY_KEYMAP
560
561Legacy Keymap uses two arrays `fn_layer[]` and `fn_keycode[]` to define Fn key. The index of arrays corresponds with postfix number of `Fn` key. Array `fn_layer[]` indicates destination layer to switch and `fn_keycode[]` has keycodes to send when tapping `Fn` key.
562
563In following setting example, `Fn0`, `Fn1` and `Fn2` switch layer to 1, 2 and 2 respectively. `Fn2` registers `Space` key when tapping while `Fn0` and `Fn1` doesn't send any key.
564
565 static const uint8_t PROGMEM fn_layer[] = {
566 1, // Fn0
567 2, // Fn1
568 2, // Fn2
569 };
570
571 static const uint8_t PROGMEM fn_keycode[] = {
572 KC_NO, // Fn0
573 KC_NO, // Fn1
574 KC_SPC, // Fn2
575 };
576
577
578## 6. Terminology
579***TBD***
580### keymap
581is comprised of multiple layers.
582### layer
583is matrix of keycodes.
584### key
585is physical button on keyboard or logical switch on software.
586### keycode
587is codes used on firmware.
588### action
589is a function assigned on a key.
590### layer transparency
591Using transparent keycode one layer can refer key definition on other lower layer.
592### layer precedence
593Top layer has higher precedence than lower layers.
594### tapping
595is to press and release a key quickly.
596### Fn key
597is key which executes a special action like layer switching, mouse key, macro or etc.
598### dual role key
599<http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys>
diff --git a/doc/other_projects.md b/doc/other_projects.md
new file mode 100644
index 000000000..bf980b0a9
--- /dev/null
+++ b/doc/other_projects.md
@@ -0,0 +1,62 @@
1Other Keyboard Firmware Projects
2================================
3## PJRC USB Keyboard/Mouse Example[USB][PJRC][Teensy][AVR]
4- <http://www.pjrc.com/teensy/usb_keyboard.html>
5- <http://www.pjrc.com/teensy/usb_mouse.html>
6
7## kbupgrade[USB][V-USB][AVR]
8- <http://github.com/rhomann/kbupgrade>
9- <http://geekhack.org/showwiki.php?title=Island:8406>
10
11## c64key[USB][V-USB][AVR]
12- <http://symlink.dk/projects/c64key/>
13
14## rump[USB][V-USB][AVR]
15- <http://mg8.org/rump/>
16- <http://github.com/clee/rump>
17
18## dulcimer[USB][V-USB][AVR]
19- <http://www.schatenseite.de/dulcimer.html>
20
21## humblehacker-keyboard[USB][LUFA][AVR][Ergo]
22- <http://github.com/humblehacker>
23- <http://www.humblehacker.com/keyboard/>
24- <http://geekhack.org/showwiki.php?title=Island:6292>
25
26## ps2avr[PS/2][AVR]
27- <http://sourceforge.net/projects/ps2avr/>
28
29## ErgoDox[Ergo][Split][USB][AVR]
30- <http://geekhack.org/index.php?topic=22780.0>
31- <https://github.com/benblazak/ergodox-firmware>
32- <https://github.com/cub-uanic/tmk_keyboard>
33
34## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR]
35- <http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534.html>
36- <https://github.com/frobiac/adnw>
37
38## bpiphany's AVR-Keyboard[PJRC][AVR][USB]
39- <https://github.com/BathroomEpiphanies/AVR-Keyboard>
40- <http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions>
41- <http://deskthority.net/wiki/Phantom>
42
43## USB-USB keyboard remapper[converter][USB-USB][AVR][Arduino]
44- <http://forum.colemak.com/viewtopic.php?pid=10837>
45- <https://github.com/darkytoothpaste/keymapper>
46
47## USB-USB converter threads[converter][USB-USB]
48- <http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841-30.html>
49- <http://geekhack.org/index.php?topic=19458.0>
50
51## kbdbabel.org[converter][vintage][protocol][8051]
52Great resource of vintage keyboard protocol information and code
53
54- <http://www.kbdbabel.org/>
55
56## Haata's kiibohd Controller[converter][vintage][protocol][AVR][PJRC][Cortex]
57A lots of vintage keyboard protocol supports
58
59- <http://gitorious.org/kiibohd-controller>
60
61## Kinesis ergonomic keyboard firmware replacement[V-USB][LUFA][Ergo]
62- <https://github.com/chrisandreae/kinesis-firmware>