Skip to content

Instantly share code, notes, and snippets.

@BobbyWibowo
Last active April 4, 2024 02:23
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BobbyWibowo/01ce6785cb3a822e5eae745ccf27d12b to your computer and use it in GitHub Desktop.
Save BobbyWibowo/01ce6785cb3a822e5eae745ccf27d12b to your computer and use it in GitHub Desktop.
QtScrcpy custom key maps for Genshin Impact.
{
"switchKey": "Key_QuoteLeft",
"mouseMoveMap": {
"startPos": {
"x": 0.5,
"y": 0.32
},
"speedRatio": 3.5
},
"keyMapNodes": [
{
"comment": "Character Movement - WASD",
"type": "KMT_STEER_WHEEL",
"centerPos": {
"x": 0.183581,
"y": 0.763636
},
"leftOffset": 0.1,
"rightOffset": 0.1,
"upOffset": 0.2167,
"downOffset": 0.2167,
"leftKey": "Key_A",
"rightKey": "Key_D",
"upKey": "Key_W",
"downKey": "Key_S"
},
{
"comment": "Attack - LMB",
"type": "KMT_CLICK",
"key": "LeftButton",
"pos": {
"x": 0.799222,
"y": 0.76431
},
"switchMap": false
},
{
"comment": "Elemental Skill - E",
"type": "KMT_CLICK",
"key": "Key_E",
"pos": {
"x": 0.721401,
"y": 0.863636
},
"switchMap": false
},
{
"comment": "Sprint - RMB",
"type": "KMT_CLICK",
"key": "RightButton",
"pos": {
"x": 0.877821,
"y": 0.858586
},
"switchMap": false
},
{
"comment": "Sprint - Shift",
"type": "KMT_CLICK",
"key": "Key_Shift",
"pos": {
"x": 0.877821,
"y": 0.858586
},
"switchMap": false
},
{
"comment": "Jump - Space",
"type": "KMT_CLICK",
"key": "Key_Space",
"pos": {
"x": 0.878599,
"y": 0.654882
},
"switchMap": false
},
{
"comment": "Elemental Burst - Q",
"type": "KMT_CLICK",
"key": "Key_Q",
"pos": {
"x": 0.649027,
"y": 0.900673
},
"switchMap": false
},
{
"comment": "Open Inventory - B",
"type": "KMT_CLICK",
"key": "Key_B",
"pos": {
"x": 0.87393,
"y": 0.0572391
},
"switchMap": false
},
{
"comment": "Open Character Screen - C",
"type": "KMT_CLICK",
"key": "Key_C",
"pos": {
"x": 0.921401,
"y": 0.0572391
},
"switchMap": false
},
{
"comment": "Open Map - M",
"type": "KMT_CLICK",
"key": "Key_M",
"pos": {
"x": 0.129183,
"y": 0.143098
},
"switchMap": false
},
{
"comment": "Open Wish Screen - F3",
"type": "KMT_CLICK",
"key": "Key_F3",
"pos": {
"x": 0.777432,
"y": 0.0538721
},
"switchMap": false
},
{
"comment": "Open Adventurer Handbook Screen - F1",
"type": "KMT_CLICK",
"key": "Key_F1",
"pos": {
"x": 0.825681,
"y": 0.0505051
},
"switchMap": false
},
{
"comment": "Open Paimon Menu - Esc",
"type": "KMT_CLICK",
"key": "Key_Escape",
"pos": {
"x": 0.0700389,
"y": 0.0622896
},
"switchMap": false
},
{
"comment": "Open Quest Menu - J",
"type": "KMT_CLICK",
"key": "Key_J",
"pos": {
"x": 0.0692607,
"y": 0.237374
},
"switchMap": false
},
{
"comment": "Quest Navigation - V",
"type": "KMT_CLICK",
"key": "Key_V",
"pos": {
"x": 0.106615,
"y": 0.318182
},
"switchMap": false
},
{
"comment": "Open Co-Op Screen - F2",
"type": "KMT_CLICK",
"key": "Key_F2",
"pos": {
"x": 0.235019,
"y": 0.0555556
},
"switchMap": false
},
{
"comment": "Elemental Sight (Tap) - MMB",
"type": "KMT_CLICK",
"key": "MiddleButton",
"pos": {
"x": 0.18677,
"y": 0.0521886
},
"switchMap": false
},
{
"comment": "Elemental Sight (Tap) - Back Button",
"type": "KMT_CLICK",
"key": "BackButton",
"pos": {
"x": 0.18677,
"y": 0.0521886
},
"switchMap": false
},
{
"comment": "Switch Character 1 - 1",
"type": "KMT_CLICK",
"key": "Key_1",
"pos": {
"x": 0.87,
"y": 0.215
},
"switchMap": false
},
{
"comment": "Switch Character 2 - 2",
"type": "KMT_CLICK",
"key": "Key_2",
"pos": {
"x": 0.87,
"y": 0.320
},
"switchMap": false
},
{
"comment": "Switch Character 3 - 3",
"type": "KMT_CLICK",
"key": "Key_3",
"pos": {
"x": 0.87,
"y": 0.425
},
"switchMap": false
},
{
"comment": "Switch Character 4 - 4",
"type": "KMT_CLICK",
"key": "Key_4",
"pos": {
"x": 0.87,
"y": 0.530
},
"switchMap": false
},
{
"comment": "Switch Character 1 and Use Elemental Burst - 5",
"type": "KMT_CLICK",
"key": "Key_5",
"pos": {
"x": 0.81,
"y": 0.215
},
"switchMap": false
},
{
"comment": "Switch Character 2 and Use Elemental Burst - 6",
"type": "KMT_CLICK",
"key": "Key_6",
"pos": {
"x": 0.81,
"y": 0.320
},
"switchMap": false
},
{
"comment": "Switch Character 3 and Use Elemental Burst - 7",
"type": "KMT_CLICK",
"key": "Key_7",
"pos": {
"x": 0.81,
"y": 0.425
},
"switchMap": false
},
{
"comment": "Switch Character 4 and Use Elemental Burst - 8",
"type": "KMT_CLICK",
"key": "Key_8",
"pos": {
"x": 0.81,
"y": 0.530
},
"switchMap": false
},
{
"comment": "Switch Aiming Mode - R",
"type": "KMT_CLICK",
"key": "Key_R",
"pos": {
"x": 0.694163,
"y": 0.747475
},
"switchMap": false
},
{
"comment": "Pick Up/Interact - F",
"type": "KMT_CLICK",
"key": "Key_F",
"pos": {
"x": 0.71032,
"y": 0.5
},
"switchMap": false
},
{
"comment": "Switch Walk/Run - Left Ctrl",
"type": "KMT_CLICK",
"key": "Key_Control",
"pos": {
"x": 0.933852,
"y": 0.947811
},
"switchMap": false
},
{
"comment": "Check Tutorial Details - G",
"type": "KMT_CLICK",
"key": "Key_G",
"pos": {
"x": 0.5,
"y": 0.747475
},
"switchMap": false
},
{
"comment": "Open the Events Menu - F5",
"type": "KMT_CLICK",
"key": "Key_F5",
"pos": {
"x": 0.679377,
"y": 0.0589226
},
"switchMap": false
},
{
"comment": "Open Battle Pass Screen - F4",
"type": "KMT_CLICK",
"key": "Key_F4",
"pos": {
"x": 0.729183,
"y": 0.0622896
},
"switchMap": false
},
{
"comment": "Quick-use Gadget - Z",
"type": "KMT_CLICK",
"key": "Key_Z",
"pos": {
"x": 0.330961,
"y": 0.898305
},
"switchMap": false
}
]
}
@BobbyWibowo
Copy link
Author

BobbyWibowo commented Dec 16, 2020

Details

Status: Somewhat usable?

Written for phones with 3120x1440 resolution (tested on OnePlus 7 Pro).
Since QtScrcpy's custom key mapping works with relative coordinates, it should theoretically work on any phones with 13:6 aspect ratio, but obviously it's only guaranteed to work on phones with the exact same resolutions.

Once it's mostly usable, this gist will be ported over to an actual Git repository.
I will not be personally working on other resolutions and/or aspect ratios, ever, so volunteers would be needed.

Resources

QtScrcpy (Android real-time screen mirroring, cross-platform Windows/macOS/Linux): https://github.com/barry-ran/QtScrcpy
QtScrcpy key mapping rules: https://github.com/barry-ran/QtScrcpy/blob/master/docs/KeyMapDes.md
Qt key codes/enums: https://doc.qt.io/qt-5/qt.html#Key-enum
Genshin Impact's default PC controls: https://genshin-impact.fandom.com/wiki/Controls#Keybinds

scrcpy (QtScrcpy was based on this): https://github.com/Genymobile/scrcpy
sndcpy (Android real-time audio forwarding, to be used together with either QtScrcpy or scrcpy): https://github.com/rom1v/sndcpy

Why custom key mapping?

In short, the Android version of the game do not accept external keyboard inputs (even with a USB keyboard that can be connected to phones).

Abbreviations

LMB: Left Mouse Button
RMB: Right Mouse Button
MMB: Middle Mouse Button (typically clicking the mouse-wheel)

Quirks, and differences with PC key binds

  • There exist an input mode switch key, which is tilde (~).
    In normal mode, cursor will appear, you interact with the game UI with taps (mouse clicks), and custom key maps inactive.
    In custom mode, cursor will disappear, mouse movement bound to camera, and custom key maps active.
  • There are no key maps for camera zooms.
    So keep your phone nearby to manually zoom out whenever the camera gets automatically zoomed in.
    Unfortunately there are no pinch in/out mapping in QtScrcpy.
  • Key maps for menus won't show cursor when the menus are opened.
    Instead you will need to use the switch key to enter normal mode, to then interact with the game UI with taps (mouse clicks).
    Exiting menus also require manually tapping/clicking the Close button on the UI.
  • For key binds that are only mapped to the left-side buttons on PC (Left Shift, Left Ctrl, etc.), the key maps instead apply to both left- and right- sides. I'm not aware of any way to instruct QtScrcpy to only apply key maps to one specific side.
  • Open Chat Screen (Enter) is not yet mapped.
  • Open Domain Screen (U) is not yet mapped.
  • Elemental Sight (MMB) is tap-based. Supposedly on PC you need to hold?
    Additionally, it's also mapped to mouse's back button (typically present on the "thumb" buttons if your mouse have them), since for some reason MMB clicks aren't getting detected on my machine.
  • Key maps for switching party member are not dependent on their actual position in the party.
    They are instead simple key maps for whomever appear on the inactive party members list.
    image
    For the example above, the first character on the list is Diona, so clicking 1 will switch to her.
    But afterwards, the game will simply position the previous character there, so clicking 1 again will switch back to the previous character.
  • Key maps for switching to N-th party member and immediately activating their Elemental Burst are: 5 for party member 1, 6 for party member 2, 7 for party member 3, and 8 for party member 4.
    Party members here refer to the logic in the previous list item.
    Unfortunately, I'm not aware of any way to capture key combinations in QtScrcpy, or otherwise Alt+1 and the likes would have been preferable.
  • Pick Up/Interact (F) only works for 1 item at a time, as it's only mapped to 1 coordinate.
    Interacting with anything but the 1st option require switching to normal mode.
    NOTICE: Mobile players can pick up ALL ITEMS in range by tapping anywhere on the screen aside from the pick up prompts, but I bound this to only the first pick up prompt since you still need to use the prompt to interact with NPCs and such. So yeah, switch to normal mode when you want to just pick up all items.
  • Open Notification Details (Y) is not yet mapped.
  • Challenge Interrupted (P) is not yet mapped.
  • F is also mapped to resisting frozen/bubble.
  • Z is mapped to quick-use gadget. This seems to be the default on PC too, but the wiki reference didn't mention it.
  • Inputs seem to have cooldown of 0.5s, approximately. Not sure if software bottleneck or by design. Noticeable impact when fast-tapping frozen/bubble resist, among other things.

@BobbyWibowo
Copy link
Author

BobbyWibowo commented Dec 19, 2020

Discontinued until more improvements to QtScrcpy's input performance.

@nxwi
Copy link

nxwi commented Nov 13, 2021

Thanks a lot <3
Works perfectly on 1080 x 2340 resolution (Realme 2 Pro)

@ss22219
Copy link

ss22219 commented Jan 21, 2022

Works on Redmi K20 PRO

@jhonwick6904
Copy link

does the mouse works too or you have to click and drag

@BobbyWibowo
Copy link
Author

@jhonwick6904 read the first entry in Quirks section

@jyaucn
Copy link

jyaucn commented Mar 4, 2022

can u get banned from this, im kinda worried abt my genshin account

@ukw16
Copy link

ukw16 commented Jul 1, 2022

@jyaucn someone used it last month. I used it way back in 2.0 as a test. Nothing happened but if you don't want to risk it, don't do it.
Here's the post I'm referring to: https://www.reddit.com/r/Genshin_Impact/comments/v2k6yy/since_controller_support_for_android_is_not/?utm_medium=android_app&utm_source=share

@LeeRina19918
Copy link

 Hi! How do u now what x-y position?

@BobbyWibowo
Copy link
Author

@LeeRina19918 When clicking on the Android viewport with left mouse button, QtScrcpy's console will output the XY relative coordinates:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment