mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 19:33:45 +08:00
openpilot v0.5.11 release
This commit is contained in:
@@ -90,3 +90,31 @@ int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) {
|
||||
return up;
|
||||
}
|
||||
|
||||
int touch_read(TouchState *s, int* out_x, int* out_y) {
|
||||
assert(out_x && out_y);
|
||||
struct input_event event;
|
||||
int err = read(s->fd, &event, sizeof(event));
|
||||
if (err < sizeof(event)) {
|
||||
return -1;
|
||||
}
|
||||
bool up = false;
|
||||
switch (event.type) {
|
||||
case EV_ABS:
|
||||
if (event.code == ABS_MT_POSITION_X) {
|
||||
s->last_x = event.value;
|
||||
} else if (event.code == ABS_MT_POSITION_Y) {
|
||||
s->last_y = event.value;
|
||||
}
|
||||
up = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (up) {
|
||||
// adjust for flippening
|
||||
*out_x = s->last_y;
|
||||
*out_y = 1080 - s->last_x;
|
||||
}
|
||||
return up;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ typedef struct TouchState {
|
||||
|
||||
void touch_init(TouchState *s);
|
||||
int touch_poll(TouchState *s, int *out_x, int *out_y, int timeout);
|
||||
int touch_read(TouchState *s, int* out_x, int* out_y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMMA_VERSION "0.5.10-release"
|
||||
#define COMMA_VERSION "0.5.11-release"
|
||||
|
||||
@@ -68,7 +68,7 @@ VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf) {
|
||||
|
||||
#ifdef QCOM
|
||||
|
||||
EGLClientBuffer visionimg_to_egl(const VisionImg *img) {
|
||||
EGLClientBuffer visionimg_to_egl(const VisionImg *img, void **pph) {
|
||||
assert((img->size % img->stride) == 0);
|
||||
assert((img->stride % img->bpp) == 0);
|
||||
|
||||
@@ -87,13 +87,14 @@ EGLClientBuffer visionimg_to_egl(const VisionImg *img) {
|
||||
|
||||
GraphicBuffer* gb = new GraphicBuffer(img->width, img->height, (PixelFormat)format,
|
||||
GraphicBuffer::USAGE_HW_TEXTURE, img->stride/img->bpp, hnd, false);
|
||||
|
||||
// GraphicBuffer is ref counted by EGLClientBuffer(ANativeWindowBuffer), no need and not possible to release.
|
||||
*pph = hnd;
|
||||
return (EGLClientBuffer) gb->getNativeBuffer();
|
||||
}
|
||||
|
||||
GLuint visionimg_to_gl(const VisionImg *img) {
|
||||
GLuint visionimg_to_gl(const VisionImg *img, EGLImageKHR *pkhr, void **pph) {
|
||||
|
||||
EGLClientBuffer buf = visionimg_to_egl(img);
|
||||
EGLClientBuffer buf = visionimg_to_egl(img, pph);
|
||||
|
||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(display != EGL_NO_DISPLAY);
|
||||
@@ -107,8 +108,15 @@ GLuint visionimg_to_gl(const VisionImg *img) {
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
|
||||
*pkhr = image;
|
||||
return tex;
|
||||
}
|
||||
|
||||
void visionimg_destroy_gl(EGLImageKHR khr, void *ph) {
|
||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(display != EGL_NO_DISPLAY);
|
||||
eglDestroyImageKHR(display, khr);
|
||||
delete (private_handle_t*)ph;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,8 +27,9 @@ void visionimg_compute_aligned_width_and_height(int width, int height, int *alig
|
||||
VisionImg visionimg_alloc_rgb24(int width, int height, VisionBuf *out_buf);
|
||||
|
||||
#ifdef QCOM
|
||||
EGLClientBuffer visionimg_to_egl(const VisionImg *img);
|
||||
GLuint visionimg_to_gl(const VisionImg *img);
|
||||
EGLClientBuffer visionimg_to_egl(const VisionImg *img, void **pph);
|
||||
GLuint visionimg_to_gl(const VisionImg *img, EGLImageKHR *pkhr, void **pph);
|
||||
void visionimg_destroy_gl(EGLImageKHR khr, void *ph);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user