diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52c505d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.idea +/.cache +/.ccls-cache +/compile_commands.json +/cmake-build-debug +/build diff --git a/main.cpp b/main.cpp index e335c57..b937c42 100644 --- a/main.cpp +++ b/main.cpp @@ -86,6 +86,7 @@ struct Axes { short RightThumbY = 0; short DPadX = 0; short DPadY = 0; + // TODO Left & Right triggers should start at -32767 because 0 would be pressed half way. short LeftTrigger = 0; short RightTrigger = 0; }; @@ -111,7 +112,7 @@ size_t get_axis_state(struct js_event *event, struct Axes& axes) size_t axis = event->number; short value = event->value; - // Appear to be mappings for XBox + // X-Box 360 & X-Box One are the same. if (axis == 0) axes.LeftThumbX = value; if (axis == 1) axes.LeftThumbY = value; if (axis == 2) axes.LeftTrigger = value; @@ -121,6 +122,45 @@ size_t get_axis_state(struct js_event *event, struct Axes& axes) if (axis == 6) axes.DPadX = value; if (axis == 7) axes.DPadY = value; + // "Sony PLAYSTATION(R)3 Controller", Has 6 axes. + /* + // D-PAD UP -> Button 12 + // D-Pad DOWN -> Button 13 + // D-Pad LEFT -> Button 14 + // D-Pad RIGHT -> Button 15 + if (axis == 0) axes.LeftThumbX = value; + if (axis == 1) axes.LeftThumbY = value; + if (axis == 3) axes.RightThumbX = value; + if (axis == 4) axes.RightThumbY = value; + if (axis == 2) axes.LeftTrigger = value; + if (axis == 5) axes.RightTrigger = value; + */ + + + // Playstation 4 + /* + if (axis == 0) axes.LeftThumbX = value; + if (axis == 1) axes.LeftThumbY = value; + if (axis == 3) axes.RightThumbX = value; + if (axis == 4) axes.RightThumbY = value; + if (axis == 2) axes.LeftTrigger = value; + if (axis == 5) axes.RightTrigger = value; + if (axis == 6) axes.DPadX = value; + if (axis == 7) axes.DPadY = value; + */ + + // "8BitDo Pro 2" in Direct Input mode. This controller also supports the Xbox mode. + /* + if (axis == 0) axes.LeftThumbX = value; + if (axis == 1) axes.LeftThumbY = value; + if (axis == 2) axes.RightThumbX = value; + if (axis == 3) axes.RightThumbY = value; + if (axis == 4) axes.RightTrigger = value; + if (axis == 5) axes.LeftTrigger = value; + if (axis == 6) axes.DPadX = value; + if (axis == 7) axes.DPadY = value; + */ + std::cout << std::format("axis_index: {}, val: {}", axis, value) << std::endl; std::cout << std::format("lthumb: {},{} ltrigger: {}, rthumb: {},{}, rtrigger: {}, dp: {},{}", axes.LeftThumbX, axes.LeftThumbY, axes.LeftTrigger, axes.RightThumbX, axes.RightThumbY, axes.RightTrigger, axes.DPadX, axes.DPadY) << std::endl;