From 818814eec827b2a9779cb6a5700fd8df0aa94565 Mon Sep 17 00:00:00 2001 From: beno Date: Sun, 22 Mar 2026 01:44:09 +0100 Subject: [PATCH] hardcoded device-specific variables have been moved to argv[] configuration --- sources/main.cpp | 93 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 20 deletions(-) diff --git a/sources/main.cpp b/sources/main.cpp index 9a141b1..c5b483e 100755 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -35,13 +35,6 @@ extern "C" { using namespace glm; using namespace std; -const char *RES_FOLDER = "/home/beno/Desktop/rg552_minimal_dev_env/WAYLAND/demos/rez_demo/resources/"; // "/CGI_DEMO/RESOURCES/"; - -const char *devPaths[2] = { - "/dev/input/event4", - "/dev/input/event5" -}; - const int TARGET_FPS = 60; static int ONE_TICK_MS = 1000 / TARGET_FPS; @@ -81,11 +74,8 @@ ReelManager* reel; TexMerger* merger; Screen* canvas; -/*was false and triggerable via keypress but i have no input capturing*/ -bool runIterator = true; - - - +/* triggerable via keypress, set to false if you cannot have input capturing */ +bool runIterator = false; uint8_t previous_touches_count = 0; uint8_t current_touches_count = 0; @@ -93,8 +83,9 @@ uint8_t current_touches_count = 0; touch_event **previous_touches = NULL; touch_event **current_touches = NULL; -uint8_t touch_rotation = 3; /* it is not always possible to use a calibration matrix for rotating the touchscreen events, 0..3 rotations of 0, 90, 180, 270 */ - +/* it is not always possible to use a calibration matrix for rotating the touchscreen events, + 0..3 rotations of 0, 90, 180, 270 */ +uint8_t touch_rotation; /* don't want to implement */ /* also removed @@ -111,6 +102,23 @@ void glutInitContextVersion( int maj, int min){} void glutInitContextProfile( GLuint profile){} void glutInitDisplayMode( GLuint OR_ed_FLAGS){} +void failForBadRotation( char* argv[]){ + std::cerr << argv[0] << " : bad rotation argument ("<< argv[1] << ")\n" + << "\n" + << "\tcall as\n" + << "\t" << argv[0] << " [ANGLE] [KEYS] [TOUCH] [RESOURCEDIR]\n" + << "\n" + << "\twhere\n" + << "\t[ANGLE] = {0,1,2,3} AS trueRotation = ANGLE * 90\n" + << "\t[KEYS] and [TOUCH] AS the number specifying the device in /dev/input/event*\n" + << "\t[RESOURCEDIR] AS the full path to the game assets\n" + << "\n" + << "\ti.e.\n" + << "\t" << argv[0] << " 2 2 11 /home/WHO/RESOURCES/\n"; + + exit(EXIT_FAILURE); +} + int glutGet(GLuint dimension){ switch( dimension) { case GLUT_SCREEN_WIDTH : @@ -415,7 +423,7 @@ void mousemoved(int x, int y) { //camera.mouseMotion(x, y); } -void emplaceModels() { +void emplaceModels(char *RES_FOLDER) { char buf_1[256]; char buf_2[256]; @@ -462,7 +470,7 @@ void emplaceModels() { } -void curveSetup() { +void curveSetup( char *RES_FOLDER) { char buf_1[256]; char buf_2[256]; @@ -517,8 +525,53 @@ void curveSetup() { } -int main(int argc, char* argv[]) { - glutInit( (char**) devPaths, 2); +int main( int argc, char* argv[]) { + + if( argc != 5){ + std::cerr << argv[0] << " : missing arguments\n" + << "\n" + << "\tcall as\n" + << "\t" << argv[0] << " [ANGLE] [KEYS] [TOUCH] [RESOURCEDIR]\n" + << "\n" + << "\twhere\n" + << "\t[ANGLE] = {0,1,2,3} AS trueRotation = ANGLE * 90\n" + << "\t[KEYS] and [TOUCH] AS the number specifying the device in /dev/input/event*\n" + << "\t[RESOURCEDIR] AS the full path to the game assets\n" + << "\n" + << "\ti.e.\n" + << "\t" << argv[0] << " 0 2 11 /home/WHO/RESOURCES/\n"; + exit(EXIT_FAILURE); + } + + char *RES_FOLDER=argv[4]; + + if( 1 != strlen( argv[1])){ + failForBadRotation( argv); + } + + touch_rotation = argv[1][0] - '0'; + if( touch_rotation < 0 || touch_rotation > 3 ){ + failForBadRotation( argv); + } + + string devPrefix = "/dev/input/event"; + string devPaths[2]; + devPaths[0] = devPrefix + argv[2]; + devPaths[1] = devPrefix + argv[3]; + + + std::clog << "screen rotation of " << 90 * touch_rotation << "\n"; + std::clog << "keyboard as " << devPaths[0] << "\n"; + std::clog << "touch/mouse as " << devPaths[1] << "\n"; + std::clog << "resource directory as " << RES_FOLDER << "\n"; + + const char* DEVSTRINGS[2]; + DEVSTRINGS[0] = devPaths[0].c_str(); + DEVSTRINGS[1] = devPaths[1].c_str(); + + glutInit( (char**) DEVSTRINGS, 2); + + glutInitContextVersion(4, 0); glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); @@ -564,8 +617,8 @@ int main(int argc, char* argv[]) { camera->setWindowData( 0, scrWidth, 0, scrHeight); camera->getCamera()->setPosition(vec3(0, 0, 2)); - curveSetup(); - emplaceModels(); + curveSetup( RES_FOLDER); + emplaceModels( RES_FOLDER); /* printf("begin effects setup\n");