Giter VIP home page Giter VIP logo

pikvm-lib's People

Contributors

dependabot[bot] avatar guanana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pikvm-lib's Issues

pipy published package is missing csv maping

Hello there,
I am starting to use this library for writing a custom integration for home assistant, unfortunately I ran into an issue using some of the websocket functions that require the key map csv files. It seems the csv files are not currently present in the published pipy package.

I was able to add these lines to the end of the pyproject.toml to fix this issue, is this something you would be willing to do and publish an updated release to pipy?

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
pikvm_lib = ["*.csv"]

absolute mouse movement?

Is your feature request related to a problem? Please describe.
clean interface for absolute mouse position

Describe the solution you'd like
some fn mouse_move_to(sx, sy) mapping screen 0..width to -i16..+i16, same for height

Describe alternatives you've considered

import ssl, time
import random
import json
import os

host = os.environ.get('HOST')
user = os.environ.get('USER', 'admin')
password = os.environ.get('PASSWORD', 'admin')

screen_width = 1920
screen_height = 1080

uri = f'wss://{host}/api/ws?stream=0'
print(f'connecting to {user}@{host} uri: {uri}')

headers = {"X-KVMD-User": user, "X-KVMD-Passwd": password}
print('headers', headers)

ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
ws.connect(uri, header=headers)

def scale_mouse_xy_to_i16(screenx, screeny, width=1920, height=1080):
    # Map from (0, width) to (i16)
    hid_x_i16 = int((screenx / width) * 0xffff - 0x8000)

    # Map from (0, height) to (i16)
    hid_y_i16 = int((screeny / height) * 0xffff - 0x8000)

    return (hid_x_i16, hid_y_i16)

def mouse_jump_to(screenx, screeny, width=1920, height=1080):
    print('mouse_move', screenx, screeny)

    kvmx, kvmy = scale_mouse_xy_to_i16(screenx, screeny)

    msg = json.dumps({
            "event_type": "mouse_move",
            "event": {
                "to": {
                    "x": kvmx,
                    "y": kvmy
                },
            }
        })
    ws.send(msg)

while True:
    for y in range(0, screen_height, 10):
        for x in range(0, screen_width, 19):
            mouse_jump_to(x, y)
            time.sleep(0.1)

ws.close()

Additional context
using kvm for automated testing without installing software on the remote device under test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.