Newt Multimedia keys

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Newt Multimedia keys

mahesh
Is there any way to listen multimedia keyevents in newt, since it listens native keys

I am working on app which needs multimedia remote keys to work.

so far the solution that seems to work is  https://github.com/kwhat/jnativehook

Will the solution I mentioned interfere with newtkeyevents?

LWGJL seems to have media key events (although i have not tested it) https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/WindowsKeycodes.java
Reply | Threaded
Open this post in threaded view
|

Re: Newt Multimedia keys

gouessej
Administrator
Hey

What is missing in KeyEvent to support what you're looking for?

What happens when you press "pause", "next track" or "previous track" in a program using NEWT?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt Multimedia keys

mahesh
This post was updated on .
for all multimedia keys , KeyCode returned is 0
BTW keypressed is fired for multimedia events, but of no use since we do not know which key was pressed

this is sample program which displays keycode and keychar in console window

/**
 * A program to listen newt keyevents
 *
 */
public class JOGL2NewtDemo {
    private static String TITLE = "JOGL 2 with NEWT";  // window's title
    private static final int WINDOW_WIDTH = 400;  // width of the drawable
    private static final int WINDOW_HEIGHT = 300; // height of the drawable
    private static final int FPS = 60; // animator's target frames per second

     /**
     * The entry main() method.
     */
    public static void main(String[] args) {
        // Get the default OpenGL profile, reflecting the best for your running platform
        GLProfile glp = GLProfile.getDefault();
        // Specifies a set of OpenGL capabilities, based on your profile.
        GLCapabilities caps = new GLCapabilities(glp);
        // Create the OpenGL rendering canvas
        GLWindow window = GLWindow.create(caps);

        // Create a animator that drives canvas' display() at the specified FPS.
        final FPSAnimator animator = new FPSAnimator(window, FPS, true);

        window.addWindowListener(new WindowAdapter() {
            @Override
            public void windowDestroyNotify(WindowEvent arg0) {
                // Use a dedicate thread to run the stop() to ensure that the
                // animator stops before program exits.
                new Thread() {
                    @Override
                    public void run() {
                        if (animator.isStarted())
                            animator.stop();    // stop the animator loop
                        System.exit(0);
                    }
                }.start();
            }
        });

        window.addKeyListener(new KeyListener(){

			@Override
			public void keyPressed(KeyEvent e) {
				System.out.println("keycode="+e.getKeyCode()+"  keyChar="+e.getKeyChar());
			}

			@Override
			public void keyReleased(KeyEvent e) {
				// TODO Auto-generated method stub
				
			}
        	
        });	
          window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        window.setTitle(TITLE);
        window.setVisible(true);
        animator.start();  // start the animator loop
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Newt Multimedia keys

gouessej
Administrator
Thank you. Please fill a bug report (request for enhancement). It will be scheduled for JOGL 2.4 (probably not for JOGL 2.3.3).
Julien Gouesse | Personal blog | Website