<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>631</bug_id>
          
          <creation_ts>2012-10-25 04:00:13 +0200</creation_ts>
          <short_desc>NEWT keyReleased event abnormal behaviour.</short_desc>
          <delta_ts>2012-10-28 04:20:46 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>core</component>
          <version>1</version>
          <rep_platform>pc_x86_64</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="leigh beattie">laykunowns</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>gouessej</cc>
    
    <cc>rami.santina</cc>
    
    <cc>rob.hatcherson</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>jogl 2f9c77a347b76bebdadd4bec1ac92aa7ab72365f</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1916</commentid>
    <comment_count>0</comment_count>
    <who name="leigh beattie">laykunowns</who>
    <bug_when>2012-10-25 04:00:13 +0200</bug_when>
    <thetext>I&apos;m building a game with jogl which runs fine on my Windows and Linux PC, which uses the latest stable jogl version. However on Mac I need to use the autobuilds to get GL3.2 support, and the keypress behaviour breaks. 

I have a listener that both handles keyPressed and keyReleased events and sets state. The problem is if I hold two keys down, say W and D for forward and strafe right and I release both of them then the one I pressed first becomes &quot;stuck&quot;. as in it doesn&apos;t fire it&apos;s keyreleased event. It seems to depend on how long I hold the keys, how slowly I release them, it&apos;s very inconsistent.

Also, for a key like W the keycode for the key pressed is 83 however while it&apos;s held down it reports that key 13 is being released and when I finally actually release it keycode 83 is reported as being released.

This is critical as flying a space ship is hard when the left or forward key is stuck in the &quot;pressed&quot; state.

@Override
	public void keyPressed(KeyEvent arg0) {
		System.out.println(&quot;KeyPressed! : &quot; + arg0.getKeyCode());
		switch(arg0.getKeyCode()){
		case FORWARD:
			shipEvent.setAction(ShipControlEvent.ACTION_FORWARD);
			shipEvent.setStatus(ShipControlEvent.STATUS_START);
			Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
			break;
		case BACKWARD:
			shipEvent.setAction(ShipControlEvent.ACTION_BACKWARD);
			shipEvent.setStatus(ShipControlEvent.STATUS_START);
			Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
			break;
		case STRAFE_LEFT:
			shipEvent.setAction(ShipControlEvent.ACTION_TURN_LEFT);
			shipEvent.setStatus(ShipControlEvent.STATUS_START);
			Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
			break;
		case STRAFE_RIGHT:
			shipEvent.setAction(ShipControlEvent.ACTION_TURN_RIGHT);
			shipEvent.setStatus(ShipControlEvent.STATUS_START);
			Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
			break;
		case SPRINT:
			shipEvent.setAction(ShipControlEvent.ACTION_SPRINT);
			shipEvent.setStatus(ShipControlEvent.STATUS_START);
			Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
			break;
		}
	}

	@Override
	public void keyReleased(KeyEvent arg0) {

		System.out.println(&quot;KeyReleased! : &quot; + arg0.getKeyCode());
			switch(arg0.getKeyCode()){
			case FORWARD:
				shipEvent.setAction(ShipControlEvent.ACTION_FORWARD);
				shipEvent.setStatus(ShipControlEvent.STATUS_STOP);
				Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
				break;
			case BACKWARD:
				shipEvent.setAction(ShipControlEvent.ACTION_BACKWARD);
				shipEvent.setStatus(ShipControlEvent.STATUS_STOP);
				Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
				break;
			case STRAFE_LEFT:
				shipEvent.setAction(ShipControlEvent.ACTION_TURN_LEFT);
				shipEvent.setStatus(ShipControlEvent.STATUS_STOP);
				Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
				break;
			case STRAFE_RIGHT:
				shipEvent.setAction(ShipControlEvent.ACTION_TURN_RIGHT);
				shipEvent.setStatus(ShipControlEvent.STATUS_STOP);
				Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
				break;
			case SPRINT:
				shipEvent.setAction(ShipControlEvent.ACTION_SPRINT);
				shipEvent.setStatus(ShipControlEvent.STATUS_STOP);
				Renderer.eventDaemon.fireEvent(shipEvent.getEventName(), shipEvent);
				break;
			}
		//}
	}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2012-10-26 16:51:13 +0200</bug_when>
    <thetext>Does multiple key press/release work on:
  - Linux/X11
  - Windows 
?
This is not quite clears, since it would be possible you tested this w/ an older version.

Can you check Bug 601 (not quite related .. but touches the issue a bit)
and use one of the new unit tests as a template to create a new one
reproducing the erroneous behavior ?
  http://jogamp.org/git/?p=jogl.git;a=commit;h=b008de41549e38aebdfcb7b094046235a8dde72f

This would really help a lot in fixing it.

Thank you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2012-10-27 02:51:45 +0200</bug_when>
    <thetext>Enhanced w/ multiple key support, see:
  &lt;http://jogamp.org/git/?p=jogl.git;a=commit;h=2f9c77a347b76bebdadd4bec1ac92aa7ab72365f&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1927</commentid>
    <comment_count>3</comment_count>
    <who name="leigh beattie">laykunowns</who>
    <bug_when>2012-10-28 04:20:46 +0100</bug_when>
    <thetext>Pulled latest repo, confirmed fixed! Thank you so much :D</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>