npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gymote

v1.0.0

Published

Use your phone as a remote pointing device on a computer

Downloads

46

Readme

Gymote

JavaScript library to use a device with a gyroscope (like every smartphone from the last few years) as a pointing device for a screen.

Documentation / API

The library consists of two parts: GymoteRemote and GymoteScreen, with the idea that both run on different devices.

It's built around the idea that a WebRTC or WebSocket connection is used to send data. To keep latency as low as possible, data ist sent as an ArrayBuffer.

GymoteRemote

The remote reads out the values of the gyroscope, calculate where the device is pointing at and return the x and y coordinates on the screen. For this to work, it needs to be aware of these two values:

  • Size of the screen in pixels
  • Distance from the phone to the screen, measured in pixels, relative to the viewport width.

You need to somehow pass this information to the remote whenever it changes.

In addition, the remote supports clicking and touch events, but again you have to update the state yourself, by having a button, attach event listeners to it and so on.

Once all is wired up you need to send the remote data to the screen whenever it changes. The remote doesn't emit an event for that, you have to pass a function which will received the data as the first argument. In there you send the data via your WebRTC or WebSocket connection.

Requesting access to gyroscope

Starting with iOS 12.2 accessing device motion data (like gyroscope) requires permission from the user. As of September 2019 there is no way to check if permission has been granted, so the best bet is to ask for permission on every page load.

GymoteScreen

The "receiving" end is mostly responsible for emitting events based on the incoming remote data. The data (ArrayBuffer) is passed to the handleRemoteData function. Common events like pointerdown, pointermove or touch are emitted, so it should be easy to integrate in various setups.

Sending data

Gymote was built with low latency and performance in mind. But for achieving the best results the data needs to be transmitted from the remote to the screen in the shortes amount of time possible.

Peersox was built with exactly this in mind, providing a client and server to pair two devices and send data via WebRTC data channels, with WebSocket for signaling and fallback.