lib/mouse.js
function Mouse(device){
  var self = this;
  Keyboard.apply(this, arguments);
  this.on('data', function(ev, data){
    if(InputEvent.EVENT_TYPES.EV_REL == ev.type){
      // @docs: https://www.kernel.org/doc/Documentation/input/joystick-api.txt
      switch(ev.code || ev.number){ // joystick define ev.number means axis/button number
        case AXES.REL_X:
        case AXES.REL_Y:
        case AXES.REL_Z:
        case AXES.REL_RX:
        case AXES.REL_RY:
        case AXES.REL_RZ:
          this.emit('move', ev);
          break;
        case AXES.REL_WHEEL:
        case AXES.REL_HWHEEL:
          this.emit('wheel', ev);
          break;
        default:
          break;
      }
    }
    // mice device
    if(data.length == 3){
      // http://stackoverflow.com/questions/15882665/how-to-read-out-scroll-wheel-info-from-dev-input-mice
      if(ev.t == 8) this.emit((ev.x == 0 && ev.y == 0) ? 'reset':'move', ev);
      if(ev.t & EV_MOUSE.BTN_LEFT  ||
         ev.t & EV_MOUSE.BTN_RIGHT ||
         ev.t & EV_MOUSE.BTN_MIDDLE
      ) this.emit('keypress', ev);
    }
  });
}
function Mouse(device){
  var self = this;
  Keyboard.apply(this, arguments);
  this.on('data', function(ev, data){
    if(InputEvent.EVENT_TYPES.EV_REL == ev.type){
      // @docs: https://www.kernel.org/doc/Documentation/input/joystick-api.txt
      switch(ev.code || ev.number){ // joystick define ev.number means axis/button number
        case AXES.REL_X:
        case AXES.REL_Y:
        case AXES.REL_Z:
        case AXES.REL_RX:
        case AXES.REL_RY:
        case AXES.REL_RZ:
          this.emit('move', ev);
          break;
        case AXES.REL_WHEEL:
        case AXES.REL_HWHEEL:
          this.emit('wheel', ev);
          break;
        default:
          break;
      }
    }
    // mice device
    if(data.length == 3){
      // http://stackoverflow.com/questions/15882665/how-to-read-out-scroll-wheel-info-from-dev-input-mice
      if(ev.t == 8) this.emit((ev.x == 0 && ev.y == 0) ? 'reset':'move', ev);
      if(ev.t & EV_MOUSE.BTN_LEFT  ||
         ev.t & EV_MOUSE.BTN_RIGHT ||
         ev.t & EV_MOUSE.BTN_MIDDLE
      ) this.emit('keypress', ev);
    }
  });
}
function Mouse ( device ) { var self = this ; Keyboard . apply ( this , arguments ) ; this . on ( 'data' , function ( ev , data ) { if ( InputEvent . EVENT_TYPES . EV_REL == ev . type ) { // @docs: https://www.kernel.org/doc/Documentation/input/joystick-api.txt switch ( ev . code || ev . number ) { // joystick define ev.number means axis/button number case AXES . REL_X : case AXES . REL_Y : case AXES . REL_Z : case AXES . REL_RX : case AXES . REL_RY : case AXES . REL_RZ : this . emit ( 'move' , ev ) ; break ; case AXES . REL_WHEEL : case AXES . REL_HWHEEL : this . emit ( 'wheel' , ev ) ; break ; default : break ; } } // mice device if ( data . length == 3 ) { // http://stackoverflow.com/questions/15882665/how-to-read-out-scroll-wheel-info-from-dev-input-mice if ( ev . t == 8 ) this . emit ( ( ev . x == 0 && ev . y == 0 ) ? 'reset' : 'move' , ev ) ; if ( ev . t & EV_MOUSE . BTN_LEFT || ev . t & EV_MOUSE . BTN_RIGHT || ev . t & EV_MOUSE . BTN_MIDDLE ) this . emit ( 'keypress' , ev ) ; } } ) ; }
[Mouse description]
@param {[type]} device [description]
[ Mouse description ]