Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yoke/assets/joypad/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div id="racing">Racing</div>
<div id="dpad">Retro (D-pad)</div>
<div id="gamepad">Gamepad</div>
<div id="testing">Testing</div>
<div id="xbox">Xbox 360</div>
</div>
<div id="warning">If you don't see any controls, please <a href="https://play.google.com/store/apps/details?id=com.google.android.webview">upgrade Android WebView</a>, then reboot your device.</div>
<script type="application/javascript" src="base.js"></script>
Expand Down
41 changes: 41 additions & 0 deletions yoke/assets/joypad/xbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Gamepad settings the user might want to change. */

/* This is for xbox 360 */
#joypad {
grid-template-columns: repeat(10, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-template-areas:
/* The map below must match the number of rows and columns specified above.
* Controls may cover any rectangular area.
* Do not try drawing non-rectangular shapes. */
"a9 a9 . . j2 j2 . . a8 a8 "
". . b6 . j2 j2 . b5 . . "
"j1 j1 j1 . . . . . b3 . "
"j1 j1 j1 . bg bg . b4 . b2 "
"j1 j1 j1 . bs bs . . b1 . "
;
/* Possible values:
* j1, j2, j3... for joystick (returns to center when released);
* s1, s2, s3... for sticky joystick (stays in place when released);
* t1, t2, t3... for thumb joystick (returns to center, and can be
pressed down with force or two fingers to simulate L3/R3 button,
like in console controllers).
* m_ for motion detector, where _ is one of these letters:
* x for acceleration in the X-axis (left to right),
* y for acceleration in the Y-axis (bottom to top),
* z for acceleration in the Z-axis (back to front),
* a for α (alpha) angle -- rotation around the Z-axis,
* b for β (beta) angle -- rotation around the X-axis,
* g for γ (gamma) angle -- rotation around the Y-axis;
* pa, pb, pt for pedals (accelerator, brake, throttle);
* k1, k2... for knobs;
* b_ for buttons, where _ is:
* s for START button,
* g for SELECT button,
* m for the branded button (HOME or equivalent),
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10... for the rest.
* a_ for analog button/trigger, where _ is a number;
* dp for D-pad;
* dbg for debug messages;
* a period for empty space. */
}
6 changes: 4 additions & 2 deletions yoke/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,13 @@
't1': 'ABS_X,ABS_Y,BTN_THUMB',
't2': 'ABS_RX,ABS_RY,BTN_THUMB2',
'mx': 'ABS_MISC',
'my': 'ABS_RZ',
'mz': 'ABS_Z',
'ma': 'ABS_TILT_X',
'mb': 'ABS_WHEEL',
'mg': 'ABS_TILT_Y',
'pa': 'ABS_GAS',
'pb': 'ABS_BRAKE',
'py': 'ABS_RZ',
'pz': 'ABS_Z',
'pt': 'ABS_THROTTLE',
'k1': 'ABS_VOLUME',
'k2': 'ABS_RUDDER',
Expand All @@ -624,6 +624,8 @@
'a6': 'ABS_HAT2Y',
'a7': 'ABS_HAT3X',
'a8': 'ABS_HAT3Y',
'a8': 'ABS_RZ',
'a9': 'ABS_Z',
'bs': 'BTN_START',
'bg': 'BTN_SELECT',
'bm': 'BTN_MODE',
Expand Down
10 changes: 8 additions & 2 deletions yoke/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ def __init__(self, id=1, name='Yoke', events=(), bytestring=b''):
self.inStruct = struct.Struct('>x' + ''.join(['H' if e in ABS_EVENTS else '?' for e in events]))
events = [e + (0, 0x7fff, 0, 0) if e in ABS_EVENTS else e for e in events]

BUS_VIRTUAL = 0x06
# see usbids here: http://www.linux-usb.org/usb.ids
# For xbox
BUS_VIRTUAL = 0x03
VENDOR_VIRTUAL = 0x45e
PRODUCT_VIRTUAL = 0x28e
VERSION_VIRTUAL = 0x110

try:
self.device = uinput.Device(events, name, BUS_VIRTUAL)
self.device = uinput.Device(events, name, BUS_VIRTUAL, VENDOR_VIRTUAL, PRODUCT_VIRTUAL, VERSION_VIRTUAL)
except Exception as e:
raise UInputDisabledError(*e.args)

Expand Down