Browse Source

Adding initial FACOM template, and buildall.bash regression script.

simple
Jacob Alexander 11 years ago
parent
commit
94390571c4
7 changed files with 759 additions and 2 deletions
  1. 296
    0
      Keymap/facom6684.h
  2. 1
    0
      Keymap/keymap.h
  3. 276
    0
      Scan/FACOM6684/scan_loop.c
  4. 67
    0
      Scan/FACOM6684/scan_loop.h
  5. 48
    0
      Scan/FACOM6684/setup.cmake
  6. 60
    0
      buildall.bash
  7. 11
    2
      setup.cmake

+ 296
- 0
Keymap/facom6684.h View File

@@ -0,0 +1,296 @@
/* Copyright (C) 2013 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 __FACOM6684_H
#define __FACOM6684_H

// This file contains various key layouts for the Fujitsu FACOM 6684KC3 Supercomputer Terminal Keyboard


// ----- Variables -----
static uint8_t facom6684_ModifierMask[] = { 0x20, 0x2D, 0x2E, 0x30, 0x3E, 0x60 };

static uint8_t facom6684_DefaultMap[] = {
0, // 0x00
0, // 0x01
0, // 0x02
0, // 0x03
0, // 0x04
0, // 0x05
0, // 0x06
0, // 0x07
0, // 0x08
0, // 0x09
0, // 0x0A
0, // 0x0B
0, // 0x0C
0, // 0x0D
0, // 0x0E
0, // 0x0F
0, // 0x10
0, // 0x11
0, // 0x12
0, // 0x13
0, // 0x14
0, // 0x15
0, // 0x16
0, // 0x17
0, // 0x18
0, // 0x19
0, // 0x1A
0, // 0x1B
0, // 0x1C
0, // 0x1D
0, // 0x1E
0, // 0x1F
KEY_LEFT_SHIFT, // 0x20
0, // 0x21
KEY_Z, // 0x22
KEY_X, // 0x23
KEY_C, // 0x24
KEY_V, // 0x25
KEY_B, // 0x26
KEY_N, // 0x27
KEY_M, // 0x28
KEY_COMMA, // 0x29
KEY_PERIOD, // 0x2A
KEY_SLASH, // 0x2B
0, // 0x2C
KEY_RIGHT_SHIFT, // 0x2D
KEY_LEFT_ALT, // 0x2E
KEY_SPACE, // 0x2F
KEY_LEFT_CTRL, // 0x30
KEY_A, // 0x31
KEY_S, // 0x32
KEY_D, // 0x33
KEY_F, // 0x34
KEY_G, // 0x35
KEY_H, // 0x36
KEY_J, // 0x37
KEY_K, // 0x38
KEY_L, // 0x39
KEY_SEMICOLON, // 0x3A
KEY_QUOTE, // 0x3B
0, // 0x3C
KEY_ENTER, // 0x3D
KEY_RIGHT_GUI, // 0x3E
KEY_LEFT, // 0x3F (KEYPAD_1)
KEY_TAB, // 0x40
KEY_Q, // 0x41
KEY_W, // 0x42
KEY_E, // 0x43
KEY_R, // 0x44
KEY_T, // 0x45
KEY_Y, // 0x46
KEY_U, // 0x47
KEY_I, // 0x48
KEY_O, // 0x49
KEY_P, // 0x4A
KEY_LEFT_BRACE, // 0x4B
KEY_RIGHT_BRACE, // 0x4C
KEY_BACKSLASH, // 0x4D
KEY_DELETE, // 0x4E
KEYPAD_4, // 0x4F
KEY_ESC, // 0x50
KEY_1, // 0x51
KEY_2, // 0x52
KEY_3, // 0x53
KEY_4, // 0x54
KEY_5, // 0x55
KEY_6, // 0x56
KEY_7, // 0x57
KEY_8, // 0x58
KEY_9, // 0x59
KEY_0, // 0x5A
KEY_MINUS, // 0x5B
KEY_EQUAL, // 0x5C
KEY_TILDE, // 0x5D
KEY_BACKSPACE, // 0x5E
KEY_NUM_LOCK, // 0x5F
KEY_LEFT_GUI, // 0x60
KEY_HOME, // 0x61
KEY_END, // 0x62
KEY_INSERT, // 0x63
KEY_DELETE, // 0x64
KEY_F1, // 0x65
KEY_F2, // 0x66
KEY_F3, // 0x67
KEY_F4, // 0x68
KEY_F5, // 0x69
KEY_F6, // 0x6A
KEY_F7, // 0x6B
KEY_F8, // 0x6C
KEY_F9, // 0x6D
KEY_F10, // 0x6E
KEY_PRINTSCREEN, // 0x6F
KEY_PAGE_UP, // 0x70
KEY_PAGE_DOWN, // 0x71
KEY_F11, // 0x72
KEYPAD_7, // 0x73
KEYPAD_8, // 0x74
KEYPAD_9, // 0x75
KEY_UP, // 0x76 (KEYPAD_5)
KEYPAD_6, // 0x77
KEY_DOWN, // 0x78 (KEYPAD_2)
KEY_RIGHT, // 0x79 (KEYPAD_3)
KEYPAD_0, // 0x7A
KEYPAD_00, // 0x7B
KEYPAD_ENTER, // 0x7C
0, // 0x7D
0, // 0x7E
0, // 0x7F
};

static uint8_t facom6684_ColemakMap[] = {
0, // 0x00
0, // 0x01
0, // 0x02
0, // 0x03
0, // 0x04
0, // 0x05
0, // 0x06
0, // 0x07
0, // 0x08
0, // 0x09
0, // 0x0A
0, // 0x0B
0, // 0x0C
0, // 0x0D
0, // 0x0E
0, // 0x0F
0, // 0x10
0, // 0x11
0, // 0x12
0, // 0x13
0, // 0x14
0, // 0x15
0, // 0x16
0, // 0x17
0, // 0x18
0, // 0x19
0, // 0x1A
0, // 0x1B
0, // 0x1C
0, // 0x1D
0, // 0x1E
0, // 0x1F
KEY_LEFT_SHIFT, // 0x20
0, // 0x21
KEY_Z, // 0x22
KEY_X, // 0x23
KEY_C, // 0x24
KEY_V, // 0x25
KEY_B, // 0x26
KEY_K, // 0x27
KEY_M, // 0x28
KEY_COMMA, // 0x29
KEY_PERIOD, // 0x2A
KEY_SLASH, // 0x2B
0, // 0x2C
KEY_RIGHT_SHIFT, // 0x2D
KEY_LEFT_ALT, // 0x2E
KEY_SPACE, // 0x2F
KEY_LEFT_CTRL, // 0x30
KEY_A, // 0x31
KEY_R, // 0x32
KEY_S, // 0x33
KEY_T, // 0x34
KEY_D, // 0x35
KEY_H, // 0x36
KEY_N, // 0x37
KEY_E, // 0x38
KEY_I, // 0x39
KEY_O, // 0x3A
KEY_QUOTE, // 0x3B
0, // 0x3C
KEY_ENTER, // 0x3D
KEY_RIGHT_GUI, // 0x3E
KEY_LEFT, // 0x3F (KEYPAD_1)
KEY_TAB, // 0x40
KEY_Q, // 0x41
KEY_W, // 0x42
KEY_F, // 0x43
KEY_P, // 0x44
KEY_G, // 0x45
KEY_J, // 0x46
KEY_L, // 0x47
KEY_U, // 0x48
KEY_Y, // 0x49
KEY_SEMICOLON, // 0x4A
KEY_LEFT_BRACE, // 0x4B
KEY_RIGHT_BRACE, // 0x4C
KEY_BACKSLASH, // 0x4D
KEY_DELETE, // 0x4E
KEYPAD_4, // 0x4F
KEY_ESC, // 0x50
KEY_1, // 0x51
KEY_2, // 0x52
KEY_3, // 0x53
KEY_4, // 0x54
KEY_5, // 0x55
KEY_6, // 0x56
KEY_7, // 0x57
KEY_8, // 0x58
KEY_9, // 0x59
KEY_0, // 0x5A
KEY_MINUS, // 0x5B
KEY_EQUAL, // 0x5C
KEY_TILDE, // 0x5D
KEY_BACKSPACE, // 0x5E
KEY_NUM_LOCK, // 0x5F
KEY_LEFT_GUI, // 0x60
KEY_HOME, // 0x61
KEY_END, // 0x62
KEY_INSERT, // 0x63
KEY_DELETE, // 0x64
KEY_F1, // 0x65
KEY_F2, // 0x66
KEY_F3, // 0x67
KEY_F4, // 0x68
KEY_F5, // 0x69
KEY_F6, // 0x6A
KEY_F7, // 0x6B
KEY_F8, // 0x6C
KEY_F9, // 0x6D
KEY_F10, // 0x6E
KEY_PRINTSCREEN, // 0x6F
KEY_PAGE_UP, // 0x70
KEY_PAGE_DOWN, // 0x71
KEY_F11, // 0x72
KEYPAD_7, // 0x73
KEYPAD_8, // 0x74
KEYPAD_9, // 0x75
KEY_UP, // 0x76 (KEYPAD_5)
KEYPAD_6, // 0x77
KEY_DOWN, // 0x78 (KEYPAD_2)
KEY_RIGHT, // 0x79 (KEYPAD_3)
KEYPAD_0, // 0x7A
KEYPAD_00, // 0x7B
KEYPAD_ENTER, // 0x7C
0, // 0x7D
0, // 0x7E
0, // 0x7F
};



#endif


+ 1
- 0
Keymap/keymap.h View File

@@ -44,6 +44,7 @@
#include "betkb.h"
#include "budkeypad.h"
#include "epsonqx10.h"
#include "facom6684.h"
#include "heathzenith.h"
#include "hp150.h"
#include "ibmconvertible.h"

+ 276
- 0
Scan/FACOM6684/scan_loop.c View File

@@ -0,0 +1,276 @@
/* Copyright (C) 2013 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 -----

// AVR Includes
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>

// Project Includes
#include <led.h>
#include <print.h>

// Local Includes
#include "scan_loop.h"



// ----- Defines -----

// Pinout Defines
#define HOLD_PORT PORTD
#define HOLD_DDR DDRD
#define HOLD_PIN 3


// ----- Macros -----

// Make sure we haven't overflowed the buffer
#define bufferAdd(byte) \
if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte



// ----- 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;
volatile uint8_t KeyIndex_Add_InputSignal; // Used to pass the (click/input value) to the keyboard for the clicker


// Buffer Signals
volatile uint8_t BufferReadyToClear;



// ----- Function Declarations -----

void processKeyValue( uint8_t keyValue );
void removeKeyValue( uint8_t keyValue );



// ----- Interrupt Functions -----

// USART Receive Buffer Full Interrupt
ISR(USART1_RX_vect)
{
cli(); // Disable Interrupts

uint8_t keyValue = 0x00;
uint8_t keyState = 0x00;

// Read the scancode packet from the USART (1st to 8th bits)
keyValue = UDR1;

// Read the release/press bit (9th bit) XXX Unnecessary, and wrong it seems, parity bit? or something else?
keyState = UCSR1B & 0x02;

// High bit of keyValue, also represents press/release
keyState = keyValue & 0x80 ? 0x00 : 0x02;

// Debug
char tmpStr[6];
hexToStr( keyValue & 0x7F, tmpStr );

// Process the scancode
switch ( keyState )
{
case 0x00: // Released
dPrintStrs( tmpStr, "R " ); // Debug

// Remove key from press buffer
removeKeyValue( keyValue & 0x7F );
break;

case 0x02: // Pressed
dPrintStrs( tmpStr, "P " ); // Debug

// New key to process
processKeyValue( keyValue & 0x7F );
break;
}

sei(); // Re-enable Interrupts
}



// ----- Functions -----

// Setup
inline void scan_setup()
{
// Setup the the USART interface for keyboard data input
// NOTE: The input data signal needs to be inverted for the Teensy USART to properly work
// Setup baud rate
// 16 MHz / ( 16 * Baud ) = UBRR
// Baud <- 0.823284 ms per bit, thus 1000 / 0.823284 = 1214.65004 -> 823.2824
// Thus baud setting = 823
uint16_t baud = 823; // Max setting of 4095
UBRR1H = (uint8_t)(baud >> 8);
UBRR1L = (uint8_t)baud;

// Enable the receiver, and RX Complete Interrupt as well as 9 bit data
UCSR1B = 0x94;

// The transmitter is only to be enabled when needed
// Set the pin to be pull-up otherwise (use the lowered voltage inverter in order to sink)
HOLD_DDR &= ~(1 << HOLD_PIN);
HOLD_PORT |= (1 << HOLD_PIN);

// Set frame format: 9 data, 1 stop bit, no parity
// Asynchrounous USART mode
UCSR1C = 0x06;

// Initially buffer doesn't need to be cleared (it's empty...)
BufferReadyToClear = 0;

// InputSignal is off by default
KeyIndex_Add_InputSignal = 0x00;

// Reset the keyboard before scanning, we might be in a wierd state
scan_resetKeyboard();
}


// Main Detection Loop
// Not needed for the BETKB, this is just a busy loop
inline uint8_t scan_loop()
{
return 0;
}

void processKeyValue( uint8_t keyValue )
{
// Interpret scan code
switch ( keyValue )
{
case 0x00: // Break code from input?
break;
default:
// Make sure the key isn't already in the buffer
for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
{
// Key isn't in the buffer yet
if ( c == KeyIndex_BufferUsed )
{
bufferAdd( keyValue );

// Only send data if enabled
if ( KeyIndex_Add_InputSignal )
scan_sendData( KeyIndex_Add_InputSignal );
break;
}

// Key already in the buffer
if ( KeyIndex_Buffer[c] == keyValue )
break;
}
break;
}
}

void removeKeyValue( uint8_t keyValue )
{
// Check for the released key, and shift the other keys lower on the buffer
uint8_t c;
for ( c = 0; c < KeyIndex_BufferUsed; c++ )
{
// Key to release found
if ( KeyIndex_Buffer[c] == keyValue )
{
// Shift keys from c position
for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];

// Decrement Buffer
KeyIndex_BufferUsed--;

break;
}
}

// Error case (no key to release)
if ( c == KeyIndex_BufferUsed + 1 )
{
errorLED( 1 );
char tmpStr[6];
hexToStr( keyValue, tmpStr );
erro_dPrint( "Could not find key to release: ", tmpStr );
}
}

// Send data
uint8_t scan_sendData( uint8_t dataPayload )
{
// Enable the USART Transmitter
UCSR1B |= (1 << 3);

// Debug
char tmpStr[6];
hexToStr( dataPayload, tmpStr );
info_dPrint( "Sending - ", tmpStr );

UDR1 = dataPayload;

// Wait for the payload
_delay_us( 800 );

// Disable the USART Transmitter
UCSR1B &= ~(1 << 3);

return 0;
}

// Signal KeyIndex_Buffer that it has been properly read
void scan_finishedWithBuffer( void )
{
}

// Signal that the keys have been properly sent over USB
void scan_finishedWithUSBBuffer( void )
{
}

// Reset/Hold keyboard
// NOTE: Does nothing with the BETKB
void scan_lockKeyboard( void )
{
}

// NOTE: Does nothing with the BETKB
void scan_unlockKeyboard( void )
{
}

// Reset Keyboard
void scan_resetKeyboard( void )
{
// Not a calculated valued...
_delay_ms( 50 );
}


+ 67
- 0
Scan/FACOM6684/scan_loop.h View File

@@ -0,0 +1,67 @@
/* Copyright (C) 2013 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 __SCAN_LOOP_H
#define __SCAN_LOOP_H

// ----- Includes -----

// Compiler Includes
#include <stdint.h>

// Local Includes



// ----- Defines -----

#define KEYBOARD_SIZE 0x7F // 127 - Size of the array space for the keyboard(max index)
#define KEYBOARD_BUFFER 24 // Max number of key signals to buffer



// ----- Variables -----

extern volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
extern volatile uint8_t KeyIndex_BufferUsed;
extern volatile uint8_t KeyIndex_Add_InputSignal;



// ----- Functions -----

// Functions used by main.c
void scan_setup( void );
uint8_t scan_loop( void );


// Functions available to macro.c
uint8_t scan_sendData( uint8_t dataPayload );

void scan_finishedWithBuffer( void );
void scan_finishedWithUSBBuffer( void );
void scan_lockKeyboard( void );
void scan_unlockKeyboard( void );
void scan_resetKeyboard( void );


#endif // __SCAN_LOOP_H


+ 48
- 0
Scan/FACOM6684/setup.cmake View File

@@ -0,0 +1,48 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2013 for the Kiibohd Controller
#
# Released into the Public Domain
#
# For the Fujitsu FACOM 6684KC3 Supercomputer Terminal Keyboard (M-780, M-1800, etc.)
#
###


###
# Module C files
#

set( SCAN_SRCS
scan_loop.c
)


###
# 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 facom6684.h )


###
# Module Specific Options
#
add_definitions( -I${HEAD_DIR}/Keymap )

#| Keymap Settings
add_definitions(
-DMODIFIER_MASK=facom6684_ModifierMask
-DKEYINDEX_MASK=facom6684_ColemakMap
#-DKEYINDEX_MASK=facom6684_DefaultMap
)


+ 60
- 0
buildall.bash View File

@@ -0,0 +1,60 @@
#!/bin/bash
###| Builder Script |###
#
# Builds all permutations of modules
# This script is an attempt to maintain module sanity as new ones are added
#
# Fortunately, sweeping API changes don't happen much anymore...but just in case...
#
# Written by Jacob Alexander 2013 for the Kiibohd Controller
# Released into the Public Domain
#
###

## TODO List ##
# - Complete non-Scan module permutations (will take extra work)
# - Add command line arguments
# - Add help flag for usage
# - Make sure the script is being run from the correct directory


main() {
ERROR="\e[5;1;31mERROR\e[0m:"
failCount=0

# Scan for list of Scan Modules
scanModules=$(ls Scan)

# Prune out "invalid" modules (parent modules)
scanModules=${scanModules[@]//matrix/}

# Create permutation directories
# Then run cmake, and run each build permutation
# Keeping track of how many builds failed/passed
for module in $scanModules; do
# Create directory, but do not error if it exists already
mkdir -p build/$module
cd build/$module

# Make sure CMake has been run, and attempt to build
cmake -DScanModuleOverride=$module ../.. && make || let failCount++

# Cleanup, for the next build
cd -
done

totalModules=$(echo $scanModules | wc -w)
if (( failCount > 0 )); then
echo -e "$ERROR $failCount/$totalModules failed"
else
echo -e "Build Success!"
fi
}


#| Main Script Entry
main "$@"


exit 0


+ 11
- 2
setup.cmake View File

@@ -1,6 +1,6 @@
###| CMAKE Kiibohd Controller Source Configurator |###
#
# Written by Jacob Alexander in 2011-2012 for the Kiibohd Controller
# Written by Jacob Alexander in 2011-2013 for the Kiibohd Controller
#
# Released into the Public Domain
#
@@ -20,7 +20,7 @@
#| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones

##| Deals with acquiring the keypress information and turning it into a key index
set( ScanModule "HP150" )
set( ScanModule "FACOM6684" )

##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
set( MacroModule "buffer" )
@@ -34,6 +34,15 @@ set( DebugModule "full" )



###
# Module Overrides (Used in the buildall.bash script)
#
if ( EXISTS ${PROJECT_SOURCE_DIR}/Scan/${ScanModuleOverride} )
set( ScanModule ${ScanModuleOverride} )
endif ( EXISTS ${PROJECT_SOURCE_DIR}/Scan/${ScanModuleOverride} )



###
# Path Setup
#