@@ -63,12 +63,12 @@ public override void Default()
6363 [ LayerHandlerMeta ( Name = "Razer Chroma" , IsDefault = true ) ]
6464 public class RazerLayerHandler : LayerHandler < RazerLayerHandlerProperties >
6565 {
66- private Color [ ] _keyboardColors ;
67- private Color [ ] _mousepadColors ;
66+ private readonly Color [ ] _keyboardColors ;
67+ private readonly Color [ ] _mousepadColors ;
6868 private Color _mouseColor ;
6969 private string _currentAppExecutable ;
70- private int _currentAppPid ;
7170 private bool _isDumping ;
71+ private readonly EffectLayer _layer = new ( "Chroma Layer" ) ;
7272
7373 public RazerLayerHandler ( )
7474 {
@@ -82,7 +82,6 @@ public RazerLayerHandler()
8282 var appList = Global . razerSdkManager . GetDataProvider < RzAppListDataProvider > ( ) ;
8383 appList . Update ( ) ;
8484 _currentAppExecutable = appList . CurrentAppExecutable ;
85- _currentAppPid = appList . CurrentAppPid ;
8685 }
8786 }
8887
@@ -93,7 +92,7 @@ protected override UserControl CreateControl()
9392
9493 private void OnDataUpdated ( object s , EventArgs e )
9594 {
96- if ( ! ( s is AbstractDataProvider provider ) )
95+ if ( s is not AbstractDataProvider provider )
9796 return ;
9897
9998 provider . Update ( ) ;
@@ -118,7 +117,6 @@ private void OnDataUpdated(object s, EventArgs e)
118117 else if ( provider is RzAppListDataProvider appList )
119118 {
120119 _currentAppExecutable = appList . CurrentAppExecutable ;
121- _currentAppPid = appList . CurrentAppPid ;
122120 }
123121 }
124122
@@ -150,33 +148,37 @@ public void DumpData(AbstractDataProvider provider)
150148 {
151149 var path = Path . Combine ( Global . LogsDirectory , "RazerLayer" ) ;
152150 var filename = $ "{ provider . GetType ( ) . Name } _{ Environment . TickCount } .bin";
153- using ( var file = File . Open ( $@ "{ path } \{ filename } ", FileMode . Create ) ) {
154- var data = provider . Read ( ) ;
155- file . Write ( data , 0 , data . Length ) ;
156- }
151+ using var file = File . Open ( $@ "{ path } \{ filename } ", FileMode . Create ) ;
152+ var data = provider . Read ( ) ;
153+ file . Write ( data , 0 , data . Length ) ;
157154 }
158155
156+ private bool _empty = true ;
159157 public override EffectLayer Render ( IGameState gamestate )
160158 {
161- var layer = new EffectLayer ( ) ;
162-
163159 if ( ! IsCurrentAppValid ( ) )
164- return layer ;
160+ {
161+ if ( _empty ) return _layer ;
162+ _layer . Clear ( ) ;
163+ _empty = true ;
164+ return _layer ;
165+ }
166+ _empty = false ;
165167
166168 foreach ( var key in ( DeviceKeys [ ] ) Enum . GetValues ( typeof ( DeviceKeys ) ) )
167169 {
168- if ( ! TryGetColor ( key , out Color color ) )
170+ if ( ! TryGetColor ( key , out var color ) )
169171 continue ;
170172
171- layer . Set ( key , color ) ;
173+ _layer . Set ( key , color ) ;
172174 }
173175
174- if ( Properties . KeyCloneMap != null )
175- foreach ( var target in Properties . KeyCloneMap )
176- if ( TryGetColor ( target . Value , out var clr ) )
177- layer . Set ( target . Key , clr ) ;
176+ if ( Properties . KeyCloneMap == null ) return _layer ;
177+ foreach ( var target in Properties . KeyCloneMap )
178+ if ( TryGetColor ( target . Value , out var clr ) )
179+ _layer . Set ( target . Key , clr ) ;
178180
179- return layer ;
181+ return _layer ;
180182 }
181183
182184 private bool TryGetColor ( DeviceKeys key , out Color color )
@@ -199,7 +201,7 @@ private bool TryGetColor(DeviceKeys key, out Color color)
199201
200202 private bool IsCurrentAppValid ( )
201203 => ! string . IsNullOrEmpty ( _currentAppExecutable )
202- && string . Compare ( _currentAppExecutable , "Aurora.exe" , true ) != 0 ;
204+ && string . Compare ( _currentAppExecutable , "Aurora.exe" , StringComparison . OrdinalIgnoreCase ) != 0 ;
203205
204206 private Color PostProcessColor ( Color color )
205207 {
0 commit comments