Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ TARGET_LINK_LIBRARIES(code PUBLIC jansson)

target_link_libraries(code PUBLIC anl)

target_link_libraries(code PUBLIC hidapi::hidapi)

target_link_libraries(code PUBLIC imgui)

IF(FSO_BUILD_WITH_OPENXR)
Expand Down
22 changes: 10 additions & 12 deletions code/io/spacemouse.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "spacemouse.h"

#include <hidapi.h>

using namespace io::spacemouse;

#pragma pack(push,1)
Expand Down Expand Up @@ -43,7 +41,7 @@ void SpaceMouse::poll() {
case SpaceMouseDefinition::Protocol::CONNEXION_3D_OLD: {
static connexion_3d_old_protocol data;

bytes_read = hid_read(m_deviceHandle, reinterpret_cast<unsigned char*>(&data), sizeof(connexion_3d_old_protocol));
bytes_read = SDL_hid_read(m_deviceHandle, reinterpret_cast<unsigned char*>(&data), sizeof(connexion_3d_old_protocol));
if (bytes_read <= 0)
continue;

Expand All @@ -69,7 +67,7 @@ void SpaceMouse::poll() {
case SpaceMouseDefinition::Protocol::CONNEXION_3D_NEW: {
static connexion_3d_new_protocol data;

bytes_read = hid_read(m_deviceHandle, reinterpret_cast<unsigned char*>(&data), sizeof(connexion_3d_new_protocol));
bytes_read = SDL_hid_read(m_deviceHandle, reinterpret_cast<unsigned char*>(&data), sizeof(connexion_3d_new_protocol));
if (bytes_read <= 0)
continue;

Expand Down Expand Up @@ -106,14 +104,14 @@ void SpaceMouse::pollMaybe() {
}
}

SpaceMouse::SpaceMouse(const SpaceMouseDefinition& definition, hid_device* deviceHandle, int pollingFrequency)
SpaceMouse::SpaceMouse(const SpaceMouseDefinition& definition, SDL_hid_device* deviceHandle, int pollingFrequency)
: m_definition(definition), m_pollingFrequency(pollingFrequency), m_deviceHandle(deviceHandle),
m_current({ ZERO_VECTOR, ZERO_ANGLES }), m_keypresses(definition.buttons, false), m_lastPolled(UI_TIMESTAMP::never()) {
hid_set_nonblocking(m_deviceHandle, 1);
SDL_hid_set_nonblocking(m_deviceHandle, 1);
}

SpaceMouse::~SpaceMouse() {
hid_close(m_deviceHandle);
SDL_hid_close(m_deviceHandle);
}

const SpaceMouseMovement& SpaceMouse::getMovement() {
Expand Down Expand Up @@ -146,14 +144,14 @@ const static SCP_vector<SpaceMouseDefinition> knownSpaceMice {
std::unique_ptr<SpaceMouse> SpaceMouse::searchSpaceMice(int pollingFrequency) {
std::unique_ptr<SpaceMouse> mouse = nullptr;

hid_device_info* devices = hid_enumerate(0, 0);
auto devices = SDL_hid_enumerate(0, 0);

for (const hid_device_info* head = devices; head != nullptr && mouse == nullptr; head = head->next) {
for (auto head = devices; head != nullptr && mouse == nullptr; head = head->next) {
for (const SpaceMouseDefinition& mouseDef : knownSpaceMice) {
if (mouseDef.vendorID != head->vendor_id || mouseDef.productID != head->product_id)
continue;

hid_device* device = hid_open_path(head->path);
auto device = SDL_hid_open_path(head->path);

if (device != nullptr) {
mouse = std::unique_ptr<SpaceMouse>(new SpaceMouse(mouseDef, device, pollingFrequency));
Expand All @@ -162,7 +160,7 @@ std::unique_ptr<SpaceMouse> SpaceMouse::searchSpaceMice(int pollingFrequency) {
}
}

hid_free_enumeration(devices);
SDL_hid_free_enumeration(devices);

return mouse;
}
Expand All @@ -182,4 +180,4 @@ void SpaceMouseMovement::handleNonlinearities(std::array<std::tuple<float, float
HANDLE_NONLINEARITY(rotation.p, 3);
HANDLE_NONLINEARITY(rotation.b, 4);
HANDLE_NONLINEARITY(rotation.h, 5);
}
}
11 changes: 4 additions & 7 deletions code/io/spacemouse.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#pragma once

#include "globalincs/vmallocator.h"
#include "globalincs/pstypes.h"
#include "math/vecmat.h"
#include "io/timer.h"

struct hid_device_;
typedef hid_device_ hid_device;

namespace io
{
namespace spacemouse {
Expand All @@ -27,14 +24,14 @@ namespace io
const SpaceMouseDefinition& m_definition;
const int m_pollingFrequency;

hid_device* m_deviceHandle;
SDL_hid_device* m_deviceHandle;
SpaceMouseMovement m_current;
SCP_vector<bool> m_keypresses;
UI_TIMESTAMP m_lastPolled;

void poll();
void pollMaybe();
SpaceMouse(const SpaceMouseDefinition& definition, hid_device* deviceHandle, int pollingFrequency = 10);
SpaceMouse(const SpaceMouseDefinition& definition, SDL_hid_device* deviceHandle, int pollingFrequency = 10);
public:
~SpaceMouse();

Expand Down Expand Up @@ -68,4 +65,4 @@ namespace io
static SpaceMouse* getSharedSpaceMouse(int pollingFrequency = 10);
};
}
}
}
4 changes: 0 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ add_subdirectory(accidental-noise)

ADD_SUBDIRECTORY(lz4)

set(HIDAPI_WITH_LIBUSB OFF)
set(HIDAPI_WITH_HIDRAW ON)
add_subdirectory(hidapi EXCLUDE_FROM_ALL)

ADD_SUBDIRECTORY(imgui)

if(FSO_BUILD_WITH_OPENXR)
Expand Down
18 changes: 0 additions & 18 deletions lib/hidapi/AUTHORS.txt

This file was deleted.

61 changes: 0 additions & 61 deletions lib/hidapi/CMakeLists.txt

This file was deleted.

9 changes: 0 additions & 9 deletions lib/hidapi/LICENSE-orig.txt

This file was deleted.

1 change: 0 additions & 1 deletion lib/hidapi/VERSION

This file was deleted.

Loading
Loading