Code Monkey home page Code Monkey logo

marley-accel's Introduction

Marley Accel

A small Linux user space mouse accel driver that supports the quake live accel settings. It allows for acceleration that is frame rate independent and consistent across applications and games. It additionally allows you to save and use multiple configurations and provides a minimal GUI that plots your current settings to assist coniguration.

Requirements

There are only a few simple requirements for the driver:

  • A modern C compiler
  • pkg-config
  • libusb-1.0
  • uinput (kernel module, requires use of su)

Usage

This is still a work in progress. The config file should adhere to the form of the provided example, configs/ex.cfg. When you want to quickly test the driver with a new config, you can compile and run it like this

make run CONFIG_FILE_PATH=configs/ex.cfg

Similarly, to run the GUI, you should pass the path to the config file that you want to modify.

python mod.py configs/ex.cfg

Configuration files allow for single-line comments and whitespace. The variables can be specified in any order. Everything needs to be spelled correctly, in lowercase, and it needs to have the equal sign.

Tests

There is a small suite of unit tests for the acceleration functions and map. it implements a very minimal unit testing framework, rather than adding a new dependency. To run the tests, simply run

export ASAN_SYMBOLIZER=/usr/bin/llvm-symbolizer  # if available, for address sanitizer
make test

marley-accel's People

Contributors

arthurfeeney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

marley-accel's Issues

Incorrect determination of interface number may result in undetermined behaviour

Hello,
I've come across your project trying to implement something very similar, just in a different language. Your project has been a good reference for me so far, providing me with some basic guidance on how to approach such a project, so thank you for that.

However, when looking at the find_mouse() function in find_mouse.c, I've noticed something that I think could be a mistake in how you obtain the value for the interface field.
Namely, you are using uid->iInterface.
The interface parameter is used then in loading_util.c, where it is passed into the different libusb functions, which each take an "interface number".

According to this document on the HID spec on page 70, iInterface is described as an "Index of string descriptor".
This would mean that instead of the actual interface number you are using something that would point to a string descriptor.
Now, the USB in a Nutshell Website writes the following on string descriptors:

String descriptors provide human readable information and are optional. If they are not used, any string index fields of descriptors must be set to zero indicating there is no string descriptor available.

This would then presumably explain why your current approach should work most of the time.
The default interface of interest is probably usually zero, why this will work most time, since the string descriptors are rarely used.
However, if the actual interface of interest has a number different from zero or the string descriptor is set, this will result in very much undefined behaviour.

As a fix, one should be able to use the bInterfaceNumber field. From the HID spec: "Number of Interface". And from the USB in a Nutshell article:

bInterfaceNumber indicates the index of the interface descriptor. This should be zero based, and incremented once for each new interface descriptor.

Another potential problem might be the use of the altsetting field instead of the cur_altsetting, though I am less sure about this. The Kernel Doc on the USB driver API writes the following about altsetting:

array of interface structures, one for each alternate setting that may be selected. Each one includes a set of endpoint configurations. They will be in no particular order.

and about cur_altsetting:

the current altsetting.

Note the sentence "They will be in no particular order.", which will mean that your code will just take the first element of the array and will break when there is a USB device which has multiple of these altsettings and the one that is currently used is not in the first position. I don't really know what the exact implications would be, but I think a solution would involve either using cur_altsetting or looping over all elements of altsetting, finding the desired one and setting it to the cur_altsetting.

I hope I didn't overlook or misinterpret something, that is just how I understand the code and the spec. I am still relatively new to this kind of stuff. If I've made a mistake somewhere, please feel free to point me towards it and close this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.