Giter Site home page Giter Site logo

jstest-sdl's Introduction

jstest-sdl

The jstest-sdl is a fork of the http://github.com/Grumbel/sdl-jstest. In this repository we have the SDL2 version only, and its name is jstest-sdl.c (in the original repo it is named sdl2-jstest.c).

The jstest-sdl is a simple program that lets you find out how many joysticks SDL2 detected on your system, how many axes, buttons, hats and balls they have each. They also lets you test the joysticks by displaying the events they send or by displaying their current button, axis, hat or ball state (this is a cool way to substitute the jstest).

(The README of the original repository says that "sdl-jstest is especially useful if you want to test your SDL_LINUX_JOYSTICK configuration." I'm repeating this info here, but I don't use this feature, it isn't usefull for my needs.)

Usage examples

Get a simple list of available joysticks with their respective index number:

[prompt]$ jstest-sdl --listsimple
0:Twin USB Joystick
1:Twin USB Joystick
2:ipega Extending Game Controller
3:8Bitdo Zero Game Pad

Now you can test the joystick input with the --test option and a joystick index number. Here is an output example of what I got using jstest-sdl --test 0:

Joystick Name:   'Twin USB Joystick'
Joystick Number: 0

Axes  4:
   0:      0  [                             #                              ]
   1:      0  [                             #                              ]
   2:      0  [                             #                              ]
   3:      0  [                             #                              ]

Buttons 12:
   0: 0  [ ]
   1: 0  [ ]
   2: 0  [ ]
   3: 0  [ ]
   4: 0  [ ]
   5: 0  [ ]
   6: 0  [ ]
   7: 0  [ ]
   8: 0  [ ]
   9: 0  [ ]
  10: 0  [ ]
  11: 0  [ ]

Hats  1:
   0: value: 0
  +-----+  up:    0
  |     |  down:  0
  |  O  |  left:  0
  |     |  right: 0
  +-----+

Balls  0:

Press Ctrl-c to exit

Now you can press the buttons and see the feedback. Those bars at the top are for analog directionals and the trigger buttons (usually R2 and L2).

Installation

jstest-sdl requires the following packages to build:

  • libsdl2-dev
  • libncurses5-dev

So, to install it in a Debian-based distribution:

install the dependencies:

sudo apt-get install libsdl2-dev libncurses5-dev

download the code

git clone http://github.com/meleu/jstest-sdl

compile it

cd jstest-sdl
make

put binary at /usr/local/bin/

make install

Info from the original repository

Configuration

The SDL behaviour of what axis is treated as a hat and which as normal axis can be configured with the environment variable SDL_LINUX_JOYSTICK:

  • ftp://ptah.lnf.kth.se/pub/misc/sdl-env-vars

SDL_LINUX_JOYSTICK: Special joystick configuration string for linux. The format is "name numaxes numhats numballs" where name is the name string of the joystick (possibly in single quotes), and the rest are the number of axes, hats and balls respectively.

A simple example would be:

export SDL_LINUX_JOYSTICK="'Xbox Gamepad (userspace driver)' 6 0 0"

Which makes all axis be handled as normal axis and none as hat, as most games don't use hats.

jstest-sdl's People

Contributors

fewtarius avatar grumbel avatar marxjohnson avatar meleu avatar ulidtko avatar

Watchers

 avatar

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.