mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 19:31:12 +00:00
nyx: gfx: add column control
gfx_getpos/setpos can now get/set column offset. setpos column can be fully custom. Otherwise GFX_COL_KEEP or GFX_COL_AUTO (2 columns) can be used. Additionally, always restore column when printing debug info in log screen.
This commit is contained in:
parent
f2bdc3f47c
commit
6de29094fe
4 changed files with 61 additions and 41 deletions
|
@ -352,14 +352,14 @@ static bool _fts_touch_read(lv_indev_data_t *data)
|
||||||
if (console_enabled)
|
if (console_enabled)
|
||||||
{
|
{
|
||||||
// Print input debugging in console.
|
// Print input debugging in console.
|
||||||
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy);
|
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy, &gfx_con.savedcol);
|
||||||
gfx_con_setpos(32, 638);
|
gfx_con_setpos(32, 638, GFX_COL_AUTO);
|
||||||
gfx_con.fntsz = 8;
|
gfx_con.fntsz = 8;
|
||||||
gfx_printf("x: %4d, y: %4d | z: %3d | ", touchpad.x, touchpad.y, touchpad.z);
|
gfx_printf("x: %4d, y: %4d | z: %3d | ", touchpad.x, touchpad.y, touchpad.z);
|
||||||
gfx_printf("1: %02x, 2: %02x, 3: %02x, ", touchpad.raw[1], touchpad.raw[2], touchpad.raw[3]);
|
gfx_printf("1: %02X, 2: %02X, 3: %02X, ", touchpad.raw[1], touchpad.raw[2], touchpad.raw[3]);
|
||||||
gfx_printf("4: %02X, 5: %02x, 6: %02x, 7: %02x",
|
gfx_printf("4: %02X, 5: %02X, 6: %02X, 7: %02X",
|
||||||
touchpad.raw[4], touchpad.raw[5], touchpad.raw[6], touchpad.raw[7]);
|
touchpad.raw[4], touchpad.raw[5], touchpad.raw[6], touchpad.raw[7]);
|
||||||
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy);
|
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy, gfx_con.savedcol);
|
||||||
gfx_con.fntsz = 16;
|
gfx_con.fntsz = 16;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -470,10 +470,10 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
||||||
{
|
{
|
||||||
display_activate_console();
|
display_activate_console();
|
||||||
console_enabled = true;
|
console_enabled = true;
|
||||||
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy);
|
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy, &gfx_con.savedcol);
|
||||||
gfx_con_setpos(964, 630);
|
gfx_con_setpos(964, 630, GFX_COL_AUTO);
|
||||||
gfx_printf("Press -/+ to close");
|
gfx_printf("Press -/+ to close");
|
||||||
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy);
|
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy, gfx_con.savedcol);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -491,14 +491,14 @@ static bool _jc_virt_mouse_read(lv_indev_data_t *data)
|
||||||
if (console_enabled)
|
if (console_enabled)
|
||||||
{
|
{
|
||||||
// Print input debugging in console.
|
// Print input debugging in console.
|
||||||
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy);
|
gfx_con_getpos(&gfx_con.savedx, &gfx_con.savedy, &gfx_con.savedcol);
|
||||||
gfx_con_setpos(32, 630);
|
gfx_con_setpos(32, 630, GFX_COL_AUTO);
|
||||||
gfx_con.fntsz = 8;
|
gfx_con.fntsz = 8;
|
||||||
gfx_printf("x: %4X, y: %4X | b: %06X | bt: %d %d | cx: %03X - %03x, cy: %03X - %03x",
|
gfx_printf("x: %4X, y: %4X | b: %06X | bt: %d %d | cx: %03X - %03X, cy: %03X - %03X",
|
||||||
jc_pad->lstick_x, jc_pad->lstick_y, jc_pad->buttons,
|
jc_pad->lstick_x, jc_pad->lstick_y, jc_pad->buttons,
|
||||||
jc_pad->batt_info_l, jc_pad->batt_info_r,
|
jc_pad->batt_info_l, jc_pad->batt_info_r,
|
||||||
jc_drv_ctx.cx_min, jc_drv_ctx.cx_max, jc_drv_ctx.cy_min, jc_drv_ctx.cy_max);
|
jc_drv_ctx.cx_min, jc_drv_ctx.cx_max, jc_drv_ctx.cy_min, jc_drv_ctx.cy_max);
|
||||||
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy);
|
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy, gfx_con.savedcol);
|
||||||
gfx_con.fntsz = 16;
|
gfx_con.fntsz = 16;
|
||||||
|
|
||||||
data->state = LV_INDEV_STATE_REL;
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
|
#define COLUMN2_X 640
|
||||||
|
|
||||||
// Global gfx console and context.
|
// Global gfx console and context.
|
||||||
gfx_ctxt_t gfx_ctxt;
|
gfx_ctxt_t gfx_ctxt;
|
||||||
gfx_con_t gfx_con;
|
gfx_con_t gfx_con;
|
||||||
|
@ -150,6 +152,7 @@ void gfx_con_init()
|
||||||
gfx_con.fntsz = 16;
|
gfx_con.fntsz = 16;
|
||||||
gfx_con.x = 0;
|
gfx_con.x = 0;
|
||||||
gfx_con.y = 0;
|
gfx_con.y = 0;
|
||||||
|
gfx_con.col = 0;
|
||||||
gfx_con.savedx = 0;
|
gfx_con.savedx = 0;
|
||||||
gfx_con.savedy = 0;
|
gfx_con.savedy = 0;
|
||||||
gfx_con.fgcol = TXT_CLR_DEFAULT;
|
gfx_con.fgcol = TXT_CLR_DEFAULT;
|
||||||
|
@ -167,20 +170,32 @@ void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol)
|
||||||
gfx_con.bgcol = bgcol;
|
gfx_con.bgcol = bgcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_con_getpos(u32 *x, u32 *y)
|
void gfx_con_getpos(u32 *x, u32 *y, u32 *c)
|
||||||
{
|
{
|
||||||
*x = gfx_con.x;
|
*x = gfx_con.x;
|
||||||
*y = gfx_con.y;
|
*y = gfx_con.y;
|
||||||
|
*c = gfx_con.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gfx_column = 0;
|
void gfx_con_setpos(u32 x, u32 y, u32 c)
|
||||||
void gfx_con_setpos(u32 x, u32 y)
|
|
||||||
{
|
{
|
||||||
gfx_con.x = x;
|
gfx_con.x = x;
|
||||||
gfx_con.y = y;
|
gfx_con.y = y;
|
||||||
|
|
||||||
if (!x)
|
switch (c)
|
||||||
gfx_column = 0;
|
{
|
||||||
|
case GFX_COL_KEEP:
|
||||||
|
break;
|
||||||
|
case GFX_COL_AUTO:
|
||||||
|
if (x < COLUMN2_X)
|
||||||
|
gfx_con.col = 0;
|
||||||
|
else
|
||||||
|
gfx_con.col = COLUMN2_X;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gfx_con.col = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_putc(char c)
|
void gfx_putc(char c)
|
||||||
|
@ -216,33 +231,33 @@ void gfx_putc(char c)
|
||||||
gfx_con.x += 16;
|
gfx_con.x += 16;
|
||||||
if (gfx_con.x > gfx_ctxt.width - 16)
|
if (gfx_con.x > gfx_ctxt.width - 16)
|
||||||
{
|
{
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
gfx_con.y += 16;
|
gfx_con.y += 16;
|
||||||
if (gfx_con.y > gfx_ctxt.height - 33)
|
if (gfx_con.y > gfx_ctxt.height - 33)
|
||||||
{
|
{
|
||||||
gfx_con.y = 0;
|
gfx_con.y = 0;
|
||||||
|
|
||||||
if (!gfx_column)
|
if (!gfx_con.col)
|
||||||
gfx_column = 640;
|
gfx_con.col = COLUMN2_X;
|
||||||
else
|
else
|
||||||
gfx_column = 0;
|
gfx_con.col = 0;
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (c == '\n')
|
else if (c == '\n')
|
||||||
{
|
{
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
gfx_con.y += 16;
|
gfx_con.y += 16;
|
||||||
if (gfx_con.y > gfx_ctxt.height - 33)
|
if (gfx_con.y > gfx_ctxt.height - 33)
|
||||||
{
|
{
|
||||||
gfx_con.y = 0;
|
gfx_con.y = 0;
|
||||||
|
|
||||||
if (!gfx_column)
|
if (!gfx_con.col)
|
||||||
gfx_column = 640;
|
gfx_con.col = COLUMN2_X;
|
||||||
else
|
else
|
||||||
gfx_column = 0;
|
gfx_con.col = 0;
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -265,35 +280,35 @@ void gfx_putc(char c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gfx_con.x += 8;
|
gfx_con.x += 8;
|
||||||
if (gfx_con.x > gfx_ctxt.width / 2 + gfx_column - 8)
|
if (gfx_con.x > gfx_ctxt.width / 2 + gfx_con.col - 8)
|
||||||
{
|
{
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
gfx_con.y += 8;
|
gfx_con.y += 8;
|
||||||
if (gfx_con.y > gfx_ctxt.height - 33)
|
if (gfx_con.y > gfx_ctxt.height - 33)
|
||||||
{
|
{
|
||||||
gfx_con.y = 0;
|
gfx_con.y = 0;
|
||||||
|
|
||||||
if (!gfx_column)
|
if (!gfx_con.col)
|
||||||
gfx_column = 640;
|
gfx_con.col = COLUMN2_X;
|
||||||
else
|
else
|
||||||
gfx_column = 0;
|
gfx_con.col = 0;
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (c == '\n')
|
else if (c == '\n')
|
||||||
{
|
{
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
gfx_con.y += 8;
|
gfx_con.y += 8;
|
||||||
if (gfx_con.y > gfx_ctxt.height - 33)
|
if (gfx_con.y > gfx_ctxt.height - 33)
|
||||||
{
|
{
|
||||||
gfx_con.y = 0;
|
gfx_con.y = 0;
|
||||||
|
|
||||||
if (!gfx_column)
|
if (!gfx_con.col)
|
||||||
gfx_column = 640;
|
gfx_con.col = COLUMN2_X;
|
||||||
else
|
else
|
||||||
gfx_column = 0;
|
gfx_con.col = 0;
|
||||||
gfx_con.x = gfx_column;
|
gfx_con.x = gfx_con.col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
#include <bdk.h>
|
#include <bdk.h>
|
||||||
|
|
||||||
|
#define GFX_COL_KEEP 0xFFFE
|
||||||
|
#define GFX_COL_AUTO 0xFFFF
|
||||||
|
|
||||||
#define TXT_CLR_BG 0xFF000000 // Black.
|
#define TXT_CLR_BG 0xFF000000 // Black.
|
||||||
#define TXT_CLR_DEFAULT 0xFFFFFFFF // White.
|
#define TXT_CLR_DEFAULT 0xFFFFFFFF // White.
|
||||||
#define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
|
#define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
|
||||||
|
@ -55,8 +58,10 @@ typedef struct _gfx_con_t
|
||||||
u32 fntsz;
|
u32 fntsz;
|
||||||
u32 x;
|
u32 x;
|
||||||
u32 y;
|
u32 y;
|
||||||
|
u32 col;
|
||||||
u32 savedx;
|
u32 savedx;
|
||||||
u32 savedy;
|
u32 savedy;
|
||||||
|
u32 savedcol;
|
||||||
u32 fgcol;
|
u32 fgcol;
|
||||||
int fillbg;
|
int fillbg;
|
||||||
u32 bgcol;
|
u32 bgcol;
|
||||||
|
@ -72,8 +77,8 @@ void gfx_clear_grey(u8 color);
|
||||||
void gfx_clear_color(u32 color);
|
void gfx_clear_color(u32 color);
|
||||||
void gfx_con_init();
|
void gfx_con_init();
|
||||||
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
|
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
|
||||||
void gfx_con_getpos(u32 *x, u32 *y);
|
void gfx_con_getpos(u32 *x, u32 *y, u32 *c);
|
||||||
void gfx_con_setpos(u32 x, u32 y);
|
void gfx_con_setpos(u32 x, u32 y, u32 c);
|
||||||
void gfx_putc(char c);
|
void gfx_putc(char c);
|
||||||
void gfx_puts(const char *s);
|
void gfx_puts(const char *s);
|
||||||
void gfx_wputs(const char *s);
|
void gfx_wputs(const char *s);
|
||||||
|
|
|
@ -348,7 +348,7 @@ static void _show_errors(int sd_error)
|
||||||
if (*excp_enabled == EXCP_MAGIC || sd_error)
|
if (*excp_enabled == EXCP_MAGIC || sd_error)
|
||||||
{
|
{
|
||||||
gfx_clear_grey(0);
|
gfx_clear_grey(0);
|
||||||
gfx_con_setpos(0, 0);
|
gfx_con_setpos(0, 0, 0);
|
||||||
display_backlight_brightness(150, 1000);
|
display_backlight_brightness(150, 1000);
|
||||||
display_init_framebuffer_log();
|
display_init_framebuffer_log();
|
||||||
display_activate_console();
|
display_activate_console();
|
||||||
|
|
Loading…
Reference in a new issue