WIP study of XInput for windows support.
This commit is contained in:
@@ -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 {
|
3
src/platform/linux/jstick_linux.cpp
Normal file
3
src/platform/linux/jstick_linux.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
//
|
||||
// Created by josh on 5/22/2025.
|
||||
//
|
29
src/platform/windows/jstick_xinput.cpp
Normal file
29
src/platform/windows/jstick_xinput.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user