The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2 cross compiling on linux x64 and rasp/gamecontroller
wrock


Joined: 03 Mar 2015
Posts: 4
hey guys, I'm trying since 3 days to get a running setup i have: a Raspberry Pie with either ARCHLINUX (and an MINIDEBIAN) as Goal system UBUNTU x64 as developing enviroment I cross compile this on the ubuntu(works with normal compiling an running on ubuntu) and copy that to the raspberry-->the gamecontroller(xbox 360) is recognized succesfully, but i never get events.... using this raspberry binaries for cross compiling: https://buildbot.libsdl.org/sdl-builds/sdl-raspberrypi/ Problem places: I'm using eclipse for cross compiling...settings: Cross G++ includes: usd/local/include Cross G++ libraries: -lSDL2 //here i also got an version of an SDL 2.0.0 binary, when i include the old version it works... -usr/local/lib ...but not with the binaries from the link, I get an" warning: libbcm_host.so, needed by..." but its there for sure(and it worked within the other binaries...) anyone an idea where i can start fixng/fnding? Problem one: Code: #include #include #include #include /* This function may run in a separate event thread */ int main() { SDL_Joystick *joy; // Initialize the joystick subsystem SDL_InitSubSystem(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER); SDL_GameController *controller; SDL_Event ev; std::cout << "program started"<< std::endl; std::cout << SDL_NumJoysticks() << std::endl; if (SDL_NumJoysticks() > 0) { // Open joystick joy = SDL_JoystickOpen(0); if (joy) { printf("Opened Joystick 0\n"); printf("Name: %s\n", SDL_JoystickNameForIndex(0)); printf("Number of Axes: %d\n", SDL_JoystickNumAxes(joy)); printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(joy)); printf("Number of Balls: %d\n", SDL_JoystickNumBalls(joy)); } else { printf("Couldn't open Joystick 0\n"); } // Close if opened if (SDL_JoystickGetAttached(joy)) { SDL_JoystickClose(joy); } } // bool isOpen = false; while (true) { usleep(1000); std::cout << "new polling"< while (SDL_PollEvent(&ev)) { std::cout << "new polling"< if (ev.type == SDL_CONTROLLERDEVICEREMOVED) { std::cout << "controller_removed" << std::endl; SDL_GameControllerClose(controller); isOpen = false; } else if (ev.type == SDL_CONTROLLERDEVICEADDED) { if (!isOpen) { std::cout << "new controller added" << std::endl; for (int i = 0; i < SDL_NumJoysticks(); i++) { if (SDL_IsGameController(i)) { controller = SDL_GameControllerOpen(i); if(controller){ std::cout << "controller is open"<< std::endl; isOpen=true; } else{ std::cout << "error opening"<< std::endl; } break; } } } } else if (ev.type == SDL_CONTROLLERBUTTONDOWN) { if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_A) { std::cout << "A pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_B) { std::cout << "B pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_Y) { std::cout << "Y pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_X) { std::cout << "X pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_START) { std::cout << "start pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) { std::cout << "back pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) { std::cout << "leftshoulder pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) { std::cout << "rightshoulder pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) { std::cout << "DPAD DOWN pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_UP) { std::cout << "DPAD UP pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) { std::cout << "DPAD LEFT pressed" << std::endl; } else if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) { std::cout << "DPAD RIGHT pressed" << std::endl; } } else if (ev.type == SDL_CONTROLLERAXISMOTION) { if (((ev.caxis.axis == SDL_CONTROLLER_AXIS_LEFTX) && (ev.caxis.value > 10000 || ev.caxis.value < -10000)) || (ev.caxis.axis == SDL_CONTROLLER_AXIS_LEFTY) && (ev.caxis.value > 10000 || ev.caxis.value < -10000) || (ev.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTX) && (ev.caxis.value > 10000 || ev.caxis.value < -10000) || (ev.caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY) && (ev.caxis.value > 10000 || ev.caxis.value < -10000) || (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT) && (ev.caxis.value > 10000 || ev.caxis.value < -10000) || (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) && (ev.caxis.value > 10000 || ev.caxis.value < -10000)) { Sint16 X_AXE_LEFT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTX); Sint16 Y_AXE_LEFT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTY); Sint16 X_AXE_RIGHT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX); Sint16 Y_AXE_RIGHT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY); Sint16 TRIGGER_LEFT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERLEFT); Sint16 TRIGGER_RIGHT = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT); std::cout << "left: " << X_AXE_LEFT; std::cout << ", " << Y_AXE_LEFT; std::cout << " right: " << X_AXE_RIGHT; std::cout << ", " << Y_AXE_RIGHT; std::cout << " trigger: " << TRIGGER_LEFT; std::cout << ", " << TRIGGER_RIGHT; std::cout << std::endl; } } } } return 0; }
SDL2 cross compiling on linux x64 and rasp/gamecontroller
wrock


Joined: 03 Mar 2015
Posts: 4
...and of course, i copied the binaries onto the archlinux/debian