+// Determines the current layer stack, and sets the LCD output accordingly
+// Will only work on a master node when using the interconnect (use LCD_layerStackExact_capability instead)
+uint16_t LCD_layerStack_prevSize = 0;
+uint16_t LCD_layerStack_prevTop = 0;
+void LCD_layerStack_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+ // Display capability name
+ if ( stateType == 0xFF && state == 0xFF )
+ {
+ print("LCD_layerStack_capability()");
+ return;
+ }
+
+ // Parse the layer stack, top to bottom
+ extern uint16_t macroLayerIndexStack[];
+ extern uint16_t macroLayerIndexStackSize;
+
+ // Ignore if the stack size hasn't changed and the top of the stack is the same
+ if ( macroLayerIndexStackSize == LCD_layerStack_prevSize
+ && macroLayerIndexStack[macroLayerIndexStackSize - 1] == LCD_layerStack_prevTop )
+ {
+ return;
+ }
+ LCD_layerStack_prevSize = macroLayerIndexStackSize;
+ LCD_layerStack_prevTop = macroLayerIndexStack[macroLayerIndexStackSize - 1];
+
+ LCD_layerStackExact_args stack_args;
+ memset( stack_args.layers, 0, sizeof( stack_args.layers ) );
+
+ // Use the LCD_layerStackExact_capability to set the LCD using the determined stack
+ // Construct argument set for capability
+ stack_args.numArgs = macroLayerIndexStackSize;
+ for ( uint16_t layer = 1; layer <= macroLayerIndexStackSize; layer++ )
+ {
+ stack_args.layers[ layer - 1 ] = macroLayerIndexStack[ macroLayerIndexStackSize - layer ];
+ }
+
+ // Only deal with the interconnect if it has been compiled in
+#if defined(ConnectEnabled_define)
+ if ( Connect_master )
+ {
+ // generatedKeymap.h
+ extern const Capability CapabilitiesList[];
+
+ // Broadcast layerStackExact remote capability (0xFF is the broadcast id)
+ Connect_send_RemoteCapability(
+ 0xFF,
+ LCD_layerStackExact_capability_index,
+ state,
+ stateType,
+ CapabilitiesList[ LCD_layerStackExact_capability_index ].argCount,
+ (uint8_t*)&stack_args
+ );
+ }
+#endif
+ // Call LCD_layerStackExact directly
+ LCD_layerStackExact_capability( state, stateType, (uint8_t*)&stack_args );
+}
+