Skip to content

SilverTuxedo/JoyConBridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JoyCon Bridge

Easy, simple, object-oriented access to JoyCons.

JoyCon Bridge allows you to access the state of any connected JoyCon, including buttons, analog sticks, accelerometer and gyroscope data - all in a simple and straightforward manner.

C++ Example

#include "JoyCon.h"
#include "connect.h"
#include "exceptions.h"

using namespace joy_con_bridge;

int main()
{
	try {
		JoyCon left = connect::getLeftJoyCon();
		while (true) {
			left.poll();

			ButtonsState buttons = left.getButtonsState();
			AnalogStick stick = left.getLeftStick();
			ThreeAxesSensor acc = left.getAccelerometer();
			ThreeAxesSensor gyro = left.getGyroscope();

			// ...
		}
	} catch (const JoyConError& e) {
		std::cout << "JoyCon error! " << e.what() << std::endl;
	} catch (const HidError& e) {
		std::cout << "Device error! " << e.what() << std::endl;
	}

	return 0;
}

Python interface

The sub-project pyjoyconbridge provides the JoyConBridge library as a Python module (pyd).

Example

import pyjoyconbridge


def main():
    try:
        left = pyjoyconbridge.get_left_joy_con()
        while True:
            left.poll()

            buttons = left.buttons_state
            stick = left.left_stick
            acc = left.accelerometer
            gyro = left.gyroscope

            # ...
    except RuntimeError as e:
        print("Error! " + str(e))

Building pyjoyconbridge

This project uses Boost.Python.

  • Install Python.
  • Download and configure Boost.
  • Set the following environment variables:
    • BOOST_ROOT: The directory where Boost is located.
    • PYTHON_ROOT: The directory where Python is installed.
  • Build using Visual Studio.

If you don't want to change your environment variables, you can manually replace $(...) occurrences in Boost.Python.props.

Limitations

  • Only Bluetooth communication is supported.
  • No support for sending rumble.
  • Windows only (can be resolved by replacing the hidapi version used).

Special thanks