<commit_before>package de.lessvoid.nifty.renderer.jogl.input;

import com.jogamp.newt.event.*;
import de.lessvoid.nifty.NiftyInputConsumer;
import de.lessvoid.nifty.input.keyboard.KeyboardInputEvent;
import de.lessvoid.nifty.spi.input.InputSystem;
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader;

import javax.annotation.Nonnull;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Logger;

/**
 * This is a direct port of the LwjglInputSystem to JOGL and the old existing InputSystem for JOGL.
 *
 * @author void
 */
public class JoglInputSystem implements InputSystem, MouseListener, KeyListener {
  private final Logger log = Logger.getLogger(JoglInputSystem.class.getName());
  @Nonnull
  private final AwtToNiftyKeyCodeConverter converter = new AwtToNiftyKeyCodeConverter();

  // queues to store events received from JOGL in
  @Nonnull
  private final ConcurrentLinkedQueue<MouseInputEvent> mouseEvents = new ConcurrentLinkedQueue<MouseInputEvent>();
  @Nonnull
  private final ConcurrentLinkedQueue<KeyboardInputEvent> keyboardEvents = new
      ConcurrentLinkedQueue<KeyboardInputEvent>();

  // queues to store events not processed by Nifty in
  @Nonnull
  private final ConcurrentLinkedQueue<MouseInputEvent> mouseEventsOut = new ConcurrentLinkedQueue<MouseInputEvent>();
  @Nonnull
  private final ConcurrentLinkedQueue<KeyboardInputEvent> keyboardEventsOut = new
      ConcurrentLinkedQueue<KeyboardInputEvent>();

  // some booleans to remember if nifty currently has the focus
  private boolean niftyHasKeyboardFocus = true;
  private boolean niftyTakesKeyboardFocusOnClick = false;

  public boolean niftyHasKeyboardFocus() {
    return niftyHasKeyboardFocus;
  }

  public void niftyTakesKeyboardFocusOnClick(final boolean niftyTakesKeyboardFocusOnClick) {
    this.niftyTakesKeyboardFocusOnClick = niftyTakesKeyboardFocusOnClick;
  }

  // InputSystem Implementation

  @Override
  public void setResourceLoader(@Nonnull final NiftyResourceLoader resourceLoader) {
    // We currently don't need any resources so we don't have any use for this
    // method
  }

  @Override
  public void forwardEvents(@Nonnull final NiftyInputConsumer inputEventConsumer) {
    mouseEventsOut.clear();
    keyboardEventsOut.clear();

    processMouseEvents(inputEventConsumer);
    processKeyboardEvents(inputEventConsumer);
  }

  @Override
  public void setMousePosition(final int x, final int y) {
    // TODO implement this method later
  }

  // MouseMotionListener Implementation

  @Override<commit_msg>Implemented setMousePointer in JoglInputSystem -setMousePointer via NEWT Window method 'warpPointer'<commit_after>package de.lessvoid.nifty.renderer.jogl.input;

import com.jogamp.newt.event.*;

import de.lessvoid.nifty.NiftyInputConsumer;
import de.lessvoid.nifty.input.keyboard.KeyboardInputEvent;
import de.lessvoid.nifty.spi.input.InputSystem;
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader;

import javax.annotation.Nonnull;

import java.awt.Window;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Logger;

/**
 * This is a direct port of the LwjglInputSystem to JOGL and the old existing InputSystem for JOGL.
 *
 * @author void
 */
public class JoglInputSystem implements InputSystem, MouseListener, KeyListener {
	
  private final Logger log = Logger.getLogger(JoglInputSystem.class.getName());
  
  @Nonnull
  private final AwtToNiftyKeyCodeConverter converter = new AwtToNiftyKeyCodeConverter();

  // queues to store events received from JOGL in
  @Nonnull
  private final ConcurrentLinkedQueue<MouseInputEvent> mouseEvents = new ConcurrentLinkedQueue<MouseInputEvent>();
  
  @Nonnull
  private final ConcurrentLinkedQueue<KeyboardInputEvent> keyboardEvents = new
      ConcurrentLinkedQueue<KeyboardInputEvent>();

  // queues to store events not processed by Nifty in
  @Nonnull
  private final ConcurrentLinkedQueue<MouseInputEvent> mouseEventsOut = new ConcurrentLinkedQueue<MouseInputEvent>();
  
  @Nonnull
  private final ConcurrentLinkedQueue<KeyboardInputEvent> keyboardEventsOut = new
      ConcurrentLinkedQueue<KeyboardInputEvent>();
      
  public JoglInputSystem(@Nonnull final Window newtWindow) {
	  this.niftyNewtWindow = newtWindow;
  }
  
  private Window niftyNewtWindow;

  // some booleans to remember if nifty currently has the focus
  private boolean niftyHasKeyboardFocus = true;
  private boolean niftyTakesKeyboardFocusOnClick = false;

  public boolean niftyHasKeyboardFocus() {
    return niftyHasKeyboardFocus;
  }

  public void niftyTakesKeyboardFocusOnClick(final boolean niftyTakesKeyboardFocusOnClick) {
    this.niftyTakesKeyboardFocusOnClick = niftyTakesKeyboardFocusOnClick;
  }

  // InputSystem Implementation

  @Override
  public void setResourceLoader(@Nonnull final NiftyResourceLoader resourceLoader) {
    // We currently don't need any resources so we don't have any use for this
    // method
  }

  @Override
  public void forwardEvents(@Nonnull final NiftyInputConsumer inputEventConsumer) {
    mouseEventsOut.clear();
    keyboardEventsOut.clear();

    processMouseEvents(inputEventConsumer);
    processKeyboardEvents(inputEventConsumer);
  }

  @Override
  public void setMousePosition(final int x, final int y) {
    int windowX = niftyNewtWindow.getX(), windowY = niftyNewtWindow.getY();
    niftyNewtWindow.warpPointer(x - windowX, y - windowY);
  }

  // MouseMotionListener Implementation

  @Override
{'fraction_non_alphanumeric': 0.07048940832724616, 'fraction_numerical': 0.0, 'mean_word_length': 5.174746335963923, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798437', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1577, 'n_words': 390}