Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes needed for Raspberry PI build on latest Raspbian #2281

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platforms/rpi/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_link_libraries(tangram
/opt/vc/lib/libbrcmGLESv2.so
/opt/vc/lib/libvchiq_arm.so
/opt/vc/lib/libvcos.so
/usr/lib/arm-linux-gnueabihf/libatomic.so.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using just atomic here seems to work on my pi. If it works on yours too, can you replace the path here with atomic? I'd rather not hard-code libraries where it isn't necessary.

)

target_compile_options(tangram
Expand Down
38 changes: 23 additions & 15 deletions platforms/rpi/src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <iostream>
#include <string>
#include <fstream>
#include <poll.h>
#include <termios.h>
#include <linux/input.h>

Expand Down Expand Up @@ -380,24 +381,31 @@ void destroySurface() {


int getKey() {
int character;
int character = -1;
struct termios orig_term_attr;
struct termios new_term_attr;

/* set the terminal to raw mode */
tcgetattr(fileno(stdin), &orig_term_attr);
memcpy(&new_term_attr, &orig_term_attr, sizeof(struct termios));
new_term_attr.c_lflag &= ~(ECHO|ICANON);
new_term_attr.c_cc[VTIME] = 0;
new_term_attr.c_cc[VMIN] = 0;
tcsetattr(fileno(stdin), TCSANOW, &new_term_attr);

/* read a character from the stdin stream without blocking */
/* returns EOF (-1) if no character is available */
character = fgetc(stdin);

/* restore the original terminal attributes */
tcsetattr(fileno(stdin), TCSANOW, &orig_term_attr);
struct pollfd fds = { 0 };
fds.fd = STDIN_FILENO;
fds.events = POLLIN;

int numready = poll(&fds, 1, 1);
if (0 < numready) {
/* set the terminal to raw mode */
tcgetattr(fileno(stdin), &orig_term_attr);
memcpy(&new_term_attr, &orig_term_attr, sizeof(struct termios));
new_term_attr.c_lflag &= ~(ECHO|ICANON);
new_term_attr.c_cc[VTIME] = 0;
new_term_attr.c_cc[VMIN] = 0;
tcsetattr(fileno(stdin), TCSANOW, &new_term_attr);

/* read a character from the stdin stream without blocking */
/* returns EOF (-1) if no character is available */
character = fgetc(stdin);

/* restore the original terminal attributes */
tcsetattr(fileno(stdin), TCSANOW, &orig_term_attr);
}

return character;
}
Expand Down
4 changes: 2 additions & 2 deletions platforms/rpi/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ int main(int argc, char **argv) {
Url baseUrl("file:///");
char pathBuffer[PATH_MAX] = {0};
if (getcwd(pathBuffer, PATH_MAX) != nullptr) {
baseUrl = Url(std::string(pathBuffer) + "/").resolved(baseUrl);
baseUrl = baseUrl.resolve(Url(std::string(pathBuffer) + "/"));
}

LOG("Base URL: %s", baseUrl.string().c_str());

Url sceneUrl = Url(options.sceneFilePath).resolved(baseUrl);
Url sceneUrl = baseUrl.resolve(Url(options.sceneFilePath));

map = std::make_unique<Map>(std::make_unique<RpiPlatform>(urlClientOptions));
map->loadScene(sceneUrl.string(), !options.hasLocationSet, updates);
Expand Down