• Stars
    star
    156
  • Rank 232,034 (Top 5 %)
  • Language
    C++
  • Created over 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A minimal C++ object-oriented API onto joystick devices under Linux

joystick++

A minimal C++ object-oriented API onto joystick devices under Linux.

usage

Create an instance of Joystick:

Joystick joystick;

Ensure that it was found and that we can use it:

if (!joystick.isFound())
{
  printf("open failed.\n");
  // hmm
}

Sample events from the Joystick:

JoystickEvent event;
if (joystick.sample(&event))
{
  // use 'event'
}

example

You might run this in a loop:

while (true)
{
  // Restrict rate
  usleep(1000);

  // Attempt to sample an event from the joystick
  JoystickEvent event;
  if (joystick.sample(&event))
  {
    if (event.isButton())
    {
      printf("Button %u is %s\n", event.number, event.value == 0 ? "up" : "down");
    }
    else if (event.isAxis())
    {
      printf("Axis %u is at position %d\n", event.number, event.value);
    }
  }
}

This produces something similar to:

Button 1 is up
Button 2 is down
Axis 0 is at position 122
Axis 1 is at position -11
Axis 2 is at position 9796
Axis 3 is at position -13850

options

You can specify the particular joystick by id:

Joystick js0(0);
Joystick js1(1);

Or provide a specific device name:

Joystick js0("/dev/input/js0");

license

Released under Apache License 2.0.

Copyright Drew Noakes 2013-2017.

More Repositories

1

metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Java
2,478
star
2

metadata-extractor-dotnet

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
C#
885
star
3

figgle

ASCII banner generation for .NET
C#
328
star
4

string-theory

Identify and reduce memory used by duplicate .NET strings
C#
295
star
5

metadata-extractor-images

Database of images from various digital cameras
PostScript
100
star
6

fix-decoder

Unravels FIX messages into human readable tables
JavaScript
78
star
7

vs-side-scroller

Scroll horizontally with the mouse wheel when holding the shift key in Visual Studio
C#
72
star
8

il-visualizer

.NET debugging visualiser for runtime-generated IL code (via DynamicMethod, etc) for VS2017 and VS2015
C#
69
star
9

style-snooper

Extract default WPF styles for controls
C#
59
star
10

xmp-core-dotnet

.NET library for working with the Extensible Metadata Platform (XMP)
C#
58
star
11

dependency-analyser

Shows the dependencies between .NET projects and assemblies as a graph.
C#
41
star
12

amusing

A command-line tool that shows what namespaces you am-using.
C#
23
star
13

nquant

A fork of https://nquant.codeplex.com with several performance improvements to reduce CPU and memory usage
C#
23
star
14

quadrilateral-finder

A solution to the computer vision problem of finding a quadrilateral shape from a set of scattered line segments
C#
13
star
15

tin-man

Program your own RoboCup 3D soccer playing agents in .NET
C#
13
star
16

suo

View contents of Visual Studio SUO files
C#
11
star
17

adobe-xmp-core

Reconstructed history of Adobe's Java XMPCore library from Maven sources
Java
10
star
18

lwsxx

A C++ API for the C libwebsockets library
C++
9
star
19

pew-pew

Sound effect synthesizer for .NET
C#
7
star
20

molly

Linux tools for the "Big Red Button" USB device manufactured by Dream Cheeky
C++
5
star
21

solution-generator

Generate solutions with arbitrary numbers of projects/files for testing purposes
C#
4
star
22

generate-code-sample

Sample code that shows generation of source code during build via MSBuild
C#
4
star
23

copy-across-project-references

Exploring .NET build behaviour when copying files across project references
C#
4
star
24

beep

Machine that goes ping, for your command line
C#
3
star
25

hex-dump

Formats a hex dump from bytes
C#
3
star
26

gitlucky

Amends the last git commit to have the desired SHA-1 prefix.
C#
2
star
27

attached-collections-sample

An example of extending Visual Studio's Solution Explorer via the attached collections APIs
C#
2
star
28

mini-lisp

Minimal C# lisp expression evaluator
C#
2
star
29

settings

Miscellaneous settings files. There's probably nothing interesting here, unless you're me.
Lua
2
star
30

msgpack-vs-visualiser-dotnet

Visual Studio Debugger Visualizer for MsgPack encoded byte arrays
C#
2
star
31

natural-sort

A .NET string comparer that orders integers within strings correctly.
C#
2
star
32

palettes

Simple web page for displaying colour palettes
JavaScript
2
star
33

optimistic-immutable-collections

Familiar collection API that wraps persistent collections and use lock-free operations for safety and correctness
C#
1
star
34

biggus-griddus-demo

Demonstrates usage of the biggus-griddus library.
JavaScript
1
star