项目作者: SamClercky

项目描述 :
A simple gamepad controller to help you with games with no gamepad support
高级语言: Kotlin
项目地址: git://github.com/SamClercky/GamepadRobot.git
创建时间: 2018-03-24T11:15:46Z
项目社区:https://github.com/SamClercky/GamepadRobot

开源协议:MIT License

下载


GamepadRobot

This is a simple cross platform gamepad controller based on lwjgl3 and 100% written in Kotlin. It helps to control games with no gamepad support.

Functionalities

  • Json-config capabilities
  • Taking control over the mouse and keyboard but with precaution so the computer doesn’t become unhandable
  • A lot of possible settings
  • Test unit where the gamepad can be tested (useful when creating a new json file)
  • Fast reaction by using multithreaded code
  • Cross platform (Windows, MacOs, Linux (x64))

    Limitations

  • Not all keys are currently availlable

    Contribute

    Like a smart roman once said, making mistakes is human, so can I make mistakes and is there always room for improvements.
    Please submit a issue or fork this repo.

    How to use

    Installation

    Go to the download page and download the jar-file (it should work on all supported platforms)
    Download the file where you want it to install and you are ready to issue commands
    On Unix-based systems, make sure you make the file executable
    Navigate to the jar-file and issue in the terminal the following command
    sudo chmod +x GamepadRobot.jar

    Adding a controller

    First connect the controller to the computer and make sure there is no other usb-device is connected.
    Navigate to the jar-file and issue the command ./GamepadRobot.jar --test. This starts the application and shows the data from the connected gamepad. Mine looks like this:
    ```
    Event(key=0, value=0, analog=true), Event(key=1, value=0, analog=true), Event(key=2, value=0, analog=true), Event(key=3, value=0, analog=true), Event(key=0, value=0, analog=false), Event(key=1, value=0, analog=false), Event(key=2, value=0, analog=false), Event(key=3, value=0, analog=false),

  1. The data gives a update every second. Now hit the buttons of the gamepad and see which value changes and write the key and value down of the Event-closule. It is possible that some buttons use the same key but a different value.
  2. Now we are ready to write the json for our gamepad.
  3. The final will look like this. It is a configuration for a xbox-controller playing Minecraft java edition.
  4. ```javascript
  5. {
  6. "buttons": [
  7. {"key": "0", "value": "Q"},
  8. {"key": "0 2", "value": "D"},
  9. {"key": "1", "value": "Z"},
  10. {"key": "1 2", "value": "S"},
  11. {"key": "2", "value": "MOUSEMOVEX"},
  12. {"key": "2 2", "value": "MOUSEMOVEX"},
  13. {"key": "3", "value": "MOUSEMOVEY"},
  14. {"key": "3 2", "value": "MOUSEMOVEY"},
  15. {"key": "4", "value": "F6"},
  16. {"key": "4 2", "value": "F7"},
  17. {"key": "4 3", "value": "F8"},
  18. {"key": "4 4", "value": "F5"},
  19. {"key": "5", "value": "MOUSELEFT"},
  20. {"key": "5 2", "value": "MOUSERIGHT"},
  21. {"key": "5 3", "value": "SHIFT"},
  22. {"key": "5 4", "value": "F9"},
  23. {"key": "6", "value": "E"},
  24. {"key": "6 2", "value": "ESC"},
  25. {"key": "6 3", "value": "SPACE"},
  26. {"key": "6 4", "value": "SPACE"},
  27. {"key": "7", "value": "F2"},
  28. {"key": "7 2", "value": "F1"},
  29. {"key": "7 3", "value": "F4"},
  30. {"key": "7 4", "value": "F3"}
  31. ],
  32. "unmappedBtn" : [
  33. {"btn": "0", "values": [-1, 1]},
  34. {"btn": "1", "values": [-1, 1]},
  35. {"btn": "4", "values": [1, 256, 65536, 16777216]},
  36. {"btn": "5", "values": [1, 256, 65536, 16777216]},
  37. {"btn": "6", "values": [1, 256, 65536, 16777216]},
  38. {"btn": "7", "values": [1, 256, 65536, 16777216]}
  39. ],
  40. "mouseSentivity": 50
  41. }

If you haven’t any experience with json, don’t be afraid, just copy mine and commit the changes you prefer.
We will start with the “unmappedBtn”. The number after “btn”: is just the key value from earlier. Make sure that the number is between the dubble quotes and there are no spaces. The values after “values”: are the different values you had for one key. This is used by the program to know which button belongs to which value.
Do this for all your data but not the buttons that will control the mouse movement.
The second section we will discuss is the buttons-section. The key value is the same as the key values from our test but also with a index. The indexes are controlled by the unmappedBtn-section: if there are 2 values, there are also 2 keys with a index, if there are 4 values, …
The value is the action that has to be bound to the button from the gamepad. Here is a list of all the availlable options. The maining is selfexplaining. (Make sure that the value is always between dubble quotes)

  • MOUSEMOVEX
  • MOUSEMOVEY
  • MOUSELEFT
  • MOUSERIGHT
  • A
  • Z
  • E
  • R
  • T
  • Y
  • U
  • I
  • O
  • P
  • Q
  • S
  • D
  • F
  • G
  • H
  • J
  • K
  • L
  • M
  • W
  • X
  • C
  • V
  • B
  • N
  • SHIFT
  • CONTROL
  • F1 (this is just the 1 on the keyboard and not f1)
  • F2
  • F3
  • F4
  • F5
  • F6
  • F7
  • F8
  • F9
  • F0
  • SPACE
  • ESC
  • NOTHING

Last but not least, there is the mouseSentivity-section. How bigger this number, how faster the mouse will react.