ソースを参照

Added layerList and layerState functions

- Added LayerIndex data structure
simple
Jacob Alexander 9年前
コミット
8193687d29
2個のファイルの変更134行の追加16行の削除
  1. 63
    4
      Macro/PartialMap/generatedKeymap.h
  2. 71
    12
      Macro/PartialMap/macro.c

+ 63
- 4
Macro/PartialMap/generatedKeymap.h ファイルの表示

@@ -172,6 +172,9 @@ Guide_RM( 1 ) = { 1, 0, 0xBE, 1, 0, 0xEF, 0 };
Guide_RM( 2 ) = { 2, 0, 0xFA, 0, 0xAD, 0 };
Guide_RM( 3 ) = { 1, 1, 0xCA, 0xFE, 0 };


// -- Result Macro List

// Total number of result macros (rm's)
// Used to create pending rm's table
#define ResultMacroNum sizeof( ResultMacroList ) / sizeof( ResultMacro )
@@ -203,6 +206,9 @@ Guide_TM( 1 ) = { 1, 0x0F, 0x01, 0x73, 1, 0x00, 0x01, 0x75, 0 };
Guide_TM( 2 ) = { 2, 0xF0, 0x01, 0x73, 0x00, 0x01, 0x74, 0 };
Guide_TM( 3 ) = { 1, 0x10, 0x01, 0x76, 0 };


// -- Trigger Macro List

// Total number of trigger macros (tm's)
// Used to create pending tm's table
#define TriggerMacroNum sizeof( TriggerMacroList ) / sizeof( TriggerMacro )
@@ -497,11 +503,15 @@ Define_TL( default, 0xFF ) = { 0 };


// myname Layer
// TODO
Define_TL( myname, 0x05 ) = { 0 };
Define_TL( myname, 0x06 ) = { 0 };
Define_TL( myname, 0x07 ) = { 0 };


// myname2 Layer
// TODO
Define_TL( myname2, 0x04 ) = { 0 };
Define_TL( myname2, 0x05 ) = { 0 };
Define_TL( myname2, 0x06 ) = { 0 };


// -- ScanCode Indexed Maps
@@ -523,14 +533,63 @@ default_tl_0x00, default_tl_0x01, default_tl_0x02, default_tl_0x03, default_tl_0
};

// Layer <name> for ScanCode Lookup
static unsigned int myname_scanMap[] = {
static unsigned int *myname_scanMap[] = {
0, 0, 0, 0, myname_tl_0x05, myname_tl_0x06, myname_tl_0x07
};

// Layer <name> for ScanCode Lookup
static unsigned int myname2_scanMap[] = {
static unsigned int *myname2_scanMap[] = {
0, 0, 0, myname2_tl_0x04, myname2_tl_0x05, myname2_tl_0x06
};



// ----- Layer Index -----

// Defines each map of trigger macro lists
// Layer 0 is always the default map
// Layer States:
// * Off - 0x00
// * Shift - 0x01
// * Latch - 0x02
// * Lock - 0x04
//
// Except for Off, all states an exist simultaneously for each layer
// For example:
// state -> 0x04 + 0x01 = 0x05 (Shift + Lock), which is effectively Off (0x00)
//
// Max defines the maximum number of keys in the map, maximum of 0xFF
// - Compiler calculates this
//
// The name is defined for cli debugging purposes (Null terminated string)

typedef struct Layer {
unsigned int **triggerMap;
char *name;
uint8_t max;
uint8_t state;
} Layer;


// Layer_IN( map, name );
// * map - Trigger map
// * name - Name of the trigger map
#define Layer_IN( map, name ) { map, name, sizeof( map ) / 4 - 1, 0 }

// -- Layer Index List
//
// Index 0: Default map
// Index n: Additional layers
Layer LayerIndex[] = {
Layer_IN( default_scanMap, "DefaultMap" ),
Layer_IN( myname_scanMap, "myname" ),
Layer_IN( myname2_scanMap, "myname2" ),
};

// Total number of layers
#define LayerNum sizeof( LayerIndex ) / sizeof( Layer )



#endif // __generatedKeymap_h


+ 71
- 12
Macro/PartialMap/macro.c ファイルの表示

@@ -42,9 +42,8 @@ void cliFunc_capList ( char* args );
void cliFunc_capSelect ( char* args );
void cliFunc_keyPress ( char* args );
void cliFunc_keyRelease( char* args );
void cliFunc_layerLatch( char* args );
void cliFunc_layerList ( char* args );
void cliFunc_layerLock ( char* args );
void cliFunc_layerState( char* args );
void cliFunc_macroDebug( char* args );
void cliFunc_macroList ( char* args );
void cliFunc_macroProc ( char* args );
@@ -62,9 +61,8 @@ CLIDictItem macroCLIDict[] = {
{ "capSelect", "Triggers the specified capabilities. First two args are state and stateType." NL "\t\t\033[35mK11\033[0m Keyboard Capability 0x0B", cliFunc_capSelect },
{ "keyPress", "Send key-presses to the macro module. Held until released. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyPress },
{ "keyRelease", "Release a key-press from the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyRelease },
{ "layerLatch", "Latch the specified indexed layer." NL "\t\t\033[35mL15\033[0m Indexed Layer 0x0F", cliFunc_layerLatch },
{ "layerList", "List available layers.", cliFunc_layerList },
{ "layerLock", "Lock the specified indexed layer." NL "\t\t\033[35mL2\033[0m Indexed Layer 0x02", cliFunc_layerLock },
{ "layerState", "Modify specified indexed layer state <layer> <state byte>." NL "\t\t\033[35mL2\033[0m Indexed Layer 0x02" NL "\t\t0 Off, 1 Shift, 2 Latch, 4 Lock States", cliFunc_layerState },
{ "macroDebug", "Disables/Enables sending USB keycodes to the Output Module and prints U/K codes.", cliFunc_macroDebug },
{ "macroList", "List the defined trigger and result macros.", cliFunc_macroList },
{ "macroProc", "Pause/Resume macro processing.", cliFunc_macroProc },
@@ -506,19 +504,80 @@ void cliFunc_keyRelease( char* args )
}
}

void cliFunc_layerLatch( char* args )
{
// TODO
}

void cliFunc_layerList( char* args )
{
// TODO
print( NL );
info_msg("Layer List");

// Iterate through all of the layers and display them
for ( unsigned int layer = 0; layer < LayerNum; layer++ )
{
print( NL "\t" );
printHex( layer );
print(" - ");

// Display layer name
dPrint( LayerIndex[ layer ].name );

// Default map
if ( layer == 0 )
print(" \033[1m(default)\033[0m");

// Layer State
print( NL "\t\t Layer State: " );
printHex( LayerIndex[ layer ].state );

// Max Index
print(" Max Index: ");
printHex( LayerIndex[ layer ].max );
}
}

void cliFunc_layerLock( char* args )
void cliFunc_layerState( char* args )
{
// TODO
// Parse codes from arguments
char* curArgs;
char* arg1Ptr;
char* arg2Ptr = args;

uint8_t arg1 = 0;
uint8_t arg2 = 0;

// Process first two args
for ( uint8_t c = 0; c < 2; c++ )
{
curArgs = arg2Ptr;
CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );

// Stop processing args if no more are found
if ( *arg1Ptr == '\0' )
break;

switch ( c )
{
// First argument (e.g. L1)
case 0:
if ( arg1Ptr[0] != 'L' )
return;

arg1 = (uint8_t)decToInt( &arg1Ptr[1] );
break;
// Second argument (e.g. 4)
case 1:
arg2 = (uint8_t)decToInt( arg1Ptr );

// Display operation (to indicate that it worked)
print( NL );
info_msg("Setting Layer L");
printInt8( arg1 );
print(" to - ");
printHex( arg2 );

// Set the layer state
LayerIndex[ arg1 ].state = arg2;
break;
}
}
}

void cliFunc_macroDebug( char* args )