Parts of the upcoming rewrite
This commit is contained in:
parent
5226cdd252
commit
47a54d654d
226
layouts.h
226
layouts.h
@ -1,226 +0,0 @@
|
|||||||
#ifndef __layouts_h
|
|
||||||
#define __layouts_h
|
|
||||||
|
|
||||||
// Modifier Mask
|
|
||||||
#define MODIFIERS_KEYPAD 0
|
|
||||||
#define MODIFIERS_KEYBOARD 4
|
|
||||||
static uint8_t keypad_modifierMask[] = {};
|
|
||||||
static uint8_t keyboard_modifierMask[] = { 1, 17, 33, 49 };
|
|
||||||
static uint8_t alternate_modifierMask[] = { 1, 17, 33, 49, 62 };
|
|
||||||
|
|
||||||
// Default 1-indexed key mappings
|
|
||||||
static uint8_t keypadDefaultMap[] = { 0,
|
|
||||||
KEYPAD_ASTERIX,
|
|
||||||
KEYPAD_MINUS,
|
|
||||||
KEYPAD_PLUS,
|
|
||||||
KEYPAD_ENTER,
|
|
||||||
KEYPAD_9,
|
|
||||||
KEYPAD_6,
|
|
||||||
KEYPAD_3,
|
|
||||||
KEYPAD_0,
|
|
||||||
KEYPAD_8,
|
|
||||||
KEYPAD_5,
|
|
||||||
KEYPAD_2,
|
|
||||||
KEYPAD_PERIOD,
|
|
||||||
KEYPAD_7,
|
|
||||||
KEYPAD_4,
|
|
||||||
KEYPAD_1,
|
|
||||||
KEYPAD_SLASH };
|
|
||||||
|
|
||||||
static uint8_t defaultMap[] = { 0,
|
|
||||||
KEY_GUI,
|
|
||||||
KEY_1,
|
|
||||||
KEY_2,
|
|
||||||
KEY_3,
|
|
||||||
KEY_4,
|
|
||||||
KEY_5,
|
|
||||||
KEY_6,
|
|
||||||
KEY_7,
|
|
||||||
KEY_8,
|
|
||||||
KEY_9,
|
|
||||||
KEY_0,
|
|
||||||
KEY_MINUS,
|
|
||||||
KEY_EQUAL,
|
|
||||||
KEY_BACKSLASH,
|
|
||||||
KEY_TILDE,
|
|
||||||
KEY_BACKSPACE,
|
|
||||||
KEY_ALT,
|
|
||||||
KEY_TAB,
|
|
||||||
KEY_Q,
|
|
||||||
KEY_W,
|
|
||||||
KEY_E,
|
|
||||||
KEY_R,
|
|
||||||
KEY_T,
|
|
||||||
KEY_Y,
|
|
||||||
KEY_U,
|
|
||||||
KEY_I,
|
|
||||||
KEY_O,
|
|
||||||
KEY_P,
|
|
||||||
KEY_LEFT_BRACE,
|
|
||||||
KEY_RIGHT_BRACE,
|
|
||||||
KEY_DELETE,
|
|
||||||
KEY_UP,
|
|
||||||
KEY_CTRL,
|
|
||||||
KEY_CAPS_LLOCK,
|
|
||||||
KEY_A,
|
|
||||||
KEY_S,
|
|
||||||
KEY_D,
|
|
||||||
KEY_F,
|
|
||||||
KEY_G,
|
|
||||||
KEY_H,
|
|
||||||
KEY_J,
|
|
||||||
KEY_K,
|
|
||||||
KEY_L,
|
|
||||||
KEY_SEMICOLON,
|
|
||||||
KEY_QUOTE,
|
|
||||||
KEY_ENTER,
|
|
||||||
KEY_DOWN,
|
|
||||||
KEY_ESC,
|
|
||||||
KEY_LEFT_SHIFT,
|
|
||||||
KEY_Z,
|
|
||||||
KEY_X,
|
|
||||||
KEY_C,
|
|
||||||
KEY_V,
|
|
||||||
KEY_B,
|
|
||||||
KEY_N,
|
|
||||||
KEY_M,
|
|
||||||
KEY_COMMA,
|
|
||||||
KEY_PERIOD,
|
|
||||||
KEY_SLASH,
|
|
||||||
KEY_RIGHT_SHIFT,
|
|
||||||
KEY_LEFT,
|
|
||||||
KEY_RIGHT,
|
|
||||||
KEY_SPACE };
|
|
||||||
|
|
||||||
static uint8_t navigationMap[] = { 0,
|
|
||||||
KEY_GUI,
|
|
||||||
KEY_F1,
|
|
||||||
KEY_F2,
|
|
||||||
KEY_F3,
|
|
||||||
KEY_F4,
|
|
||||||
KEY_F5,
|
|
||||||
KEY_F6,
|
|
||||||
KEY_F7,
|
|
||||||
KEY_F8,
|
|
||||||
KEY_F9,
|
|
||||||
KEY_F10,
|
|
||||||
KEY_F11,
|
|
||||||
KEY_F12,
|
|
||||||
KEY_INSERT,
|
|
||||||
KEY_DELETE,
|
|
||||||
KEY_BACKSPACE,
|
|
||||||
KEY_ALT,
|
|
||||||
KEY_CAPS_LOCK,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
KEY_SYSREQ_ATT,
|
|
||||||
KEY_SCROLL_LOCK,
|
|
||||||
KEY_PAUSE,
|
|
||||||
KEY_UP,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
KEY_CTRL,
|
|
||||||
KEY_CAPS_LLOCK,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
KEYPAD_ASTERIX,
|
|
||||||
KEYPAD_SLASH,
|
|
||||||
KEY_HOME,
|
|
||||||
KEY_PAGE_UP,
|
|
||||||
KEY_LEFT,
|
|
||||||
KEY_RIGHT,
|
|
||||||
KEY_ENTER,
|
|
||||||
0,
|
|
||||||
KEY_ESC,
|
|
||||||
KEY_LEFT_SHIFT,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
KEYPAD_PLUS,
|
|
||||||
KEYPAD_MINUS,
|
|
||||||
KEY_END,
|
|
||||||
KEY_PAGE_DOWN,
|
|
||||||
KEY_DOWN,
|
|
||||||
KEY_RIGHT_SHIFT,
|
|
||||||
165,
|
|
||||||
KEY_RIGHT_ALT,
|
|
||||||
KEY_SPACE };
|
|
||||||
|
|
||||||
static uint8_t colemakMap[] = { 0,
|
|
||||||
KEY_GUI,
|
|
||||||
KEY_1,
|
|
||||||
KEY_2,
|
|
||||||
KEY_3,
|
|
||||||
KEY_4,
|
|
||||||
KEY_5,
|
|
||||||
KEY_6,
|
|
||||||
KEY_7,
|
|
||||||
KEY_8,
|
|
||||||
KEY_9,
|
|
||||||
KEY_0,
|
|
||||||
KEY_MINUS,
|
|
||||||
KEY_EQUAL,
|
|
||||||
KEY_BACKSLASH,
|
|
||||||
KEY_TILDE,
|
|
||||||
KEY_BACKSPACE,
|
|
||||||
KEY_ALT,
|
|
||||||
KEY_TAB,
|
|
||||||
KEY_Q,
|
|
||||||
KEY_W,
|
|
||||||
KEY_F,
|
|
||||||
KEY_P,
|
|
||||||
KEY_G,
|
|
||||||
KEY_J,
|
|
||||||
KEY_L,
|
|
||||||
KEY_U,
|
|
||||||
KEY_Y,
|
|
||||||
KEY_SEMICOLON,
|
|
||||||
KEY_LEFT_BRACE,
|
|
||||||
KEY_RIGHT_BRACE,
|
|
||||||
KEY_DELETE,
|
|
||||||
KEY_PAGE_UP,
|
|
||||||
KEY_CTRL,
|
|
||||||
KEY_CAPS_LLOCK,
|
|
||||||
KEY_A,
|
|
||||||
KEY_R,
|
|
||||||
KEY_S,
|
|
||||||
KEY_T,
|
|
||||||
KEY_D,
|
|
||||||
KEY_H,
|
|
||||||
KEY_N,
|
|
||||||
KEY_E,
|
|
||||||
KEY_I,
|
|
||||||
KEY_O,
|
|
||||||
KEY_QUOTE,
|
|
||||||
KEY_ENTER,
|
|
||||||
KEY_PAGE_DOWN,
|
|
||||||
KEY_ESC,
|
|
||||||
KEY_LEFT_SHIFT,
|
|
||||||
KEY_Z,
|
|
||||||
KEY_X,
|
|
||||||
KEY_C,
|
|
||||||
KEY_V,
|
|
||||||
KEY_B,
|
|
||||||
KEY_K,
|
|
||||||
KEY_M,
|
|
||||||
KEY_COMMA,
|
|
||||||
KEY_PERIOD,
|
|
||||||
KEY_SLASH,
|
|
||||||
KEY_RIGHT_SHIFT,
|
|
||||||
165,
|
|
||||||
KEY_RIGHT_ALT,
|
|
||||||
KEY_SPACE };
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
63
main.c
63
main.c
@ -24,7 +24,8 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include "usb_keys.h"
|
#include "usb_keys.h"
|
||||||
#include "layouts.h"
|
#include "scan_loop.h"
|
||||||
|
//#include "layouts.h"
|
||||||
//#include "usb_keyboard.h"
|
//#include "usb_keyboard.h"
|
||||||
|
|
||||||
// TEMP INCLUDES
|
// TEMP INCLUDES
|
||||||
@ -33,10 +34,6 @@
|
|||||||
|
|
||||||
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
|
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
|
||||||
|
|
||||||
// Number of keys
|
|
||||||
#define KEYBOARD_SIZE 63
|
|
||||||
#define KEYPAD_SIZE 16
|
|
||||||
|
|
||||||
|
|
||||||
// Debouncing Defines
|
// Debouncing Defines
|
||||||
#define SAMPLE_THRESHOLD 110
|
#define SAMPLE_THRESHOLD 110
|
||||||
@ -46,6 +43,10 @@
|
|||||||
// Verified Keypress Defines
|
// Verified Keypress Defines
|
||||||
#define USB_TRANSFER_DIVIDER 10 // 1024 == 1 Send of keypresses per second, 1 == 1 Send of keypresses per ~1 millisecond
|
#define USB_TRANSFER_DIVIDER 10 // 1024 == 1 Send of keypresses per second, 1 == 1 Send of keypresses per ~1 millisecond
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Number of keys
|
||||||
|
#define KEYBOARD_SIZE 63
|
||||||
|
#define KEYPAD_SIZE 16
|
||||||
|
|
||||||
// Drive Pin Defines
|
// Drive Pin Defines
|
||||||
#define DRIVE_reg_1 PORTD
|
#define DRIVE_reg_1 PORTD
|
||||||
@ -219,8 +220,7 @@
|
|||||||
|
|
||||||
// NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
|
// NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
|
||||||
// Other Bits: Pressed state sample counter
|
// Other Bits: Pressed state sample counter
|
||||||
uint8_t keyDetectArray[KEYBOARD_SIZE + 1];
|
uint8_t keyboardDetectArray[KEYBOARD_SIZE + 1];
|
||||||
uint8_t keypadDetectArray[KEYPAD_SIZE + 1];
|
|
||||||
|
|
||||||
// Interrupt Variables
|
// Interrupt Variables
|
||||||
uint16_t sendKeypressCounter = 0;
|
uint16_t sendKeypressCounter = 0;
|
||||||
@ -242,30 +242,47 @@ void detection( int group )
|
|||||||
DET_GROUP(9,1)
|
DET_GROUP(9,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Error LED Control
|
||||||
|
void errorLED( uint8_t on )
|
||||||
|
{
|
||||||
|
// Error LED On
|
||||||
|
if ( on ) {
|
||||||
|
DDRD |= (1<<6);
|
||||||
|
PORTD |= (1<<6);
|
||||||
|
}
|
||||||
|
// Error LED Off
|
||||||
|
else {
|
||||||
|
DDRD &= ~(1<<6);
|
||||||
|
PORTD &= ~(1<<6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// XXX This part is configurable
|
// Initial Pin Setup
|
||||||
|
// If the matrix is properly set, this function does not need to be changed
|
||||||
inline void pinSetup(void)
|
inline void pinSetup(void)
|
||||||
{
|
{
|
||||||
// For each pin, 0=input, 1=output
|
// For each pin, 0=input, 1=output
|
||||||
DDRA = 0x00;
|
DDRA = 0x00;
|
||||||
DDRB = 0x00;
|
DDRB = 0x00;
|
||||||
DDRC = 0x00;
|
DDRC = 0x00;
|
||||||
DDRD = 0xFC;
|
DDRD = 0x40; // LED Setup
|
||||||
DDRE = 0x43;
|
DDRE = 0x00;
|
||||||
DDRF = 0x00;
|
DDRF = 0x00;
|
||||||
|
|
||||||
|
|
||||||
// Setting pins to either high or pull-up resistor
|
// Setting pins to either high or pull-up resistor
|
||||||
PORTA = 0xFF;
|
PORTA = 0x00;
|
||||||
PORTB = 0xFF;
|
PORTB = 0x00;
|
||||||
PORTC = 0x01;
|
PORTC = 0x00;
|
||||||
PORTD = 0xFF;
|
PORTD = 0x40; // LED Enable
|
||||||
PORTE = 0xC3;
|
PORTE = 0x00;
|
||||||
PORTF = 0xFF;
|
PORTF = 0x00;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// Given a sampling array, and the current number of detected keypress
|
// Given a sampling array, and the current number of detected keypress
|
||||||
// Add as many keypresses from the sampling array to the USB key send array as possible.
|
// Add as many keypresses from the sampling array to the USB key send array as possible.
|
||||||
void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys, uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map ) {
|
void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys, uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map ) {
|
||||||
@ -297,6 +314,7 @@ void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
@ -323,6 +341,16 @@ int main( void )
|
|||||||
TIMSK0 = (1 << TOIE0);
|
TIMSK0 = (1 << TOIE0);
|
||||||
|
|
||||||
// Main Detection Loop
|
// Main Detection Loop
|
||||||
|
while ( 1 ) {
|
||||||
|
scan_loop();
|
||||||
|
|
||||||
|
// Loop should never get here (indicate error)
|
||||||
|
errorLED( 1 );
|
||||||
|
|
||||||
|
// TODO HID Debug message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
int8_t group = 1;
|
int8_t group = 1;
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
for ( ;;group++ ) {
|
for ( ;;group++ ) {
|
||||||
@ -420,6 +448,7 @@ int main( void )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Timer Interrupt for flagging a send of the sampled key detection data to the USB host
|
// Timer Interrupt for flagging a send of the sampled key detection data to the USB host
|
||||||
ISR( TIMER0_OVF_vect )
|
ISR( TIMER0_OVF_vect )
|
||||||
|
Reference in New Issue
Block a user