X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Scan%2FDPH%2Fscan_loop.c;h=5d8d832a5cc034901e51d6597bee29a8154ccce0;hb=f57e069bb9d00b8bf59c2388a922a85d2e30ec66;hp=69d5719aee862f5bb836a3c487423a04f3dc0a70;hpb=1fd777815b465951ba558f290f9be8d7b241b95c;p=kiibohd-controller.git diff --git a/Scan/DPH/scan_loop.c b/Scan/DPH/scan_loop.c index 69d5719..5d8d832 100644 --- a/Scan/DPH/scan_loop.c +++ b/Scan/DPH/scan_loop.c @@ -1,18 +1,23 @@ -/* Copyright (C) 2011-2013 by Joseph Makuch - * Additions by Jacob Alexander (2013-2014) +/* Copyright (C) 2011-2013 by Joseph Makuch (jmakuch+f@gmail.com) + * Additions by Jacob Alexander (2013-2014) (haata@kiibohd.com) * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. + * 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: * - * This library 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 - * Lesser General Public License for more details. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * 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 ----- @@ -143,27 +148,29 @@ void recovery( uint8_t on ); // ----- Variables ----- -// Buffer used to inform the macro processing module which keys have been detected as pressed -volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER]; -volatile uint8_t KeyIndex_BufferUsed; - - // Scan Module command dictionary -char* scanCLIDictName = "DPH Module Commands"; -CLIDictItem scanCLIDict[] = { - { "echo", "Example command, echos the arguments.", cliFunc_echo }, - { "avgDebug", "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages.", cliFunc_avgDebug }, - { "keyDebug", "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin", cliFunc_keyDebug }, - { "pressDebug", "Enables/Disables short debug for each keypress.", cliFunc_pressDebug }, - { "problemKeys", "Display current list of problem keys,", cliFunc_problemKeys }, - { "senseDebug", "Prints out the current sense table N times." NL "\t\tsense:max sense:delta", cliFunc_senseDebug }, +CLIDict_Entry( echo, "Example command, echos the arguments." ); +CLIDict_Entry( avgDebug, "Enables/Disables averaging results." NL "\t\tDisplays each average, starting from Key 0x00, ignoring 0 valued averages." ); +CLIDict_Entry( keyDebug, "Enables/Disables long debug for each keypress." NL "\t\tkeycode - [strobe:mux] : sense val : threshold+delta=total : margin" ); +CLIDict_Entry( pressDebug, "Enables/Disables short debug for each keypress." ); +CLIDict_Entry( problemKeys, "Display current list of problem keys," ); +CLIDict_Entry( senseDebug, "Prints out the current sense table N times." NL "\t\tsense:max sense:delta" ); + +CLIDict_Def( scanCLIDict, "DPH Module Commands" ) = { + CLIDict_Item( echo ), + CLIDict_Item( avgDebug ), + CLIDict_Item( keyDebug ), + CLIDict_Item( pressDebug ), + CLIDict_Item( problemKeys ), + CLIDict_Item( senseDebug ), { 0, 0, 0 } // Null entry for dictionary end }; + // CLI Control Variables uint8_t enableAvgDebug = 0; uint8_t enableKeyDebug = 0; -uint8_t enablePressDebug = 1; +uint8_t enablePressDebug = 0; uint8_t senseDebugCount = 3; // In order to get boot-time oddities @@ -320,17 +327,17 @@ inline uint8_t Scan_loop() } -// Signal KeyIndex_Buffer that it has been properly read +// Signal from macro module that keys have been processed // NOTE: Only really required for implementing "tricks" in converters for odd protocols -void Scan_finishedWithBuffer( uint8_t sentKeys ) +void Scan_finishedWithMacro( uint8_t sentKeys ) { return; } -// Signal KeyIndex_Buffer that it has been properly read and sent out by the USB module +// Signal from output module that keys have been processed/sent // NOTE: Only really required for implementing "tricks" in converters for odd protocols -void Scan_finishedWithUSBBuffer( uint8_t sentKeys ) +void Scan_finishedWithOutput( uint8_t sentKeys ) { return; } @@ -607,7 +614,7 @@ void recovery( uint8_t on ) PORTD &= ~D_MASK; PORTE &= ~E_MASK; - DDRB |= (1 << RECOVERY_SINK); // SINK pull + DDRB |= (1 << RECOVERY_SINK); // SINK pull PORTB |= (1 << RECOVERY_CONTROL); PORTB |= (1 << RECOVERY_SOURCE); // SOURCE high DDRB |= (1 << RECOVERY_SOURCE); @@ -617,7 +624,7 @@ void recovery( uint8_t on ) PORTB &= ~(1 << RECOVERY_CONTROL); DDRB &= ~(1 << RECOVERY_SOURCE); PORTB &= ~(1 << RECOVERY_SOURCE); // SOURCE low - DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp + DDRB &= ~(1 << RECOVERY_SINK); // SINK high-imp } } @@ -806,22 +813,22 @@ void testColumn( uint8_t strobe ) // Initial Keypress Macro_keyState( key, 0x01 ); } - else if ( keys_debounce[key] >= DEBOUNCE_THRESHOLD ) - { - // Held Key - Macro_keyState( key, 0x02 ); - } keys_debounce[key]++; } + else if ( keys_debounce[key] >= DEBOUNCE_THRESHOLD ) + { + // Held Key + Macro_keyState( key, 0x02 ); + } // Long form key debugging if ( enableKeyDebug ) { // Debug message // [:] : : : - dbug_msg("0x"); + dbug_msg(""); printHex_op( key, 1 ); print(" ["); printInt8( strobe ); @@ -844,7 +851,7 @@ void testColumn( uint8_t strobe ) else { // Release Key - if ( KeyIndex_BufferUsed > 0 && keys_debounce[key] >= DEBOUNCE_THRESHOLD ) + if ( keys_debounce[key] >= DEBOUNCE_THRESHOLD ) { Macro_keyState( key, 0x03 ); } @@ -1027,7 +1034,7 @@ void cliFunc_senseDebug( char* args ) // If there was an argument, use that instead if ( *arg1Ptr != '\0' ) { - senseDebugCount = decToInt( arg1Ptr ); + senseDebugCount = numToInt( arg1Ptr ); } }