Archived
1
0

Major code cleanup and preparation for PartialMap Macro Module

- Code should be working, but much is untested
- All of the old modules will need to update and use the new DefaultMap keymap
- There might still be some naming conflicts with some Scan Modules
This commit is contained in:
Jacob Alexander 2014-04-06 11:49:27 -07:00
parent f3e22fb242
commit 9d423a64a8
81 changed files with 1373 additions and 904 deletions

View File

@ -11,9 +11,6 @@
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
set( CMAKE_USE_RELATIVE_PATHS 1 )
#| Add Dependency Macro
include( AddFileDependencies )
###

View File

@ -58,7 +58,7 @@ inline void prompt()
}
// Initialize the CLI
inline void init_cli()
inline void CLI_init()
{
// Reset the Line Buffer
CLILineBufferCurrent = 0;
@ -68,7 +68,7 @@ inline void init_cli()
// Register first dictionary
CLIDictionariesUsed = 0;
registerDictionary_cli( basicCLIDict, basicCLIDictName );
CLI_registerDictionary( basicCLIDict, basicCLIDictName );
// Initialize main LED
init_errorLED();
@ -79,7 +79,7 @@ inline void init_cli()
}
// Query the serial input buffer for any new characters
void process_cli()
void CLI_process()
{
// Current buffer position
uint8_t prev_buf_pos = CLILineBufferCurrent;
@ -88,11 +88,11 @@ void process_cli()
while ( 1 )
{
// No more characters to process
if ( output_availablechar() == 0 )
if ( Output_availablechar() == 0 )
break;
// Retrieve from output module
char cur_char = (char)output_getchar();
char cur_char = (char)Output_getchar();
// Make sure buffer isn't full
if ( CLILineBufferCurrent >= CLILineBufferMaxSize )
@ -143,7 +143,7 @@ void process_cli()
CLILineBufferCurrent--;
// Process the current line buffer
commandLookup_cli();
CLI_commandLookup();
// Reset the buffer
CLILineBufferCurrent = 0;
@ -158,7 +158,7 @@ void process_cli()
case 0x09: // Tab
// Tab completion for the current command
tabCompletion_cli();
CLI_tabCompletion();
CLILineBufferCurrent--; // Remove the Tab
@ -207,7 +207,7 @@ void process_cli()
// One to the first non-space character
// The second to the next argument (first NULL if there isn't an argument). delimited by a space
// Places a NULL at the first space after the first argument
inline void argumentIsolation_cli( char* string, char** first, char** second )
inline void CLI_argumentIsolation( char* string, char** first, char** second )
{
// Mark out the first argument
// This is done by finding the first space after a list of non-spaces and setting it NULL
@ -228,7 +228,7 @@ inline void argumentIsolation_cli( char* string, char** first, char** second )
}
// Scans the CLILineBuffer for any valid commands
void commandLookup_cli()
void CLI_commandLookup()
{
// Ignore command if buffer is 0 length
if ( CLILineBufferCurrent == 0 )
@ -241,7 +241,7 @@ void commandLookup_cli()
// Places a NULL at the first space after the command
char* cmdPtr;
char* argPtr;
argumentIsolation_cli( CLILineBuffer, &cmdPtr, &argPtr );
CLI_argumentIsolation( CLILineBuffer, &cmdPtr, &argPtr );
// Scan array of dictionaries for a valid command match
for ( uint8_t dict = 0; dict < CLIDictionariesUsed; dict++ )
@ -267,7 +267,7 @@ void commandLookup_cli()
}
// Registers a command dictionary with the CLI
inline void registerDictionary_cli( CLIDictItem *cmdDict, char* dictName )
inline void CLI_registerDictionary( CLIDictItem *cmdDict, char* dictName )
{
// Make sure this max limit of dictionaries hasn't been reached
if ( CLIDictionariesUsed >= CLIMaxDictionaries )
@ -281,7 +281,7 @@ inline void registerDictionary_cli( CLIDictItem *cmdDict, char* dictName )
CLIDict[CLIDictionariesUsed++] = cmdDict;
}
inline void tabCompletion_cli()
inline void CLI_tabCompletion()
{
// Ignore command if buffer is 0 length
if ( CLILineBufferCurrent == 0 )
@ -294,7 +294,7 @@ inline void tabCompletion_cli()
// Places a NULL at the first space after the command
char* cmdPtr;
char* argPtr;
argumentIsolation_cli( CLILineBuffer, &cmdPtr, &argPtr );
CLI_argumentIsolation( CLILineBuffer, &cmdPtr, &argPtr );
// Tab match pointer
char* tabMatch = 0;
@ -393,7 +393,7 @@ void cliFunc_led( char* args )
void cliFunc_reload( char* args )
{
// Request to output module to be set into firmware reload mode
output_firmwareReload();
Output_firmwareReload();
}
void cliFunc_reset( char* args )
@ -404,7 +404,7 @@ void cliFunc_reset( char* args )
void cliFunc_restart( char* args )
{
// Trigger an overall software reset
output_softReset();
Output_softReset();
}
void cliFunc_version( char* args )

View File

@ -66,13 +66,13 @@ uint8_t CLIHexDebugMode;
// ----- Functions and Corresponding Function Aliases -----
void init_cli();
void process_cli();
void registerDictionary_cli( CLIDictItem *cmdDict, char* dictName );
void argumentIsolation_cli( char* string, char** first, char** second );
void CLI_init();
void CLI_process();
void CLI_registerDictionary( CLIDictItem *cmdDict, char* dictName );
void CLI_argumentIsolation( char* string, char** first, char** second );
void commandLookup_cli();
void tabCompletion_cli();
void CLI_commandLookup();
void CLI_tabCompletion();
// CLI Command Functions
void cliFunc_arch ( char* args );

View File

@ -19,13 +19,6 @@ set( DEBUG_SRCS
)
###
# Setup File Dependencies
#
add_file_dependencies( ../led/led.c ../led/led.h )
add_file_dependencies( ../print/print.c ../print/print.h )
###
# Module Specific Options
#

View File

@ -1,6 +1,6 @@
###| CMake Kiibohd Controller Debug Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
@ -16,12 +16,6 @@ set( DEBUG_SRCS
)
###
# Setup File Dependencies
#
add_file_dependencies( ../led/led.c ../led/led.h )
###
# Module Specific Options
#

View File

@ -45,7 +45,7 @@ void printstrs( char* first, ... )
while ( !( cur[0] == '\0' && cur[1] == '\0' && cur[2] == '\0' ) )
{
// Print out the given string
output_putstr( cur );
Output_putstr( cur );
// Get the next argument ready
cur = va_arg( ap, char* );
@ -62,10 +62,10 @@ void _print( const char* s )
char c;
while ( ( c = pgm_read_byte( s++ ) ) != '\0' )
{
output_putchar( c );
Output_putchar( c );
}
#elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
output_putstr( (char*)s );
Output_putstr( (char*)s );
#endif
}

View File

@ -46,8 +46,8 @@
*/
// Function Aliases
#define dPrint(c) output_putstr(c)
#define dPrintStr(c) output_putstr(c)
#define dPrint(c) Output_putstr(c)
#define dPrintStr(c) Output_putstr(c)
#define dPrintStrs(...) printstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro
#define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro
#define dPrintStrsNL(...) printstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro

View File

@ -1,6 +1,6 @@
###| CMake Kiibohd Controller Debug Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
@ -16,12 +16,6 @@ set( DEBUG_SRCS
)
###
# Setup File Dependencies
#
add_file_dependencies( ../led/print.c ../led/print.h )
###
# Module Specific Options
#

172
Macro/PartialMap/macro.c Normal file
View File

@ -0,0 +1,172 @@
/* Copyright (C) 2014 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// ----- Includes -----
// Compiler Includes
#include <Lib/MacroLib.h>
// Project Includes
#include <cli.h>
#include <led.h>
#include <print.h>
#include <scan_loop.h>
#include <output_com.h>
// Keymaps
#include "usb_hid.h"
#include <defaultMap.h>
// Local Includes
#include "macro.h"
// ----- Function Declarations -----
void cliFunc_capList ( char* args );
void cliFunc_capSelect ( char* args );
void cliFunc_lookComb ( char* args );
void cliFunc_lookDefault( char* args );
void cliFunc_lookPartial( char* args );
void cliFunc_macroDebug ( char* args );
// ----- Variables -----
// Output Module command dictionary
char* macroCLIDictName = "Macro Module Commands";
CLIDictItem macroCLIDict[] = {
{ "capList", "Prints an indexed list of all non USB keycode capabilities.", cliFunc_capList },
{ "capSelect", "Triggers the specified capability. U10 is USB Code 0x0A (G). K11 is keyboard capability 0x0B.", cliFunc_capSelect },
{ "lookComb", "Do a lookup on the Combined map. S10 specifies Scancode 0x0A. U10 specified USB keycode 0x0A.", cliFunc_lookComb },
{ "lookDefault", "Do a lookup on the Default map. S10 specifies Scancode 0x0A. USB keycodes are not valid.", cliFunc_lookDefault },
{ "lookPartial", "Do a lookup on the layered partial map. S10 specifies Scancode 0x0A. U10 specifies USB keycode 0x0A.", cliFunc_lookPartial },
{ "macroDebug", "Disables/Enables sending USB keycodes to the Output Module and prints U/K codes.", cliFunc_macroDebug },
{ 0, 0, 0 } // Null entry for dictionary end
};
// ----- Functions -----
inline void Macro_bufferAdd( uint8_t byte )
{
// Make sure we haven't overflowed the key buffer
// Default function for adding keys to the KeyIndex_Buffer, does a DefaultMap_Lookup
if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER )
{
KeyIndex_Buffer[KeyIndex_BufferUsed++] = DefaultMap_Lookup[byte];
}
}
inline void Macro_finishWithUSBBuffer( uint8_t sentKeys )
{
}
inline void Macro_process()
{
// Only do one round of macro processing between Output Module timer sends
if ( USBKeys_Sent != 0 )
return;
// Loop through input buffer
for ( uint8_t index = 0; index < KeyIndex_BufferUsed; index++ )
{
// Get the keycode from the buffer
uint8_t key = KeyIndex_Buffer[index];
// Set the modifier bit if this key is a modifier
if ( key & KEY_LCTRL ) // AND with 0xE0
{
USBKeys_Modifiers |= 1 << (key ^ KEY_LCTRL); // Left shift 1 by key XOR 0xE0
// Modifier processed, move on to the next key
continue;
}
// Too many keys
if ( USBKeys_Sent >= USBKeys_MaxSize )
{
info_print("USB Key limit reached");
errorLED( 1 );
break;
}
// Allow ignoring keys with 0's
if ( key != 0 )
{
USBKeys_Array[USBKeys_Sent++] = key;
}
else
{
// Key was not mapped
// TODO Add dead key map
erro_dPrint( "Key not mapped... - " );
printHex( key );
errorLED( 1 );
}
}
// Signal buffer that we've used it
Scan_finishedWithBuffer( KeyIndex_BufferUsed );
}
inline void Macro_setup()
{
// Register Macro CLI dictionary
CLI_registerDictionary( macroCLIDict, macroCLIDictName );
}
// ----- CLI Command Functions -----
void cliFunc_capList( char* args )
{
// TODO
}
void cliFunc_capSelect( char* args )
{
// TODO
}
void cliFunc_lookComb( char* args )
{
// TODO
}
void cliFunc_lookDefault( char* args )
{
// TODO
}
void cliFunc_lookPartial( char* args )
{
// TODO
}
void cliFunc_macroDebug( char* args )
{
// TODO
}

48
Macro/PartialMap/macro.h Normal file
View File

@ -0,0 +1,48 @@
/* Copyright (C) 2014 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __macro_h
#define __macro_h
// ----- Includes -----
// Compiler Includes
#include <stdint.h>
// ----- Variables -----
// ----- Macros -----
// ----- Functions -----
void Macro_bufferAdd( uint8_t byte );
void Macro_finishWithUSBBuffer( uint8_t sentKeys );
void Macro_process();
void Macro_setup();
#endif

View File

@ -0,0 +1,31 @@
###| CMake Kiibohd Controller Macro Module |###
#
# Written by Jacob Alexander in 2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
###
###
# Module C files
#
set( MACRO_SRCS
macro.c
)
###
# Module Specific Options
#
###
# Compiler Family Compatibility
#
set( MacroModuleCompatibility
arm
avr
)

365
Macro/PartialMap/usb_hid.h Normal file
View File

@ -0,0 +1,365 @@
/* Copyright (C) 2011-2014 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef __usb_hid_h
#define __usb_hid_h
// ----- Defines -----
// The USB codes are all taken from the USB HID Spec
// http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
// List of Keycodes - USB HID 1.11 pg 53
#define KEY_NOEVENT 0x00 // Event, not a physical key
#define KEY_ERRORROLLOVER 0x01 // Event, not a physical key
#define KEY_POSTFAIL 0x02 // Event, not a physical key
#define KEY_ERRORUNDEFINED 0x03 // Event, not a physical key
#define KEY_A 0x04
#define KEY_B 0x05
#define KEY_C 0x06
#define KEY_D 0x07
#define KEY_E 0x08
#define KEY_F 0x09
#define KEY_G 0x0A
#define KEY_H 0x0B
#define KEY_I 0x0C
#define KEY_J 0x0D
#define KEY_K 0x0E
#define KEY_L 0x0F
#define KEY_M 0x10
#define KEY_N 0x11
#define KEY_O 0x12
#define KEY_P 0x13
#define KEY_Q 0x14
#define KEY_R 0x15
#define KEY_S 0x16
#define KEY_T 0x17
#define KEY_U 0x18
#define KEY_V 0x19
#define KEY_W 0x1A
#define KEY_X 0x1B
#define KEY_Y 0x1C
#define KEY_Z 0x1D
#define KEY_1 0x1E
#define KEY_2 0x1F
#define KEY_3 0x20
#define KEY_4 0x21
#define KEY_5 0x22
#define KEY_6 0x23
#define KEY_7 0x24
#define KEY_8 0x25
#define KEY_9 0x26
#define KEY_0 0x27
#define KEY_ENTER 0x28
#define KEY_ESC 0x29
#define KEY_BACKSPACE 0x2A
#define KEY_TAB 0x2B
#define KEY_SPACE 0x2C
#define KEY_MINUS 0x2D
#define KEY_EQUAL 0x2E
#define KEY_LEFT_BRACE 0x2F
#define KEY_RIGHT_BRACE 0x30
#define KEY_BACKSLASH 0x31
#define KEY_NUMBER 0x32
#define KEY_SEMICOLON 0x33
#define KEY_QUOTE 0x34
#define KEY_TILDE 0x35
#define KEY_COMMA 0x36
#define KEY_PERIOD 0x37
#define KEY_SLASH 0x38
#define KEY_CAPS_LOCK 0x39
#define KEY_F1 0x3A
#define KEY_F2 0x3B
#define KEY_F3 0x3C
#define KEY_F4 0x3D
#define KEY_F5 0x3E
#define KEY_F6 0x3F
#define KEY_F7 0x40
#define KEY_F8 0x41
#define KEY_F9 0x42
#define KEY_F10 0x43
#define KEY_F11 0x44
#define KEY_F12 0x45
#define KEY_PRINTSCREEN 0x46
#define KEY_SCROLL_LOCK 0x47
#define KEY_PAUSE 0x48
#define KEY_INSERT 0x49
#define KEY_HOME 0x4A
#define KEY_PAGE_UP 0x4B
#define KEY_DELETE 0x4C
#define KEY_END 0x4D
#define KEY_PAGE_DOWN 0x4E
#define KEY_RIGHT 0x4F
#define KEY_LEFT 0x50
#define KEY_DOWN 0x51
#define KEY_UP 0x52
#define KEY_NUM_LOCK 0x53
#define KEYPAD_SLASH 0x54
#define KEYPAD_ASTERIX 0x55
#define KEYPAD_MINUS 0x56
#define KEYPAD_PLUS 0x57
#define KEYPAD_ENTER 0x58
#define KEYPAD_1 0x59
#define KEYPAD_2 0x5A
#define KEYPAD_3 0x5B
#define KEYPAD_4 0x5C
#define KEYPAD_5 0x5D
#define KEYPAD_6 0x5E
#define KEYPAD_7 0x5F
#define KEYPAD_8 0x60
#define KEYPAD_9 0x61
#define KEYPAD_0 0x62
#define KEYPAD_PERIOD 0x63
#define KEY_ISO_BACKSLASH 0x64
#define KEY_APP 0x65
#define KEYBOARD_STATUS 0x66 // Used for indicating status or errors, not a key
#define KEYPAD_EQUAL 0x67
#define KEY_F13 0x68
#define KEY_F14 0x69
#define KEY_F15 0x6A
#define KEY_F16 0x6B
#define KEY_F17 0x6C
#define KEY_F18 0x6D
#define KEY_F19 0x6E
#define KEY_F20 0x6F
#define KEY_F21 0x70
#define KEY_F22 0x71
#define KEY_F23 0x72
#define KEY_F24 0x73
#define KEY_EXEC 0x74
#define KEY_HELP 0x75
#define KEY_MENU 0x76
#define KEY_SELECT 0x77
#define KEY_STOP 0x78
#define KEY_AGAIN 0x79
#define KEY_UNDO 0x7A
#define KEY_CUT 0x7B
#define KEY_COPY 0x7C
#define KEY_PASTE 0x7D
#define KEY_FIND 0x7E
#define KEY_MUTE 0x7F
#define KEY_VOL_UP 0x80
#define KEY_VOL_DOWN 0x81
#define KEY_CAPS_LLOCK 0x82 // "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
#define KEY_NUM_LLOCK 0x83
#define KEY_SCROLL_LLOCK 0x84
#define KEYPAD_COMMA 0x85 // Brazillian (See spec)
#define KEYPAD_EQUAL_AS 0x86 // AS/400 Keyboard (See spec)
#define KEY_INTER1 0x87 // KANJI1 - Brazillian and Japanese "Ru" and "-"
#define KEY_INTER2 0x88 // KANJI2 - Japanese Katakana/Hiragana
#define KEY_INTER3 0x89 // KANJI3 - Japanese Yen
#define KEY_INTER4 0x8A // KANJI4 - Japanese Henkan
#define KEY_INTER5 0x8B // KANJI5 - Japanese Muhenkan
#define KEY_INTER6 0x8C // KANJI6 - PC0x62 Comma (Ka-m-ma)
#define KEY_INTER7 0x8D // KANJI7 - Double-Byte/Single-Byte Toggle
#define KEY_INTER8 0x8E // KANJI8 - Undefined
#define KEY_INTER9 0x8F // KANJI9 - Undefined
#define KEY_LANG1 0x90 // Korean Hangul/English Toggle
#define KEY_LANG2 0x91 // Korean Hanja Conversion - Japanese Eisu
#define KEY_LANG3 0x92 // Japanese Katakana Key (USB)
#define KEY_LANG4 0x93 // Japanese Hiragana Key (USB)
#define KEY_LANG5 0x94 // Japanese Zenkaku/Hankaku Key (USB)
#define KEY_LANG6 0x95 // Reserved (Application Specific)
#define KEY_LANG7 0x96 // Reserved (Application Specific)
#define KEY_LANG8 0x97 // Reserved (Application Specific)
#define KEY_LANG9 0x98 // Reserved (Application Specific)
#define KEY_ALT_ERASE 0x99 // Special Erase (See Spec)
#define KEY_SYSREQ_ATT 0x9A // Modifier Type
#define KEY_CANCEL 0x9B
#define KEY_CLEAR 0x9C
#define KEY_PRIOR 0x9D
#define KEY_RETURN 0x9E
#define KEY_SEPARATOR 0x9F
#define KEY_OUT 0xA0
#define KEY_OPER 0xA1
#define KEY_CLEAR_AGAIN 0xA2
#define KEY_CRSEL_PROPS 0xA3
#define KEY_EXSEL 0xA4
// 0xA5 - 0xAF Reserved
#define KEYPAD_00 0xB0
#define KEYPAD_000 0xB1
#define KEY_1000_SEP 0xB2
#define KEY_DECIMAL_SEP 0xB3
#define KEY_CURRENCY_MAIN 0xB4
#define KEY_CURRENCY_SUB 0xB5
#define KEYPAD_LPAREN 0xB6
#define KEYPAD_RPAREN 0xB7
#define KEYPAD_LBRACE 0xB8
#define KEYPAD_RBRACE 0xB9
#define KEYPAD_TAB 0xBA
#define KEYPAD_BACKSPACE 0xBB
#define KEYPAD_A 0xBC
#define KEYPAD_B 0xBD
#define KEYPAD_C 0xBE
#define KEYPAD_D 0xBF
#define KEYPAD_E 0xC0
#define KEYPAD_F 0xC1
#define KEYPAD_XOR 0xC2
#define KEYPAD_CHEVRON 0xC3
#define KEYPAD_PERCENT 0xC4
#define KEYPAD_LTHAN 0xC5
#define KEYPAD_GTHAN 0xC6
#define KEYPAD_BITAND 0xC7
#define KEYPAD_AND 0xC8
#define KEYPAD_BITOR 0xC9
#define KEYPAD_OR 0xCA
#define KEYPAD_COLON 0xCB
#define KEYPAD_POUND 0xCC
#define KEYPAD_SPACE 0xCD
#define KEYPAD_AT 0xCE
#define KEYPAD_EXCLAIM 0xCF
#define KEYPAD_MEM_STORE 0xD0
#define KEYPAD_MEM_RECALL 0xD1
#define KEYPAD_MEM_CLEAR 0xD2
#define KEYPAD_MEM_ADD 0xD3
#define KEYPAD_MEM_SUB 0xD4
#define KEYPAD_MEM_MULT 0xD5
#define KEYPAD_MEM_DIV 0xD6
#define KEYPAD_PLUS_MINUS 0xD7
#define KEYPAD_CLEAR 0xD8
#define KEYPAD_CLEAR_ENTRY 0xD9
#define KEYPAD_BINARY 0xDA
#define KEYPAD_OCTAL 0xDB
#define KEYPAD_DECIMAL 0xDC
#define KEYPAD_HEX 0xDD
// 0xDE - 0xDF Reserved
#define KEY_CTRL 0xE0 // Convenience
#define KEY_LCTRL 0xE0
#define KEY_SHIFT 0xE1 // Convenience
#define KEY_LSHIFT 0xE1
#define KEY_ALT 0xE2 // Convenience
#define KEY_LALT 0xE2
#define KEY_GUI 0xE3 // Convenience
#define KEY_LGUI 0xE3
#define KEY_RCTRL 0xE4
#define KEY_RSHIFT 0xE5
#define KEY_RALT 0xE6
#define KEY_RGUI 0xE7
// 0xE8 - 0xFFFF Reserved
// Except for 0xE0-0xE7 which are DV (Dynamic Flags), all Keycodes are Sel (Selectors).
// List of LED codes - USB HID 1.11 pg 61
// LED/Indicators are defined as:
// OOC - On/Off Control
// US - Usage Indicator: 1 - In Use, 0 - Not In Use
// UM - Usage Multi Mode Indicator Collection of 1 or more indicators: On, Flash, Slow Blink, Fast Blink, Off
// Sel - Selector
// DV - Dynamic Flag
#define LED_UNDEFINED 0x00
#define LED_NUM_LOCK 0x01 // OOC
#define LED_CAPS_LOCK 0x02 // OOC
#define LED_SCROLL_LOCK 0x03 // OOC
#define LED_COMPOSE 0x04 // OOC
#define LED_KANA 0x05 // OOC
#define LED_POWER 0x06 // OOC
#define LED_SHIFT 0x07 // OOC
#define LED_DO_NOT_DISTURB 0x08 // OOC
#define LED_MUTE 0x09 // OOC
#define LED_TONE_ENABLE 0x0A // OOC
#define LED_HIGHCUT_FILTER 0x0B // OOC
#define LED_LOWCUT_FILTER 0x0C // OOC
#define LED_EQL_ENABLE 0x0D // OOC
#define LED_SND_FLD_ON 0x0E // OOC
#define LED_SURROUND_ON 0x0F // OOC
#define LED_REPEAT 0x10 // OOC
#define LED_STEREO 0x11 // OOC
#define LED_SAMPLE_RT_DET 0x12 // OOC
#define LED_SPINNING 0x13 // OOC
#define LED_CAV 0x14 // OOC
#define LED_CLV 0x15 // OOC
#define LED_REC_FMT_DET 0x16 // OOC
#define LED_OFF_HOOK 0x17 // OOC
#define LED_RING 0x18 // OOC
#define LED_MSG_WAITING 0x19 // OOC
#define LED_DATA_MODE 0x1A // OOC
#define LED_BAT_OPERATION 0x1B // OOC
#define LED_BAT_OK 0x1C // OOC
#define LED_BAT_LOW 0x1D // OOC
#define LED_SPEAKER 0x1E // OOC
#define LED_HEAD_SET 0x1F // OOC
#define LED_HOLD 0x20 // OOC
#define LED_MICROPHONE 0x21 // OOC
#define LED_COVERAGE 0x22 // OOC
#define LED_NIGHT_MODE 0x23 // OOC
#define LED_SEND_CALLS 0x24 // OOC
#define LED_CALL_PICKUP 0x25 // OOC
#define LED_CONFERENCE 0x26 // OOC
#define LED_STAND_BY 0x27 // OOC
#define LED_CAMERA_ON 0x28 // OOC
#define LED_CAMERA_OFF 0x29 // OOC
#define LED_ON_LINE 0x2A // OOC
#define LED_OFF_LINE 0x2B // OOC
#define LED_BUSY 0x2C // OOC
#define LED_READY 0x2D // OOC
#define LED_PAPER_OUT 0x2E // OOC
#define LED_PAPER_JAM 0x2F // OOC
#define LED_REMOTE 0x30 // OOC
#define LED_FORWARD 0x31 // OOC
#define LED_REVERSE 0x32 // OOC
#define LED_STOP 0x33 // OOC
#define LED_REWIND 0x34 // OOC
#define LED_FAST_FORWARD 0x35 // OOC
#define LED_PLAY 0x36 // OOC
#define LED_PAUSE 0x37 // OOC
#define LED_RECORD 0x38 // OOC
#define LED_ERROR 0x39 // OOC
#define LED_USI 0x3A // US
#define LED_UIUI 0x3B // US
#define LED_UMMI 0x3C // UM
#define LED_IND_ON 0x3D // Sel
#define LED_IND_FLASH 0x3E // Sel
#define LED_IND_SLOW_BLNK 0x3F // Sel
#define LED_IND_FAST_BLNK 0x40 // Sel
#define LED_IND_OFF 0x41 // Sel
#define LED_FLASH_ON_TIME 0x42 // DV
#define LED_SLW_B_ON_TIME 0x43 // DV
#define LED_SLW_B_OFF_TIME 0x44 // DV
#define LED_FST_B_ON_TIME 0x45 // DV
#define LED_FST_B_OFF_TIME 0x46 // DV
#define LED_UIC 0x47 // UM
#define LED_IND_RED 0x48 // Sel
#define LED_IND_GREEN 0x49 // Sel
#define LED_IND_AMBER 0x4A // Sel
#define LED_GENERIC_IND 0x4B // OOC
#define LED_SYS_SUSPEND 0x4C // OOC
#define LED_EXT_PWR_CONN 0x4D // OOC
// 0x4E - 0xFFFF Reserved
// List of Mouse Buttons - USB HID 1.11 pg 67
#define MOUSE_NOPRESS 0x00
#define MOUSE_PRIMARY 0x01 // Button 1
#define MOUSE_SECONDARY 0x02 // Button 2
#define MOUSE_TERTIARY 0x03 // Button 3
#define MOUSE_BUTTON(x) x
// Continues to 0xFFFF, the higher the Mouse code, the selector significance descreases
// Buttons can be defined as:
// Sel - Selector
// OOC - On/Off Control
// MC - Momentary Control
// OSC - One-Shot Control
// depending on context.
#endif

View File

@ -1,6 +1,6 @@
###| CMake Kiibohd Controller Macro Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
@ -14,7 +14,8 @@
message( AUTHOR_WARNING
"The 'basic' macro module was originally designed for matrix scanning designs,
it was found not to be scalable with NKRO keyboard converters.
It has also not been tested in a long time, use at your own risk."
It has also not been tested in a (very) long time, use at your own risk.
It is older than the deprecated 'buffer' macro module."
)

View File

@ -1,12 +1,22 @@
###| CMake Kiibohd Controller Macro Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
###
###
# Warning, this module has been deprecated
#
message( AUTHOR_WARNING
"The 'buffer' macro module has been deprecated in favour of 'Partial Map'.
This module may or may not compile/function properly.
It has been kept for historical purposes."
)
###
# Module C files
#

View File

@ -98,7 +98,7 @@ volatile uint8_t USBKeys_LEDs = 0;
// ----- Functions -----
// USB Module Setup
inline void output_setup()
inline void Output_setup()
{
// Initialize the USB, and then wait for the host to set configuration.
// If the Teensy is powered without a PC connected to the USB port,
@ -106,8 +106,8 @@ inline void output_setup()
usb_init();
while ( !usb_configured() ) /* wait */ ;
// Register USB Output dictionary
registerDictionary_cli( outputCLIDict, outputCLIDictName );
// Register USB Output CLI dictionary
CLI_registerDictionary( outputCLIDict, outputCLIDictName );
// Wait an extra second for the PC's operating system to load drivers
// and do whatever it does to actually be ready for input
@ -116,7 +116,7 @@ inline void output_setup()
// USB Data Send
inline void output_send(void)
inline void Output_send(void)
{
// TODO undo potentially old keys
for ( uint8_t c = USBKeys_Sent; c < USBKeys_MaxSize; c++ )
@ -130,12 +130,12 @@ inline void output_send(void)
USBKeys_Sent = 0;
// Signal Scan Module we are finishedA
scan_finishedWithUSBBuffer( USBKeys_Sent <= USBKeys_MaxSize ? USBKeys_Sent : USBKeys_MaxSize );
Scan_finishedWithUSBBuffer( USBKeys_Sent <= USBKeys_MaxSize ? USBKeys_Sent : USBKeys_MaxSize );
}
// Sets the device into firmware reload mode
inline void output_firmwareReload()
inline void Output_firmwareReload()
{
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
usb_debug_reload();
@ -146,14 +146,14 @@ inline void output_firmwareReload()
// USB Input buffer available
inline unsigned int output_availablechar()
inline unsigned int Output_availablechar()
{
return usb_serial_available();
}
// USB Get Character from input buffer
inline int output_getchar()
inline int Output_getchar()
{
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
// XXX Make sure to check output_availablechar() first! Information is lost with the cast (error codes)
@ -165,14 +165,14 @@ inline int output_getchar()
// USB Send Character to output buffer
inline int output_putchar( char c )
inline int Output_putchar( char c )
{
return usb_serial_putchar( c );
}
// USB Send String to output buffer, null terminated
inline int output_putstr( char* str )
inline int Output_putstr( char* str )
{
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
uint16_t count = 0;
@ -188,7 +188,7 @@ inline int output_putstr( char* str )
// Soft Chip Reset
inline void output_softReset()
inline void Output_softReset()
{
#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
usb_debug_software_reset();
@ -232,7 +232,7 @@ void cliFunc_setKeys( char* args )
for ( USBKeys_SentCLI = 0; USBKeys_SentCLI < USBKeys_MaxSize; ++USBKeys_SentCLI )
{
curArgs = arg2Ptr;
argumentIsolation_cli( curArgs, &arg1Ptr, &arg2Ptr );
CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
// Stop processing args if no more are found
if ( *arg1Ptr == '\0' )
@ -250,7 +250,7 @@ void cliFunc_setLEDs( char* args )
// NOTE: Only first argument is used
char* arg1Ptr;
char* arg2Ptr;
argumentIsolation_cli( args, &arg1Ptr, &arg2Ptr );
CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
USBKeys_LEDs = decToInt( arg1Ptr );
}
@ -262,7 +262,7 @@ void cliFunc_setMod( char* args )
// NOTE: Only first argument is used
char* arg1Ptr;
char* arg2Ptr;
argumentIsolation_cli( args, &arg1Ptr, &arg2Ptr );
CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
USBKeys_ModifiersCLI = decToInt( arg1Ptr );
}

View File

@ -41,7 +41,8 @@
// ----- Variables -----
// Variables used to communciate to the usb module
// Variables used to communciate to the output module
// XXX Even if the output module is not USB, this is internally understood keymapping scheme
extern uint8_t USBKeys_Modifiers;
extern uint8_t USBKeys_Array[USB_MAX_KEY_SEND];
extern uint8_t USBKeys_Sent;
@ -58,18 +59,18 @@ extern uint8_t USBKeys_Idle_Count;
// ----- Functions -----
void output_setup();
void output_send();
void Output_setup();
void Output_send();
void output_firmwareReload();
void output_softReset();
void Output_firmwareReload();
void Output_softReset();
// Relies on USB serial module
unsigned int output_availablechar();
unsigned int Output_availablechar();
int output_getchar();
int output_putchar( char c );
int output_putstr( char* str );
int Output_getchar();
int Output_putchar( char c );
int Output_putstr( char* str );
#endif

View File

@ -1,15 +1,15 @@
/* Copyright (C) 2012 by Jacob Alexander
*
/* Copyright (C) 2012,2014 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -43,11 +43,6 @@
// ----- Macros -----
// Make sure we haven't overflowed the buffer
#define bufferAdd(byte) \
if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
// ----- Variables -----
@ -176,7 +171,7 @@ void processKeyValue( uint8_t keyValue )
// Key isn't in the buffer yet
if ( c == KeyIndex_BufferUsed )
{
bufferAdd( keyValue );
Macro_bufferAdd( keyValue );
// Only send data if enabled
if ( KeyIndex_Add_InputSignal )
@ -222,7 +217,7 @@ void removeKeyValue( uint8_t keyValue )
}
}
// Send data
// Send data
uint8_t scan_sendData( uint8_t dataPayload )
{
// Enable the USART Transmitter
@ -245,12 +240,12 @@ uint8_t scan_sendData( uint8_t dataPayload )
}
// Signal KeyIndex_Buffer that it has been properly read
void scan_finishedWithBuffer( uint8_t sentKeys )
void Scan_finishedWithBuffer( uint8_t sentKeys )
{
}
// Signal that the keys have been properly sent over USB
void scan_finishedWithUSBBuffer( uint8_t sentKeys )
void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
{
}

View File

@ -1,15 +1,15 @@
/* Copyright (C) 2012 by Jacob Alexander
*
/* Copyright (C) 2012,2014 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -49,18 +49,18 @@ extern volatile uint8_t KeyIndex_Add_InputSignal;
// ----- Functions -----
// Functions used by main.c
void scan_setup( void );
uint8_t scan_loop( void );
void Scan_setup( void );
uint8_t Scan_loop( void );
// Functions available to macro.c
uint8_t scan_sendData( uint8_t dataPayload );
uint8_t Scan_sendData( uint8_t dataPayload );
void scan_finishedWithBuffer( uint8_t sentKeys );
void scan_finishedWithUSBBuffer( uint8_t sentKeys );
void scan_lockKeyboard( void );
void scan_unlockKeyboard( void );
void scan_resetKeyboard( void );
void Scan_finishedWithBuffer( uint8_t sentKeys );
void Scan_finishedWithUSBBuffer( uint8_t sentKeys );
void Scan_lockKeyboard( void );
void Scan_unlockKeyboard( void );
void Scan_resetKeyboard( void );
#endif // __SCAN_LOOP_H

View File

@ -1,6 +1,6 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#
@ -18,33 +18,9 @@ set( SCAN_SRCS
)
###
# Module H files
#
set( SCAN_HDRS
scan_loop.h
)
###
# File Dependency Setup
#
ADD_FILE_DEPENDENCIES( scan_loop.c ${SCAN_HDRS} )
#add_file_dependencies( scan_loop.c ${SCAN_HDRS} )
#add_file_dependencies( macro.c keymap.h microswitch8304.h )
###
# Module Specific Options
#
add_definitions( -I${HEAD_DIR}/Keymap )
#| Keymap Settings
add_definitions(
-DMODIFIER_MASK=betkb_ModifierMask
-DKEYINDEX_MASK=betkb_ColemakMap
#-DKEYINDEX_MASK=betkb_DefaultMap
)
###

View File

@ -1,6 +1,6 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2011 for the Kiibohd Controller
# Written by Jacob Alexander in 2011,2014 for the Kiibohd Controller
#
# Released into the Public Domain
#