WIP study of XInput for windows support.

This commit is contained in:
2025-05-22 23:08:10 -05:00
parent 71094053a2
commit 2be8d8e7a1
5 changed files with 124 additions and 8 deletions

View File

@@ -1,14 +1,22 @@
#include <jstick.hpp>
#ifdef UNIX
#include <linux/joystick.h>
#include <unistd.h>
#include <bits/fs_fwd.h>
#endif
#ifdef WIN32
//#include <joystickapi.h>
#endif
#include <cstddef>
#include <cstdio>
#include <fcntl.h>
#include <format>
#include <filesystem>
#include <iostream>
#include <unistd.h>
#include <bits/fs_fwd.h>
#include <J3ML/LinearAlgebra/Vector2i.hpp>
struct axis_state {

View File

@@ -0,0 +1,3 @@
//
// Created by josh on 5/22/2025.
//

View File

@@ -0,0 +1,29 @@
#include <iostream>
#include <jstick.hpp>
#include <windows.h>
#include <XInput.h>
bool jstick::Initialize()
{
}
bool jstick::JoystickDetected(int jsHandle)
{
DWORD dwUserIndex = (DWORD)jsHandle;
XINPUT_STATE state;
ZeroMemory(&state, sizeof(XINPUT_STATE));
DWORD result = XInputGetState(dwUserIndex, &state);
if (result == ERROR_SUCCESS)
{
return true;
} else {
std::cout << "Error Code: " << result << std::endl;
return false;
}
}