Posted March 13, 20187 yr I am creating a mod that interfaces with the Logitech LED SDK to access the lighting of certain G-series keyboards. In any game that either interfaces with the LED SDK natively or is added via a profile in the Logitech Gaming Software switches from its specific lighting profile to the standard profile when it goes out of focus and back when it regains focus. To achieve this I need to check if the game window is in focus. When the player is in a world I can use a client tick event handler and check for Display.isActive() every tick but if I am in the main menu the tick handler is not running and therefore the profile switching doesn't work. Is there a way to get notified of a change in the window focus (kinda like the WindowListener in Swing)? This is the code I am currently using: private boolean focused = true; @SubscribeEvent(priority = EventPriority.LOWEST) public void onClientTick(TickEvent.ClientTickEvent event) { if (Display.isCreated()) { if (focused && !Display.isActive()) { focused = false; //shutdown lighting } else if (!focused && Display.isActive()) { focused = true; //restart lighting } } } Edited March 13, 20187 yr by XFactHD
March 13, 20187 yr This thread discussed how to get a window handle and might be useful to you: http://www.minecraftforge.net/forum/topic/63434-1122-hooking-into-lwjgl-minecraft-window-to-add-macos-touch-bar-features/ Also, I think there is a RenderTickEvent. That should probably tick no matter whether you're in a world or in main menu. Note that that event is called a couple times per tick so you should check the phase (like START). Edited March 13, 20187 yr by jabelar Check out my tutorials here: http://jabelarminecraft.blogspot.com/
March 13, 20187 yr The first hint is definetly interesting but unfortunately it doesn't allow me to attach some kind of callback. The RenderTickEvent however is the perfect solution, I don't know why I didn't think of that. Thank you very much for that.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.