Last active
February 16, 2020 22:07
-
-
Save werpu/4fd3d4741299a56be787044018fea710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* MIT License | |
# | |
# Copyright (c) 2019 Werner Punz | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
###################################################################### | |
# device definitions | |
####################################################################### | |
*/ | |
#parse("macros.vm") | |
{ | |
/** | |
* Input devices | |
*/ | |
inputs: { | |
/*second match after the first, responsible for delivering | |
the mouse signals, unfortunately same name*/ | |
#input_def_phys( "trackball_paddle_y" "usb-0000:01:00.0-1.1.2/input1" "true" "1"), | |
#input_def( "digital" "Ultimarc I-PAC Ultimarc I-PAC" "true" "1"), | |
#input_def_mm_re( "analog_left" "^Ultimarc.*Ultra-Stik\\\\s+Player\\\\s+1$" "true" "1" "0" "255" "18"), | |
#input_def_re( "analog_right" "^Ultimarc.*Ultra-Stik\\\\s+Player\\\\s+2$" "true" "1") | |
}, | |
/** | |
* output device definitions | |
*/ | |
outputs: { | |
#output_def( "xbox2" "Microsoft X-Box 360 pad" "xbx360"), | |
/** | |
* register an execution driver for external script execution of shell scripts | |
*/ | |
#output_def( "exec1" "Execution Driver" "exec"), | |
/** | |
* register an eval driver for python plugin execution | |
*/ | |
#output_def( "eval1" "Evaluation Driver" "eval"), | |
/** | |
* Register a serial line uart communications driver to our first | |
* external board | |
*/ | |
#output_def_meta( "serial0" "Serial Line 0 (first external joystick)" "serial" "/dev/serial0") | |
}, | |
rules: [ | |
{ | |
from: "trackball_paddle_y", | |
target_rules: [ | |
#mapping( "(EV_REL), code 0 (REL_X)" "serial0" "(EV_REL), code 0 (REL_X)" ), | |
#mapping( "(EV_REL), code 1 (REL_Y)" "serial0" "(EV_REL), code 1 (REL_Y)" ) | |
] | |
}, | |
{ | |
from: "digital", | |
/* | |
* First set of rules mapping for the simulated pad | |
*/ | |
target_rules: [ | |
/* | |
* HAT controls top bottom, left, right | |
*/ | |
#mapping( "(EV_KEY), code 103 (KEY_UP)" "serial0" "(EV_ABS), code 17 (ABS_HAT0Y), value -1" ), | |
//key down left digital | |
#mapping( "(EV_KEY), code 108 (KEY_DOWN)" "serial0" "(EV_ABS), code 17 (ABS_HAT0Y), value 1" ), | |
//left left stick digital | |
#mapping( "(EV_KEY), code 105 (KEY_LEFT)" "serial0" "(EV_ABS), code 16 (ABS_HAT0X), value -1" ), | |
//right left stick digital | |
#mapping( "(EV_KEY), code 106 (KEY_RIGHT)" "serial0" "(EV_ABS), code 16 (ABS_HAT0X), value 1" ), | |
//BTN A - auto frequency mapping for periodical trigger | |
#af_mapping( "(EV_KEY), code 29 (KEY_LEFTCTRL)" "serial0" "(EV_KEY), code 304 (BTN_SOUTH)" "1" "200" ), | |
//BTN B | |
#mapping( "(EV_KEY), code 56 (KEY_LEFTALT)" "serial0" "(EV_KEY), code 305 (BTN_EAST)" ), | |
//BTN X | |
#mapping( "(EV_KEY), code 57 (KEY_SPAVE)" "serial0" "(EV_KEY), code 307 (BTN_NORTH)" ), | |
//BTN Y | |
#mapping( "(EV_KEY), code 42 (KEY_LEFTSHIFT)" "serial0" "(EV_KEY), code 308 (BTN_WEST)" ), | |
//BTN L | |
#mapping( "(EV_KEY), code 44 (KEY_Z)" "serial0" "(EV_KEY), code 310 (BTN_TL)" ), | |
//BTN R | |
#mapping( "(EV_KEY), code 45 (KEY_X)" "serial0" "(EV_KEY), code 311 (BTN_TR)" ), | |
//BTN TL | |
#mapping( "(EV_KEY), code 47 (KEY_V)" "serial0" "(EV_KEY), code 312 (BTN_TL2)" ), | |
//BTN TR | |
#mapping( "(EV_KEY), code 25 (KEY_P)" "serial0" "(EV_KEY), code 313 (BTN_TR2)" ), | |
//THUMB LEFT | |
#mapping( "(EV_KEY), code 46 (KEY_C)" "serial0" "(EV_KEY), code 317 (BTN_THUMBL)" ), | |
//THUMB RIGHT | |
#mapping( "(EV_KEY), code 15 (KEY_TAB)" "serial0" "(EV_KEY), code 318 (BTN_THUMBR)" ), | |
//SELECT | |
#mapping( "(EV_KEY), code 6 (KEY_5)" "serial0" "(EV_KEY), code 314 (BTN_SELECT)" ), | |
//START | |
#mapping( "(EV_KEY), code 2 (KEY_1)" "serial0" "(EV_KEY), code 315 (BTN_START)" ), | |
//MODE XBOX BUTTON | |
{ | |
from_ev: "(EV_KEY), code 102 (KEY_HOME)", | |
targets: [ | |
#output("xbox2" "(EV_KEY), code 316 (BTN_MODE)"), | |
#output("serial0" "(EV_KEY), code 316 (BTN_MODE)") | |
] | |
} | |
] | |
}, | |
//ANALOG STICK | |
{ | |
from: "analog_left", | |
target_rules: [ | |
#forward( "(EV_ABS), code 1 (ABS_Y)" "serial0"), | |
#forward( "(EV_ABS), code 0 (ABS_X)" "serial0"), | |
] | |
}, | |
//ANALOG STICK RIGHT | |
{ | |
from: "analog_right", | |
target_rules: [ | |
{ | |
from_ev: "(EV_ABS), code 1 (ABS_Y)", | |
targets: [ | |
#output("xbox2" "(EV_ABS), code 1 (ABS_Y)"), | |
#output("serial0" "(EV_ABS), code 4 (ABS_RY)") | |
] | |
}, | |
{ | |
from_ev: "(EV_ABS), code 0 (ABS_X)", | |
targets: [ | |
#output("xbox2" "(EV_ABS), code 0 (ABS_X)"), | |
#output("serial0" "(EV_ABS), code 3 (ABS_RX)") | |
] | |
}, | |
//front orange button left -> 4 way switch | |
#mapping( "(EV_KEY), code 292 (BTN_TOP2)" "exec1" "(META), /home/pi/jstools/4way.sh" ), | |
//front orange button left -> 8 way switch | |
#mapping( "(EV_KEY), code 291 (BTN_TOP1)" "exec1" "(META), /home/pi/jstools/8way.sh" ), | |
//button front right -> special key | |
//burp sound, reserve for now | |
#mapping( "(EV_KEY), code 290 (BTN_THUMB2)" "eval1" "(META), /home/werpu/gamepadservice/burping.py" ), | |
//osd reserve for now | |
#mapping( "(EV_KEY), code 293 (BTN_PINKIE)" "eval1" "(META), /home/werpu/gamepadservice/florence.py" ) | |
] | |
}, | |
// ----------- todo progress with the mapping from here onwards for the full definition ------- | |
{ | |
//digital pad2 definition (right digital) | |
from: "digital", | |
target_rules: [ | |
//hat y up joystick2 | |
#mapping( "(EV_KEY), code 32 (KEY_D)" "xbox2" "(EV_ABS), code 17 (ABS_HAT0Y), value -1" ), | |
//hat y down joystick2 | |
#mapping( "(EV_KEY), code 33 (KEY_F)" "xbox2" "(EV_ABS), code 17 (ABS_HAT0Y), value 1" ), | |
//hat left joystick2 | |
#mapping( "(EV_KEY), code 34 (KEY_G)" "xbox2" "(EV_ABS), code 16 (ABS_HAT0X), value -1" ), | |
//hat right joystick2 | |
#mapping( "(EV_KEY), code 19 (KEY_R)" "xbox2" "(EV_ABS), code 16 (ABS_HAT0X), value 1" ), | |
//js2 btn A | |
#mapping( "(EV_KEY), code 31 (KEY_S)" "xbox2" "(EV_KEY), code 304 (BTN_SOUTH)" ), | |
//js2 btn B | |
#mapping( "(EV_KEY), code 30 (KEY_A)" "xbox2" "(EV_KEY), code 305 (BTN_EAST)" ), | |
// js2 btn Y | |
#mapping( "(EV_KEY), code 16 (KEY_Q)" "xbox2" "(EV_KEY), code 307 (BTN_NORTH)" ), | |
// js2 btn X | |
#mapping( "(EV_KEY), code 17 (KEY_W)" "xbox2" "(EV_KEY), code 308 (BTN_WEST)" ), | |
// js2 btn L | |
#mapping( "(EV_KEY), code 37 (KEY_K)" "xbox2" "(EV_KEY), code 310 (BTN_TL)" ), | |
// js2 btn r | |
#mapping( "(EV_KEY), code 23 (KEY_I)" "xbox2" "(EV_KEY), code 310 (BTN_TR)" ), | |
//js2 btn LT | |
#mapping( "(EV_KEY), code 36 (KEY_J)" "xbox2" "(EV_KEY), code 312 (BTN_TL2)" ), | |
//js2 btn RT | |
#mapping( "(EV_KEY), code 38 (KEY_L)" "xbox2" "(EV_KEY), code 313 (BTN_TR2)" ), | |
//js2 thumbl | |
#mapping( "(EV_KEY), code 15 (KEY_TAB)" "xbox2" "(EV_KEY), code 317 (BTN_THUMBL)" ), | |
// select | |
#mapping( "(EV_KEY), code 7 (KEY_6)" "xbox2" "(EV_KEY), code 314 (BTN_SELECT)" ), | |
// start | |
#mapping( "(EV_KEY), code 3 (KEY_2)" "xbox2" "(EV_KEY), code 315 (BTN_START)" ), | |
// select 1 + start 2 => alt f4 | |
#mapping( "(EV_KEY), code 56 (KEY_LEFTALT)" "serial0" "(EV_KEY), code 56 (KEY_LEFTALT)" ), | |
// player2 home -> f4 | |
#mapping( "(EV_KEY), code 62 (KEY_F4)" "serial0" "(EV_KEY), code 62 (KEY_F4)" ), | |
] | |
}, | |
//mouse left (button left 2 | |
{ | |
from: "analog_left", | |
target_rules: [ | |
//mouse right (button left 1) | |
#mapping( "(EV_KEY), code 288 (BTN_TRIGGER)" "serial0" "(EV_KEY), code 272 (BTN_LEFT)" ), | |
//mouse btn right | |
#mapping( "(EV_KEY), code 289 (BTN_THUMB)" "serial0" "(EV_KEY), code 273 (BTN_RIGHT)" ), | |
#mapping( "(EV_KEY), code 290 (BTN_THUMB2)" "serial0" "(EV_KEY), code 2 (KEY_1)" ), | |
#mapping( "(EV_KEY), code 291 (BTN_TOP)" "serial0" "(EV_KEY), code 3 (KEY_2)" ), | |
#mapping( "(EV_KEY), code 291 (BTN_TOP2)" "serial0" "(EV_KEY), code 4 (KEY_3)" ), | |
#mapping( "(EV_KEY), code 293 (BTN_PINKIE)" "serial0" "(EV_KEY), code 5 (KEY_4)" ), | |
#mapping( "(EV_KEY), code 294 (BTN_BASE)" "serial0" "(EV_KEY), code 6 (KEY_5)" ), | |
#mapping( "(EV_KEY), code 295 (BTN_BASE2)" "serial0" "(EV_KEY), code 7 (KEY_6)" ), | |
#mapping( "(EV_KEY), code 296 (BTN_WHATEVER)" "serial0" "(EV_KEY), code 8 (KEY_9)" ) | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment