Commit MetaInfo

Revisioncec9252a158c7cbed41bba9bfa645843eb71e951 (tree)
Time2020-02-29 03:39:53
AuthorDavid Ludwig <dludwig@pobo...>
CommiterDavid Ludwig

Log Message

hat-layout tweaks; added a bit of optional debug code

Change Summary

Incremental Difference

diff -r 2897613916f8 -r cec9252a158c main.cpp
--- a/main.cpp Thu Feb 27 20:03:58 2020 -0500
+++ b/main.cpp Fri Feb 28 13:39:53 2020 -0500
@@ -200,6 +200,11 @@
200200 ImGui::SameLine();
201201 const int num_joysticks = SDL_NumJoysticks();
202202 ImGui::Text("Joysticks, Total-Count: %d", num_joysticks);
203+ static bool autoOpenJoysticks = false; // TODO: persist this on-disk
204+ // ImGui::SameLine();
205+ // ImGui::Dummy(ImVec2(32,0));
206+ // ImGui::SameLine();
207+ // ImGui::Checkbox("Auto-Open Joysticks?", &autoOpenJoysticks);
203208
204209 ImGui::Separator();
205210 ImGui::Separator();
@@ -228,7 +233,7 @@
228233 ImGui::NextColumn();
229234 #if 1
230235 if (!joystick) {
231- if (ImGui::Button("Open")) {
236+ if (ImGui::Button("Open") || autoOpenJoysticks) {
232237 joystick = SDL_JoystickOpen(device_index);
233238 if (joystick != nullptr) {
234239 printf("Joystick opened successfully\n");
@@ -518,11 +523,12 @@
518523 { "Raw State:", true },
519524 };
520525
521- ImGui::Columns(nhats + 1);
526+ const int debugAddFakeHats = 0;
527+ ImGui::Columns(nhats + 1 + debugAddFakeHats);
522528 ImGui::SetColumnWidth(0, 85);
523529 for (int i = 1; i < nhats + 1; ++i) {
524530 // ImGui::SetColumnWidth(i, ImGui::GetWindowWidth() / (nbuttons + 1));
525- ImGui::SetColumnWidth(i, 200);
531+ ImGui::SetColumnWidth(i, 95);
526532 }
527533
528534 for (int row = 0; row < SDL_arraysize(rowLabels); ++row) {
@@ -533,9 +539,9 @@
533539 ImGui::Text("%s", rowLabels[row].name);
534540 ImGui::NextColumn();
535541
536- for (int col = 0; col < nhats; ++col) {
542+ for (int col = 0; col < nhats + debugAddFakeHats; ++col) {
537543 ImGui::PushID(col);
538- const Uint8 hatState = SDL_JoystickGetHat(joystick, col);
544+ const Uint8 hatState = SDL_JoystickGetHat(joystick, std::clamp(col, 0, nhats-1));
539545 switch (row) {
540546 case 0: {
541547 // display hat-index
Show on old repository browser