Remove all tabs
This commit is contained in:
parent
d4300c9c04
commit
18fb916834
|
|
@ -215,7 +215,7 @@ mk22fn512_def = {'_POSIX_PRIORITY_SCHEDULING':''}
|
||||||
## Linux
|
## Linux
|
||||||
##
|
##
|
||||||
linux_platform_src = ['platform/targets/linux/emulator/emulator.c',
|
linux_platform_src = ['platform/targets/linux/emulator/emulator.c',
|
||||||
'platform/targets/linux/emulator/sdl_engine.c',
|
'platform/targets/linux/emulator/sdl_engine.c',
|
||||||
'platform/drivers/display/display_libSDL.c',
|
'platform/drivers/display/display_libSDL.c',
|
||||||
'platform/drivers/keyboard/keyboard_linux.c',
|
'platform/drivers/keyboard/keyboard_linux.c',
|
||||||
'platform/drivers/NVM/nvmem_linux.c',
|
'platform/drivers/NVM/nvmem_linux.c',
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
void chan_init(chan_t *c)
|
void chan_init(chan_t *c)
|
||||||
{
|
{
|
||||||
if(c == NULL) return;
|
if (c == NULL) return;
|
||||||
|
|
||||||
pthread_mutex_init(&c->m_meta, NULL);
|
pthread_mutex_init(&c->m_meta, NULL);
|
||||||
pthread_mutex_init(&c->m_read, NULL);
|
pthread_mutex_init(&c->m_read, NULL);
|
||||||
|
|
@ -38,12 +38,12 @@ void chan_send(chan_t *c, void *data)
|
||||||
pthread_mutex_lock(&c->m_write);
|
pthread_mutex_lock(&c->m_write);
|
||||||
pthread_mutex_lock(&c->m_meta);
|
pthread_mutex_lock(&c->m_meta);
|
||||||
|
|
||||||
if(c->closed)
|
if (c->closed)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&c->m_meta);
|
pthread_mutex_unlock(&c->m_meta);
|
||||||
pthread_mutex_unlock(&c->m_write);
|
pthread_mutex_unlock(&c->m_write);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->data = data;
|
c->data = data;
|
||||||
|
|
@ -52,7 +52,7 @@ void chan_send(chan_t *c, void *data)
|
||||||
// notify the waiting reader that data is ready
|
// notify the waiting reader that data is ready
|
||||||
if (c->reader)
|
if (c->reader)
|
||||||
{
|
{
|
||||||
pthread_cond_signal(&c->c_writer);
|
pthread_cond_signal(&c->c_writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until data is consumed
|
// wait until data is consumed
|
||||||
|
|
@ -69,24 +69,24 @@ void chan_recv(chan_t *c, void **data)
|
||||||
pthread_mutex_lock(&c->m_meta);
|
pthread_mutex_lock(&c->m_meta);
|
||||||
|
|
||||||
// wait for a writer
|
// wait for a writer
|
||||||
while(!c->closed && !c->writer)
|
while (!c->closed && !c->writer)
|
||||||
{
|
{
|
||||||
c->reader = true;
|
c->reader = true;
|
||||||
pthread_cond_wait(&c->c_writer, &c->m_meta);
|
pthread_cond_wait(&c->c_writer, &c->m_meta);
|
||||||
c->reader = false;
|
c->reader = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->closed)
|
if (c->closed)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&c->m_meta);
|
pthread_mutex_unlock(&c->m_meta);
|
||||||
pthread_mutex_unlock(&c->m_read);
|
pthread_mutex_unlock(&c->m_read);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
*data = c->data;
|
*data = c->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify the waiting writer that the reader consumed the data
|
// notify the waiting writer that the reader consumed the data
|
||||||
|
|
@ -120,9 +120,9 @@ void chan_close(chan_t *c)
|
||||||
pthread_mutex_lock(&c->m_meta);
|
pthread_mutex_lock(&c->m_meta);
|
||||||
if (!c->closed)
|
if (!c->closed)
|
||||||
{
|
{
|
||||||
c->closed = true;
|
c->closed = true;
|
||||||
pthread_cond_broadcast(&c->c_reader);
|
pthread_cond_broadcast(&c->c_reader);
|
||||||
pthread_cond_broadcast(&c->c_writer);
|
pthread_cond_broadcast(&c->c_writer);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&c->m_meta);
|
pthread_mutex_unlock(&c->m_meta);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,77 +41,77 @@ keyboard_t sdl_keys; /* Store the keyboard status */
|
||||||
|
|
||||||
bool sdk_key_code_to_key(SDL_KeyCode sym, keyboard_t *key)
|
bool sdk_key_code_to_key(SDL_KeyCode sym, keyboard_t *key)
|
||||||
{
|
{
|
||||||
switch (sym)
|
switch (sym)
|
||||||
{
|
{
|
||||||
case SDLK_0:
|
case SDLK_0:
|
||||||
*key = KEY_0;
|
*key = KEY_0;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_1:
|
case SDLK_1:
|
||||||
*key = KEY_1;
|
*key = KEY_1;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_2:
|
case SDLK_2:
|
||||||
*key = KEY_2;
|
*key = KEY_2;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_3:
|
case SDLK_3:
|
||||||
*key = KEY_3;
|
*key = KEY_3;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_4:
|
case SDLK_4:
|
||||||
*key = KEY_4;
|
*key = KEY_4;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_5:
|
case SDLK_5:
|
||||||
*key = KEY_5;
|
*key = KEY_5;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_6:
|
case SDLK_6:
|
||||||
*key = KEY_6;
|
*key = KEY_6;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_7:
|
case SDLK_7:
|
||||||
*key = KEY_7;
|
*key = KEY_7;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
*key = KEY_8;
|
*key = KEY_8;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_9:
|
case SDLK_9:
|
||||||
*key = KEY_9;
|
*key = KEY_9;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_ASTERISK:
|
case SDLK_ASTERISK:
|
||||||
*key = KEY_STAR;
|
*key = KEY_STAR;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
*key = KEY_ESC;
|
*key = KEY_ESC;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
*key = KEY_LEFT;
|
*key = KEY_LEFT;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
*key = KEY_RIGHT;
|
*key = KEY_RIGHT;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
*key = KEY_ENTER;
|
*key = KEY_ENTER;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_HASH:
|
case SDLK_HASH:
|
||||||
*key = KEY_HASH;
|
*key = KEY_HASH;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_n:
|
case SDLK_n:
|
||||||
*key = KEY_F1;
|
*key = KEY_F1;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_m:
|
case SDLK_m:
|
||||||
*key = KEY_MONI;
|
*key = KEY_MONI;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_PAGEUP:
|
case SDLK_PAGEUP:
|
||||||
*key = KNOB_LEFT;
|
*key = KNOB_LEFT;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_PAGEDOWN:
|
case SDLK_PAGEDOWN:
|
||||||
*key = KNOB_RIGHT;
|
*key = KNOB_RIGHT;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
*key = KEY_UP;
|
*key = KEY_UP;
|
||||||
return true;
|
return true;
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
*key = KEY_DOWN;
|
*key = KEY_DOWN;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int screenshot_display(const char *filename)
|
int screenshot_display(const char *filename)
|
||||||
|
|
@ -242,58 +242,59 @@ void sdl_task()
|
||||||
pthread_mutex_unlock(&mu);
|
pthread_mutex_unlock(&mu);
|
||||||
|
|
||||||
SDL_Event ev = { 0 };
|
SDL_Event ev = { 0 };
|
||||||
while(!Radio_State.PowerOff)
|
while (!Radio_State.PowerOff)
|
||||||
{
|
{
|
||||||
keyboard_t key = 0;
|
keyboard_t key = 0;
|
||||||
if(SDL_PollEvent(&ev) == 1)
|
if (SDL_PollEvent(&ev) == 1)
|
||||||
{
|
{
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
Radio_State.PowerOff = true;
|
Radio_State.PowerOff = true;
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (sdk_key_code_to_key(ev.key.keysym.sym, &key))
|
if (sdk_key_code_to_key(ev.key.keysym.sym, &key))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mu);
|
pthread_mutex_lock(&mu);
|
||||||
sdl_keys |= key;
|
sdl_keys |= key;
|
||||||
pthread_mutex_unlock(&mu);
|
pthread_mutex_unlock(&mu);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (sdk_key_code_to_key(ev.key.keysym.sym, &key))
|
if (sdk_key_code_to_key(ev.key.keysym.sym, &key))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mu);
|
pthread_mutex_lock(&mu);
|
||||||
sdl_keys ^= key;
|
sdl_keys ^= key;
|
||||||
pthread_mutex_unlock(&mu);
|
pthread_mutex_unlock(&mu);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( ev.type == SDL_Screenshot_Event)
|
if (ev.type == SDL_Screenshot_Event)
|
||||||
{
|
{
|
||||||
char *filename = (char *)ev.user.data1;
|
char *filename = (char *)ev.user.data1;
|
||||||
screenshot_display(filename);
|
screenshot_display(filename);
|
||||||
free(ev.user.data1);
|
free(ev.user.data1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we update the window only if there is a something ready to render
|
// we update the window only if there is a something ready to render
|
||||||
if (chan_can_send(&fb_sync))
|
if (chan_can_send(&fb_sync))
|
||||||
{
|
{
|
||||||
PIXEL_SIZE *pixels;
|
PIXEL_SIZE *pixels;
|
||||||
int pitch = 0;
|
int pitch = 0;
|
||||||
if (SDL_LockTexture(displayTexture, NULL, (void **) &pixels, &pitch) < 0)
|
if (SDL_LockTexture(displayTexture, NULL,
|
||||||
{
|
(void **) &pixels, &pitch) < 0)
|
||||||
SDL_Log("SDL_lock failed: %s", SDL_GetError());
|
{
|
||||||
}
|
SDL_Log("SDL_lock failed: %s", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
chan_send(&fb_sync, pixels);
|
chan_send(&fb_sync, pixels);
|
||||||
chan_recv(&fb_sync, NULL);
|
chan_recv(&fb_sync, NULL);
|
||||||
|
|
||||||
SDL_UnlockTexture(displayTexture);
|
SDL_UnlockTexture(displayTexture);
|
||||||
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
} /* while(!Radio_State.PowerOff) */
|
} /* while(!Radio_State.PowerOff) */
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
|
@ -307,7 +308,7 @@ void init_sdl()
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0)
|
||||||
{
|
{
|
||||||
printf("SDL video init error!!\n");
|
printf("SDL video init error!!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register an SDL custom event type to handle screenshot requests
|
// Register an SDL custom event type to handle screenshot requests
|
||||||
|
|
@ -316,18 +317,18 @@ void init_sdl()
|
||||||
chan_init(&fb_sync);
|
chan_init(&fb_sync);
|
||||||
|
|
||||||
window = SDL_CreateWindow("OpenRTX",
|
window = SDL_CreateWindow("OpenRTX",
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SCREEN_WIDTH * 3, SCREEN_HEIGHT * 3,
|
SCREEN_WIDTH * 3, SCREEN_HEIGHT * 3,
|
||||||
SDL_WINDOW_SHOWN );
|
SDL_WINDOW_SHOWN );
|
||||||
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
|
SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
displayTexture = SDL_CreateTexture(renderer,
|
displayTexture = SDL_CreateTexture(renderer,
|
||||||
PIXEL_FORMAT,
|
PIXEL_FORMAT,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
SCREEN_WIDTH,
|
SCREEN_WIDTH,
|
||||||
SCREEN_HEIGHT);
|
SCREEN_HEIGHT);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue