Skip to content

Instantly share code, notes, and snippets.

@werpu
Created June 2, 2019 19:18
Show Gist options
  • Save werpu/d60c640700d2e4d811ab0cd1f8d8797d to your computer and use it in GitHub Desktop.
Save werpu/d60c640700d2e4d811ab0cd1f8d8797d to your computer and use it in GitHub Desktop.
# 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
#######################################################################
inputs:
digital:
name: Ultimarc I-PAC Ultimarc I-PAC
exclusive: true
relpos: 1
analog_left:
name_re: ^Ultimarc.*Ultrastik\sPlayer\ 1$
exclusive: true
relpos: 1
analog_right:
name_re: ^Ultimarc.*Ultrastik\sPlayer\ 2$
exclusive: true
relpos: 1
########################################################################
# output devices
########################################################################
outputs:
xbox1:
name: Microsoft X-Box 360 pad
type: xbx360
xbox2:
name: Microsoft X-Box 360 pad
type: xbx360
mouse1:
name: mouse
type: mouse
keybd1:
name: key1
type: keybd
##########################################################
# rules section, maps events from one device into another
##########################################################
rules:
##################################
# xbox1 (partial xbox2) Mapping
##################################
- from: digital
target_rules:
-from_ev: (EV_KEY), code 103 (KEY_UP) # keyup event as coming in from evtest
targets:
- to: xbox1 # artificial xbox controiler
to_ev: (EV_ABS), code 17 (ABS_HAT0Y), value -1 # pad up event
- from_ev: (EV_KEY), code 108 (KEY_DOWN) # keyup event as coming in from evtest
targets:
- to: xbox1
to_ev: (EV_ABS), code 17 (ABS_HAT0Y), value 1 # pad down event
- from_ev: (EV_KEY), code 105 (KEY_LEFT) # keyleft event as coming in from evtest
targets:
- to: xbox1
to_ev: (EV_ABS), code 16 (ABS_HAT0X), value -1 # pad left event
- from_ev: (EV_KEY), code 106 (KEY_RIGHT) # keyleft event as coming in from evtest
targets:
- to: xbox1
to_ev: (EV_ABS), code 16 (ABS_HAT0X), value 1 # pad right event
# button events
- from_ev: (EV_KEY), code 29 (KEY_LEFTCTRL) # btn a
targets:
- to: xbox1
to_ev: (EV_KEY), code 304 (BTN_SOUTH)
- from_ev: (EV_KEY), code 56 (KEY_LEFTALT) #btn b
targets:
- to: xbox1
to_ev: (EV_KEY), code 305 (BTN_EAST)
- from_ev: (EV_KEY), code 57 (KEY_SPACE) # btn x
targets:
- to: xbox1
to_ev: (EV_KEY), code 307 (BTN_NORTH)
- from_ev: (EV_KEY), code 42 (KEY_LEFTSHIFT) # btn y
targets:
- to: xbox1
to_ev: (EV_KEY), code 308 (BTN_WEST)
- from_ev: (EV_KEY), code 44 (KEY_Z) # btn 1l
targets:
- to: xbox1
to_ev: (EV_KEY), code 310 (BTN_TL)
- from_ev: (EV_KEY), code 45 (KEY_X) # btn 1r
targets:
- to: xbox1
to_ev: (EV_KEY), code 311 (BTN_TR)
- from_ev: (EV_KEY), code 47 (KEY_V) # btn tl
targets:
- to: xbox1
to_ev: (EV_KEY), code 312 (BTN_TL2)
- from_ev: (EV_KEY), code 25 (KEY_P) # btn tr
targets:
- to: xbox1
to_ev: (EV_KEY), code 313 (BTN_TR2)
- from_ev: (EV_KEY), code 46 (KEY_C) # btn thumb l
targets:
- to: xbox1
to_ev: (EV_KEY), code 317 (BTN_THUMBL)
- from_ev: (EV_KEY), code 15 (KEY_TAB) # btn thumb r
targets:
- to: xbox1
to_ev: (EV_KEY), code 318 (BTN_THUMBR)
- to: xbox2
to_ev: (EV_KEY), code 318 (BTN_THUMBR)
- from_ev: (EV_KEY), code 3 (KEY_2) # sel
targets:
- to: xbox1
to_ev: (EV_KEY), code 314 (BTN_SELECT)
- from_ev: (EV_KEY), code 6 (KEY_5) # start
targets:
- to: xbox1
to_ev: (EV_KEY), code 315 (BTN_START)
# TODO HOME
# left analog stick
- from: analog_left
target_rules:
- from_ev: (EV_ABS), code 1 (ABS_Y) # up down
targets:
- to: xbox1
to_ev: (EV_ABS), code 1 (ABS_Y)
- from_ev: (EV_ABS), code 0 (ABS_X) #up down
targets:
- to: xbox1
to_ev: (EV_ABS), code 0 (ABS_X)
# right analog stick
- from: analog_right
target_rules:
- from_ev: (EV_ABS), code 1 (ABS_Y) # up down
targets:
- to: xbox1
to_ev: (EV_ABS), code 4 (ABS_RY)
- to: xbox2
to_ev: (EV_ABS), code 1 (ABS_Y)
- from_ev: (EV_ABS), code 1 (ABS_X) # lef right
targets:
- to: xbox1
to_ev: (EV_ABS), code 3 (ABS_RX)
- to: xbox2
to_ev: (EV_ABS), code 0 (ABS_X)
##################################
# rest of xbox2 mapping
##################################
- from: digital # digital
target_rules:
- from_ev: (EV_KEY), code 32 (KEY_D) # keyup event as coming in from evtest
targets:
- to: xbox2 # artificial xbox controiler
to_ev: (EV_ABS), code 17 (ABS_HAT0Y), value -1 # pad up event
- from_ev: (EV_KEY), code 33 (KEY_F) # keyup event as coming in from evtest
targets:
- to: xbox2
to_ev: (EV_ABS), code 17 (ABS_HAT0Y), value 1 # pad down event
- from_ev: (EV_KEY), code 34 (KEY_G) # keyleft event as coming in from evtest
targets:
- to: xbox2
to_ev: (EV_ABS), code 16 (ABS_HAT0X), value -1 # pad left event
- from_ev: (EV_KEY), code 19 (KEY_R) # keyright event as coming in from evtest
targets:
- to: xbox2
to_ev: (EV_ABS), code 16 (ABS_HAT0X), value 1 # pad right event
# button events
- from_ev: (EV_KEY), code 31 (KEY_S) # btn a
targets:
- to: xbox2
to_ev: (EV_KEY), code 304 (BTN_SOUTH)
- from_ev: (EV_KEY), code 30 (KEY_A) #btn b
targets:
- to: xbox2
to_ev: (EV_KEY), code 305 (BTN_EAST)
- from_ev: (EV_KEY), code 16 (KEY_Q) # btn x
targets:
- to: xbox2
to_ev: (EV_KEY), code 307 (BTN_NORTH)
- from_ev: (EV_KEY), code 17 (KEY_W) # btn y
targets:
- to: xbox2
to_ev: (EV_KEY), code 308 (BTN_WEST)
- from_ev: (EV_KEY), code 37 (KEY_K) # btn 1l
targets:
- to: xbox2
to_ev: (EV_KEY), code 310 (BTN_TL)
- from_ev: (EV_KEY), code 23 (KEY_I) # btn 1r
targets:
- to: xbox2
to_ev: (EV_KEY), code 311 (BTN_TR)
- from_ev: (EV_KEY), code 36 (KEY_J) # btn tl
targets:
- to: xbox2
to_ev: (EV_KEY), code 312 (BTN_TL2)
- from_ev: (EV_KEY), code 38 (KEY_L) # btn tr
targets:
- to: xbox2
to_ev: (EV_KEY), code 313 (BTN_TR2)
- from_ev: (EV_KEY), code 15 (KEY_TAB) # btn thumb l
targets:
- to: xbox2
to_ev: (EV_KEY), code 317 (BTN_THUMBL)
#thumbr already defined
- from_ev: (EV_KEY), code 7 (KEY_6) # sel
targets:
- to: xbox2
to_ev: (EV_KEY), code 314 (BTN_SELECT)
- from_ev: (EV_KEY), code 2 (KEY_1) # start
targets:
- to: xbox2
to_ev: (EV_KEY), code 315 (BTN_START)
### special buttons connected to the analog sticks
- from: analog_left
- from_ev: (EV_KEY), code 288 (BTN_TRIGGER)
-to: keybd
-to_ev: (EV_KEY), code 30 (KEY_A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment