diff --git a/keyboard/sculpt/Makefile b/keyboard/sculpt/Makefile new file mode 100755 index 0000000000..c5cb88a0b4 --- /dev/null +++ b/keyboard/sculpt/Makefile @@ -0,0 +1,129 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = sculpt_lufa + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap.c \ + keymap_common.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + +# MCU name +#MCU = at90usb1287 +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +NKRO_ENABLE = no # USB Nkey Rollover - not yet supported in LUFA + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/sculpt/README.md b/keyboard/sculpt/README.md new file mode 100755 index 0000000000..99642fc79d --- /dev/null +++ b/keyboard/sculpt/README.md @@ -0,0 +1,101 @@ +Microsoft Sculpt Ergonomic Desktop keyboard firmware +====================== +Ergonomic keyboard by Microsoft modified to work with Teensy 2.0. + +- TODO: put original controller PCB version + +## Microsoft Sculpt Ergonomic Desktop keyboard resources +- [Microsoft Sculpt Ergonomic Desktop support page] +(https://www.microsoft.com/hardware/en-us/d/sculpt-ergonomic-desktop) + +## Build +Move to this directory and run `make`: + + $ make + +## Matrix +Only keyboard with US layout was traced. + +### Original US layout keyboard matrix +Original US layout keboard matrix is 8 rows and 18 columns: + + A B C D E F G H I + ---------------------------------------------------- + 1 PAUS DEL 0 9 8 BSPC --> + 2 PGUP F12 LBRC MINS RBRC INS --> + 3 HOME CALC P O I --> + 4 SLCK ENT SCLN L K BSLS --> + 5 APP SLSH QUOT RALT LEFT --> + 6 END RSFT PGDN DOT COMM --> + 7 LCTL RGHT UP DOWN SPC --> + 8 PSCR F11 EQL F9 F8 F10 --> + + J K L M N O P Q R + ------------------------------------------------- + --> 7 TAB Q 2 1 1 + --> Y F5 F3 W 4 F6 2 + --> U R E CAPS 3 T 3 + --> J F D A LGUI 4 + --> H G F4 S ESC LALT 5 + --> M V C X Z LSFT 6 + --> N B SPC RCTL 7 + --> F7 5 F2 F1 GRV 6 8 + +Note that original matrix requires 8+18=26 pins on micro-controller and will +not work verbatim on Teensy 2.0 because it only has 25 pins. + +### Modified US layout keyboard matrix + +To make all keys work on Teensy 2.0 it is best to merge keys on column C and G +of orininal matrix (see above). To achieve that simply connect colums C and G +to the same pin on Teensy. + +Modified matrix will have 8 rows and 17 columns and will require 25 pins: + + A B C D E F G H + ---------------------------------------------- + 1 PAUS DEL 0 9 8 BSPC --> + 2 PGUP F12 LBRC MINS RBRC INS --> + 3 HOME CALC P O I --> + 4 SLCK ENT SCLN L K BSLS --> + 5 RALT APP SLSH QUOT LEFT --> + 6 END RSFT PGDN DOT COMM --> + 7 LCTL RGHT UP DOWN SPC --> + 8 PSCR F11 EQL F9 F8 F10 --> + + I J K L M N O P Q + ------------------------------------------------- + --> 7 TAB Q 2 1 1 + --> Y F5 F3 W 4 F6 2 + --> U R E CAPS 3 T 3 + --> J F D A LGUI 4 + --> H G F4 S ESC LALT 5 + --> M V C X Z LSFT 6 + --> N B SPC RCTL 7 + --> F7 5 F2 F1 GRV 6 8 + +Note that RALT and RSFT are now sitting on the same column (C). + + +## Keymap + +### 1 Original Scultp keymap +[keymap.c](keymap.c) represents original Sculpt layout + + Fn + {F1, F2, F3} = {play/pause, mute, volume down, volume up} + Fn + {left, down, up, right} = {home, pgdown, pgup, end} + +#### 1.0 Default layer + ,---------------------------. ,-----------------------------------------------. + |Esc| F1| F2| F3| F4| F5| F6| | F7| F8| F9|F10|F11|F12|PrSc|ScLk|Pau|Calc| | + |---------------------------| |-----------------------------------------------| + | `| 1| 2| 3| 4| 5| 6| | 7| 8| 9| 0| -| =| Bcksp| Del|Home| + |---------------------------| |-------------------------------------| |----| + | Tab| Q| W| E| R| T| | Y| U| I| O| P| [| ]| \| | End| + |---------------------------| |-----------------------------------------------| + | Caps| A| S| D| F| G| | H| J| K| L| ;| '| Enter| Ins|PgUp| + |---------------------------| |-----------------------------------------------| + | Shift| Z| X| C| V| B| | N| M| ,| .| /| Shift| Up|PgDn| + |---------------------------`----'-----------------------------------------------| + | Ctrl| Gui| Alt| | | Alt| Fn| Ctrl|Left|Down|Righ| + `--------------------------------------------------------------------------------' diff --git a/keyboard/sculpt/config.h b/keyboard/sculpt/config.h new file mode 100755 index 0000000000..5722fbd1eb --- /dev/null +++ b/keyboard/sculpt/config.h @@ -0,0 +1,68 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT Microsoft Sculpt mod +#define DESCRIPTION t.m.k. keyboard firmware for Microsoft Sculpt + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 17 + +/* define if matrix has ghost */ +#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/sculpt/keymap.c b/keyboard/sculpt/keymap.c new file mode 100755 index 0000000000..3ec7b33082 --- /dev/null +++ b/keyboard/sculpt/keymap.c @@ -0,0 +1,30 @@ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP( + PAUS, DEL, 0, 9, 8, BSPC, 7, TAB, Q, 2, 1, \ + PGUP, F12,LBRC,MINS,RBRC, INS, Y, F5, F3, W, 4, F6, \ + HOME, CALC, P, O, I, U, R, E, CAPS, 3, T, \ + SLCK, ENT, SCLN, L, K, BSLS, J, F, D, A, LGUI, \ + RALT, FN1, SLSH, QUOT, LEFT, H, G, F4, S, ESC, LALT, \ + END, RSFT, PGDN, DOT, COMM, M, V, C, X, Z, LSFT, \ + RCTL, RGHT, UP, DOWN, SPC, N, B, SPC, LCTL, \ + PSCR, F11, EQL, F9, F8, F10, F7, 5, F2, F1, GRV, 6), + /* 1: FN1 (Replaces arrows with pagination, home and end and activates + multimedia keys on top row). + */ + KEYMAP( + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, VOLD, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, HOME, TRNS, TRNS, VOLU, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, END, PGUP, PGDN, TRNS, TRNS, TRNS, TRNS, TRNS, \ + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MUTE, MPLY, TRNS, TRNS ), +}; +const uint16_t PROGMEM fn_actions[] = { + ACTION_DEFAULT_LAYER_SET(0), // Default layer. Not used. + ACTION_LAYER_TAP_KEY(1, KC_APP), // FN1 +}; diff --git a/keyboard/sculpt/keymap_common.c b/keyboard/sculpt/keymap_common.c new file mode 100755 index 0000000000..fdb1769e1c --- /dev/null +++ b/keyboard/sculpt/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/sculpt/keymap_common.h b/keyboard/sculpt/keymap_common.h new file mode 100755 index 0000000000..6c4483b643 --- /dev/null +++ b/keyboard/sculpt/keymap_common.h @@ -0,0 +1,58 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +// Microsoft Sculpt US keymap definition macro +#define KEYMAP( \ + K01, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, \ + K12, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1F, \ + K23, K25, K26, K27, K28, K2A, K2B, K2C, K2D, K2E, K30, \ + K34, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3F, K41, \ + K46, K47, K48, K49, K4B, K4C, K4D, K4E, K4F, K50, K53, \ + K56, K57, K58, K5A, K5B, K5D, K5E, K5F, K60, K61, K62, \ + K66, K67, K69, K6A, K6D, K6E, K6F, K70, K76, \ + K78, K7A, K7B, K7C, K7D, K7E, K7F, K80, K81, K82, K83, K85 \ +) { \ + { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##K12, KC_NO, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_NO, KC_##K1F, KC_NO, KC_NO }, \ + { KC_NO, KC_##K23, KC_NO, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_NO, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO, KC_##K30, KC_NO, KC_NO }, \ + { KC_NO, KC_##K34, KC_NO, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_NO, KC_##K3F, KC_NO, KC_##K41, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_NO, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K50, KC_NO, KC_NO, KC_##K53, KC_NO }, \ + { KC_NO, KC_##K56, KC_##K57, KC_##K58, KC_NO, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K60, KC_##K61, KC_##K62, KC_NO, KC_NO, KC_NO }, \ + { KC_##K66, KC_##K67, KC_NO, KC_##K69, KC_##K6A, KC_NO, KC_NO, KC_##K6D, KC_##K6E, KC_##K6F, KC_##K70, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K76 }, \ + { KC_NO, KC_##K78, KC_NO, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_##K7F, KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_NO, KC_##K85, KC_NO, KC_NO } \ +} + +#endif diff --git a/keyboard/sculpt/led.c b/keyboard/sculpt/led.c new file mode 100755 index 0000000000..2d52fbf1c3 --- /dev/null +++ b/keyboard/sculpt/led.c @@ -0,0 +1,25 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/keyboard/sculpt/matrix.c b/keyboard/sculpt/matrix.c new file mode 100755 index 0000000000..b106ec9196 --- /dev/null +++ b/keyboard/sculpt/matrix.c @@ -0,0 +1,227 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + _delay_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + _delay_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + return 1; +} + +bool matrix_is_modified(void) +{ + if (debouncing) return false; + return true; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<