Controls a handle by computer (naive computer vs player)
322161
function ComputerController(ball) {
    var myHandle;

    this.mount = function (handle) {
        myHandle = handle;
    };

    this.dismount = function () {
        myHandle = null;
    };

    this.step = function () {
        if (myHandle) {
            if (myHandle.y > ball.y) {
                myHandle.move(Math.random() * 2 + 1);
            } else {
                myHandle.move(-(Math.random() * 2 + 1));
            }
        }
    };
}
348059
def player(self, player_handle):
        """"""
        try:
            url = self.pubg_url + player_handle
            response = requests.request("GET", url, headers=self.headers)
            return json.loads(response.text)
        except BaseException as error:
            print('Unhandled exception: ' + str(error))
            raise
704616
def handle_input(*input)
      while ch = next_ch(input)
        quit  = QUIT_CONTROLS.include?(ch)
        enter = ENTER_CONTROLS.include?(ch)
        inc   = INC_CONTROLS.include?(ch)
        dec   = DEC_CONTROLS.include?(ch)

        break if shutdown? ||
                (quit && (!enter || quit_on_enter?))

        if enter
          on_enter

        elsif inc
          on_inc

        elsif dec
          on_dec
        end

        if key_bound?(ch)
          invoke_key_bindings(ch)
        end

        on_key(ch)
      end

      ch
    end
773635
def human_play(w, i, grid):
    ""
    plaint = ''
    prompt = whose_move(grid) + " move? [1-9] "
    while True:
        w.render_to_terminal(w.array_from_text(view(grid)
                                               + '\n\n' + plaint + prompt))
        key = c = i.next()
        try:
            move = int(key)
        except ValueError:
            pass
        else:
            if 1 <= move <= 9:
                successor = apply_move(grid, from_human_move(move))
                if successor: return successor
        plaint = ("Hey, that's illegal. Give me one of these digits:\n\n"
                  + (grid_format
                     % tuple(move if apply_move(grid, from_human_move(move)) else '-'
                             for move in range(1, 10))
                     + '\n\n'))
1264956
def run_console(*, locals=None, banner=None, serve=None, prompt_control=None):
    """"""
    loop = InteractiveEventLoop(
        locals=locals,
        banner=banner,
        serve=serve,
        prompt_control=prompt_control)
    asyncio.set_event_loop(loop)
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass
338773
def handle_play_clicked(self):
        
        if self.__hardware_source:
            if self.is_playing:
                self.__hardware_source.stop_playing()
            else:
                self.__hardware_source.start_playing()
49408
def OnPadIntCtrl(self, event):
        """"""

        self.attrs["pad"] = event.GetValue()

        post_command_event(self, self.DrawChartMsg)
384931
function (e) {
            if (this.dragging === false) {
                this.dragging = true;
                this.grabOffset.set(e.gameX, e.gameY);
                this.grabOffset.sub(this.pos);
                return false;
            }
        }
745158
function (previousHand) {
    var controlConfiguration;
    var el = this.el;
    var hand = this.data;
    var self = this;

    // Get common configuration to abstract different vendor controls.
    controlConfiguration = {
      hand: hand,
      model: false,
      orientationOffset: {x: 0, y: 0, z: hand === 'left' ? 90 : -90}
    };

    // Set model.
    if (hand !== previousHand) {
      this.loader.load(MODEL_URLS[hand], function (gltf) {
        var mesh = gltf.scene.children[0];
        mesh.mixer = new THREE.AnimationMixer(mesh);
        self.clips = gltf.animations;
        el.setObject3D('mesh', mesh);
        mesh.position.set(0, 0, 0);
        mesh.rotation.set(0, 0, 0);
        el.setAttribute('vive-controls', controlConfiguration);
        el.setAttribute('oculus-touch-controls', controlConfiguration);
        el.setAttribute('windows-motion-controls', controlConfiguration);
      });
    }
  }
1183756
function _upHandler(e) {
      if (_settings('mouseEnabled') && _isMouseDown) {
        _isMouseDown = false;
        if (_movingTimeoutId)
          clearTimeout(_movingTimeoutId);

        _camera.isMoving = false;

        var x = sigma.utils.getX(e),
            y = sigma.utils.getY(e);

        if (_isMoving) {
          sigma.misc.animation.killAll(_camera);
          sigma.misc.animation.camera(
            _camera,
            {
              x: _camera.x +
                _settings('mouseInertiaRatio') * (_camera.x - _lastCameraX),
              y: _camera.y +
                _settings('mouseInertiaRatio') * (_camera.y - _lastCameraY)
            },
            {
              easing: 'quadraticOut',
              duration: _settings('mouseInertiaDuration')
            }
          );
        } else if (
          _startMouseX !== x ||
          _startMouseY !== y
        )
          _camera.goTo({
            x: _camera.x,
            y: _camera.y
          });

        _self.dispatchEvent('mouseup',
          sigma.utils.mouseCoords(e));

        // Update _isMoving flag:
        _isMoving = false;
      }
    }
289590
def set_bind(self):
        
        # Arrow keys and enter
        self.bind('<Up>', lambda e: self.on_key_press_repeat('Up'))
        self.bind('<Down>', lambda e: self.on_key_press_repeat('Down'))
        self.bind('<Shift-Up>', lambda e: self.on_key_press_repeat('Shift-Up'))
        self.bind('<Shift-Down>', lambda e: self.on_key_press_repeat('Shift-Down'))
        self.bind('<Control-Up>', lambda e: self.on_key_press_repeat('Control-Up'))
        self.bind('<Control-Down>', lambda e: self.on_key_press_repeat('Control-Down'))
        self.bind('<KeyRelease>', lambda e: self.on_key_release_repeat())

        # Mouse buttons: bit complex since they don't automatically
        # run in continuous mode like the arrow keys
        self.bind('<ButtonPress-1>', self._leftMouseDown)
        self.bind('<ButtonRelease-1>', self._leftMouseUp)
        self.bind('<Shift-ButtonPress-1>', self._shiftLeftMouseDown)
        self.bind('<Shift-ButtonRelease-1>', self._shiftLeftMouseUp)
        self.bind('<Control-Button-1>', lambda e: self.add(100))

        self.bind('<ButtonPress-3>', self._rightMouseDown)
        self.bind('<ButtonRelease-3>', self._rightMouseUp)
        self.bind('<Shift-ButtonPress-3>', self._shiftRightMouseDown)
        self.bind('<Shift-ButtonRelease-3>', self._shiftRightMouseUp)
        self.bind('<Control-Button-3>', lambda e: self.sub(100))

        self.bind('<Double-Button-1>', self._dadd1)
        self.bind('<Double-Button-3>', self._dsub1)
        self.bind('<Shift-Double-Button-1>', self._dadd10)
        self.bind('<Shift-Double-Button-3>', self._dsub10)
        self.bind('<Control-Double-Button-1>', self._dadd100)
        self.bind('<Control-Double-Button-3>', self._dsub100)

        self.bind('<Enter>', self._enter)
607107
function TMEhandler(manager, inputEvent, inputData) {
    var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
    var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);

    // when we're in a touch event, so  block all upcoming mouse events
    // most mobile browser also emit mouseevents, right after touchstart
    if (isTouch) {
      this.mouse.allow = false;
    } else if (isMouse && !this.mouse.allow) {
      return;
    }

    // reset the allowMouse when we're done
    if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
      this.mouse.allow = true;
    }

    this.callback(manager, inputEvent, inputData);
  }
796415
def take_control(self):
        

        if has_termios:
            # Get attributes of the shell you were in before going to the
            # new one
            original_tty = termios.tcgetattr(sys.stdin)
            try:
                tty.setraw(sys.stdin.fileno())
                tty.setcbreak(sys.stdin.fileno())

                # We must set the timeout to 0 so that we can bypass times when
                # there is no available text to receive
                self.channel.settimeout(0)

                # Loop forever until the user exits (i.e. read buffer is empty)
                while True:
                    select_read, select_write, select_exception = (
                        select.select([self.channel, sys.stdin], [], [])
                    )
                    # Read any output from the terminal and print it to the
                    # screen.  With timeout set to 0, we just can ignore times
                    # when there's nothing to receive.
                    if self.channel in select_read:
                        try:
                            buffer = self.channel.recv(self.buffer_size)
                            if len(buffer) == 0:
                                break
                            sys.stdout.write(buffer.decode(self.encoding))
                            sys.stdout.flush()
                        except socket.timeout:
                            pass
                    # Send any keyboard input to the terminal one byte at a
                    # time
                    if sys.stdin in select_read:
                        buffer = sys.stdin.read(1)
                        if len(buffer) == 0:
                            break
                        self.channel.send(buffer)
            finally:
                # Restore the attributes of the shell you were in
                termios.tcsetattr(sys.stdin, termios.TCSADRAIN, original_tty)
        else:
            def writeall(sock):
                while True:
                    buffer = sock.recv(self.buffer_size)
                    if len(buffer) == 0:
                        break
                    sys.stdout.write(buffer.decode(self.encoding))
                    sys.stdout.flush()

            writer = threading.Thread(target=writeall, args=(self.channel,))
            writer.start()

            try:
                while True:
                    buffer = sys.stdin.read(1)
                    if len(buffer) == 0:
                        break
                    self.channel.send(buffer)
            # User has hit Ctrl+Z or F6
            except EOFError:
                pass
1127229
function registerEventHandlers(cm){var d=cm.display;on(d.scroller,"mousedown",operation(cm,onMouseDown));// Older IE's will not fire a second mousedown for a double click
if(ie&&ie_version<11){on(d.scroller,"dblclick",operation(cm,function(e){if(signalDOMEvent(cm,e)){return;}var pos=posFromMouse(cm,e);if(!pos||clickInGutter(cm,e)||eventInWidget(cm.display,e)){return;}e_preventDefault(e);var word=cm.findWordAt(pos);extendSelection(cm.doc,word.anchor,word.head);}));}else{on(d.scroller,"dblclick",function(e){return signalDOMEvent(cm,e)||e_preventDefault(e);});}// Some browsers fire contextmenu *after* opening the menu, at
// which point we can't mess with it anymore. Context menu is
// handled in onMouseDown for these browsers.
if(!captureRightClick){on(d.scroller,"contextmenu",function(e){return onContextMenu(cm,e);});}// Used to suppress mouse event handling when a touch happens
var touchFinished,prevTouch={end:0};function finishTouch(){if(d.activeTouch){touchFinished=setTimeout(function(){return d.activeTouch=null;},1000);prevTouch=d.activeTouch;prevTouch.end=+new Date();}}function isMouseLikeTouchEvent(e){if(e.touches.length!=1){return false;}var touch=e.touches[0];return touch.radiusX<=1&&touch.radiusY<=1;}function farAway(touch,other){if(other.left==null){return true;}var dx=other.left-touch.left,dy=other.top-touch.top;return dx*dx+dy*dy>20*20;}on(d.scroller,"touchstart",function(e){if(!signalDOMEvent(cm,e)&&!isMouseLikeTouchEvent(e)&&!clickInGutter(cm,e)){d.input.ensurePolled();clearTimeout(touchFinished);var now=+new Date();d.activeTouch={start:now,moved:false,prev:now-prevTouch.end<=300?prevTouch:null};if(e.touches.length==1){d.activeTouch.left=e.touches[0].pageX;d.activeTouch.top=e.touches[0].pageY;}}});on(d.scroller,"touchmove",function(){if(d.activeTouch){d.activeTouch.moved=true;}});on(d.scroller,"touchend",function(e){var touch=d.activeTouch;if(touch&&!eventInWidget(d,e)&&touch.left!=null&&!touch.moved&&new Date()-touch.start<300){var pos=cm.coordsChar(d.activeTouch,"page"),range;if(!touch.prev||farAway(touch,touch.prev))// Single tap
{range=new Range(pos,pos);}else if(!touch.prev.prev||farAway(touch,touch.prev.prev))// Double tap
{range=cm.findWordAt(pos);}else// Triple tap
{range=new Range(Pos(pos.line,0),_clipPos(cm.doc,Pos(pos.line+1,0)));}cm.setSelection(range.anchor,range.head);cm.focus();e_preventDefault(e);}finishTouch();});on(d.scroller,"touchcancel",finishTouch);// Sync scrolling between fake scrollbars and real scrollable
// area, ensure viewport is updated when scrolling.
on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){updateScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,true);signal(cm,"scroll",cm);}});// Listen to wheel events in order to try and update the viewport on time.
on(d.scroller,"mousewheel",function(e){return onScrollWheel(cm,e);});on(d.scroller,"DOMMouseScroll",function(e){return onScrollWheel(cm,e);});// Prevent wrapper from ever scrolling
on(d.wrapper,"scroll",function(){return d.wrapper.scrollTop=d.wrapper.scrollLeft=0;});d.dragFunctions={enter:function enter(e){if(!signalDOMEvent(cm,e)){e_stop(e);}},over:function over(e){if(!signalDOMEvent(cm,e)){onDragOver(cm,e);e_stop(e);}},start:function start(e){return onDragStart(cm,e);},drop:operation(cm,onDrop),leave:function leave(e){if(!signalDOMEvent(cm,e)){clearDragCursor(cm);}}};var inp=d.input.getField();on(inp,"keyup",function(e){return onKeyUp.call(cm,e);});on(inp,"keydown",operation(cm,onKeyDown));on(inp,"keypress",operation(cm,onKeyPress));on(inp,"focus",function(e){return onFocus(cm,e);});on(inp,"blur",function(e){return onBlur(cm,e);});}
1023591
def mouse_handler(self, cli, mouse_event):
        
        b = cli.current_buffer

        if mouse_event.event_type == MouseEventType.MOUSE_UP:
            # Select completion.
            b.go_to_completion(mouse_event.position.y)
            b.complete_state = None

        elif mouse_event.event_type == MouseEventType.SCROLL_DOWN:
            # Scroll up.
            b.complete_next(count=3, disable_wrap_around=True)

        elif mouse_event.event_type == MouseEventType.SCROLL_UP:
            # Scroll down.
            b.complete_previous(count=3, disable_wrap_around=True)
284837
private boolean handleWrapping(MouseEvent e)
    {
        if (robot == null)
        {
            return false;
        }
        PointerInfo pointerInfo = null;
        try
        {
            pointerInfo = MouseInfo.getPointerInfo();
        }
        catch (SecurityException ex)
        {
            return false;
        }
        Rectangle r = 
            pointerInfo.getDevice().getDefaultConfiguration().getBounds();
        Point onScreen = pointerInfo.getLocation();
        if (onScreen.y == 0)
        {
            robot.mouseMove(onScreen.x, r.height-2);
            previousPoint = new Point(onScreen.x, r.height-2);
            SwingUtilities.convertPointFromScreen(previousPoint, spinner);
            return true;
        } 
        else if (onScreen.y == r.height - 1)
        {
            robot.mouseMove(onScreen.x, 1);
            previousPoint = new Point(onScreen.x, 1);
            SwingUtilities.convertPointFromScreen(previousPoint, spinner);
            return true;
        }
        return false;
    }
893476
def handle_input(from_parent=false)
      @focus ||= 0

      # focus on first component
      ch = handle_focused unless nav_select

      # Repeat until quit
      until quit_nav?(ch)

        # Navigate to the specified component (nav_select)
        if self.nav_select 
          # it is a descendent of this one
          if self.contains?(self.nav_select)
            nav_to_selected

          # specified component is not a descendent,
          else
            nav_to_parent
            return nil
          end

        elsif ENTER_CONTROLS.include?(ch)
          focused.activate!

        elsif MOVEMENT_CONTROLS.include?(ch)
          handle_movement(ch, from_parent)

        elsif mev = process_mouse(ch)
          handle_mouse(mev)

        else
          dispatch(:entry, ch)

        end

        return ch unless sanitize_focus!(from_parent)
        ch = handle_focused unless nav_select ||
                                   shutdown?  ||
                                   deactivate?
      end

      ch
    end