public void GameStateUpdate(IGameState gs) { //Debug.WriteLine("Received gs!"); //Global.logger.LogLine(gs.ToString(), Logging_Level.None, false); if (Global.Configuration.detection_mode == Settings.ApplicationDetectionMode.ForegroroundApp && (currentTick >= nextProcessNameUpdate)) { process_path = GetActiveWindowsProcessname(); nextProcessNameUpdate = currentTick + 1000L; } string process_name = System.IO.Path.GetFileName(process_path).ToLowerInvariant(); if (Global.Configuration.excluded_programs.Contains(process_name)) { return; } EffectsEngine.EffectFrame newframe = new EffectsEngine.EffectFrame(); try { bool resolved_state = false; switch (Newtonsoft.Json.Linq.JObject.Parse(gs.GetNode("provider")).GetValue("appid").ToString()) { case "570": if (process_name.EndsWith("dota2.exe") && profiles.ContainsKey(process_name) && profiles[process_name].IsEnabled()) { profiles[process_name].UpdateLights(newframe, new Profiles.Dota_2.GSI.GameState_Dota2(gs)); resolved_state = true; } break; case "730": if (process_name.EndsWith("csgo.exe") && profiles.ContainsKey(process_name) && profiles[process_name].IsEnabled()) { profiles[process_name].UpdateLights(newframe, new Profiles.CSGO.GSI.GameState_CSGO(gs)); resolved_state = true; } break; case "218620": if (process_name.EndsWith("payday2_win32_release.exe") && profiles.ContainsKey(process_name) && profiles[process_name].IsEnabled()) { profiles[process_name].UpdateLights(newframe, new Profiles.Payday_2.GSI.GameState_PD2(gs)); resolved_state = true; } break; case "0": if (process_name.EndsWith("gta5.exe") && Newtonsoft.Json.Linq.JObject.Parse(gs.GetNode("provider")).GetValue("name").ToString().ToLowerInvariant().Equals("gta5.exe") && profiles.ContainsKey(process_name) && profiles[process_name].IsEnabled()) { profiles[process_name].UpdateLights(newframe, gs as Profiles.GTA5.GSI.GameState_GTA5); resolved_state = true; } else if (Newtonsoft.Json.Linq.JObject.Parse(gs.GetNode("provider")).GetValue("name").ToString().ToLowerInvariant().Equals("skype.exe") && skype_overlay.IsEnabled()) { skype_overlay.UpdateLights(newframe, new Profiles.Overlays.SkypeOverlay.State_SkypeOverlay(gs)); } else { if (gs is GameState_Wrapper && Global.Configuration.allow_all_logitech_bitmaps) { string gs_process_name = Newtonsoft.Json.Linq.JObject.Parse(gs.GetNode("provider")).GetValue("name").ToString().ToLowerInvariant(); if (!profiles.ContainsKey(gs_process_name)) { profiles.Add(gs_process_name, new GameEvent_Aurora_Wrapper()); } if (process_name.EndsWith(gs_process_name)) { profiles[gs_process_name].UpdateLights(newframe, gs as GameState_Wrapper); resolved_state = true; } else { (profiles[gs_process_name] as GameEvent_Aurora_Wrapper).UpdateWrapperLights(gs as GameState_Wrapper); } } } break; default: break; } tagLASTINPUTINFO LastInput = new tagLASTINPUTINFO(); Int32 IdleTime; LastInput.cbSize = (uint)Marshal.SizeOf(LastInput); LastInput.dwTime = 0; if (GetLastInputInfo(ref LastInput) && resolved_state) { IdleTime = System.Environment.TickCount - LastInput.dwTime; if (IdleTime >= Global.Configuration.idle_delay * 60 * 1000) { if (!(Global.Configuration.time_based_dimming_enabled && Global.Configuration.time_based_dimming_affect_games && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { idle_e.UpdateLights(newframe); } } } if (!(Global.Configuration.time_based_dimming_enabled && Global.Configuration.time_based_dimming_affect_games && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { if (resolved_state) { //Add overlays TimedListObject[] overlay_events = overlays.ToArray(); foreach (TimedListObject evnt in overlay_events) { if ((evnt.item as LightEvent).IsEnabled()) { (evnt.item as LightEvent).UpdateLights(newframe); } } Global.effengine.PushFrame(newframe); } } } catch (Exception e) { Global.logger.LogLine("Exception during GameStateUpdate(), error: " + e, Logging_Level.Warning); } }
private void Update() { if (Global.Configuration.detection_mode == Settings.ApplicationDetectionMode.ForegroroundApp && (currentTick >= nextProcessNameUpdate)) { process_path = GetActiveWindowsProcessname(); nextProcessNameUpdate = currentTick + 1000L; } string process_name = System.IO.Path.GetFileName(process_path).ToLowerInvariant(); if (Global.Configuration.excluded_programs.Contains(process_name)) { return; } EffectsEngine.EffectFrame newframe = new EffectsEngine.EffectFrame(); tagLASTINPUTINFO LastInput = new tagLASTINPUTINFO(); Int32 IdleTime; LastInput.cbSize = (uint)Marshal.SizeOf(LastInput); LastInput.dwTime = 0; if (GetLastInputInfo(ref LastInput)) { IdleTime = System.Environment.TickCount - LastInput.dwTime; if (IdleTime >= Global.Configuration.idle_delay * 60 * 1000) { if (!(Global.Configuration.time_based_dimming_enabled && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { idle_e.UpdateLights(newframe); } } } if (Global.Configuration.additional_profiles.ContainsKey(process_name) && (Global.Configuration.additional_profiles[process_name].Settings as GenericApplicationSettings).isEnabled) { Global.dev_manager.InitializeOnce(); Global.Configuration.additional_profiles[process_name].Event.UpdateLights(newframe); /*if (profiles.ContainsKey(process_name)) * { * profiles[process_name] * } * else * { * Event_GenericApplication app_event = new Event_GenericApplication(); * app_event.UpdateLights(newframe); * profiles.Add(process_name, app_event); * }*/ } else if (preview_mode == PreviewType.GenericApplication && Global.Configuration.additional_profiles.ContainsKey(preview_mode_profile_key) && (Global.Configuration.additional_profiles[preview_mode_profile_key].Settings as GenericApplicationSettings).isEnabled) { Global.dev_manager.InitializeOnce(); Global.Configuration.additional_profiles[preview_mode_profile_key].Event.UpdateLights(newframe); /*if (profiles.ContainsKey(preview_mode_profile_key)) * profiles[preview_mode_profile_key].UpdateLights(newframe); * else * { * Event_GenericApplication app_event = new Event_GenericApplication(); * app_event.UpdateLights(newframe); * profiles.Add(preview_mode_profile_key, app_event); * }*/ } else if (preview_mode == PreviewType.Predefined && profiles.ContainsKey(preview_mode_profile_key) && profiles[preview_mode_profile_key].IsEnabled()) { Global.dev_manager.InitializeOnce(); profiles[preview_mode_profile_key].UpdateLights(newframe); } else if (profiles.ContainsKey(process_name) && profiles[process_name].IsEnabled()) { if (process_name.Equals("csgo.exe")) { //Update timer set to 100 ticks a second for CSGO for Smooth Bomb Effect timer_interval = 10; // in miliseconds } else { //UPDATE at 30 ticks per second for rest. timer_interval = 33; } if (!(Global.Configuration.time_based_dimming_enabled && Global.Configuration.time_based_dimming_affect_games && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { Global.dev_manager.InitializeOnce(); profiles[process_name].UpdateLights(newframe); } } else if (Global.Configuration.allow_wrappers_in_background && Global.net_listener != null && Global.net_listener.IsWrapperConnected && profiles.ContainsKey(Global.net_listener.WrappedProcess) && profiles[Global.net_listener.WrappedProcess].IsEnabled()) { timer_interval = 33; // in miliseconds if (!(Global.Configuration.time_based_dimming_enabled && Global.Configuration.time_based_dimming_affect_games && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { Global.dev_manager.InitializeOnce(); profiles[Global.net_listener.WrappedProcess].UpdateLights(newframe); } } else { timer_interval = (int)(1000.0D / 30); //50 in miliseconds if (!(Global.Configuration.time_based_dimming_enabled && Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)) ) { if (!(Global.Configuration.desktop_profile.Settings as DesktopSettings).isEnabled) { Global.dev_manager.Shutdown(); } else { Global.dev_manager.InitializeOnce(); desktop_e.UpdateLights(newframe); } } } //Add overlays TimedListObject[] overlay_events = overlays.ToArray(); foreach (TimedListObject evnt in overlay_events) { if ((evnt.item as LightEvent).IsEnabled()) { (evnt.item as LightEvent).UpdateLights(newframe); } } Global.effengine.PushFrame(newframe); currentTick += (long)timer_interval; }