<commit_before>var stick = new VirtualJoystick({
  mouseSupport: false,
  container: document.getElementById("stick"),
  strokeStyle: 'blue',
  stationaryBase: true,
  baseX: window.innerWidth/2,
  baseY: window.innerHeight/4,
  limitStickTravel: true,
  stickRadius: 50
});

stick.addEventListener('touchStartValidation', function(event){
  var touch	= event.changedTouches[0];
  console.log(touch.pageX, touch.pageY);
  if( touch.pageX >= window.innerWidth/2 &&  touch.pageY > window.innerHeight/2)	return true;
  return false;
});

var listener = new window.keypress.Listener();

var socket = io();
socket.emit('newUser');

var commands = [
  {"com": "forward", "key": "up" },
  {"com": "left", "key": "left" },
  {"com": "right", "key": "right" },
  {"com": "reverse", "key": "down" },
  {"com": "stop", "key": "space" },
];

// Loop through our commands
commands.forEach( function(command) {
  command.el = document.getElementById(command.com);

  command.el.addEventListener("mousedown", function() {
    console.log(command.com);
    socket.emit(command.com);
  });

  // Listen for keypress events
  listener.register_combo({
    "keys"              : command.key,
    "on_keydown"        : function() { socket.emit(command.com); },
    "on_release"        : function() { socket.emit("stop"); },
    "prevent_default"   : true,
    "prevent_repeat"    : true
  });
});
<commit_msg>Work on joystick<commit_after>var stick = new VirtualJoystick({
  mouseSupport: true,
  container: document.getElementById("stick"),
  strokeStyle: 'blue',
  limitStickTravel: true
});

// stick.addEventListener('touchStartValidation', function(event){
//   var touch	= event.changedTouches[0];
//   console.log(touch.pageX, touch.pageY);
//   if( touch.pageX >= window.innerWidth/2 &&  touch.pageY > window.innerHeight/2)	return true;
//   return false;
// });

var listener = new window.keypress.Listener();

var socket = io();
socket.emit('newUser');

var commands = [
  {"com": "forward", "key": "up" },
  {"com": "left", "key": "left" },
  {"com": "right", "key": "right" },
  {"com": "reverse", "key": "down" },
  {"com": "stop", "key": "space" },
];

// Loop through our commands
commands.forEach( function(command) {
  command.el = document.getElementById(command.com);

  command.el.addEventListener("touchstart", function() {
    socket.emit(command.com);
    return false;
  });

  command.el.addEventListener("touchend", function() {
    socket.emit("stop");
  });

  // Listen for keypress events
  listener.register_combo({
    "keys"              : command.key,
    "on_keydown"        : function() { socket.emit(command.com); },
    "on_release"        : function() { socket.emit("stop"); },
    "prevent_default"   : true,
    "prevent_repeat"    : true
  });
});

{'fraction_non_alphanumeric': 0.18483754512635378, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 3.785837651122625, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 7, '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': '5858500', 'n_tokens_mistral': 909, 'n_tokens_neox': 893, 'n_words': 188}