TODO: Static Event<> seemingly does not propagate

This commit is contained in:
2025-03-19 13:32:11 -04:00
parent 0c4d012627
commit cda59803a5
4 changed files with 14 additions and 12 deletions

View File

@@ -30,7 +30,7 @@ file(GLOB_RECURSE jstick_SRC "src/*.cpp")
include_directories("include")
if (UNIX)
if (UNIX AND NOT APPLE)
add_library(jstick SHARED ${jstick_SRC})
endif()

View File

@@ -11,6 +11,10 @@
// TODO: Implement simulate DPad Axis button.
// TODO: Make sure Ash applies @ redlobster website.
// TODO: Periodically poll the system to discover device connection and disconnection.
// TODO: Rumble Motor Support
// TODO: Gyroscope Support
// TODO: Calibration API
// TODO: The static events are not propagating.
namespace jstick {
@@ -35,8 +39,6 @@ namespace jstick {
private:
};
enum class ControllerType {
XBox,
PS3, PS4, PS5,

View File

@@ -238,31 +238,31 @@ int main(int argc, char *argv[])
std::cout << jstick::GetDeviceName(hwid) << std::endl;
jstick::ButtonPressed += [](jstick::XBoxButton btn){
jstick::ButtonPressed += [&](jstick::XBoxButton btn){
std::cout << std::format("Button Pressed: {}", (int)btn) << std::endl;
};
jstick::ButtonReleased += [](jstick::XBoxButton btn) {
jstick::ButtonReleased += [&](jstick::XBoxButton btn) {
std::cout << std::format("Button Released: {}", (int)btn) << std::endl;
};
jstick::DPadMoved += [](Vector2 v) {
jstick::DPadMoved += [&](Vector2 v) {
std::cout << std::format("DPad Moved {},{}", v.x, v.y) << std::endl;
};
jstick::LeftThumbstickMoved += [](Vector2 v){
jstick::LeftThumbstickMoved += [&](Vector2 v){
std::cout << std::format("LThumb Moved {},{}", v.x, v.y) << std::endl;
};
jstick::RightThumbstickMoved += [](Vector2 v){
jstick::RightThumbstickMoved += [&](Vector2 v){
std::cout << std::format("RThumb Moved {},{}", v.x, v.y) << std::endl;
};
jstick::LeftTriggerMoved += [] (short val) {
jstick::LeftTriggerMoved += [&] (short val) {
std::cout << std::format("LTrigger Moved {}", val) << std::endl;
};
jstick::RightTriggerMoved += [](short val) {
jstick::RightTriggerMoved += [&](short val) {
std::cout << std::format("RTrigger Moved {}", val) << std::endl;
};
}

View File

@@ -125,6 +125,8 @@ void ProcessButtonEvent(uint8_t button_index, bool value) {
} else {
jstick::ButtonReleased.Invoke(btn);
}
}
void ProcessAxisEvent(uint8_t axis, short value) {
@@ -138,8 +140,6 @@ void ProcessAxisEvent(uint8_t axis, short value) {
if (device_type == jstick::ControllerType::XBox)
{
if (axis == 0) l_thumb.x = value;
if (axis == 1) l_thumb.y = value;
if (axis == 2) l_trigger = value;