Map joystick events to mouse/key events

Overview

enjoy

map joystick events to mouse/key events

Recently, I got a DevTerm and enjoy is specially written for this device to map joystick events to mouse click/scroll/motion or key events, or use joystick buttons to launch applications. It should work with other joysticks but not tested.

DevTerm

Build

enjoy almost have no dependencies but use libx11 and libxtst to simulate mouse/key events:

sudo apt-get install libx11-dev libxtst-dev
make
./enjoy

Features

enjoy support:

  • simulate key use 'X KeySym'. it support single key or combined keys with + delimiter, for example : Super_L+Shift_L+q.

    • Standard KeySym names are obtained from X11/keysymdef.h by removing the XK_ prefix from each name.
  • simulate key sequence, use keyseq prefix and continue with 'X KeySym', for example : keyseq Control_L+g c.

  • simulate mouse button, use mouse_button prefix, continue with a 'button number'.

    • 1 = left button, 2 = middle button, 3 = right button, 4 = scroll up, 5 = scroll down.
  • launch application, with exec prefix, for example : exec st -D.

  • simulate mouse motion, by set axis_as_mouse to 1.

Usage

-D : to enable debug mode to help you find with joystick "key" should be mapped.

-n : to ignore default configuration.

-c <config file name> : to load another config file instead of ~/.config/enjoyrc, useful for launching multiple instances to support multiple joystick devices.

-h : to show help message.

For more than one joysticks:

You may need to create multiple config files under ~/.config and launch multiple enjoy instance.

Default configuration

Since I am a heavy user of i3wm, the default configuration for DevTerm set to:

# joystick device
device=/dev/input/js0
# button x of DevTerm
button_0=Super_L
# button a of DevTerm
button_1=mouse_button 3
# button b of DevTerm
button_2=mouse_button 1
# button y of DevTerm
button_3=Control_L
# button select of DevTerm
button_8=Super_L+End
# button start of DevTerm
button_9=Super_L+d
# set it to 0 to use axis to simulate key/mouse event.
axis0_as_mouse=1
axis0_button0_up=Up
axis0_bttton0_down=Down
axis0_button1_left=Left
axis0_button1_right=Right

You can create your own config file such as ~/.config/enjoyrc or ~/.config/<your config file>.

And, enjoy.

TODO

  • Support verbose mode to found which joystick event generated and not bound.

  • Support multiple axis on one joystick, maybe with axis[n]_button[n]_up/down/left/right keys.

  • Support multiple joysticks by multiple config files, can launch multiple instances.

Issues
  • style and compilation fixes for src/uinput.c

    style and compilation fixes for src/uinput.c

    • drop trailing whitespace
    • consistently use 4 spaces for indent (replace some instances where 3 spaces were used instead)
    • set timestamp of struct input_event in a portable fashion to fix the following compilation error on (some) 32 bit systems:
    uinput.c: In function 'emit':
    uinput.c:25:20: error: 'struct input_event' has no member named 'time'
       25 |    gettimeofday(&ie.time, NULL);
          |                    ^
    
    opened by maribu 1
  • style and compilation fixes for src/enjoy.c

    style and compilation fixes for src/enjoy.c

    • drop same trailing whitespace in src/enjoy.c
    • consistently use 4 spaces for indent (replace some instances where 3 spaces were used instead)
    • fix incorrect use of printf format specifier to fix
    enjoy.c:413:55: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
      413 |                     sprintf(axis_as_mouse_key, "axis%ld_as_mouse", axis);
          |                                                     ~~^            ~~~~
          |                                                       |            |
          |                                                       long int     size_t {aka unsigned int}
          |                                                     %d
    
    opened by maribu 0
  • Configs by Device Name/Id

    Configs by Device Name/Id

    Would it be possible to use configs by the lsusb device name or id?

    If I'm disconnecting controller 1 (js0) and connect the second one, it becomes js0 too and it uses the config of the previous controller. Also if I want to use both controllers, I have to plug them in in the same order as I've defined the config files :)

    opened by fbrinker 1
  • Switch blocks/repeats HID Input

    Switch blocks/repeats HID Input

    What a nice project. I just wanted to test controlling i3wm with my current FlightSim Arduino project and stumbled upon this :)

    I am using toggle switches, keeping the input button always pressed down. That seems to block the interaction with my laptop or at least repeated keypresses all the time111111111111111111111111111111111111 <- This is a result of it :D

    sudo enjoy -D -c /etc/enjoy/js0
    ...
    Key: 'button_6', State: 'pressed'
    Key 'button_6' map to 'super_l+1'
    Uinput: super_l, Super_L, 125, 1
    Uinput: 1, 1, 2, 1
    Key: 'button_7', State: 'released'
    Key 'button_7' map to 'super_l+2'
    Uinput: super_l, Super_L, 125, 0
    Uinput: 2, 2, 3, 0
    1111111111111111111111111111111^C%
    

    The cmd is super_l+1 and the 1 gets repeated. I am thinking of changing my firmware to one-time presses anyways, just wanted to let you know :) Maybe a global option to "trigger once" could be a solution (excluding the axis)

    opened by fbrinker 0
ESP32 software USB host through general IO pins. We can connect up to 4 USB-LS HID (keyboard mouse joystick) devices simultaneously.

esp32_usb_soft_host esp32 USB-LS pure software host thru general IO pins. Up to 4 HID devices simultaneously. board ~$3 :https://www.aliexpress.com/pr

Samsonov Dima 246 May 1, 2022
ESP8266 software USB host through general IO pins. We can connect up to 2 USB-LS HID (keyboard mouse joystick) devices simultaneously.

esp8266_usb_soft_host Test for esp8266 usb host . Works with ESP-IDF v3.4 80MHz and 160MHz. WorkInProgress Test run with mouse & combined mouse & keyb

Samsonov Dima 25 Apr 21, 2022
A fantasy map generator based on Martin O'Leary's "Generating fantasy map" notes

Fantasy Map Generator This program is an implementation of a fantasy map generator written in C++ based on the methods described in Martin O'Leary's "

Ryan Guy 601 Apr 29, 2022
A lightweight C++14 parsing library for tmx map files created with the Tiled map editor

tmxlite Description A lightweight C++14 parsing library for tmx map files created with the Tiled map editor. Requires no external linking, all depende

Matt Styles 301 Apr 29, 2022
⌨️ Personal key mapping for The Key.

The Key Personal key mapping for The Key. This firmware configures: The first key to be the mute key on single tap, and the pause/play key on double t

Zihua Li 1 Dec 25, 2021
Allows to swap the Fn key and left Control key and other tweaks on Macbook Pro and Apple keyboards in GNU/Linux

A patched hid-apple kernel module UPDATE August 2020: swap_fn_leftctrl is now built-in in Linux 5.8 ?? UPDATE Jun 2020: New feature added (swap_fn_f13

Zakhar Semenov 288 Apr 30, 2022
Amos Arcade Joystick input driver for RaspberryPi

am_joyin Amos Joystick Input Driver for Raspbrri-pi Arcade (or another SBC) am_joyin은 라즈베리파이를 이용하여 아케이드 게임기를 제작할 때 다양한 입력장치를 사용할 수 있도록 기획되고 제작되었다. 기본적

Ju, Gyeongmin 2 Mar 22, 2022
Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound.

Plua2c Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound. This is the source code

Cameron Kaiser 8 May 16, 2022
Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele

Wortuhr_ESP8266 Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele, Webzugriff So

null 21 Apr 15, 2022
Realtime Micro Kernel -- Event-driven Run-to-Completion RTOS with Active Objects, Timed Events, Memory Pools, and Message Queues

Realtime Micro Kernel Features Active Objects Message queues Variable sized, custom messages Periodic and single timed events Memory pools Supported P

null 2 Feb 25, 2022
Reactive - Simple, non intrusive reactive programming library for C++. (Events + Observable Properties + Reactive Properties)

Header only reactive C++ library. Thread-safe, memory-safe. Concsists from: Event (C# like Event, but thread-safe, does not block while event occurs,

null 58 Mar 3, 2022
A self-contained minimal library for interacting with Linux hot-plug events

libue Zero dependency minimal library for interacting with Linux hot-plug events. Installation Just drop the header file into your C project. Usage #i

QP Hou 20 Feb 10, 2022
evtest is a tool to print evdev kernel events

evtest is a tool to print evdev kernel events. It reads directly from the kernel device and prints a device description and the events with the value and the symbolic name.

Travis West 4 Jan 27, 2022
Control your mouse using razer synapse

rzctl Control your mouse using razer synapse Compile in x64 Not tested for x86 Credits Process Hacker - https://github.com/processhacker/processhacker

null 37 May 11, 2022
Simple tool to visualize and amplify mouse movements

mousemic Simple tool to visualize and amplify mouse movements. This utility uses a high-level X11 Api so is not really more sensitive than your screen

Alfredo Ortega 41 Dec 21, 2021
A Simple tool to execute shellcode with the ability to detect mouse movement

Noobi A Simple tool to execute shellcode with the ability to detect mouse movement Features: Sandbox evasion through detecting mouse movement and chec

null 10 Feb 20, 2022
ORBION the OpenSource Space Mouse 3D

Orbion The OpenSource Space Mouse To ensure greater precision and fluidity it is recommended to put a foam ring under the knob (see photo above) and d

FaqTotum 96 May 8, 2022
Arduino code to interface with quadrature-encoder mice, specifically the Depraz mouse

Depraz Mice on USB via Arduino This code lets you connect a Depraz mouse to a modern computer via USB. The Depraz mouse has a male DE-9 connector but

John Floren 4 Jan 7, 2022
Eliminate double clicks due to failing mouse switches.

Double Click Monitor Eliminate double clicks due to failing mouse switches. Binaries Pre-compiled binaries have been uploaded here. Compiling This sol

null 9 Jan 11, 2022