Add info from controllers I have.
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/.idea
|
||||
/.cache
|
||||
/.ccls-cache
|
||||
/compile_commands.json
|
||||
/cmake-build-debug
|
||||
/build
|
42
main.cpp
42
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;
|
||||
|
Reference in New Issue
Block a user