~ruther/qmk_firmware

f4125707399d11a7d80587659c464b9bcddb8c56 — tmk 13 years ago 225de7a
Moved files to common, protocol and doc  directory
98 files changed, 0 insertions(+), 210 deletions(-)

D LICENSE.txt
R {bootloader => common/bootloader}.c
R {bootloader => common/bootloader}.h
R {command => common/command}.c
R {command => common/command}.h
R {controller_teensy => common/controller_teensy}.h
R {debug => common/debug}.h
R {host => common/host}.c
R {host => common/host}.h
R {host_driver => common/host_driver}.h
R {keyboard => common/keyboard}.c
R {keyboard => common/keyboard}.h
R {keymap => common/keymap}.h
R {layer => common/layer}.c
R {layer => common/layer}.h
R {led => common/led}.h
R {matrix => common/matrix}.h
R {mousekey => common/mousekey}.c
R {mousekey => common/mousekey}.h
R {print => common/print}.c
R {print => common/print}.h
R {report => common/report}.h
R {sendchar => common/sendchar}.h
R {sendchar_null => common/sendchar_null}.c
R {sendchar_uart => common/sendchar_uart}.c
R {timer => common/timer}.c
R {timer => common/timer}.h
R {uart => common/uart}.c
R {uart => common/uart}.h
R {usb_keycodes => common/usb_keycodes}.h
R {util => common/util}.c
R {util => common/util}.h
R {COPYING => doc/COPYING}.GPLv2
R {COPYING => doc/COPYING}.GPLv3
R {hhkb => doc}/FUSE.txt
R {POWER => doc/POWER}.txt
R {USB_NKRO => doc/USB_NKRO}.txt
D pjrc/host.c
R {adb => protocol/adb}.c
R {adb => protocol/adb}.h
R {iwrap => protocol/iwrap}.mk
R {iwrap => protocol/iwrap}/iWRAP.txt
R {iwrap => protocol/iwrap}/iwrap.c
R {iwrap => protocol/iwrap}/iwrap.h
R {iwrap => protocol/iwrap}/main.c
R {iwrap => protocol/iwrap}/suart.S
R {iwrap => protocol/iwrap}/suart.h
R {iwrap => protocol/iwrap}/wd.h
R {m0110 => protocol/m0110}.c
R {m0110 => protocol/m0110}.h
R {pjrc => protocol/pjrc}.mk
R {pjrc => protocol/pjrc}/bootloader_teensy.c
R {pjrc => protocol/pjrc}/main.c
R {pjrc => protocol/pjrc}/pjrc.c
R {pjrc => protocol/pjrc}/pjrc.h
R {pjrc => protocol/pjrc}/usb.c
R {pjrc => protocol/pjrc}/usb.h
R {pjrc => protocol/pjrc}/usb_debug.c
R {pjrc => protocol/pjrc}/usb_debug.h
R {pjrc => protocol/pjrc}/usb_extra.c
R {pjrc => protocol/pjrc}/usb_extra.h
R {pjrc => protocol/pjrc}/usb_keyboard.c
R {pjrc => protocol/pjrc}/usb_keyboard.h
R {pjrc => protocol/pjrc}/usb_mouse.c
R {pjrc => protocol/pjrc}/usb_mouse.h
R {ps2 => protocol/ps2}.c
R {ps2 => protocol/ps2}.h
R {ps2_mouse => protocol/ps2_mouse}.c
R {ps2_mouse => protocol/ps2_mouse}.h
R {ps2_usart => protocol/ps2_usart}.c
R {vusb => protocol/vusb}.mk
R {vusb => protocol/vusb}/bootloader_usbasp.c
R {vusb => protocol/vusb}/main.c
R {vusb => protocol/vusb}/sendchar_usart.c
R {vusb => protocol/vusb}/usbdrv/Changelog.txt
R {vusb => protocol/vusb}/usbdrv/CommercialLicense.txt
R {vusb => protocol/vusb}/usbdrv/License.txt
R {vusb => protocol/vusb}/usbdrv/Readme.txt
R {vusb => protocol/vusb}/usbdrv/USB-ID-FAQ.txt
R {vusb => protocol/vusb}/usbdrv/USB-IDs-for-free.txt
R {vusb => protocol/vusb}/usbdrv/asmcommon.inc
R {vusb => protocol/vusb}/usbdrv/oddebug.c
R {vusb => protocol/vusb}/usbdrv/oddebug.h
R {vusb => protocol/vusb}/usbdrv/usbconfig-prototype.h
R {vusb => protocol/vusb}/usbdrv/usbdrv.c
R {vusb => protocol/vusb}/usbdrv/usbdrv.h
R {vusb => protocol/vusb}/usbdrv/usbdrvasm.S
R {vusb => protocol/vusb}/usbdrv/usbdrvasm.asm
R {vusb => protocol/vusb}/usbdrv/usbdrvasm12.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm128.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm15.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm16.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm165.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm18-crc.inc
R {vusb => protocol/vusb}/usbdrv/usbdrvasm20.inc
R {vusb => protocol/vusb}/usbdrv/usbportability.h
R {vusb => protocol/vusb}/vusb.c
R {vusb => protocol/vusb}/vusb.h
D LICENSE.txt => LICENSE.txt +0 -27
@@ 1,27 0,0 @@
Codes are released under each license. See heading of each file for details.

Modified BSD license:
    ps2.c
    ps2.h
    adb.c
    adb.h

GPLv2 or later:
    other codes

PJRC's license:
    print.c
    print.h
    pjrc/

GPLv2 or GPLv3 or OBJECTIVE DEVELOPMENT's commercial license:
    vusb/




This software includes following codes from other parties.
    - V-USB from OBJECTIVE DEVELOPMENT
        http://www.obdev.at/products/vusb/index.html
    - Teensy example codes from PJRC
        http://www.pjrc.com/teensy/

R bootloader.c => common/bootloader.c +0 -0
R bootloader.h => common/bootloader.h +0 -0
R command.c => common/command.c +0 -0
R command.h => common/command.h +0 -0
R controller_teensy.h => common/controller_teensy.h +0 -0
R debug.h => common/debug.h +0 -0
R host.c => common/host.c +0 -0
R host.h => common/host.h +0 -0
R host_driver.h => common/host_driver.h +0 -0
R keyboard.c => common/keyboard.c +0 -0
R keyboard.h => common/keyboard.h +0 -0
R keymap.h => common/keymap.h +0 -0
R layer.c => common/layer.c +0 -0
R layer.h => common/layer.h +0 -0
R led.h => common/led.h +0 -0
R matrix.h => common/matrix.h +0 -0
R mousekey.c => common/mousekey.c +0 -0
R mousekey.h => common/mousekey.h +0 -0
R print.c => common/print.c +0 -0
R print.h => common/print.h +0 -0
R report.h => common/report.h +0 -0
R sendchar.h => common/sendchar.h +0 -0
R sendchar_null.c => common/sendchar_null.c +0 -0
R sendchar_uart.c => common/sendchar_uart.c +0 -0
R timer.c => common/timer.c +0 -0
R timer.h => common/timer.h +0 -0
R uart.c => common/uart.c +0 -0
R uart.h => common/uart.h +0 -0
R usb_keycodes.h => common/usb_keycodes.h +0 -0
R util.c => common/util.c +0 -0
R util.h => common/util.h +0 -0
R COPYING.GPLv2 => doc/COPYING.GPLv2 +0 -0
R COPYING.GPLv3 => doc/COPYING.GPLv3 +0 -0
R hhkb/FUSE.txt => doc/FUSE.txt +0 -0
R POWER.txt => doc/POWER.txt +0 -0
R USB_NKRO.txt => doc/USB_NKRO.txt +0 -0
D pjrc/host.c => pjrc/host.c +0 -183
@@ 1,183 0,0 @@
/*
Copyright 2011 Jun Wako <wakojun@gmail.com>

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 <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>
#include <avr/interrupt.h>
#include "usb_keycodes.h"
#include "usb_keyboard.h"
#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
#include "usb_mouse.h"
#endif
#ifdef EXTRAKEY_ENABLE
#include "usb_extra.h"
#endif
#include "debug.h"
#include "host.h"
#include "util.h"


#ifdef NKRO_ENABLE
bool keyboard_nkro = false;
#endif

static report_keyboard_t report0;
static report_keyboard_t report1;
report_keyboard_t *keyboard_report = &report0;
report_keyboard_t *keyboard_report_prev = &report1;

static inline void add_key_byte(uint8_t code);
static inline void add_key_bit(uint8_t code);


uint8_t host_keyboard_leds(void)
{
    return usb_keyboard_leds;
}

/* keyboard report operations */
void host_add_key(uint8_t key)
{
#ifdef NKRO_ENABLE
    if (keyboard_nkro) {
        add_key_bit(key);
        return;
    }
#endif
    add_key_byte(key);
}

void host_add_mod_bit(uint8_t mod)
{
    keyboard_report->mods |= mod;
}

void host_set_mods(uint8_t mods)
{
    keyboard_report->mods = mods;
}

void host_add_code(uint8_t code)
{
    if (IS_MOD(code)) {
        host_add_mod_bit(MOD_BIT(code));
    } else {
        host_add_key(code);
    }
}

void host_swap_keyboard_report(void)
{
    uint8_t sreg = SREG;
    cli();
    report_keyboard_t *tmp = keyboard_report_prev;
    keyboard_report_prev = keyboard_report;
    keyboard_report = tmp;
    SREG = sreg;
}

void host_clear_keyboard_report(void)
{
    keyboard_report->mods = 0;
    for (int8_t i = 0; i < REPORT_KEYS; i++) {
        keyboard_report->keys[i] = 0;
    }
}

uint8_t host_has_anykey(void)
{
    uint8_t cnt = 0;
    for (int i = 0; i < REPORT_KEYS; i++) {
        if (keyboard_report->keys[i])
            cnt++;
    }
    return cnt;
}

uint8_t host_get_first_key(void)
{
#ifdef NKRO_ENABLE
    if (keyboard_nkro) {
        uint8_t i = 0;
        for (; i < REPORT_KEYS && !keyboard_report->keys[i]; i++)
            ;
        return i<<3 | biton(keyboard_report->keys[i]);
    }
#endif
    return keyboard_report->keys[0];
}


void host_send_keyboard_report(void)
{
    usb_keyboard_send_report(keyboard_report);
}

#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
void host_mouse_send(report_mouse_t *report)
{
    usb_mouse_send(report->x, report->y, report->v, report->h, report->buttons);
}
#endif

#ifdef EXTRAKEY_ENABLE
void host_system_send(uint16_t data)
{
    usb_extra_system_send(data);
}

void host_consumer_send(uint16_t data)
{
    static uint16_t last_data = 0;
    if (data == last_data) return;
    last_data = data;

    usb_extra_consumer_send(data);
}
#endif


static inline void add_key_byte(uint8_t code)
{
    // TODO: fix ugly code
    int8_t i = 0;
    int8_t empty = -1;
    for (; i < REPORT_KEYS; i++) {
        if (keyboard_report_prev->keys[i] == code) {
            keyboard_report->keys[i] = code;
            break;
        }
        if (empty == -1 &&
                keyboard_report_prev->keys[i] == 0 &&
                keyboard_report->keys[i] == 0) {
            empty = i;
        }
    }
    if (i == REPORT_KEYS) {
        if (empty != -1) {
            keyboard_report->keys[empty] = code;
        }
    }
}

static inline void add_key_bit(uint8_t code)
{
    if ((code>>3) < REPORT_KEYS) {
        keyboard_report->keys[code>>3] |= 1<<(code&7);
    } else {
        debug("add_key_bit: can't add: "); phex(code); debug("\n");
    }
}

R adb.c => protocol/adb.c +0 -0
R adb.h => protocol/adb.h +0 -0
R iwrap.mk => protocol/iwrap.mk +0 -0
R iwrap/iWRAP.txt => protocol/iwrap/iWRAP.txt +0 -0
R iwrap/iwrap.c => protocol/iwrap/iwrap.c +0 -0
R iwrap/iwrap.h => protocol/iwrap/iwrap.h +0 -0
R iwrap/main.c => protocol/iwrap/main.c +0 -0
R iwrap/suart.S => protocol/iwrap/suart.S +0 -0
R iwrap/suart.h => protocol/iwrap/suart.h +0 -0
R iwrap/wd.h => protocol/iwrap/wd.h +0 -0
R m0110.c => protocol/m0110.c +0 -0
R m0110.h => protocol/m0110.h +0 -0
R pjrc.mk => protocol/pjrc.mk +0 -0
R pjrc/bootloader_teensy.c => protocol/pjrc/bootloader_teensy.c +0 -0
R pjrc/main.c => protocol/pjrc/main.c +0 -0
R pjrc/pjrc.c => protocol/pjrc/pjrc.c +0 -0
R pjrc/pjrc.h => protocol/pjrc/pjrc.h +0 -0
R pjrc/usb.c => protocol/pjrc/usb.c +0 -0
R pjrc/usb.h => protocol/pjrc/usb.h +0 -0
R pjrc/usb_debug.c => protocol/pjrc/usb_debug.c +0 -0
R pjrc/usb_debug.h => protocol/pjrc/usb_debug.h +0 -0
R pjrc/usb_extra.c => protocol/pjrc/usb_extra.c +0 -0
R pjrc/usb_extra.h => protocol/pjrc/usb_extra.h +0 -0
R pjrc/usb_keyboard.c => protocol/pjrc/usb_keyboard.c +0 -0
R pjrc/usb_keyboard.h => protocol/pjrc/usb_keyboard.h +0 -0
R pjrc/usb_mouse.c => protocol/pjrc/usb_mouse.c +0 -0
R pjrc/usb_mouse.h => protocol/pjrc/usb_mouse.h +0 -0
R ps2.c => protocol/ps2.c +0 -0
R ps2.h => protocol/ps2.h +0 -0
R ps2_mouse.c => protocol/ps2_mouse.c +0 -0
R ps2_mouse.h => protocol/ps2_mouse.h +0 -0
R ps2_usart.c => protocol/ps2_usart.c +0 -0
R vusb.mk => protocol/vusb.mk +0 -0
R vusb/bootloader_usbasp.c => protocol/vusb/bootloader_usbasp.c +0 -0
R vusb/main.c => protocol/vusb/main.c +0 -0
R vusb/sendchar_usart.c => protocol/vusb/sendchar_usart.c +0 -0
R vusb/usbdrv/Changelog.txt => protocol/vusb/usbdrv/Changelog.txt +0 -0
R vusb/usbdrv/CommercialLicense.txt => protocol/vusb/usbdrv/CommercialLicense.txt +0 -0
R vusb/usbdrv/License.txt => protocol/vusb/usbdrv/License.txt +0 -0
R vusb/usbdrv/Readme.txt => protocol/vusb/usbdrv/Readme.txt +0 -0
R vusb/usbdrv/USB-ID-FAQ.txt => protocol/vusb/usbdrv/USB-ID-FAQ.txt +0 -0
R vusb/usbdrv/USB-IDs-for-free.txt => protocol/vusb/usbdrv/USB-IDs-for-free.txt +0 -0
R vusb/usbdrv/asmcommon.inc => protocol/vusb/usbdrv/asmcommon.inc +0 -0
R vusb/usbdrv/oddebug.c => protocol/vusb/usbdrv/oddebug.c +0 -0
R vusb/usbdrv/oddebug.h => protocol/vusb/usbdrv/oddebug.h +0 -0
R vusb/usbdrv/usbconfig-prototype.h => protocol/vusb/usbdrv/usbconfig-prototype.h +0 -0
R vusb/usbdrv/usbdrv.c => protocol/vusb/usbdrv/usbdrv.c +0 -0
R vusb/usbdrv/usbdrv.h => protocol/vusb/usbdrv/usbdrv.h +0 -0
R vusb/usbdrv/usbdrvasm.S => protocol/vusb/usbdrv/usbdrvasm.S +0 -0
R vusb/usbdrv/usbdrvasm.asm => protocol/vusb/usbdrv/usbdrvasm.asm +0 -0
R vusb/usbdrv/usbdrvasm12.inc => protocol/vusb/usbdrv/usbdrvasm12.inc +0 -0
R vusb/usbdrv/usbdrvasm128.inc => protocol/vusb/usbdrv/usbdrvasm128.inc +0 -0
R vusb/usbdrv/usbdrvasm15.inc => protocol/vusb/usbdrv/usbdrvasm15.inc +0 -0
R vusb/usbdrv/usbdrvasm16.inc => protocol/vusb/usbdrv/usbdrvasm16.inc +0 -0
R vusb/usbdrv/usbdrvasm165.inc => protocol/vusb/usbdrv/usbdrvasm165.inc +0 -0
R vusb/usbdrv/usbdrvasm18-crc.inc => protocol/vusb/usbdrv/usbdrvasm18-crc.inc +0 -0
R vusb/usbdrv/usbdrvasm20.inc => protocol/vusb/usbdrv/usbdrvasm20.inc +0 -0
R vusb/usbdrv/usbportability.h => protocol/vusb/usbdrv/usbportability.h +0 -0
R vusb/vusb.c => protocol/vusb/vusb.c +0 -0
R vusb/vusb.h => protocol/vusb/vusb.h +0 -0