-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Custom keyboard mapping #712
Comments
#149 I THOUGHT the bit that said closed meant it was closed... its another thread u linked under it. |
Is anyone still working on scrcpy? If so is this on the road map? |
Yes, on my free time.
TBH, not really, unless someone wants to work on it (define how to configure key mapping and implement it…). |
How the user would configure it: opens an overlay(i.e. steam overlay) and clicks where they want a button and assigns a letter to that button, making that letter click at that spot. |
hi , am working keyboard mapping for pubg , but i stuck at camera movement (mouse movement) |
For my use case, that is controlling a racing game, I was able to workaround this using a bit of Python scripting (I used pynput as pyautogui and keyboard both require running as sudo under Linux). #!/usr/bin/python2.7
from pynput.mouse import Button, Controller
from pynput.keyboard import Key, Listener
global MOUSE
MOUSE = Controller()
global LISTEN
global CENTER
global OFFSET
global LEFT
global RIGHT
global HEIGHT
# for scrcpy with -2M switch
#HEIGHT = 700 CENTER = 900 OFFSET = 500
# HEIGHT = 500 OFFSET 450 for 1024 -b 4M
# -m 768 -b 4M gives good enough quality while still working (-m 640 doesn't register clicks)
HEIGHT = 650
CENTER = 950
OFFSET = 300
LEFT = CENTER - OFFSET
RIGHT = CENTER + OFFSET
def cust_click(x,y):
MOUSE.position = (x,y)
# MOUSE.click(Button.left)
MOUSE.press(Button.left)
def space():
cust_click(CENTER,HEIGHT+120) # 150 for -m 1024
def left():
cust_click(LEFT, HEIGHT)
def right():
cust_click(RIGHT, HEIGHT)
def on_press(key):
#print('{0} pressed'.format(
# key))
if key == Key.left:
left()
elif key == Key.right:
right()
elif key == Key.space:
space()
elif key == Key.tab:
LISTEN.stop()
def on_release(key):
#print('{0} release'.format(
# key))
if key == Key.right or key == Key.left or key == Key.space:
MOUSE.release(Button.left)
# can't use esc because it is the phone 'back' hotkey, at least in snap version
# if key == Key.esc:
# # Stop listener
# return False
# Collect events until released
with Listener(
on_press=on_press,
on_release=on_release) as LISTEN:
LISTEN.join() |
Zireal please help me how can i use this code? |
@AnishKumar0285: You need pynput installed (pip install pynput) and you need to run the script while having the scrcpy open. You'll need to adjust the keys and positions for the game you want to control, obviously, as well as the scrcpy screen's size. |
Hello but i have a question i use your script but how can i add new keys and the key when im playing a shot game thet hide the cursor for use only the movement of the mouse, Thanks |
Anyone knows how to add a keys like the a or s key on pynput? |
I would also like to know how to properly change and add to this code. I am trying to make it for a shooter game (pubg mobile). |
Pynput has very good documentation, it should tell you everything you two want to know: https://pythonhosted.org/pynput/index.html The mouse positions, as I said, have to be eyeballed. |
Fixed it in guiscrcpy, https://github.com/srevinsaju/guiscrcpy/blob/master/guiscrcpy/mapper.py |
Thanks, i will try this. |
I think, it will be better to have a file external yaml/json from the project (the project just give us an example for the format, like what guiscrcpy do for example) and externalize the work of input_manager.c to do the matching between the event and the correspond on SDL2 action. |
Yes @karousn, the only drawback for the guiscrcpy mapping is that it conflicts with the input of characters into a text box, using a mapper key such as Ctrl or Meta may enhance |
TC games is windows only, though. |
If you want an easy implementation, I have a suggestion. I will be really hard for the user to configure, but you can build upon it. Simplest thing to do is use a config file, preferably json, in which you can map clicks and movements simulation. Why would this be hard? because you have to map the keys and movements using pixels for measurement. Now if you want a hard implementation but easy for users to configure, here's what you need to do.
Just a suggestion. this extends #1453 |
"qtscrcpy" I can create all buttons myself except this one. I can't create move mouse button. I can't create more than one "Smalleyes" button. What should I do? |
guys sorry for asking here but i dont want create a new thread but... did you be able to run mapping keyboard to screenpress positions? i want to configure it to play genshin impact but i really dont understand well the suggestions with phyton theres an resumed area on how to configure it? |
Perhaps you guys can look at this project. It currently works with Bliss OS (Android-x86) however I don't see how it can't be adapted to real mobile devices...?? |
Please, see the project QtScrcpy. Is it easy to install? Absolutely not. Good luck. On Linux, there is no easy way to play Android games. |
Thanks so much friend, you're a friend |
may be, we can make a script for the android device to listen to the input through the tunnel or something like that...! |
do you guys playing watching by mobile screen or pc's monitor? for me, i cant handle input lag, i tried to manipulate screen resolution with qts and bitrate, but fps drops a lot |
What is qts?
That's not expected. |
Sorry for being late at the party here which I find very interesting for mimicking touch movements, dragging and such. I am using Ubuntu 22.10 and 23.04 with scrcpy 2.0. Which method would be recommended to easily map for example the WASD keys to a touchscreen area for the up, down, left, right movements. |
If it helps for research purposes, the xdotool is the one I am using to more or less mimic this: Currently it is able to drag the center of the virtual joystick (What I call the center position) and drag it to the corresponding X/Y coordinates for the UP | DOWN | LEFT | RIGHT positions. Depending if I hold the SHIFT, it will go longer to any direction to mimic the running speed, or move less to the sides to mimic the stealth/slower movement. The only problems are the following:
This is what I am working on with the xdotool and thinking my way through. The github mentioned above did not help at all btw. |
This seems promising can you do one with wtype and put it on git? |
Thanks, I will research what wtype is and if it can solve an issue with multiple keys being pressed. |
How can I make scrcpy use ESCAPE for BACK instead of using the Right Click ? |
Please someone create a scrcpy client library for cpp so people can customize scrcpy please. |
Really want custom mapping keyboard controls. I have seen another post about this and someone said it would be too much work but the thread is closed. Keyboard mapping would be amazing :)
The text was updated successfully, but these errors were encountered: