Single-header multi-platform tablet library

Overview

EasyTab

Single-header multi-platform tablet library, for easy integration of drawing tablets (e.g. Wacom) into your code.

Features

  • Single-file header-only. Extremely easy to integrate.
  • Multi-platform. Currently supports Windows and Linux.
  • Simple API. Only 3 API calls.
  • Public domain

Documentation

Usage instructions and examples are included in the header file.

Contributions

Pull requests with new features, platforms or fixes are most welcome.

Comments
  • Relative system mode.

    Relative system mode.

    Took me a while and some reading through the wacom sdk docs to figure out how to make it work in relative mode but in the end it only took these 3 lines of code added to EasyTab_Load()

    LogContext.lcSysMode = 1; LogContext.lcSysSensX = 5000; LogContext.lcSysSensY = 5000;

    However it would be nice if some information about this were added to the usage examples along with how to disable system mode if you don't want the tablet moving the cursor etc.

    Cheers for the handy library btw =)

    opened by chronokun 12
  • Potential fix for Milton/HMH tablet issue

    Potential fix for Milton/HMH tablet issue

    On handmade hero, @cmuratori is running into an issue where the tablet input in @serge-rgb's Milton stops working occasionally, and I think at one point he noticed it happen when his timer overlay thing gained focus.

    I looked into the WinTab stuff and think calling WTEnable and WTOverlap when focus changes might fix it, but I don't have a tablet to test it.

    opened by baines 8
  • Should EasyTab handle context changes?

    Should EasyTab handle context changes?

    Changing Wacom settings, like the wacom input area or screen area, when the EasyTab client app is open requires the client to handle it.

    Changing display settings (like turning off one display) also requires the client to handle it, since the Wacom context needs to be rebuilt.

    In my case, I am currently not handling it. My app needs a restart whenever those two particular cases happen. Not a huge deal, but the other applications I test seem to handle these cases without problems.

    I was debating whether to open this issue or not, since this is one of those "Drop the Easy from EasyTab" issues.

    The applications I mentioned that handle these cases seem to work when the wacom driver crashes, so I have to assume that they are using the Windows Stylus API. Also, the Wacom sample code is not helpful at all for cases like these.

    So I'm thinking that one way forward should be to support the Stylus API and leave the Wacom layer as a fallback for when the Stylus API is not available or when EasyTab is compiled as C99.

    This could add a lot of complexity to the code, so it might be a bad idea? I just wanted to write my thoughts somewhere that wasn't email, since this is an open source project. I'm curious to read your thoughts, but feel free to close the issue, since there is no code to show yet :)

    opened by serge-rgb 4
  • Add includes? Define allocator macro?

    Add includes? Define allocator macro?

    I had a problem compiling EasyTab as a standalone lib (vs2015). It doesn't find calloc or strstr. On windows this is fixed by including #include <stdlib.h> and #include <string.h>.

    IMO, the library should include what it needs, although in practice I am guessing that it will only ever be included into codebases that already have calloc and strstr included.

    Related: Maybe instead of directly using calloc and free, there should be a EASYTAB_CALLOC and EASYTAB_FREE to give the client control over the allocation scheme.

    opened by serge-rgb 3
  • Separate EasyTabInfo into two structs.

    Separate EasyTabInfo into two structs.

    1. Leave only Position and Pressure info in EasyTab. Which allows for it to be moved to the top where the public interface is declared.
    2. Created EasyTabContext to hold the guts and live inside EASYTAB_IMPLEMENTATION.

    I don't know if commit comments will be shown in the pull request. So:

    • Removed MaxPressure from the public-facing struct. Pressure ranges in [0,1], so MaxPressure is currently only useful inside EasyTab_Handle() when doing the divide.
    • Renamed struct member Context to WintabContext because EasyTabContext->Context was confusing

    (Edit: Yup. Comments do show up in the Pull Request. Today I Learned :)

    opened by serge-rgb 3
  • Add a license

    Add a license

    I would like to use this library however I do not feel comfortable using it until it has a license. Well I would like to believe the author means his claim of public domain it cannot hold up in every country and furthermore the author could turn around and sue for copyright. So I would like to propose adding a license of some sort. If you would like to keep it basically public domain I would recommend https://creativecommons.org/choose/zero/ as a license. It basically is public domain however covers more countries and ensures developer safety. At the end of the day it is your choice obviously but I would like to propose this.

    opened by Vixeliz 1
  • Fixed small memory leak by closing the device in EasyTab_Unload

    Fixed small memory leak by closing the device in EasyTab_Unload

    Implemented a small fix to correct a memory leak when unloading EasyTab, the device handle returned by XOpenDevice was not being closed.

    This does change the API, as unloading now requires a pointer to the Display* in order to close the device. I opted for this approach because it is more explicit and avoids retaining additional state. Alternatively, a copy to the original Display* passed in during load could be retained in the EasyTabInfo struct.

    opened by AfroDave 1
  • Simple example?

    Simple example?

    Cool project you started here! :)

    Can you make a simple app that can be used to test tablets, like xev or xinput test on Linux, but for your library?

    Thanks in advance!

    opened by ghost 1
  • EasyTab declaration should be extern

    EasyTab declaration should be extern

    EasyTab can't be currently linked as a library, because the declaration

    static EasyTabInfo* EasyTab

    creates two copies of EasyTab -- one in the library memory and one in the client memory.

    Fix is to declare it as extern and define it once in the implementation code. (Pull request incoming)

    opened by serge-rgb 0
  • EasyTab global inside EASYTAB_IMPLEMENTATION

    EasyTab global inside EASYTAB_IMPLEMENTATION

    When including easytab.h without defining EASYTAB_IMPLEMENTATION (defining it somewhere else for whatever reason), the global variable EasyTab is not available, so the client can't pull PosX, PosX, Pressure, etc...

    (Sorry that I was the one who suggested moving the global in the first place)

    Still... Should there be two structures? A lightweight struct that is exposed to the client and a heavyweight structure that contains all the guts?

    I mean something like

    typedef struct {
      int32_t PosX;
      int32_t PosY;
      float Pressure;
    } EasyTab_;
    
    static EasyTab_* EasyTab;
    

    Right at the beginning of easytab.h, where the public interface is declared, and some other struct which contains the Win32 function pointers xor X11 stuff that can live beneath EASYTAB_IMPLEMENTATION.

    opened by serge-rgb 0
  • C99; Fix X11

    C99; Fix X11

    • Stopped using bool and introduced EasyTabResult. It helped make it valid C99 and is a little step forward to having nice error reporting

    • X11 had two problems. a) It was reporting in display coordinates, not window coordinates b) It was reporting in tablet resolution, not pixels (i.e. (x,y) in [0, EasyTab->RangeX]x[0, EasyTab->RangeY] which was different from the Windows behavior, where it works in pixels.

      Now, EasyTab_Handle is using X and Y window-relative coordinates reported by the XEvent. (This means that axis_data[0] and axis_data[1] is no longer used. Will open an issue about it)

      There was a bug (that was also present in Milton, so it's my bad) where it was not grabbing the correct window when asking for XDeviceMotionEvents (line 669). This changes the signature for EasyTab_Load on X11 but I'm pretty sure that it is the Right Way to do things.

    opened by serge-rgb 0
  • Screen area setting.

    Screen area setting.

    [Edit: Clarity. Also, I had said something about EasyTab not working with multiple monitors, which wasn't true! EasyTab was working, but setting the whole monitor as the output area. ]

    This implements support for screen area mapping, which means not setting the SysOrg and SysExt variables in LogContext.

    screenshot 2016-06-06 20 55 16

    Looking at lines 895 and 896 of the PR:

           Point.x = EasyTab->ScreenOriginX + Packet.pkX / EasyTab->ScreenAreaRatioX;
           Point.y = EasyTab->ScreenOriginY + Packet.pkY / EasyTab->ScreenAreaRatioY;
    

    when before it was:

            Point.x = Packet.pkX;
            Point.y = Packet.pkY;
    

    This should work as before when the feature is not being used.

    • On a single monitor config, ScreenOrigin(X|Y) should be 0.
    • When the feature is disabled, SysExt(X|Y) will be equal to CoordRange(X|Y), so ScreenAreaRatio(X|Y) will be 1.

    I tested it on my machine enabling only one monitor and toggling the feature, but please test it if you choose to merge this :)

    The feature works as expected with Milton compared with other programs that support it (Krita, Mischief, Gimp) but I have only tried it out with Milton. Maybe test it with Papaya first?

    Finally, requesting code review :)

    opened by serge-rgb 2
Owner
Apoorva Joshi
Apoorva Joshi
A single file, single function, header to make notifications on the PS4 easier

Notifi Synopsis Adds a single function notifi(). It functions like printf however the first arg is the image to use (NULL and any invalid input should

Al Azif 9 Oct 4, 2022
A cross platform shader language with multi-threaded offline compilation or platform shader source code generation

A cross platform shader language with multi-threaded offline compilation or platform shader source code generation. Output json reflection info and c++ header with your shaders structs, fx-like techniques and compile time branch evaluation via (uber-shader) "permutations".

Alex Dixon 285 Nov 16, 2022
Collection of cross-platform single-header C libraries for doing a lot of stuff! (Still WIP)

ice_libs Collection of cross-platform single-header C libraries for doing a lot of stuff! (Still WIP) Brief ice_libs is collection of Single-Header C

Rabia Alhaffar 117 Nov 22, 2022
Multi-dimensional dynamically distorted staggered multi-bandpass LV2 plugin

B.Angr A multi-dimensional dynamicly distorted staggered multi-bandpass LV2 plugin, for extreme soundmangling. Based on Airwindows XRegion. Key featur

null 21 Nov 7, 2022
Wykobi is an efficient, robust and simple to use multi-platform 2D/3D computational geometry library.

Description Wykobi is an efficient, robust and simple to use multi-platform 2D/3D computational geometry library. Wykobi provides a concise, predictab

Arash Partow 131 Oct 24, 2022
A single-header C/C++ library for parsing and evaluation of arithmetic expressions

ceval A C/C++ header for parsing and evaluation of arithmetic expressions. [README file is almost identical to that of the ceval library] Functions ac

e_t 9 Oct 10, 2022
A single-header C/C++ library for parsing and evaluation of arithmetic expressions

ceval A C/C++ header for parsing and evaluation of arithmetic expressions. [README file is almost identical to that of the ceval library] Functions ac

e_t 9 Oct 10, 2022
Tuibox - A single-header terminal UI (TUI) library, capable of creating mouse-driven, interactive applications on the command line.

tuibox tuibox ("toybox") is a single-header terminal UI library, capable of creating mouse-driven, interactive applications on the command line. It is

Andrew 31 Nov 9, 2022
A single header C++ wasm frontend library leveraging Emscripten

Livid Livid is a single header C++ wasm frontend library leveraging Emscripten. Usage The code looks something like this: #include "livid/livid.hpp" #

Mohammed Alyousef 18 Nov 6, 2022
C++ single-header entity component system library

ECS This is a simple C++ header-only type-safe entity component system library. It makes heavy use of C++11 constructs, so make sure you have an up to

Sam Bloomberg 413 Nov 16, 2022
multi-sdr-gps-sim generates a IQ data stream on-the-fly to simulate a GPS L1 baseband signal using a SDR platform like HackRF or ADLAM-Pluto.

multi-sdr-gps-sim generates a GPS L1 baseband signal IQ data stream, which is then transmitted by a software-defined radio (SDR) platform. Supported at the moment are HackRF, ADLAM-Pluto and binary IQ file output. The software interacts with the user through a curses based text user interface (TUI) in terminal.

null 66 Oct 29, 2022
Multi OS Platform Wallpaper Engine using SDL2

MOWE MOWE is 'Multi OS Wallpaper Engine'. This is Wallpaper Engine for any OS like MacOSX, Windows, Linux. This Project use SDL, WinAPI, X11 API conte

null 7 Dec 26, 2021
Cross-platform C++11 header-only library for memory mapped file IO

mio An easy to use header-only cross-platform C++11 memory mapping library with an MIT license. mio has been created with the goal to be easily includ

null 1.4k Nov 12, 2022
Single-header, ranges-compatible generator type built on C++20 coroutines

generator Single-header, ranges-compatible generator type built with C++20 coroutines. A generator allows implementing sequence producers which are te

Sy Brand 36 Nov 16, 2022
stackwalkerc - Windows single header stack walker in C (DbgHelp.DLL)

stackwalkerc - Windows single header stack walker in C (DbgHelp.DLL) Features Can be used in C or C++ code Super simple API Single header library make

Sepehr Taghdisian 29 Jul 4, 2022
A single-header, new syntax for C & C++

sea A new syntax for C & C++, in one header file sea is a new syntax for C & C++. It can be used by adding the following line of code to a .c, or .cc/

Cloud Worm 1 Nov 19, 2021
base64 single header encode/decode

b64.h base64 single header encode/decode #include <stdio.h> #include "b64.h" // strings are stored on the heap, don't forget to free() them int main(i

null 4 Jul 27, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 209 Nov 22, 2022
Single-header VMT hook class using vfptr swap method

Single-header C++ VMT hooking (vfptr swap) Supports RAII Unit tested with Catch2 Tested on x86/x64, MSVC and Clang/LLVM VMT size calculation Windows-o

shavit 6 Oct 5, 2022