Merge branch 'rhaberkorn-serial-mouse'

example_keyboards
tmk 10 years ago
commit b9e265368f

@ -37,6 +37,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef PS2_MOUSE_ENABLE #ifdef PS2_MOUSE_ENABLE
# include "ps2_mouse.h" # include "ps2_mouse.h"
#endif #endif
#ifdef SERIAL_MOUSE_ENABLE
#include "serial_mouse.h"
#endif
#ifdef MATRIX_HAS_GHOST #ifdef MATRIX_HAS_GHOST
@ -64,6 +67,10 @@ void keyboard_init(void)
#ifdef PS2_MOUSE_ENABLE #ifdef PS2_MOUSE_ENABLE
ps2_mouse_init(); ps2_mouse_init();
#endif #endif
#ifdef SERIAL_MOUSE_ENABLE
serial_mouse_init();
#endif
#ifdef BOOTMAGIC_ENABLE #ifdef BOOTMAGIC_ENABLE
bootmagic(); bootmagic();
@ -126,6 +133,10 @@ MATRIX_LOOP_END:
ps2_mouse_task(); ps2_mouse_task();
#endif #endif
#ifdef SERIAL_MOUSE_ENABLE
serial_mouse_task();
#endif
// update LED // update LED
if (led_status != host_keyboard_leds()) { if (led_status != host_keyboard_leds()) {
led_status = host_keyboard_leds(); led_status = host_keyboard_leds();

@ -0,0 +1,106 @@
#
# Makefile for Teensy
#
# Target file name (without extension).
TARGET = serialmouse_usb
# Directory common source filess exist
TOP_DIR = ../..
# Directory keyboard dependent files exist
TARGET_DIR = .
# project specific files
SRC = keymap.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=512
# 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
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
# Serial Mouse Options
# You can choose a mouse protocol and the implementation of
# the underlying serial connection.
#
SERIAL_MOUSE_MICROSOFT_ENABLE = yes # Enable support for Microsoft-compatible mice
#SERIAL_MOUSE_MOUSESYSTEMS_ENABLE = yes # Enable support for Mousesystems-compatible mice
#SERIAL_MOUSE_USE_UART = yes # use hardware UART for serial connection
SERIAL_MOUSE_USE_SOFT = yes # use software serial implementation
# Optional serial mouse driver features
# Support scrolling while holding the middle mouse button
# (currently only supported for Mousesystems mice):
#OPT_DEFS += -DSERIAL_MOUSE_CENTER_SCROLL
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
include $(TOP_DIR)/protocol.mk
include $(TOP_DIR)/protocol/lufa.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk

@ -0,0 +1,11 @@
Serial mouse converter
======================
See https://github.com/tmk/tmk_keyboard/pull/131
Supported protocols
-------------------
### Microsoft
Not tested.
### Mousesystems

@ -0,0 +1,119 @@
/*
Copyright 2012 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/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <avr/interrupt.h>
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x2222
#define DEVICE_VER 0x0001
#define MANUFACTURER t.m.k.
#define PRODUCT serial mouse converter
#define DESCRIPTION convert serial mouse into USB
/* matrix size */
#define MATRIX_ROWS 0
#define MATRIX_COLS 0
/* key combination for command */
#define IS_COMMAND() false
#ifdef SERIAL_MOUSE_MICROSOFT
/*
* Serial(USART) configuration (for Microsoft serial mice)
* asynchronous, positive logic, 1200baud, bit order: LSB first
* 1-start bit, 7-data bit, no parity, 1-stop bit
*/
#define SERIAL_UART_BAUD 1200
#define SERIAL_UART_DATA UDR1
#define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
#define SERIAL_UART_RXD_VECT USART1_RX_vect
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
#define SERIAL_UART_INIT() do { \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
UCSR1C = (1<<UCSZ11) | (0<<UCSZ10); /* no parity, 1 stop bit, 7-bit characters */ \
sei(); \
} while(0)
// for Microsoft mouse protocol
/* Serial(USART) configuration
* asynchronous, negative logic, 1200baud, no flow control
* 1-start bit, 7-data bit, non parity, 1-stop bit
*/
#define SERIAL_SOFT_BAUD 1200
#define SERIAL_SOFT_DATA_7BIT
#define SERIAL_SOFT_PARITY_NONE
#define SERIAL_SOFT_BIT_ORDER_LSB
#define SERIAL_SOFT_LOGIC_NEGATIVE
/* RXD Port */
#define SERIAL_SOFT_RXD_DDR DDRD
#define SERIAL_SOFT_RXD_PORT PORTD
#define SERIAL_SOFT_RXD_PIN PIND
#define SERIAL_SOFT_RXD_BIT 2
#define SERIAL_SOFT_RXD_VECT INT2_vect
/* RXD Interupt */
#define SERIAL_SOFT_RXD_INIT() do { \
/* pin configuration: input with pull-up */ \
SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
/* enable interrupt: INT2(rising edge) */ \
EICRA |= ((1<<ISC21)|(1<<ISC20)); \
EIMSK |= (1<<INT2); \
sei(); \
} while (0)
#define SERIAL_SOFT_RXD_INT_ENTER()
#define SERIAL_SOFT_RXD_INT_EXIT() do { \
/* clear interrupt flag */ \
EIFR = (1<<INTF2); \
} while (0)
#define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
/* TXD Port */
#define SERIAL_SOFT_TXD_HI()
#define SERIAL_SOFT_TXD_LO()
#define SERIAL_SOFT_TXD_INIT()
#elif defined(SERIAL_MOUSE_MOUSESYSTEMS)
/*
* Serial(USART) configuration (for Mousesystems serial mice)
* asynchronous, positive logic, 1200baud, bit order: LSB first
* 1-start bit, 8-data bit, no parity, 1-stop bit
*/
#define SERIAL_UART_BAUD 1200
#define SERIAL_UART_DATA UDR1
#define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
#define SERIAL_UART_RXD_VECT USART1_RX_vect
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
#define SERIAL_UART_INIT() do { \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
UCSR1C = (1<<UCSZ11) | (1<<UCSZ10); /* no parity, 1 stop bit, 8-bit characters */ \
sei(); \
} while(0)
#endif
#endif

@ -0,0 +1,33 @@
/*
Copyright 2011,2012,2013 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 <stdbool.h>
#include "keymap.h"
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
return KC_NO;
}
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return (action_t){};
}

@ -0,0 +1,30 @@
/*
Copyright 2011,2012,2013 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 "keymap_common.h"
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_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)]) };
}

@ -0,0 +1,174 @@
/*
Copyright 2011,2012,2013 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/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
// 32*8(256) byte array which converts PS/2 code into USB code
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
/* All keys */
#define KEYMAP_ALL( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
\
K61, /* for European ISO */ \
K51, K13, K6A, K64, K67, /* for Japanese JIS */ \
K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \
KB7, KBF, KDE, /* System Power, Sleep, Wake */ \
KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \
KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \
KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \
K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \
KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \
) { \
{ 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_##K0D, KC_##K0E, KC_NO }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
{ KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
{ KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
{ KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \
{ KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \
{ KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
{ KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
{ KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \
{ KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \
{ KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \
{ KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \
{ KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \
{ KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \
{ KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \
{ KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \
{ KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \
{ KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \
}
/* US layout */
#define KEYMAP( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
) \
KEYMAP_ALL( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
\
NUBS, \
RO, KANA, JYEN, HENK, MHEN, \
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
MAIL, CALCULATOR, MY_COMPUTER, \
WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
)
/* ISO layout */
#define KEYMAP_ISO( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \
K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
) \
KEYMAP_ALL( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
\
K61, \
RO, KANA, JYEN, HENK, MHEN, \
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
MAIL, CALCULATOR, MY_COMPUTER, \
WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
)
/* JIS layout */
#define KEYMAP_JIS( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
) \
KEYMAP_ALL( \
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
\
NUBS, \
K51, K13, K6A, K64, K67, \
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
MAIL, CALCULATOR, MY_COMPUTER, \
WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
)
#endif

@ -0,0 +1,24 @@
/*
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 "led.h"
void led_set(uint8_t usb_led)
{
}

@ -0,0 +1,83 @@
/*
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 <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "action.h"
#include "print.h"
#include "util.h"
#include "debug.h"
#include "matrix.h"
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
void matrix_init(void)
{
debug_enable = true;
debug_mouse=true;
return;
}
uint8_t matrix_scan(void)
{
return 0;
}
bool matrix_is_modified(void)
{
return false;
}
inline
bool matrix_has_ghost(void)
{
return false;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return false;
}
inline
uint8_t matrix_get_row(uint8_t row)
{
return 0;
}
void matrix_print(void)
{
}
uint8_t matrix_key_count(void)
{
return 0;
}

@ -23,5 +23,25 @@ ifdef PS2_USE_USART
endif endif
ifdef SERIAL_MOUSE_MICROSOFT_ENABLE
SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
-DMOUSE_ENABLE
endif
ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE
SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
-DMOUSE_ENABLE
endif
ifdef SERIAL_MOUSE_USE_SOFT
SRC += $(PROTOCOL_DIR)/serial_soft.c
endif
ifdef SERIAL_MOUSE_USE_UART
SRC += $(PROTOCOL_DIR)/serial_uart.c
endif
# Search Path # Search Path
VPATH += $(TOP_DIR)/protocol VPATH += $(TOP_DIR)/protocol

@ -0,0 +1,33 @@
/*
Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.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/>.
*/
#ifndef SERIAL_MOUSE_H
#define SERIAL_MOUSE_H
#include <stdint.h>
#include "serial.h"
static inline uint8_t serial_mouse_init(void)
{
serial_init();
return 0;
}
void serial_mouse_task(void);
#endif

@ -0,0 +1,124 @@
/*
Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.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/io.h>
#include <util/delay.h>
#include "serial.h"
#include "serial_mouse.h"
#include "report.h"
#include "host.h"
#include "timer.h"
#include "print.h"
#include "debug.h"
#ifdef MAX
#undef MAX
#endif
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
static void print_usb_data(const report_mouse_t *report);
void serial_mouse_task(void)
{
/* 3 byte ring buffer */
static uint8_t buffer[3];
static int buffer_cur = 0;
static report_mouse_t report = {};
int16_t rcv;
rcv = serial_recv2();
if (rcv < 0)
/* no new data */
return;
if (debug_mouse)
xprintf("serial_mouse: byte: %04X\n", rcv);
/*
* If bit 6 is one, this signals the beginning
* of a 3 byte sequence/packet.
*/
if (rcv & (1 << 6))
buffer_cur = 0;
buffer[buffer_cur] = (uint8_t)rcv;
if (buffer_cur == 0 && buffer[buffer_cur] == 0x20) {
/*
* Logitech extension: This must be a follow-up on
* the last 3-byte packet signaling a middle button click
*/
report.buttons |= MOUSE_BTN3;
report.x = report.y = 0;
print_usb_data(&report);
host_mouse_send(&report);
return;
}
buffer_cur++;
if (buffer_cur < 3)
return;
buffer_cur = 0;
/*
* parse 3 byte packet.
* NOTE: We only get a complete packet
* if the mouse moved or the button states
* change.
*/
report.buttons = 0;
if (buffer[0] & (1 << 5))
report.buttons |= MOUSE_BTN1;
if (buffer[0] & (1 << 4))
report.buttons |= MOUSE_BTN2;
report.x = (buffer[0] << 6) | buffer[1];
report.y = ((buffer[0] << 4) & 0xC0) | buffer[2];
/* USB HID uses values from -127 to 127 only */
report.x = MAX(report.x, -127);
report.y = MAX(report.y, -127);
#if 0
if (!report.buttons && !report.x && !report.y) {
/*
* Microsoft extension: Middle mouse button pressed
* FIXME: I don't know how exactly this extension works.
*/
report.buttons |= MOUSE_BTN3;
}
#endif
print_usb_data(&report);
host_mouse_send(&report);
}
static void print_usb_data(const report_mouse_t *report)
{
if (!debug_mouse)
return;
xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n",
report->buttons, report->x, report->y,
report->v, report->h);
}

@ -0,0 +1,131 @@
/*
Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.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/io.h>
#include <util/delay.h>
#include "serial.h"
#include "serial_mouse.h"
#include "report.h"
#include "host.h"
#include "timer.h"
#include "print.h"
#include "debug.h"
#ifdef MAX
#undef MAX
#endif
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
//#define SERIAL_MOUSE_CENTER_SCROLL
static void print_usb_data(const report_mouse_t *report);
void serial_mouse_task(void)
{
/* 5 byte ring buffer */
static uint8_t buffer[5];
static int buffer_cur = 0;
int16_t rcv;
report_mouse_t report = {0, 0, 0, 0, 0};
rcv = serial_recv2();
if (rcv < 0)
/* no new data */
return;
if (debug_mouse)
xprintf("serial_mouse: byte: %04X\n", rcv);
/*
* Synchronization: mouse(4) says that all
* bytes but the first one in the packet have
* bit 7 == 0, but this is untrue.
* Therefore we discard all bytes up to the
* first one with the characteristic bit pattern.
*/
if (buffer_cur == 0 && (rcv >> 3) != 0x10)
return;
buffer[buffer_cur++] = (uint8_t)rcv;
if (buffer_cur < 5)
return;
buffer_cur = 0;
#ifdef SERIAL_MOUSE_CENTER_SCROLL
if ((buffer[0] & 0x7) == 0x5 && (buffer[1] || buffer[2])) {
/* USB HID uses only values from -127 to 127 */
report.h = MAX((int8_t)buffer[1], -127);
report.v = MAX((int8_t)buffer[2], -127);
print_usb_data(&report);
host_mouse_send(&report);
if (buffer[3] || buffer[4]) {
report.h = MAX((int8_t)buffer[3], -127);
report.v = MAX((int8_t)buffer[4], -127);
print_usb_data(&report);
host_mouse_send(&report);
}
return;
}
#endif
/*
* parse 5 byte packet.
* NOTE: We only get a complete packet
* if the mouse moved or the button states
* change.
*/
if (!(buffer[0] & (1 << 2)))
report.buttons |= MOUSE_BTN1;
if (!(buffer[0] & (1 << 1)))
report.buttons |= MOUSE_BTN3;
if (!(buffer[0] & (1 << 0)))
report.buttons |= MOUSE_BTN2;
/* USB HID uses only values from -127 to 127 */
report.x = MAX((int8_t)buffer[1], -127);
report.y = MAX(-(int8_t)buffer[2], -127);
print_usb_data(&report);
host_mouse_send(&report);
if (buffer[3] || buffer[4]) {
report.x = MAX((int8_t)buffer[3], -127);
report.y = MAX(-(int8_t)buffer[4], -127);
print_usb_data(&report);
host_mouse_send(&report);
}
}
static void print_usb_data(const report_mouse_t *report)
{
if (!debug_mouse)
return;
xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n",
report->buttons, report->x, report->y,
report->v, report->h);
}

@ -122,7 +122,11 @@ void serial_send(uint8_t data)
/* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */ /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */
#ifdef SERIAL_SOFT_BIT_ORDER_MSB #ifdef SERIAL_SOFT_BIT_ORDER_MSB
#ifdef SERIAL_SOFT_DATA_7BIT
uint8_t mask = 0x40;
#else
uint8_t mask = 0x80; uint8_t mask = 0x80;
#endif
#else #else
uint8_t mask = 0x01; uint8_t mask = 0x01;
#endif #endif
@ -133,7 +137,11 @@ void serial_send(uint8_t data)
SERIAL_SOFT_TXD_OFF(); SERIAL_SOFT_TXD_OFF();
_delay_us(WAIT_US); _delay_us(WAIT_US);
while (mask) { #ifdef SERIAL_SOFT_DATA_7BIT
while (mask&0x7F) {
#else
while (mask&0xFF) {
#endif
if (data&mask) { if (data&mask) {
SERIAL_SOFT_TXD_ON(); SERIAL_SOFT_TXD_ON();
parity ^= 1; parity ^= 1;
@ -173,7 +181,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
uint8_t data = 0; uint8_t data = 0;
#ifdef SERIAL_SOFT_BIT_ORDER_MSB #ifdef SERIAL_SOFT_BIT_ORDER_MSB
#ifdef SERIAL_SOFT_DATA_7BIT
uint8_t mask = 0x40;
#else
uint8_t mask = 0x80; uint8_t mask = 0x80;
#endif
#else #else
uint8_t mask = 0x01; uint8_t mask = 0x01;
#endif #endif
@ -197,7 +209,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
#else #else
mask <<= 1; mask <<= 1;
#endif #endif
} while (mask); #ifdef SERIAL_SOFT_DATA_7BIT
} while (mask&0x7F);
#else
} while (mask&0xFF);
#endif
#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) #if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
/* to center of parity bit */ /* to center of parity bit */

Loading…
Cancel
Save