Coder Social home page Coder Social logo

sdl-jstest's Introduction

sdl-jstest

sdl-jstest and sdl2-jstest are simple programs that lets you find out how many joysticks SDL or 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. sdl-jstest is especially useful if you want to test your SDL_LINUX_JOYSTICK configuration.

Screenshots

sdl-jstest 0.2.1

Requirements

sdl-jstest requires the following packages to build:

  • cmake
  • libsdl1.2-dev
  • libsdl2-dev
  • libncurses5-dev

Submodules

To fetch submodule dependencies:

git submodule init
git submodule update

Compilation

To compile type:

mkdir build
cd build
cmake ..
make

To install (optional):

make install

The DESTDIR and PREFIX can be configured as follows:

make install DESTDIR=/tmp/pingus

cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr

Cross-compilation to Win32

MXE (http://mxe.cc) is needed. Follow its installation instructions, but you can build it with just the needed packages for sdl-jstest:

make gcc cmake sdl sdl2 ncurses pdcurses

This still takes quite a while.

After MXE installation finishes, for sdl-jstest compilation type:

mkdir build
cd build
i686-w64-mingw32.static-cmake ..
make

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.

sdl-jstest's People

Contributors

bentley avatar ghostlydark avatar grumbel avatar marxjohnson avatar orbea avatar protocultor avatar stuaxo avatar ulidtko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sdl-jstest's Issues

Confusing "not a gamepad" message

I was puzzled (as were others in forums) by the message "not a gamepad". The error should instead read, "SDL cannot use this as a GameController until it is added to gamecontrollerdb.txt or SDL_GAMECONTROLLERCONFIG."

warning: result of comparison of constant with expression of type 'int' is always false

OS: Gentoo
sdl-jstest: 62124aa
clang: 16.0.6

With clang it prints a few -Wtautological-constant-out-of-range-compare warnings that seem somewhat concerning.

[1/4] /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -DSDL2_JSTEST_DATADIR=\"/usr/share/sdl-jstest\" -DSDL_JSTEST_VERSION=\"0.2.2-1-g62124aa\" -isystem /usr/include/SDL2 -isystem /usr/include/ncursesw  -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -D_REENTRANT -DNCURSES_WIDECHAR -MD -MT CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -MF CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o.d -o CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -c /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c
[2/4] /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -DSDL_JSTEST_VERSION=\"0.2.2-1-g62124aa\" -isystem /usr/include/SDL -isystem /usr/include/ncursesw  -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -DNCURSES_WIDECHAR -MD -MT CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -MF CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o.d -o CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -c /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c:53:53: warning: result of comparison of constant -9223372036854775808 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                                               ~~~~ ^  ~~~~~~~~
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl-jstest.c:53:33: warning: result of comparison of constant 9223372036854775807 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                           ~~~~ ^  ~~~~~~~~
2 warnings generated.
[3/4] : && /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed    -rdynamic CMakeFiles/sdl-jstest.dir/src/sdl-jstest.c.o -o sdl-jstest  -Wl,-Bstatic  -lSDLmain  -Wl,-Bdynamic  -lSDL  -lncursesw  -ltinfow && :
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c:46:53: warning: result of comparison of constant -9223372036854775808 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                                               ~~~~ ^  ~~~~~~~~
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999/src/sdl2-jstest.c:46:33: warning: result of comparison of constant 9223372036854775807 with expression of type 'int' is always false [-Wtautological-constant-out-of-range-compare]
  if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
                           ~~~~ ^  ~~~~~~~~
2 warnings generated.
[4/4] : && /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -std=c99 -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed    -rdynamic CMakeFiles/sdl2-jstest.dir/src/sdl2-jstest.c.o -o sdl2-jstest  -lSDL2  -lncursesw  -ltinfow && :

Load gamecontrollerdb.txt, if available

Before checking with SDL_IsGameController(), it makes sense to see if there is an updated database in the current directory. Traditionally this is called "gamecontrollerdb.txt". You can load it automatically (and ignore it if it is missing) by adding this line:

SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");

sdl-jstest has no output (SDL1)

OS: Gentoo
sdl-jstest: fbfb4dd
SDL: 1.2.64
musl:1.2.4

With SDL1 there is no output when testing a controller with sdl-jstest, the command sdl-jstest -t 0 will only show a blank terminal.

I am not sure if its worth fixing this or just dropping support for SDL1?

Instructions are out of date for compilation

Hey there, the AUR build of sdl2-jstest is broken, so I wanted to compile from source, but there is no Makefile, and make fails. I don't really know how to use CMake. Could you put updated instructions in the readme? Thank you!

BUILD_TESTS does nothing

In commit 5bc418e the appdata files were removed, but the BUILD_TESTS cmake option remained.

if(BUILD_TESTS)
# add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
enable_testing()
endif(BUILD_TESTS)

It now does nothing since the appdata files are gone, what was the intent here? Are different tests going to be created in the future? Should BUILD_TESTS be removed altogether? Should the appdata files be restored? I don't have a personal preference here.

cmake issue building on OS X

On OS X, I need to apply the following to get things to build

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47e5e1a..0c75d53 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,6 +44,7 @@ if(WERROR)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
 endif()

+link_directories("/usr/local/lib")
 add_executable(sdl2-jstest sdl2-jstest.c)
 target_link_libraries(sdl2-jstest ${SDL2_LIBRARIES} ${CURSES_LIBRARIES})
 target_include_directories(sdl2-jstest PUBLIC ${SDL2_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR})

I don't really know much cmake-fu, but the above is obviously not suitable for committing. I have sdl2 via brew, and pkg-config outputs the correct arguments for the linker:

$ brew info sdl2
sdl2: stable 2.0.4 (bottled), HEAD
Low-level access to audio, keyboard, mouse, joystick, and graphics
https://www.libsdl.org/
/usr/local/Cellar/sdl2/2.0.3 (75 files, 3.7M)
  Poured from bottle
/usr/local/Cellar/sdl2/2.0.4 (82 files, 3.9M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/sdl2.rb
==> Options
--universal
    Build a universal binary
--HEAD
    Install HEAD version
$ pkg-config --libs sdl2
-L/usr/local/lib -lSDL2

Not sure if the fault is in your CMakeLists.txt file or in whatever package provides the Cmake helpers for SDL2 (perhaps SDL2-via-brew itself?)

Readme should call out submodules

I couldn't build without the submodules, so I think it would be nice for the readme to call that out as part of the build process or maybe in the requirements.

Thanks for the super helpful tool.

Compilation fails

I get this on Archlinux when trying to build.

$ cmake .                                                                                                                                                             12:24 
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Curses: /usr/lib/libcurses.so  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found SDL: /usr/lib/libSDLmain.a;/usr/lib/libSDL.so;-lpthread (found version "1.2.15") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for one of the modules 'sdl2'
-- docbook2x-man: not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chais/AUR/sdl2-jstest-git/src/sdl-jstest
$ make
Scanning dependencies of target sdl2-jstest
[ 25%] Building C object CMakeFiles/sdl2-jstest.dir/sdl2-jstest.c.o
[ 50%] Linking C executable sdl2-jstest
/usr/bin/ld: CMakeFiles/sdl2-jstest.dir/sdl2-jstest.c.o: undefined reference to symbol 'stdscr'
/usr/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sdl2-jstest.dir/build.make:97: sdl2-jstest] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/sdl2-jstest.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Versions:
ncurses 6.0+20170902
sdl2 2.0.7
docbook2x 0.8.8

Tests require an out of repo png file

Is it possible to host the image required for the test inside of the repo? Downloading them during the build is problematic in Gentoo where network can be restricted during the build process.

Start testing: Jul 13 13:51 PDT
----------------------------------------------------------
1/2 Testing: sdl-jstest.appdata.xml
1/2 Test: sdl-jstest.appdata.xml
Command: "/usr/bin/appstream-util" "validate-relax" "/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build/sdl-jstest.appdata.xml"
Directory: /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build
"sdl-jstest.appdata.xml" start time: Jul 13 13:51 PDT
Output:
----------------------------------------------------------
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build/sdl-jstest.appdata.xml: FAILED:
• url-not-found         : <screenshot> url not valid [https://sdl-jstest.gitlab.io/screenshot-0.2.1-1.png]: Could not resolve host: sdl-jstest.gitlab.io
Validation of files failed
<end of output>
Test time =   0.01 sec
----------------------------------------------------------
Test Failed.
"sdl-jstest.appdata.xml" end time: Jul 13 13:51 PDT
"sdl-jstest.appdata.xml" time elapsed: 00:00:00
----------------------------------------------------------

2/2 Testing: sdl2-jstest.appdata.xml
2/2 Test: sdl2-jstest.appdata.xml
Command: "/usr/bin/appstream-util" "validate-relax" "/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build/sdl2-jstest.appdata.xml"
Directory: /var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build
"sdl2-jstest.appdata.xml" start time: Jul 13 13:51 PDT
Output:
----------------------------------------------------------
/var/tmp/portage/dev-util/sdl-jstest-9999/work/sdl-jstest-9999_build/sdl2-jstest.appdata.xml: FAILED:
• url-not-found         : <screenshot> url not valid [https://sdl-jstest.gitlab.io/screenshot-0.2.1-1.png]: Could not resolve host: sdl-jstest.gitlab.io
Validation of files failed
<end of output>
Test time =   0.01 sec
----------------------------------------------------------
Test Failed.
"sdl2-jstest.appdata.xml" end time: Jul 13 13:51 PDT
"sdl2-jstest.appdata.xml" time elapsed: 00:00:00
----------------------------------------------------------

End testing: Jul 13 13:51 PDT

make release bundles?

Hi,

I maintain a port of sdl-jstest on OpenBSD. It would be great if you would consider making releases of this awesome port on github, ideally with an upload of the sourcefiles/distfiles. The issue is that this is the only way that there is some guarantee that size/hash may not change when github changes some of its tools or other behind-the-scenes stuff. Our ports system (and that of other OS, too) checks the size and hash of the distfiles; so github's changes regularly break stuff unnecessarily.

Thanks!

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.