Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by XFactHD

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 by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.