Repository: Ryochan7/sc-controller
Branch: python3
Commit: 4899f6999580
Files: 275
Total size: 2.5 MB
Directory structure:
gitextract_w078v14n/
├── .github/
│ └── workflows/
│ ├── appimage.yml
│ └── scc-linux.yml
├── ADDITIONAL-LICENSES
├── AppImageBuilder.yml
├── Dockerfile
├── LICENSE
├── README.md
├── TODO.md
├── appimage-build.sh
├── daemon.sh
├── default_menus/
│ ├── Default.menu
│ └── Profiles.menu
├── default_profiles/
│ ├── Desktop.sccprofile
│ ├── XBox Controller with High Precision Camera.sccprofile
│ └── XBox Controller.sccprofile
├── docs/
│ ├── actions.md
│ ├── menu-file.md
│ ├── profile-file.md
│ └── protocol.md
├── gamecontrollerdb.txt
├── generate-icons.py
├── generate_svg.py
├── glade/
│ ├── about.glade
│ ├── action_editor.glade
│ ├── ae/
│ │ ├── axis.glade
│ │ ├── axis_action.glade
│ │ ├── buttons.glade
│ │ ├── custom.glade
│ │ ├── dpad.glade
│ │ ├── first_page.glade
│ │ ├── gesture.glade
│ │ ├── gyro.glade
│ │ ├── gyro_action.glade
│ │ ├── menu_only.glade
│ │ ├── osk_action.glade
│ │ ├── per_axis.glade
│ │ ├── recent_list.glade
│ │ ├── special_action.glade
│ │ ├── tilt.glade
│ │ └── trigger.glade
│ ├── app.glade
│ ├── controller_settings.glade
│ ├── creg.glade
│ ├── global_settings.glade
│ ├── icon_chooser.glade
│ ├── import_export.glade
│ ├── key_grabber.glade
│ ├── macro_editor.glade
│ ├── menu_editor.glade
│ ├── modeshift_editor.glade
│ ├── osk_binding_editor.glade
│ ├── ring_editor.glade
│ └── simple_chooser.glade
├── images/
│ ├── button-images/
│ │ └── groups.json
│ ├── deck.config.json
│ ├── ds4-config.json
│ ├── ds5-config.json
│ ├── keyboard.svg.json
│ ├── menu-icons/
│ │ ├── buttons/
│ │ │ └── LICENCES
│ │ ├── driving/
│ │ │ └── LICENCES
│ │ ├── items/
│ │ │ └── LICENCES
│ │ ├── media/
│ │ │ └── LICENCES
│ │ ├── system/
│ │ │ ├── LICENCES
│ │ │ └── profiles.bw.xcf
│ │ └── weapons/
│ │ └── LICENCES
│ ├── radial-menu.svg.json
│ ├── remotepad.json
│ ├── sc-config.json
│ └── x360-config.json
├── osd-styles/
│ ├── Blue.colors.json
│ ├── Classic.gtkstyle.css
│ ├── Cyan.colors.json
│ ├── Green.colors.json
│ ├── Red.colors.json
│ ├── Reloaded.gtkstyle.css
│ └── Yellow.colors.json
├── profile_examples/
│ ├── DeSmuME.sccprofile
│ ├── DiRT Rally.sccprofile
│ ├── GZDoom.sccprofile
│ ├── Kodi.sccprofile
│ ├── No Man Sky.sccprofile
│ ├── Portal 2 coop.sccprofile
│ ├── Portal 2.sccprofile
│ ├── README.md
│ ├── Stardew Valley.sccprofile
│ ├── Tomb Raider 2013.sccprofile
│ ├── Undertale.sccprofile
│ ├── Vanguard Princess.sccprofile
│ └── firefox.sccprofile
├── run.sh
├── scc/
│ ├── __init__.py
│ ├── actions.py
│ ├── aliases.py
│ ├── c_branch.h
│ ├── cemuhook_server.c
│ ├── cemuhook_server.py
│ ├── cheader.py
│ ├── config.py
│ ├── constants.py
│ ├── controller.py
│ ├── custom.py
│ ├── device_monitor.py
│ ├── drivers/
│ │ ├── __init__.py
│ │ ├── ds4drv.py
│ │ ├── ds5drv.py
│ │ ├── evdevdrv.py
│ │ ├── fake.py
│ │ ├── hiddrv.c
│ │ ├── hiddrv.py
│ │ ├── remotepad.h
│ │ ├── remotepad.py
│ │ ├── remotepad_controller.c
│ │ ├── sc_by_bt.c
│ │ ├── sc_by_bt.py
│ │ ├── sc_by_cable.py
│ │ ├── sc_dongle.py
│ │ ├── scc_future.h
│ │ ├── steamdeck.py
│ │ └── usb.py
│ ├── foreign/
│ │ ├── __init__.py
│ │ ├── vdf.py
│ │ └── vdffz.py
│ ├── gestures.py
│ ├── gui/
│ │ ├── __init__.py
│ │ ├── aboutdialog.py
│ │ ├── action_editor.py
│ │ ├── ae/
│ │ │ ├── __init__.py
│ │ │ ├── axis.py
│ │ │ ├── axis_action.py
│ │ │ ├── buttons.py
│ │ │ ├── custom.py
│ │ │ ├── dpad.py
│ │ │ ├── first_page.py
│ │ │ ├── gesture.py
│ │ │ ├── gyro.py
│ │ │ ├── gyro_action.py
│ │ │ ├── menu_action.py
│ │ │ ├── menu_only.py
│ │ │ ├── osk_action.py
│ │ │ ├── osk_buttons.py
│ │ │ ├── per_axis.py
│ │ │ ├── recent_list.py
│ │ │ ├── special_action.py
│ │ │ ├── tilt.py
│ │ │ └── trigger.py
│ │ ├── app.py
│ │ ├── area_to_action.py
│ │ ├── binding_editor.py
│ │ ├── chooser.py
│ │ ├── controller_image.py
│ │ ├── controller_settings.py
│ │ ├── controller_widget.py
│ │ ├── creg/
│ │ │ ├── __init__.py
│ │ │ ├── constants.py
│ │ │ ├── data.py
│ │ │ ├── dialog.py
│ │ │ ├── grabs.py
│ │ │ └── tester.py
│ │ ├── daemon_manager.py
│ │ ├── dwsnc.py
│ │ ├── editor.py
│ │ ├── gdk_to_key.py
│ │ ├── gestures.py
│ │ ├── global_settings.py
│ │ ├── icon_chooser.py
│ │ ├── importexport/
│ │ │ ├── __init__.py
│ │ │ ├── dialog.py
│ │ │ ├── export.py
│ │ │ ├── import_sccprofile.py
│ │ │ └── import_vdf.py
│ │ ├── key_grabber.py
│ │ ├── keycode_to_key.py
│ │ ├── macro_editor.py
│ │ ├── menu_editor.py
│ │ ├── modeshift_editor.py
│ │ ├── osd_mode.py
│ │ ├── osk_binding_editor.py
│ │ ├── parser.py
│ │ ├── profile_switcher.py
│ │ ├── ribar.py
│ │ ├── ring_editor.py
│ │ ├── simple_chooser.py
│ │ ├── statusicon.py
│ │ ├── svg_widget.py
│ │ └── userdata_manager.py
│ ├── lib/
│ │ ├── __init__.py
│ │ ├── daemon.py
│ │ ├── enum.py
│ │ ├── eudevmonitor.py
│ │ ├── hidparse.py
│ │ ├── hidparse_data.py
│ │ ├── hidraw.py
│ │ ├── ioctl_opt.py
│ │ ├── jsonencoder.py
│ │ ├── libusb1.py
│ │ ├── usb1.py
│ │ ├── vdf.py
│ │ ├── xinput.py
│ │ └── xwrappers.py
│ ├── macros.py
│ ├── mapper.py
│ ├── menu_data.py
│ ├── modifiers.py
│ ├── osd/
│ │ ├── __init__.py
│ │ ├── area.py
│ │ ├── binding_display.py
│ │ ├── dialog.py
│ │ ├── gesture_display.py
│ │ ├── grid_menu.py
│ │ ├── hmenu.py
│ │ ├── inputdisplay.py
│ │ ├── keyboard.py
│ │ ├── launcher.py
│ │ ├── menu.py
│ │ ├── menu_generators.py
│ │ ├── message.py
│ │ ├── osk_actions.py
│ │ ├── quick_menu.py
│ │ ├── radial_menu.py
│ │ ├── slave_mapper.py
│ │ └── timermanager.py
│ ├── parser.py
│ ├── paths.py
│ ├── poller.py
│ ├── profile.py
│ ├── sccdaemon.py
│ ├── scheduler.py
│ ├── scripts.py
│ ├── special_actions.py
│ ├── tools.py
│ ├── uinput.c
│ ├── uinput.py
│ └── x11/
│ ├── __init__.py
│ ├── autoswitcher.py
│ ├── scc-autoswitch-daemon.py
│ ├── scc-osd-daemon.py
│ └── scc_autoswitch_daemon.py
├── scc-mime-types.xml
├── scripts/
│ ├── 69-sc-controller.rules
│ ├── appimage-AppRun.sh
│ ├── sc-controller
│ ├── sc-controller.appdata.xml
│ ├── sc-controller.desktop
│ ├── scc
│ ├── scc-daemon
│ ├── scc-osd-dialog
│ ├── scc-osd-keyboard
│ ├── scc-osd-launcher
│ ├── scc-osd-menu
│ ├── scc-osd-message
│ ├── scc-osd-radial-menu
│ └── scc-osd-show-bindings
├── setup.py
├── tests/
│ ├── README.md
│ ├── test_boolean.py
│ ├── test_compress.py
│ ├── test_docs.py
│ ├── test_glade.py
│ ├── test_inputs.py
│ ├── test_parser/
│ │ ├── __init__.py
│ │ ├── test_actions.py
│ │ ├── test_macros.py
│ │ ├── test_modifiers.py
│ │ └── test_special_actions.py
│ ├── test_profile/
│ │ ├── __init__.py
│ │ ├── test_actions.py
│ │ ├── test_modeshift.py
│ │ ├── test_modifiers.py
│ │ └── test_special_actions.py
│ ├── test_setup.py
│ ├── test_strings/
│ │ ├── __init__.py
│ │ ├── test_keys.py
│ │ └── test_modifiers.py
│ └── test_vdf.py
└── update-wiki.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/appimage.yml
================================================
name: Build and publish AppImages
on:
push:
tags:
- "v*"
env:
BASE_OS: ubuntu
APT_PUBKEY: 871920D1991BC93C
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
platform:
- linux/amd64
- linux/arm64
codename:
- jammy
- lunar
- mantic
steps:
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v4
- name: Setup qemu for docker
uses: docker/setup-qemu-action@v2
if: matrix.platform != 'linux/amd64'
- name: Setup buildx for docker
uses: docker/setup-buildx-action@v2
- name: Compile in docker
uses: docker/build-push-action@v4
with:
platforms: ${{ matrix.platform }}
outputs: build
build-args: |
BASE_OS
BASE_CODENAME=${{ matrix.codename }}
- name: Prepare environment to build AppImage
env:
TARGET_PLATFORM: ${{ matrix.platform }}
shell: bash
run: |
set -eua
if [ -r build/.build-metadata.env ]; then
. build/.build-metadata.env
rm build/.build-metadata.env
fi
APPIMAGE_SOURCE=build
APPIMAGE_VERSION="${GITHUB_REF_SLUG}-${{ matrix.codename }}"
APPIMAGE_APT_ARCH="${TARGETARCH}"
APPIMAGE_APT_DISTRO="${{ matrix.codename }}"
APPIMAGE_APT_PUBKEY="${APT_PUBKEY}"
APPIMAGE_ARCH="${TARGETMACHINE}"
printenv | grep ^APPIMAGE_ >>"${GITHUB_ENV}"
- name: Build AppImage
uses: AppImageCrafters/build-appimage@v1.3
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: appimages
path: |
./*.AppImage
./*.AppImage.zsync
if-no-files-found: error
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: appimages
path: assets
- name: Create checksum for release assets
shell: bash
run: |
algo="${SHA_ALGORITHM:-256}"
find assets -type f | while read -r asset; do
shasum --binary --algorithm "${algo}" "${asset}" >"${asset}.sha${algo}"
done
- name: Upload artifacts to GitHub release
uses: softprops/action-gh-release@v1
with:
files: assets/*
================================================
FILE: .github/workflows/scc-linux.yml
================================================
name: SCC Linux CI
on:
push:
branches:
- main
- master
- python3
pull_request:
branches:
- main
- master
- python3
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
# Install dependencies
- run: pip install pytest vdf
# Build
- run: python setup.py build
# Test
- run: python -m pytest tests
================================================
FILE: ADDITIONAL-LICENSES
================================================
All images in images/ directory, profile files in default_profiles/
and profile_examples/ and menu files in default_menus/ directories
are licensed under CC0 license - https://creativecommons.org/publicdomain/zero/1.0/
Images in images/menu-icons subdirectories are licensed as described
in 'LICENSES' files in their respective subdirectories.
lib/enum.py is licensed under BSD license, as described in that file.
lib/usb1.py and lib/libusb1.py are licensed under LGPL 2.1, as described in those files.
lib/jsonencoder.py is licensed under PSFL, https://www.python.org/download/releases/2.7/license/
scripts/gamecontrollerdb.txt is taken from Simple DirectMedia Layer library and licensed under zlib license.
lib/xwrappers.py and lib/vdf.py are part of SC-Controller, licensed under GPL2 as rest of the project.
Everything else is licensed under GPL2, as described in 'LICENCE' file.
================================================
FILE: AppImageBuilder.yml
================================================
version: 1
script:
- |
if [ "{{APPIMAGE_SOURCE}}" != "${TARGET_APPDIR}" ]; then
mv "{{APPIMAGE_SOURCE}}" "${TARGET_APPDIR}"
fi
# Manual installation of squashfs-tools is required
# until https://github.com/AppImageCrafters/build-appimage/issues/5 is fixed
if ! command -v mksquashfs >/dev/null; then
apt-get update && apt-get install -y --no-install-recommends squashfs-tools
fi
AppDir:
app_info:
id: org.ryochan7.sc-controller
name: sc-controller
version: "{{APPIMAGE_VERSION}}"
icon: sc-controller
exec: usr/bin/python3
exec_args: -c "import os, sys; os.execvp('$APPDIR/usr/bin/scc', ['$APPDIR/usr/bin/scc'] + (sys.argv[1:] if len(sys.argv) > 1 else ['gui']))" $@
after_bundle: |
set -eu
# appimage-builder expects .desktop file to start with appinfo-id
desktop="$(find "${TARGET_APPDIR}/usr" -name sc-controller.desktop)"
sed -i "s:Exec=.*:Exec=./usr/bin/scc gui:g" "${desktop}"
ln -sr "${desktop}" "${TARGET_APPDIR}/usr/share/applications/org.ryochan7.sc-controller.desktop"
# appimage-builder expects utf-8 encoding when patching shebangs,
# but pygettext3 has iso-8859-1 encoding
find "${TARGET_APPDIR}/usr/bin" -name 'pygettext*' | while read -r file; do
encoding="ISO-8859-1"
if file -bi "${file}" | grep -iq "${encoding}"; then
<"${file}" iconv -f "${encoding}" -t utf-8 -o "${file}"
sed -i -E '1,2 s|^(\s*#.*coding[=:]\s*)([[:alnum:].-]+)|\1utf-8|g' "${file}"
fi
done
apt:
arch:
- "{{APPIMAGE_APT_ARCH}}"
sources:
- sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ {{APPIMAGE_APT_DISTRO}} main universe
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}}
- sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ {{APPIMAGE_APT_DISTRO}}-updates main universe
- sourceline: deb [arch=amd64] http://security.ubuntu.com/ubuntu/ {{APPIMAGE_APT_DISTRO}}-security main universe
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}} main universe
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}}-updates main universe
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}}-security main universe
include:
- gir1.2-rsvg-2.0
- libbluetooth3
- librsvg2-common
- python3-evdev
- python3-gi-cairo
- python3-pylibacl
- python3-vdf
- binutils # required for detection of bluetooth library
- coreutils # provides /usr/bin/env
- shared-mime-info # required for gui if host provides no MIME info, e.g. when XDG_DATA_DIRS is missing
exclude:
- gcc* # development
- libgcc* # development
- libstdc* # development
- libtirpc* # development
- libuuid* # development
- libattr* # filesystem
- libblkid* # filesystem
- libmount* # filesystem
- libbz* # codec
- libjpeg* # codec
- liblzma* # codec
- libtiff* # codec
- libxml* # codec
- libwebp* # codec
- media-types # codec
- libpixman* # X
- libxext* # X
- libxrender* # X
- libfontconfig* # fonts
- libfreetype* # fonts
- libfribidi* # i18n
- libicu* # i18n
- libgmp* # arithmetics
- libmpdec* # arithmetics
- libncurses* # terminal
- libreadline* # terminal
- readline* # terminal
- libssl* # security
- "*crypt*" # security
- "*krb*" # security
- libdb* # database
- "*sqlite*" # database
- libnsl* # network
files:
exclude:
- usr/bin/*gold* # alternative for ld
- usr/bin/*gp-display-html* # since Ubuntu Lunatic, requires perl
- usr/lib/*/gconv # unicode
- usr/lib/*/gdk-pixbuf-2.0/*/loaders/libpixbufloader-[!s]*.so # only svg is required
- usr/lib/*/glib-2.0
- usr/lib/python*/cgi.py
- usr/lib/python*/email
- usr/lib/python*/test
- usr/lib/python*/unittest
- usr/share/doc
- usr/share/glib-2.0
- usr/share/gtk-doc
- usr/share/icu
- usr/share/locale
- usr/share/man
- usr/share/python3/runtime.d
- usr/share/thumbnailers
runtime:
env:
# `usr/lib/python3.*/site-packages` is required in $PYTHONPATH,
# but the python version and hence the actual location is unknown here.
# Fortunately the site-packages directory is on the $PATH, so we add $PATH instead.
# It must precede an existing $PYTHONPATH to work.
PYTHONPATH: "${APPDIR}/usr/lib/python3/dist-packages:${PATH}:${PYTHONPATH}"
SCC_SHARED: "${APPDIR}/usr/share/scc"
AppImage:
arch: "{{APPIMAGE_ARCH}}"
update-information: "gh-releases-zsync|Ryochan7|sc-controller|latest|sc-controller-*-{{APPIMAGE_APT_DISTRO}}-{{APPIMAGE_ARCH}}.AppImage.zsync"
================================================
FILE: Dockerfile
================================================
ARG BASE_OS=ubuntu
ARG BASE_CODENAME=jammy
FROM $BASE_OS:$BASE_CODENAME AS build-stage
# Download build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc librsvg2-bin linux-headers-generic python3-dev python3-setuptools
# Prepare working directory and target
COPY . /work
WORKDIR /work
ARG TARGET=/build/usr
# Build and install
RUN python3 setup.py build --executable "/usr/bin/env python3" && \
python3 setup.py install --single-version-externally-managed --home "${TARGET}" --record /dev/null
# Provide input-event-codes.h as fallback for runtime systems without linux headers
RUN cp -a \
"$(find /usr -type f -name input-event-codes.h -print -quit)" \
"$(find "${TARGET}" -type f -name uinput.py -printf '%h\n' -quit)"
# Create short name symlinks for static libraries
RUN suffix=".cpython-*-$(uname -m)-linux-gnu.so" && \
find "${TARGET}" -type f -path "*/site-packages/*${suffix}" \
| while read -r path; do ln -sfr "${path}" "${path%${suffix}}.so"; done
# Put AppStream metadata to required location according to https://wiki.debian.org/AppStream/Guidelines
RUN metainfo=/build/usr/share/metainfo && \
mkdir -p "${metainfo}" && \
cp -a scripts/sc-controller.appdata.xml "${metainfo}"
# Convert icon to png format (required for icons in .desktop file)
RUN iconpath="${TARGET}/share/icons/hicolor/512x512/apps" && \
mkdir -p "${iconpath}" && \
rsvg-convert --background-color none -o "${iconpath}/sc-controller.png" images/sc-controller.svg
# Store build metadata
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN export "TARGETMACHINE=$(uname -m)" && printenv | grep ^TARGET >>/build/.build-metadata.env
# Keep only files required for runtime
FROM scratch AS export-stage
COPY --from=build-stage /build /
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
================================================
FILE: README.md
================================================
# SC Controller [](https://travis-ci.org/kozec/sc-controller)
User-mode driver, mapper and GTK3 based GUI for Steam Controller, DS4 and similar controllers.
[](docs/screenshot1.png?raw=true)
[](docs/screenshot2.png?raw=true)
[](docs/screenshot3.png?raw=true)
[](docs/screenshot4.png?raw=true)
## Features
- Allows to setup, configure and use Steam Controller(s) without ever launching Steam
- Supports profiles switchable in GUI or with controller button
- Stick, Pads and Gyroscope input
- Haptic Feedback and in-game Rumble support
- OSD, Menus, On-Screen Keyboard for desktop *and* in games.
- Automatic profile switching based on active window.
- Macros, button cycling, rapid fire, modeshift, mouse regions...
- Emulates Xbox360 controller, mouse, trackball and keyboard.
Based on [Standalone Steam Controller Driver](https://github.com/ynsta/steamcontroller) by [Ynsta](https://github.com/ynsta).
## Like what I'm doing?
[](https://liberapay.com/kozec) or [](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=77DQD3L9K8RPU&lc=SK&item_name=kozec&item_number=scc¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted)
## Packages
- **Ubuntu (deb-based distros):** Found in [openSUSE Build Service](https://software.opensuse.org/download.html?project=home%3Akozec&package=sc-controller).
- **Fedora, SUSE (rpm-based distros):** Found in [openSUSE Build Service](https://software.opensuse.org/download.html?project=home%3Akozec&package=sc-controller).
- **Arch, Manjaro (arch-based distros):** Found in [AUR](https://aur.archlinux.org/packages/sc-controller-git/)
- **Solus:** Search for `sc-controller` in Software Center or run `sudo eopkg it sc-controller` from a terminal.
- **Exherbo:** Found in [hardware](https://git.exherbo.org/summer/packages/input/sc-controller)
- **Void Linux:** Run `xbps-install -S sc-controller` in a terminal.
## Building the package by yourself
### Dependencies
- python 3, GTK 3.22 or newer and [PyGObject](https://live.gnome.org/PyGObject)
- [python-gi-cairo](https://packages.debian.org/sid/python-gi-cairo) and [gir1.2-rsvg-2.0](https://packages.debian.org/sid/gir1.2-rsvg-2.0) on debian based distros (included in PyGObject elsewhere)
- [setuptools](https://pypi.python.org/pypi/setuptools)
- [python-pylibacl](http://pylibacl.k1024.org/) is recommended
- [python-evdev](https://python-evdev.readthedocs.io/en/latest/) is strongly recommended
- [python-vdf](https://pypi.org/project/vdf/)
- [gtk-layer-shell](https://github.com/wmww/gtk-layer-shell) (Wayland only)
### Installing
- Download and extract [latest release](https://github.com/kozec/sc-controller/releases/latest)
- `python3 setup.py build`
- `python3 setup.py install`
## Running with non distro-specific package
- Download and extract [latest release](https://github.com/kozec/sc-controller/releases/latest)
- Navigate to extracted directory and execute `./run.sh`
================================================
FILE: TODO.md
================================================
List of (possibly) planned features in no particular order:
- Multiple on-screen menus (and possibly keyboards) when using multiple controllers
- Injecting emulated xbox controller into wine
Hard stuff:
- Injecting emulated xbox controller into PlayOnLinux
Very hard stuff:
- Visual feedback in binding editor ( [what this guy says](https://www.reddit.com/r/linux_gaming/comments/5pcdmr/sc_controller_use_steam_controller_without_steam/dcqpvf4/) )
**Done** stuff:
- Multicontroller support
- Configurable gamepad type (e.g. 4 axes and 16 buttons)
- Steam Profile import
- Radial Menu for the Joystick/Trackpad
- Copy & paste
- Cycling Buttons
- Process monitor (or active window monitor) with switch
- Mouse regions
- Touch-Menu
- Menu in OSD
- OSD
- double click
- on-screen keyboard
- Spining mouse wheel rotation
- Haptic feedback support
- Gyroscope input
- Gamepad button as modifier (modeshift)
- Macros
- Turbo
- Trigger settings
- DPAD that acts only when clicked
- 8-way DPAD
- Selector for media keys
================================================
FILE: appimage-build.sh
================================================
#!/bin/bash
APP="sc-controller"
EXEC="scc"
LIB="lib"
EVDEV_VERSION=0.7.0
[ x"$BUILD_APPDIR" == "x" ] && BUILD_APPDIR=$(pwd)/appimage
PYTHON_VERSION=$(python3 -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))')
SITE_PACKAGES_PATH=$(python3 -c "import os,sys; print([p for p in sys.path if p.endswith('site-packages') and sys.prefix in p][0])")
if [ -z ${SITE_PACKAGES_PATH} ]; then
echo "Could not determine global site-packages path. Exiting";
exit 1;
fi
function download_dep() {
NAME=$1
URL=$2
if [ -e ../../${NAME}.obstargz ] ; then
# Special case for OBS
cp ../../${NAME}.obstargz /tmp/${NAME}.tar.gz
elif [ -e ${NAME}.tar.gz ] ; then
cp ${NAME}.tar.gz /tmp/${NAME}.tar.gz
elif [ -e /tmp/${NAME}.tar.gz ] ; then
echo "/tmp/${NAME}.tar.gz already downloaded"
else
wget -c "${URL}" -O /tmp/${NAME}.tar.gz
fi
}
function build_dep() {
NAME="$1"
mkdir -p /tmp/${NAME}
pushd /tmp/${NAME}
tar --extract --strip-components=1 -f /tmp/${NAME}.tar.gz
PYTHONPATH=${BUILD_APPDIR}/usr/lib/python${PYTHON_VERSION}/site-packages python3 \
setup.py install --optimize=1 \
--prefix="/usr/" --root="${BUILD_APPDIR}"
mkdir -p "${BUILD_APPDIR}/usr/lib/python${PYTHON_VERSION}/site-packages/"
python3 setup.py install --prefix="/usr/" --root="${BUILD_APPDIR}"
popd
}
function unpack_dep() {
NAME="$1"
pushd ${BUILD_APPDIR}
tar --extract --exclude="usr/include**" --exclude="usr/lib/pkgconfig**" \
--exclude="usr/lib/python2.7**" -f /tmp/${NAME}.tar.gz
popd
}
set -ex # display commands, terminate after 1st failure
# Download deps
download_dep "python-evdev-0.7.0" "https://github.com/gvalkov/python-evdev/archive/v0.7.0.tar.gz"
download_dep "pylibacl-0.6.0" "https://github.com/iustin/pylibacl/releases/download/v0.6.0/pylibacl-0.6.0.tar.gz"
download_dep "python-gobject-3.36.1" "https://archive.archlinux.org/packages/p/python-gobject/python-gobject-3.36.1-1-x86_64.pkg.tar.zst"
download_dep "python-vdf-3.4" "https://github.com/ValvePython/vdf/archive/v3.4.tar.gz"
download_dep "libpng-1.6.34" "https://archive.archlinux.org/packages/l/libpng/libpng-1.6.34-2-x86_64.pkg.tar.xz"
download_dep "gdk-pixbuf-2.36.9" "https://archive.archlinux.org/packages/g/gdk-pixbuf2/gdk-pixbuf2-2.36.9-1-x86_64.pkg.tar.xz"
download_dep "libcroco-0.6.13" "https://archive.archlinux.org/packages/l/libcroco/libcroco-0.6.13-1-x86_64.pkg.tar.xz"
download_dep "libxml2-2.9.10" "https://archive.archlinux.org/packages/l/libxml2/libxml2-2.9.10-2-x86_64.pkg.tar.zst"
download_dep "librsvg-2.48.7" "https://archive.archlinux.org/packages/l/librsvg/librsvg-2%3A2.48.7-1-x86_64.pkg.tar.zst"
download_dep "icu-67.1" "https://archive.archlinux.org/packages/i/icu/icu-67.1-1-x86_64.pkg.tar.zst"
download_dep "zlib-1:1.2.12" "https://archive.archlinux.org/packages/z/zlib/zlib-1%3A1.2.12-2-x86_64.pkg.tar.zst"
download_dep "libffi-3.4.3" "https://archive.archlinux.org/packages/l/libffi/libffi-3.4.3-1-x86_64.pkg.tar.zst"
# Prepare & build deps
export PYTHONPATH=${BUILD_APPDIR}/usr/lib/python${PYTHON_VERSION}/site-packages/
mkdir -p "$PYTHONPATH"
if [[ $(grep ID_LIKE /etc/os-release) == *"suse"* ]] ; then
# Special handling for OBS
ln -s lib64 ${BUILD_APPDIR}/usr/lib
export PYTHONPATH="$PYTHONPATH":${BUILD_APPDIR}/usr/lib64/python${PYTHON_VERSION}/site-packages/
LIB=lib64
fi
build_dep "python-evdev-0.7.0"
build_dep "pylibacl-0.6.0"
build_dep "python-vdf-3.4"
unpack_dep "python-gobject-3.36.1"
unpack_dep "libpng-1.6.34"
unpack_dep "gdk-pixbuf-2.36.9"
unpack_dep "libcroco-0.6.13"
unpack_dep "libxml2-2.9.10"
unpack_dep "librsvg-2.48.7"
unpack_dep "icu-67.1"
unpack_dep "zlib-1:1.2.12"
unpack_dep "libffi-3.4.3"
# Remove uneeded files
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-bmp.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gif.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-icns.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ico.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jasper.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jpeg.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-qtif.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tga.so"
rm -f "${BUILD_APPDIR}/usr/${LIB}/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tiff.so"
rm -R "${BUILD_APPDIR}/usr/lib/cmake"
rm -R "${BUILD_APPDIR}/usr/share/doc"
rm -R "${BUILD_APPDIR}/usr/share/gtk-doc"
rm -R "${BUILD_APPDIR}/usr/share/locale"
rm -R "${BUILD_APPDIR}/usr/share/man"
rm -R "${BUILD_APPDIR}/usr/share/thumbnailers"
rm -R "${BUILD_APPDIR}/usr/share/vala"
rm -R "${BUILD_APPDIR}/usr/share/icu"
# Build important part. Need executable flag to place custom interpreter line.
# Setuptools overrrides original #! line in scripts with /usr/bin/python.
# Ubuntu 22.04 LTS does not provide an executable at /usr/bin/python
# by default.
python3 setup.py build --executable "/usr/bin/env python3"
# Need to use single-version-externally-managed due to setuptools behavior
python3 setup.py install --single-version-externally-managed --prefix ${BUILD_APPDIR}/usr --record /dev/null
# Move udev stuff
mv ${BUILD_APPDIR}/usr/lib/udev/rules.d/69-${APP}.rules ${BUILD_APPDIR}/
rmdir ${BUILD_APPDIR}/usr/lib/udev/rules.d/
rmdir ${BUILD_APPDIR}/usr/lib/udev/
mkdir -p ${BUILD_APPDIR}/usr/${LIB}/python${PYTHON_VERSION}/site-packages/scc/
cp "/usr/include/linux/input-event-codes.h" ${BUILD_APPDIR}/usr/${LIB}/python${PYTHON_VERSION}/site-packages/scc/
# Move & patch desktop file
mv ${BUILD_APPDIR}/usr/share/applications/${APP}.desktop ${BUILD_APPDIR}/
sed -i "s/Icon=.*/Icon=${APP}/g" ${BUILD_APPDIR}/${APP}.desktop
sed -i "s/Exec=.*/Exec=.\/usr\/bin\/scc gui/g" ${BUILD_APPDIR}/${APP}.desktop
# Convert icon
convert -background none ${BUILD_APPDIR}/usr/share/pixmaps/${APP}.svg ${BUILD_APPDIR}/${APP}.png
# Copy appdata.xml
mkdir -p ${BUILD_APPDIR}/usr/share/metainfo/
cp scripts/${APP}.appdata.xml ${BUILD_APPDIR}/usr/share/metainfo/${APP}.appdata.xml
# Make symlinks
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libcemuhook.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libcemuhook.so
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libhiddrv.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}//libhiddrv.so
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libremotepad.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libremotepad.so
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libsc_by_bt.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libsc_by_bt.so
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libuinput.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/libuinput.so
ln -sfr ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/posix1e.cpython-310-x86_64-linux-gnu.so ${BUILD_APPDIR}${SITE_PACKAGES_PATH}/posix1e.so
# Copy AppRun script
cp scripts/appimage-AppRun.sh ${BUILD_APPDIR}/AppRun
chmod +x ${BUILD_APPDIR}/AppRun
echo "Run appimagetool -n ${BUILD_APPDIR} to finish prepared appimage"
================================================
FILE: daemon.sh
================================================
#!/bin/bash
# Ensure correct cwd
cd "$(dirname "$0")"
# Set PATH
SCRIPTS="$(pwd)/scripts"
export PATH="$SCRIPTS":"$PATH"
export PYTHONPATH=".":"$PYTHONPATH"
export SCC_SHARED="$(pwd)"
if [ x"$1" == x"lldb" ] ; then
shift
lldb python3 -- 'scripts/scc-daemon' debug $@
else
python3 'scripts/scc-daemon' $@
fi
================================================
FILE: default_menus/Default.menu
================================================
[{
"separator": true,
"name": "Recent profiles"
}, {
"generator": "recent",
"rows": 3
}, {
"submenu": "Profiles.menu",
"icon": "system/profiles",
"name": "All Profiles"
}, {
"separator": true,
"name": "Options"
}, {
"submenu": ".autoswitch.menu",
"icon": "system/autoswitch",
"name": "Autoswitch Options"
}, {
"action": "turnoff()",
"id": "item4",
"icon": "system/turn-off",
"name": "Turn Controller OFF",
"osd": true
}, {
"action": "keyboard()",
"id": "item5",
"icon": "system/keyboard",
"name": "Display Keyboard"
}]
================================================
FILE: default_menus/Profiles.menu
================================================
[{
"separator": true,
"name": "All profiles"
}, {
"generator" : "profiles"
}]
================================================
FILE: default_profiles/Desktop.sccprofile
================================================
{
"_": "",
"buttons": {
"A": {
"action": "button(Keys.KEY_ENTER)"
},
"B": {
"action": "button(Keys.KEY_ESC)"
},
"BACK": {
"action": "button(Keys.KEY_BACKSPACE)"
},
"C": {
"action": "hold(menu('Default.menu'), menu('Default.menu'))"
},
"CPADPRESS": {
"action": "button(Keys.BTN_LEFT)"
},
"LB": {
"action": "button(Keys.KEY_LEFTCTRL)"
},
"RB": {
"action": "button(Keys.KEY_LEFTALT)"
},
"RPAD": {
"action": "button(Keys.BTN_LEFT)"
},
"START": {
"action": "button(Keys.KEY_LEFTSHIFT)"
},
"X": {
"action": "button(Keys.KEY_SPACE)"
},
"Y": {
"action": "button(Keys.KEY_TAB)"
}
},
"cpad": {
"action": "mouse()"
},
"gyro": {},
"is_template": false,
"menus": {},
"pad_left": {
"action": "feedback(LEFT, 4096, 16, ball(XY(mouse(Rels.REL_HWHEEL, 1.0), mouse(Rels.REL_WHEEL, 1.0))))"
},
"pad_right": {
"action": "smooth(8, 0.78, 2.0, feedback(RIGHT, 256, ball(mouse())))"
},
"stick": {
"action": "dpad(button(Keys.KEY_UP), button(Keys.KEY_DOWN), button(Keys.KEY_LEFT), button(Keys.KEY_RIGHT))"
},
"trigger_left": {
"action": "button(Keys.BTN_RIGHT)"
},
"trigger_right": {
"action": "button(Keys.BTN_LEFT)"
},
"version": 1.4
}
================================================
FILE: default_profiles/XBox Controller with High Precision Camera.sccprofile
================================================
{
"_": "",
"buttons": {
"A": {
"action": "button(Keys.BTN_GAMEPAD)"
},
"B": {
"action": "button(Keys.BTN_EAST)"
},
"BACK": {
"action": "button(Keys.BTN_SELECT)"
},
"C": {
"action": "hold(menu('Default.menu'), menu('Default.menu'))"
},
"LB": {
"action": "button(Keys.BTN_TL)"
},
"LGRIP": {
"action": "button(Keys.BTN_GAMEPAD)"
},
"RB": {
"action": "button(Keys.BTN_TR)"
},
"RGRIP": {
"action": "button(Keys.BTN_NORTH)"
},
"RPAD": {
"action": "button(Keys.BTN_THUMBR)"
},
"START": {
"action": "button(Keys.BTN_START)"
},
"STICKPRESS": {
"action": "button(Keys.BTN_THUMBL)"
},
"X": {
"action": "button(Keys.BTN_NORTH)"
},
"Y": {
"action": "button(Keys.BTN_WEST)"
}
},
"cpad": {},
"gyro": {},
"is_template": false,
"menus": {},
"pad_left": {
"action": "click(dpad(hatup(Axes.ABS_HAT0Y), hatdown(Axes.ABS_HAT0Y), hatleft(Axes.ABS_HAT0X), hatright(Axes.ABS_HAT0X)))"
},
"pad_right": {
"action": "smooth(8, 0.78, feedback(RIGHT, 256, ball(mouse())))"
},
"stick": {
"action": "sens(1.2, 1.2, XY(axis(Axes.ABS_X), raxis(Axes.ABS_Y)))"
},
"trigger_left": {
"action": "axis(Axes.ABS_Z)"
},
"trigger_right": {
"action": "axis(Axes.ABS_RZ)"
},
"version": 1.4
}
================================================
FILE: default_profiles/XBox Controller.sccprofile
================================================
{
"_": "",
"buttons": {
"A": {
"action": "button(Keys.BTN_GAMEPAD)"
},
"B": {
"action": "button(Keys.BTN_EAST)"
},
"BACK": {
"action": "button(Keys.BTN_SELECT)"
},
"C": {
"action": "hold(menu('Default.menu'), menu('Default.menu'))"
},
"LB": {
"action": "button(Keys.BTN_TL)"
},
"LGRIP": {
"action": "button(Keys.BTN_GAMEPAD)"
},
"RB": {
"action": "button(Keys.BTN_TR)"
},
"RGRIP": {
"action": "button(Keys.BTN_NORTH)"
},
"RPAD": {
"action": "button(Keys.BTN_THUMBR)"
},
"START": {
"action": "button(Keys.BTN_START)"
},
"STICKPRESS": {
"action": "button(Keys.BTN_THUMBL)"
},
"X": {
"action": "button(Keys.BTN_NORTH)"
},
"Y": {
"action": "button(Keys.BTN_WEST)"
}
},
"cpad": {},
"gyro": {
"action": "cemuhook"
},
"is_template": false,
"menus": {},
"pad_left": {
"action": "click(dpad(hatup(Axes.ABS_HAT0Y), hatdown(Axes.ABS_HAT0Y), hatleft(Axes.ABS_HAT0X), hatright(Axes.ABS_HAT0X)))"
},
"pad_right": {
"action": "feedback(RIGHT, 256, XY(axis(Axes.ABS_RX), raxis(Axes.ABS_RY)))"
},
"stick": {
"action": "sens(1.2, 1.2, XY(axis(Axes.ABS_X), raxis(Axes.ABS_Y)))"
},
"trigger_left": {
"action": "axis(Axes.ABS_Z)"
},
"trigger_right": {
"action": "axis(Axes.ABS_RZ)"
},
"version": 1.4
}
================================================
FILE: docs/actions.md
================================================
### In this document
- [Custom Action page](#examples1)
- [List of all known actions](#actions)
- [Macros and operators](#macros)
- [Profile file examples](#examples2)
# Custom Action page examples
- To do two or more things at once, type `action() and action()`
- To do two or more things in sequence, type `action() ; action()`
- Typing second action on new line is same thing as using `and`
#### Press button repeadedly, rapid fire mode
`repeat(button(BTN_A))` (see [repeat](#repeat), [button](#button))
#### Press Alt+F4
`button(KEY_LEFTALT) and button(KEY_F4)`
#### Press multiple buttons in sequence
`button(BTN_A) ; button(BTN_X); button(BTN_B)`
#### Press button and hold it for set delay
`press(BTN_A) ; sleep(0.5); release(BTN_B)` (see [press](#press), [sleep](#sleep), [release](#release))
# Actions
#### button(button1 [, button2 = None ])
- For button, simply maps real button to emulated
- For stick or pad, 'button1' is pressed when stick or finger on pad is moved
to up or left and 'button2' when to down or right.
Using [dpad](#dpad) may be better for such situations.
- For trigger, when trigger is pressed, but until it clicks, 'button2' is
pressed. When trigger clicks 'button2' is released and replaced by 'button1'.
If only 'button1' is set, trigger acts as big button.
Note that 'button2' is always optional.
#### mouse(axis)
- For stick, lets cursor or mouse wheel to be controlled by stick tilt.
- For pad, acts as trackpad - sliding finger over pad moves the mouse.
If set to *REL_WHEEL* or *REL_HWHEEL*, emulates finger scroll.
You can use `ball(mouse)` to emulate trackball.
- For gyroscope, controls mouse with changes in controller pitch and roll/yaw.
Axis parameter should be either YAW or ROLL (constants) and decides which
gyroscope axis controls X mouse axis.
- For button, pressing button maps to single movement over mouse axis or
single step on scroll wheel.
#### mouseabs(axis)
- For stick, lets cursor or mouse wheel to be controlled by stick tilt.
- For pad, distance from center of pad controls speed of mouse movement
- For gyroscope, please, use gyroabs action.
#### trackpad(axis)
Merged with [mouse](#mouse), does same thing.
#### axis(id [, min = -32767, max = 32767 ])
- For button, pressing button maps to moving axis full way to 'max'.
eleasing button returns emulated axis back to 'min'.
- For stick or pad, simply maps real axis to emulated
- For trigger, maps trigger position to to emulated axis. Note that default
trigger position is not in middle, but in minimal possible value.
#### dpad([diagonal_range,] up, down, left, right)
Emulates dpad. Touchpad is divided into 8 triangular parts. When the user
touches the touchpad, action is executed depending on finger position.
'diagonal_range' is specified in degrees (1 to 89). If not set, all parts are
sized equally, otherwise, diagonal parts are taking specified portion of pad
and rest is assigned to up/left/right/down portions.
Available only for pads and sticks.
#### dpad8([diagonal_range,] up, down, left, right, upleft, upright, downleft, downright)
Same as dpad, with more directions.
#### ring([radius=0.5], inner, outer)
Defines outer and inner ring bindings. When distance of finger from center of
pad is smaller than 'radius', 'inner' action is activated, otherwise, 'outer'
takes place.
Unlike [dpad](#dpad), which executes actions as if they were bound to buttons,
ring works more like defining two actions on same pad with non-overlapping
deadzones.
#### area(x1, y1, x2, y2), winarea(x1, y1, x2, y2)
Creates 1:1 mapping between finger position on pad and mouse position in
specified screen area. Coordinates are in pixels with (0,0) on top,left corner.
Negative number can be used to count from other side of screen.
`winarea` does same thing but with position relative to current window instead of entire screen.
#### relarea(x1, y1, x2, y2), relwinarea(x1, y1, x2, y2)
Creates 1:1 mapping between finger position on pad and mouse position in
specified screen area. Coordinates are fractions of screen width and height,
(0,0) is top,left and (1,1) bottom,right corner of screen.
`relwinarea` does same thing but with position relative to current window instead of entire screen.
#### trigger(press_level, [release_level, ] action)
Maps action to be executed as by button press when trigger is pressed through
'press_level'. Level goes from 0 to 255, where 255 is level after physical
trigger clicks.
Then, optionally, if trigger is pressed through 'release_level', action is
"released". If release_level is not set, action will be released only after
trigger value moves back beyond press_level.
It's possible to map multiple actions on different trigger levels using [and](#and).
Examples:
Hold right mouse button while trigger is being pressed, press left button when
trigger clicks. Right button is released only when trigger is fully released.
```
trigger(64, 255, button(BTN_RIGHT)) and trigger(255, button(BTN_LEFT))
```
Control left virtual trigger while trigger is being pressed and press left button
just before trigger clicks. If trigger clicks, press enter key and play feedback.
```
trigger(64, 255, axis(ABS_Z))
and
trigger(240, 254, button(BTN_LEFT))
and
trigger(255, feedback(LEFT, button(KEY_ENTER)))
```
#### hipfire([partialpress_level, ][fullpress_level, ] partialpress_action, fullpress_action [, mode][, delay])
Maps two different actions to be executed when trigger is inside a defined range and meet predefined conditions.
Basically, the "partialpress_action" will be activated if the trigger is pressed passed the "partialpress_level" and it stays inside the range between this level and the "fullpress_level" until the "delay" ends, otherwise, the "fullpress_action" will be activated ALONE if the "fullpress_level" is reached before the "delay" ends.
The partial and full levels goes from 0 to 255, and the values 50 and 254 are used for "partialpress_level" and "fullpress_level", respectively, if none is passed.
The "mode" can be defined as described below and the "NORMAL" one is used if none is passed.
Modes available:
- NORMAL - if trigger is pressed beyond the "partialpress_level" and the timeout is reached, the "partialpress_action" is executed. If the "partialpress_action" was pressed it will only be released after the trigger return back beyond the "partialpress_level". The "fullpress_action" will be executed every time the "fullpress_level" is reached, but if this level is reached before the timeout the "partialpres_action" will not be triggered until releasing the trigger.
- EXCLUSIVE - Acts similar to the previous mode, but the "fullpress_action" is only triggered if the "partialpres_action" was not triggered. Meaning it will only activate if the "fullpress_level" is reached before the timeout ends.
- SENSIBLE - Acts similar to NORMAL, but after the "partialpress_action" is activated, releasing the trigger a little, will deactivate the action allowing it to be activated again more faster without needing to release the trigger back beyond the "partialpress_level".
The "delay" is time window used to determine if the "partialpress_action" should or not be activated.
Examples:
Hold right mouse button while trigger is being softly pressed and press left mouse button when trigger click, but will bypass the right mouse button and only press the left mouse button if the trigger is pressed very fast to the click.
```
hipfire(50, 254, button(BTN_RIGHT),button(BTN_LEFT), NORMAL, 0.20)
```
Press A if the trigger is pressed slowly and not reaches the click or press B if the trigger is pressed fast and reached the click, and will execute only one of this two actions.
```
hipfire(50, 254, button(KEY_A),button(KEY_B), EXCLUSIVE, 0.15)
```
#### gyro(axis1 [, axis2 [, axis3]])
Maps *changes* in gyroscope pitch, yaw and roll movement into movements of gamepad stick.
Can be used to map gyroscope to camera when camera can be controlled only with analog stick.
#### gyroabs(axis1 [, axis2 [, axis3]])
Maps absolute gyroscope pitch, yaw and roll movement into movements of mouse
or gamepad stick.
Can be used to map gyroscope to movement stick or to use controller as racing wheel.
#### resetgyro()
Resets gyroscope offsets so current orientation is treated as neutral.
#### cemuhook()
When set to gyro, outputs gyroscope data in way compatibile with Cemu, Citra and
other applications using CemuHookUDP motion provider protocol.
#### gyro(front_down, front_up, tilt_left, tilt_right)
Maps tilting of gamepad into actions. When gamepad is tilt to one of for supported
sides, assigned action is executed as if by button press and then "released" after
gamepad is balanced again.
#### trackball()
Split to [ball](#ball) modifier and [mouse](#mouse) action.
Typing `trackball` works as alias for `ball(mouse())`
#### XY(xaction, yaction)
Provides way to assign two different actions to two stick or pad axes.
This is automatically handled by GUI, so user usually doesn't need
to write it directly.
#### relXY(xaction, yaction)
Works same as [XY](#XY), but treats position where pad is touched as "center"
of pad.
#### press(button)
Presses button and leaves it pressed.
#### release(button)
Releases pressed button.
#### tap(button, number=1)
Presses button for a short while, 'number' times.
If 'number' is greater than 1 (when double-tap is performed), tapped button
is kept press as long as physical button that started tap is pressed. For single
tap, virtual button is released right away.
If virtual button is already pressed before tapping, it is released first and
restored after tap, resulting in sequence of "release - press - release - press"
#### profile(name)
Loads another profile
#### shell(command)
Executes command on background
#### turnoff()
Turns controller off
#### restart()
Restarts scc-daemon. Don't use unless you have good reason to.
#### led(brightness)
Sets brightness of controller led. 'Brightness' is percent in 0 to 100 range.
#### osd([timeout=5, [size=3]], text)
Displays message in OSD.
'timeout' sets for how many seconds should message stay visible. Value of 0 has
special meaning and leaves message displayed indefinitely, until profile is
changed or [clearosd](#clearosd) action is used.
'size' sets size of font on message. Only three options are supported right now,
3 for "default size", 2 for "smalller" and 1 for "small".
#### clearosd()
Clears all windows from OSD layer. Cancels all menus, clears all messages,
hides on screen keyboard.
Does _not_ clear OSD windows created using command line tools.
#### menu(menu [, confirm_button=A [, cancel_button=B [, show_with_release=False]]]])
Displays OSD menu.
'confirm_button' and 'cancel_button' sets which gamepad button should be used to
confirm/cancel menu. Additionaly, 'confirm_button' can be set to SAME (constant),
in which case menu will be closed and selected item choosen when button used to
display menu is released.
If 'show_with_release' is set to true, menu is displayed only after button
is released.
'menu' can be either id of menu defined in same profile file or filename
relative to `~/.config/scc/menus` or `/usr/share/scc/default_menus/`, whichever
exists, in that order.
#### hmenu(menu [, confirm_button=A [, cancel_button=B [, show_with_release=False]]]])
Same as `menu`, but packed in one row.
#### gridmenu(menu [, confirm_button=A [, cancel_button=B [, show_with_release=False]]]])
Same as `menu`, but displays items in grid.
#### radialmenu(menu [, confirm_button=A [, cancel_button=B [, show_with_release=False]]]])
Same as `menu`, but displays items in radial menu.
#### quickmenu(menu)
Special kind of menu controled by buttons instead of stick. Every item has
assigned button and user selects it by pressing that button.
Fast to use, but is limited to 6 items at most.
#### dialog([ confirm_button=A [, cancel_button=B ], ] text, action1, [action2... actionN])
Displays OSD dialog. Dialog works similary to horizontal menu and displays
text message above list of options.
#### keyboard()
Displays on-screen keyboard
# Modifiers:
#### click(action)
Creates action action that occurs only if pad or stick is pressed.
For example, `click(dpad(...))` set to pad will create dpad that activates
buttons only when pressed.
#### pressed(action)
Creates action that occurs for brief moment when button is pressed.
For example, `pressed(button(A))` will press and instantly release virtual
A button whenever physical button is pressed.
#### released(action)
Creates action that occurs for brief moment when button is released.
#### pressed(action)
Creates action that occurs for brief moment when finger touches pad.
#### released(action)
Creates action that occurs for brief moment when pad is released.
#### mode(button1, action1, [button2, action2... buttonN, actionN] [, default] )
Defines mode shifting. If physical buttonX is pressed, actionX is executed.
Optional default action is executed if none from specified buttons is pressed.
#### gestures([precision=0,] gesture1, action1, [gesture2, action2... gestureN, actionN] )
If set to left or right pad, enables gesture recognition. If GestureX
is drawn, actionX is executed.
If 'precision' is set to 1.0, gesture has to be exact. Otherwise,
gestures resembling input with given precision are compared and
one that matches it most is used. At precision of 0.0, all gestures are considered.
Gestures are encoded in string and it's
recommended to use GUI to record them. Nevertheless, format is simple:
- Each stroke in one of four directions is stored as single character.
- Characters are uppercase `U`, `D`, `L`, `R` for up, down, left, right
- Default stroke length is 1/3 of pad size.
- For stroke with twice of that length, characters is repeated twice
- Three times for stroke through entire pad, or even more for longer.
- If string starts with lowercase `i`, stroke length is ignored.
#### doubleclick(doubleclick_action [, normal_action [, timeout ]])
Executes action if user double-clicks button.
Optional normal_action parameter specifies action that is executed when user
click button only once. Optional time arguments modifies maximum delay in
doubleclick and in effect sets delay before normal action is executed.
#### hold(hold_action [, normal_action [, timeout ]])
Executes action if user holds button for longer time.
Optional normal_action parameter specifies action that is executed when user
click button shortly. Optional time arguments modifies how long "longer time" is.
Hold and doubleclick can be combined together by writing
`hold([time,] hold_action, doubleclick(doubleclick_action, normal_action))`
#### sens(x_axis [, y_axis [, z_axis]], action)
Modifies sensitivity of physical stick or pad.
#### rotate(angle, action)
Rotates input pad or stick input by given angle.
#### feedback(side, [amplitude=256 [, frequency=4 [, period=100 [, count=1 ]]]], action)
Enables haptic feedback for specified action, if action supports it.
Side has to be one of LEFT, RIGHT or BOTH. All remaining numbers can be anything
from 1 to 32767, but note that setting count to large number will start long
running feedback that you may not be able to stop.
'frequency' is used only when emulating touchpad and describes how many pixels
should mouse travel between two feedback ticks.
#### ball([friction=10.0, [mass=80.0, ]] action)
Enables trackball mode. Moving finger over pad will keep repeating same action
with decreasing speed, based on set mass and friction, until virtual
'spinning ball' stops moving.
#### circular(action)
Designed to controls scroll wheel by scrolling finger around pad.
Can be used with any axis. For example,
`circular(axis(Axes.ABS_X))`
turns touchpad into small raing wheel.
#### circular(action)
Works as to `circular`, but instead of counting with finger movements,
translates exact position on dpad to axis value.
#### deadzone([mode,] lower, [upper, ] action)
Enables deadzone on trigger, pad or stick.
Mode defaults to 'CUT' and can be one of:
- CUT - if value is out of deadzone range, output value is zero
- ROUND - for values bellow deadzone range, output value is zero. For values
above range, output value is maximum allowed.
- LINEAR - input value is scaled, so entire output range is covered by
range of deadzone.
- MINIMUM - any non-zero input value is scaled so entire input range is mapped
to range of deadzone. Zero on input is mapped to zero on output, so there is
area over which output "jumps" when stick is tilted.
#### smooth([buffer=8, [multiplier=0.7, [filter=2, ]]] action)
Enables input smoothing. Position is computed as weighed average of last X
input positions with highest weight given to most recent position. If 'filter'
is above zero, movements bellow that value are ignored.
#### osd([timeout=5], action)
Enables on screen display for action. In most cases just displays action
description in OSD and executes it normally.
Works only if executed by pressing physical button or with `dpad`. Otherwise
just executes child action.
#### position(x, y, action)
Specifies menu position on screen. X is position from left, Y from top. To
specify position from right or bottom, use negative values.
#### name(name, action)
Allow inline setting of action name
# Shortcuts:
#### raxis(id)
Shortcut for `axis(id, 32767, -32767)`, that is call to axis with min/max values
reversed. Effectively inverted axis mapping.
#### hatup(id)
Shortcut for `axis(id, 0, 32767)`, emulates moving hat up or pressing 'up'
button on dpad.
#### hatdown(id)
Shortcut for `axis(id, 0, -32767)`, emulates moving hat down or pressing 'down'
button on dpad.
#### hatleft(id), hatright(id)
Same thing as hatup/hatdown, as vertical hat movement and left/right dpad
buttons are same events on another axis
# Macros and operators
#### and - executing actions at once
It is possible to join two (or more) actions with `and` keyword (or newline) to have them executed together.
- `button(KEY_LEFTALT) and button(KEY_F4)` presses Alt+F4
#### semicolon - sequence (macro)
When `;` is placed between actions, they are executed as sequence.
- `hatup(ABS_Y); hatup(ABS_Y); button(BTN_B); button(BTN_A)` presses 'UP UP B A' on gamepad, as fast as possible
- `button(KEY_A); button(KEY_B); button(KEY_C)` types 'abc'.
#### type('text')
Special type of macro where keys to press are specified as string.
Basically, writing `type("iddqd")` is same thing as `button(KEY_I) ; button(KEY_D) ;
button(KEY_D); button(KEY_Q); button(KEY_D)`, just much shorter.
#### sleep(x)
To insert pause between macro actions, use sleep() action.
- `button(KEY_A); button(KEY_B); sleep(1.0); button(KEY_C)` types 'ab', waits 1s and types 'c'
#### repeat(action)
Turbo / rapid fire mode. Repeats macro (or even single action) until physical button is released. Macro is always played to end, even if button is released before macro is finished.
- `repeat(button(BTN_X))` deals with "mash X to not die" events in some games.
#### cycle(action1, action2...)
Executes different action every time when button is pressed (action1 upon first press, action2 with second, etc.)
Works only on buttons.
# Examples for profile file
Emulate key presses based on stick position
```
"stick" : {
"X" : { "action" : "pad(KEY_A, KEY_D)" },
"Y" : { "action" : "key(KEY_W, KEY_S)" },
```
Emulate left/right stick movement with X and B buttons
```
"buttons" : {
"B" : { "action" : "axis(ABS_X, 0, 32767)" },
"X" : { "action" : "axis(ABS_X, 0, -32767)" },
```
Emulate dpad on left touchpad, but act only when dpad is pressed
```
"left_pad" : {
"action" : "click( dpad('hatup(ABS_HAT0Y)', 'hatdown(ABS_HAT0Y)', 'hatleft(ABS_HAT0X)', 'hatright(ABS_HAT0X)' ) )"
}
```
Emulate button A when left trigger is half-pressed and button B when
it is pressed fully
```
"triggers" : {
"LEFT" : { "action" : "pad(BTN_A, BTN_B)" },
```
================================================
FILE: docs/menu-file.md
================================================
SC-Controller menu file specification
----------------------------------------
Menu file contains json-encoded list with menu items (actions), submenus,
separators and menu generators.
### Menu Items
Every menu item is defined by action, in same way as action would be defined
[in profile file](profile-file.md#Action_definition) with one additional
`id` key. `id` specifies action ID and can be anything, but each menu item
should have unique ID.
`name` key is still optional, but highly recommended as used as menu item title
displayed on screen. If `name` is not specified, title is auto-generated.
Example:
[{
"id": "item1",
"action": "profile('Desktop')",
"name": "Switch to Desktop profile",
}, {
"id": "item2",
"action": "turnoff()",
"name": "Turn controller OFF",
}]
specifies menu with two items.
### Submenus
Submenu is reference to another menu file (submenu cannot be defined in same
file or profile file). When selected, another menu is loaded and drawn over
original menu.
Submenu is dict with `submenu` key, value of key is filename relative to
`~/.config/scc/menus` or `/usr/share/scc/default_menus/`, whichever exists, in
that order.
`name` key may be defined.
Example:
[{
"submenu": "profiles.menu",
"name": "All Profiles"
}]
specifies menu with sumbmenu called "All Profiles" defined in *profiles.menu*
### Separators
Separator is empty space that splits menu into two or more logical blocks.
Name, if set, is displayed in different way from menu items. Separator is
defined by dict with `separator` key set to True.
### Menu Generators
Generator is something that generates menu items automatically. It is defined
by dict with `generator` key, where value is type of generator to use.
Example:
[{
"generator": "profiles"
}, {
"id": "item2",
"action": "turnoff()",
"name": "Turn controller OFF",
}]
specifies menu with list of all profiles, followed by one normal menu item.
### Available generators
#### `profiles`
Generates menu item for each available profile. Selecting item will switch to
represented profile.
#### `recent`
Generates menu item for *X* recently selected profiles. *X* is 5 by default and
can be set with additional `rows` key.
================================================
FILE: docs/profile-file.md
================================================
SC-Controller profile file specification
----------------------------------------
Profile file contains json-encoded dictonary with specific keys. Missing keys are substituted with defaults, unknown keys are ignored. See [Desktop.sccprofile](../default_profiles/Desktop.sccprofile) for example.
Root dictonary has to contain following keys:
- `buttons` - contains subkey for controller buttons. See [buttons](#buttons).
- `pad_left` - sets action executed when finger is moved on left touchpad.
- `pad_right` - ... when finger is moved on right touchpad.
- `stick` - ... when stick angle is changed.
- `trigger_left` - ... when left trigger value is changed.
- `trigger_right` - ... when right trigger value is changed.
- `gyro` - ... when gyroscope reading changes. Gyroscope in is activated only if this key is set to something else than `NoAction`
- `menus` - stores menus saved in profile. See [menus](#menus).
- `version` - profile file version. Current version is _1_. See If not pressent, _0_ is assumed. If profile file version is lower than expected, automatic conversion may happen. This conversion is in-memory only, but changing and saving such profile in GUI will save converted data.
See [actions.md](actions.md) file for list of possible actions.
## Action definition
Action definition is dictionary containing `action` key and optional `name` key. Value assigned to `action` describes action to be executed.
`action` key can describe entire action, but for better readability, it is also possible to specify additional properties using [additional keys](#Additional_keys).
For example,
{
"trigger_left": {
"action": "axis(Axes.ABS_Z)",
"name": "Aim",
}}
assigns `axis` action with *Axes.ABS_Z* parameter to left trigger.
## Additional keys in action definition
#### `X` and `Y`
Turns action into `XYAction`, allowing to specify different action for each pad
or stick axis. If either of keys is specified, `action` key is ignored.
Example:
"stick" : {
"X": { "action": "axis(Axes.ABS_RX)" },
"Y": { "action": "raxis(Axes.ABS_RY)" }
},
is same as
`"stick" : { "action" : "XY(axis(Axes.ABS_RX), raxis(Axes.ABS_RY))" }`
#### `levels`
Turns action into `TriggerAction`, allowing to specify lower and upper trigger
levels among which is action executed.
Example:
"trigger_left": {
"action": "button(BTN_LEFT)",
"levels": [127, 255]
},
Sets action that presses left mouse button, but only if trigger
is roughly half-pressed.
#### `dpad`
Turns action into `DPadAction`, allowing to assign different action for each
side of pad or stick alignment.
Example:
"dpad" : [
{ "action": "button(Keys.KEY_UP)" },
{ "action": "button(Keys.KEY_DOWN)" },
{ "action": "button(Keys.KEY_LEFT)" },
{ "action": "button(Keys.KEY_RIGHT)" }
],
#### `ring`
Defines outer and inner ring bindings. Expects keys with 'inner' and 'outer'
actions and 'radius' as float value, but all keys are optional.
Example:
"pad_left": {
"ring": {
"inner": { "action": "XY(axis(Axes.ABS_X), raxis(Axes.ABS_Y))" },
"outer": { "action": "XY(axis(Axes.ABS_RX), raxis(Axes.ABS_RY))" },
"radius": 0.4
}
},
defines inner ring binding controlling left stick and outer ring right stick
of emulated gamepad.
#### `tilt`
Turns action into `TiltAction`, allowing to assign different action for tilting
dpad. Works pretty-much as `dpad` on gyro.
Example:
"tilt" : [
{ "action": "button(Keys.KEY_UP)" },
{ "action": "button(Keys.KEY_DOWN)" },
{ "action": "button(Keys.KEY_LEFT)" },
{ "action": "button(Keys.KEY_RIGHT)" }
],
#### `deadzone`
Specifies deadzone. Allows for `lower` and `upper` subkeys defaulting to
*0* and *32767* and `mode` subkey defaulting to 'CUT'.
See see [deadzone modifier](actions.md#deadzone) for list of modes.
Example:
"trigger_left": {
"mode" : "linear",
"action": "axis(Axes.ABS_Z)",
"deadzone": {
"lower": 100,
"upper": 200
}},
#### `sensitivity`
Specifies input sensitivity. Value is list with one or two values for sensitivity
over X and Y axis (or one value for sensitivity of trigger.)
Default sensitivity is 1.0
Example:
"stick" : {
"action": "trackball()",
"sensitivity": [2.0, 0.5]
},
doubles sensitivity over X and halves over Y axis.
#### `rotate`
Rotates input pad or stick input by given angle.
Example:
"stick" : {
"action": "trackball()",
"rotate": 15
},
#### `feedback`
Enables haptic feedback for action. Value is list with one to three values
specifying feedback position (*'LEFT'*, *'RIGHT'* or *'BOTH'*),
amplitude and frequency.
Example:
"pad_left": {
"action": "trackball()",
"feedback": ["LEFT", 512.0, 5.0]
},
specifies feedback with amplitude of 512 (default vlaue)
and frequency of 5 generated by left motor.
#### `smooth`
Enables input smoothing (see [smooth modifier](actions.md#smooth))
Example:
"pad_left": {
"action": "trackball()",
"smooth": [ 8, 0.7, 2.0 ]
},
enables smoothing with buffer of 8 and modifier set to 0.7.
#### `osd`
If set to True, enables OSD for action.
Example:
"X": {
"action": "button(Keys.BTN_EAST)",
"osd": true
},
enables OSD feedback for X button.
#### `click`
If set to True, enables 'click' modifier, making action executed only when
pad or stick is pressed.
Example:
"pad_left": {
"action": "mouse()",
"click": True
},
#### `ball`
If set to value, enables trackball mode. Value is list with zero to two values
specifying friction and mass of virtual 'spinning ball'.
See [ball modifier](actions.md#ball) for more info.
Example:
"pad_left": {
"action": "mouse()",
"ball": [ 10.0 ]
},
#### `circular`
Designed to controls scroll wheel by scrolling finger around pad, but can
be used with any axis.
Example:
"pad_left": {
"action": "mouse(Rels.REL_WHEEL)",
"circular": true
},
#### `circularabs`
Works as to `circular`, but instead of counting with finger movements,
translates exact position on dpad to axis value.
Example:
"pad_left": {
"action": "circularabs(Rels.REL_WHEEL)",
"circular": true
},
#### `modes`
Defines mode shifting (see [mode modifier](actions.md#mode)).
Value is dict with physical key names (A, B, X, Y...) as keys and actions
for each mode as values. Action on same level as `mode` is used as default
action.
Example:
"modes": {
"A": { "action": "mouse()" },
"B": { "action": "XY( axis(Axes.ABS_X), raxis(Axes.ABS_Y) )" }
},
defines pad or stick that controls mouse while button A is pressed
and left virtual stick while button B is pressed.
#### `gestures`
Enables gesture cognition on pad (see [gestures modifier](actions.md#gestures)).
Value is dict with encoded gestures (see [description in actions.md](actions.md#gesture_format)) and actions
for each gesture as values.
Example:
"gestures": {
"UD": { "action": "button(Key.R)" }
},
enables gesture recognition with single gesture activated when user does short stroke up followed by short stroke down.
#### `doubleclick`
Defines action that is executed when user double-clicks with button.
Optional `time` key can be used on same level as `doubleclick` to modify
double-click time.
Example:
"buttons": {
"A": {
"action": "button(KEY_X)",
"doubleclick": { "action": "button(KEY_Z)" },
"time": 5
}
}
defines button that emulates pressing X key when pressed normally and
pressing Z key when doubleclicked.
#### `hold`
Defines action that is executed when user holds button for short time.
Optional `time` key can be used on same level as `hold` to modify
double-click time.
Example:
"buttons": {
"A": {
"action": "button(KEY_X)",
"hold": { "action": "button(KEY_Z)" },
"time": 5
}
}
defines button that emulates pressing X key when pressed normally and
pressing Z key when held for 5 seconds.
## Buttons
`buttons` is dictionary with keys for each gamepad button.
Possible keys are:
- `X`, `Y`, `A` and `B` for colored buttons
- `C` for Steam button in center
- `SELECT` and `START` for small "( < )" and "( > )" buttons
- `LB` and `RB` for left and right bumper
- `LPAD`, `RPAD` and `STICK` for presing pads or stick.
All keys are optional. Value for each key is [action definition](#Action_definition)
Example:
"buttons": {
"A": { "action": "button(Keys.BTN_WEST)", },
"B": { "action": "osd('Hello world!')" },
"BACK": { "action": "button(Keys.KEY_LEFTCTRL) and button(Keys.KEY_A)" },
}
## Menus
`menus` is dictionary with menus stored along with profile. Keys are IDs of
menus; Menu ID can contain any characters but dots (".") and slashes ("/").
Value for each key is same as root list in [menu file](menu-file.md)
================================================
FILE: docs/protocol.md
================================================
SCCDaemon Protocol specification
--------------------------------
To control running daemon instance, unix socket in user directory is used.
Controlling protocol uses case-sensitive messages terminated by newline. Message type and message arguments are delimited by `:`.
When new connection is accepted, daemon sends some info:
```
SCCDaemon
Version: 0.2.6
PID: 123456
Current profile: filename.sccprofile
Ready.
```
Connection is then held until client side closes it.
### Messages sent by daemon:
#### `Controller Count: n`
Informs about total number of connected controllers.
Always sent after `Controller:` messages
#### `Controller: controller_id type flags config_file`
Provides info about controller 'n'.
- `controller_id` is unique string identifier of controller (should stay same at
least until daemon exits) and doesn't contains spaces.
- `type` is string identifier (without spaces) of driver.
- `flags` describes controller features, such as having central touchpad.
See ControllerFlags definition in scc/constants.py for more info.
- `config_file` is None or file name of json-encoded file that can GUI use
to get additional data about controller (background image, button images, etc)
File name may be absolute path or just name of file in /usr/share/scc
This message is repeated for every connected controller and followed by
`Controller Count:` message. It is automatically sent to every client when
number of connected controllers changes. It is also sent automatically to
every new client.
#### `Controller profile: controller_id filename.sccprofile`
Sent to every client when profile file for any controller is loaded and used.
Also sent automatically to every new client.
#### `Current profile: filename.sccprofile`
Similar to `Controller profile:`, sent to every client when profile file for
first controller is loaded and used. Also sent automatically to every new client.
Unlike `Controller profile:`, this message is sent even if there is no
controller connected.
#### `Event: source values`
Sent to client that requested locking of source (that is button, pad or axis).
List of possible events:
- `Event: B 1` - Sent when button is pressed. *B* is button, is one of *SCButtons.\** constants.
- `Event: B 0` - Sent when button is released. *B* is button one of *SCButtons.\** constants.
- `Event: STICK x y` - Sent when stick position is changed. *x* and *y* are new values.
- `Event: LEFT x y` - Sent when finger on left pad is moved. *x* and *y* is new position.
- `Event: RIGHT x y` - Sent when finger on right pad is moved. *x* and *y* is new position.
#### `Error: message`
Sent to every client when error is detected. May be sent repeatedly to indicate
multiple errors.
After all error conditions are cleared, `Ready.` is sent to indicate that emulation works again.
#### `Fail: text`
Indicates error as response to client's request.
#### `Gesture: side gesturestring`
Sent to client that requested gesture to be detected.
#### `OK.`
Indicates sucess as response to client's request.
### `OSD: tool param1 param2...`
Send to scc-osd-daemon when osd-related action is requested.
*tool* can be *'message'*, *'menu'*, *'hmenu'*, *'gridmenu'*,*'radialmenu'* or *'gesture'*
*params* are same as command-line arguments for scc-osd-* script with that name.
#### `PID: xyz`
Reports PID of *scc-daemon* instance. Automatically sent when connection is accepted.
#### `Ready.`
Automatically sent when connection is accepted to indicate that there is no error and daemon is working as expected.
#### `Reconfigured.`
Sent to all clients when daemon receives `Reconfigure.` message.
#### `SCCDaemon`
Just identification message, automatically sent when connection is accepted.
Can be either ignored or used to check if remote side really is *scc-daemon*.
#### `State: ....`
Sent to client as response to `State.` message. String after colon describes
current state of controller (such as pressed buttons and stick position...)
and is device-specific.
#### `Version: x.y.z`
Identifies daemon version. Automatically sent when connection is accepted.
## Commands sent from client
#### `Controller: controller_id`
By default, all messages sent from client are related to first connected
controller. This message changes which controller are following messages meant
for.
If controller with specified controller_id is known, daemon responds with `OK.`
Otherwise, `Fail: no such controller` error message is sent.
#### `Controller.`
Restores default state after controller is chosen.
Daemon responds with `OK.`
#### `Gesture: side up_angle`
Requests gesture to be detected on one of pads. 'side' can be LEFT or RIGHT.
'up_angle' is angle in radians and sets how much should be gesture input
rotated.
Daemon always responds with `OK.` unless request cannot be parsed.
Then, when gesture detection is completed, daemon sends
`Gesture: side detectedgesture` message. If gesture detection fails for any
reason, sent gesture is empty.
#### `Led: brightness`
Sets brightness of controller led. 'Brightness' is percent in 0 to 100 range.
Daemon responds with `OK.`, unless 'brightness' cannot be parsed, in which case
`Fail: ...` with error message is sent.
#### `Lock: button1 button2...`
Locks physical button, axis or pad. Events from locked sources are not processed normally, but sent to client that initiated lock.
Only one client can have one source locked at one time. Second attempt to lock already locked source will fail and `Fail: cannot lock