process fxlink messages in some menus
This commit is contained in:
parent
352ddfaa73
commit
6abd90b4ab
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
//---
|
||||
// Platform disambiguation functions
|
||||
|
@ -20,6 +21,16 @@
|
|||
#define _(fx,cg) cg
|
||||
#endif
|
||||
|
||||
//---
|
||||
// Application-specific getkey() with extra hooks
|
||||
//---
|
||||
|
||||
/* Set to break out of gintctl_getkey_opt() */
|
||||
extern int volatile gintctl_interrupt;
|
||||
|
||||
key_event_t gintctl_getkey_opt(int options);
|
||||
key_event_t gintctl_getkey(void);
|
||||
|
||||
//---
|
||||
// Row manipulation functions
|
||||
//---
|
||||
|
@ -85,12 +96,4 @@ void fkey_menu(int position, char const *text);
|
|||
|
||||
#endif /* FXCG50 */
|
||||
|
||||
//---
|
||||
// Screenshot saving
|
||||
//---
|
||||
|
||||
/* screen_mono(): Take a screenshot of the mono VRAM
|
||||
@path File path (will be overwritten) */
|
||||
void screen_mono(uint16_t const *filepath);
|
||||
|
||||
#endif /* GINTCTL_UTIL */
|
||||
|
|
|
@ -41,6 +41,5 @@ void gintctl_gint_topti(void)
|
|||
if(key == KEY_RIGHT && x <= DWIDTH) x++;
|
||||
if(key == KEY_UP && y >= -DHEIGHT) y--;
|
||||
if(key == KEY_DOWN && y <= DHEIGHT) y++;
|
||||
if(key == KEY_F6) screen_mono(u"\\\\fls0\\topti.bin");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,11 @@
|
|||
|
||||
/* USB log buffer */
|
||||
#define LOG_SIZE _(768, 4096)
|
||||
static char log_buffer[LOG_SIZE];
|
||||
static int log_pos;
|
||||
static char log_buffer[LOG_SIZE] = { 0 };
|
||||
static int log_pos = 0;
|
||||
static int const log_lines = _(8,15);
|
||||
static int volatile log_interrupt = 0;
|
||||
static int volatile *global_interrupt_flag = NULL;
|
||||
|
||||
struct alignment_write_data {
|
||||
uint32_t al4_shbuf[4];
|
||||
|
@ -48,6 +49,8 @@ static void reset_logger(void)
|
|||
static void usb_logger(char const *format, va_list args)
|
||||
{
|
||||
/* Interrupt getkey() so that the log can be printed */
|
||||
if(global_interrupt_flag)
|
||||
*global_interrupt_flag = 1;
|
||||
log_interrupt = 1;
|
||||
if(log_pos >= LOG_SIZE) return;
|
||||
|
||||
|
@ -461,8 +464,8 @@ void gintctl_gint_usb(void)
|
|||
|
||||
struct alignment_write_data awd = { 0 };
|
||||
|
||||
reset_logger();
|
||||
usb_set_log(usb_logger);
|
||||
global_interrupt_flag = &gintctl_interrupt;
|
||||
srand(0xc0ffee);
|
||||
|
||||
while(key != KEY_EXIT)
|
||||
|
@ -485,7 +488,7 @@ void gintctl_gint_usb(void)
|
|||
|
||||
#ifdef FXCG50
|
||||
if(tab == 2)
|
||||
row_title("USB logs (SHIFT+7 to save to file)");
|
||||
row_title("USB logs (SHIFT+7: Save to file, SHIFT+8: Clear)");
|
||||
else
|
||||
row_title("USB 2.0 function module and communication");
|
||||
fkey_menu(1, "REGS");
|
||||
|
@ -499,12 +502,11 @@ void gintctl_gint_usb(void)
|
|||
dfont(old_font);
|
||||
dupdate();
|
||||
|
||||
key_event_t ev;
|
||||
ev = getkey_opt(GETKEY_DEFAULT, &log_interrupt);
|
||||
key_event_t ev = gintctl_getkey();
|
||||
key = ev.key;
|
||||
|
||||
/* Scroll down log automatically at the cost of a redraw */
|
||||
if(log_interrupt == 1 && tab == 2)
|
||||
if(log_interrupt && tab == 2)
|
||||
scroll2 = draw_log(0);
|
||||
|
||||
log_interrupt = 0;
|
||||
|
@ -543,6 +545,8 @@ void gintctl_gint_usb(void)
|
|||
scroll2 = min(scroll2 + scroll_speed, maxscroll2);
|
||||
if(tab == 2 && ev.shift && key == KEY_7)
|
||||
gint_world_switch(GINT_CALL(save_logger));
|
||||
if(tab == 2 && ev.shift && key == KEY_8)
|
||||
reset_logger();
|
||||
|
||||
if(tab == 4 && key == KEY_1 && usb_is_open()) {
|
||||
// extern prof_t usb_cpu_write_prof;
|
||||
|
@ -577,4 +581,6 @@ void gintctl_gint_usb(void)
|
|||
if(tab == 4 && key == KEY_5 && usb_is_open())
|
||||
alignment_write_tests(&awd);
|
||||
}
|
||||
|
||||
global_interrupt_flag = NULL;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,42 @@ static bool getkey_global_shortcuts(key_event_t e)
|
|||
return false;
|
||||
}
|
||||
|
||||
int volatile gintctl_interrupt = 0;
|
||||
|
||||
static void gintctl_fxlink_notification(void)
|
||||
{
|
||||
/* Hack: use bit #31 to indicate an internal interrupt */
|
||||
gintctl_interrupt |= (1 << 31);
|
||||
}
|
||||
|
||||
key_event_t gintctl_getkey_opt(int options)
|
||||
{
|
||||
usb_fxlink_header_t header;
|
||||
|
||||
while(1) {
|
||||
key_event_t ev = getkey_opt(options, &gintctl_interrupt);
|
||||
|
||||
while(usb_fxlink_handle_messages(&header)) {
|
||||
USB_LOG("[gintctl] dropping %.16s.%.16s\n",
|
||||
header.application, header.type);
|
||||
usb_fxlink_drop_transaction();
|
||||
USB_LOG("[gintctl] done dropping\n");
|
||||
}
|
||||
|
||||
/* Keep waiting only if we were interrupted *and* the interrupt only
|
||||
set bit #31 */
|
||||
if(ev.type != KEYEV_NONE || ((gintctl_interrupt << 1) != 0)) {
|
||||
gintctl_interrupt = 0;
|
||||
return ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
key_event_t gintctl_getkey(void)
|
||||
{
|
||||
return gintctl_getkey_opt(GETKEY_DEFAULT);
|
||||
}
|
||||
|
||||
//---
|
||||
// Main application
|
||||
//---
|
||||
|
@ -246,6 +282,11 @@ int main(GUNUSED int isappli, GUNUSED int optnum)
|
|||
dfont(&font_uf5x7);
|
||||
#endif
|
||||
|
||||
/* Get notified when fxlink messages arrive through USB */
|
||||
usb_fxlink_set_notifier(gintctl_fxlink_notification);
|
||||
|
||||
/* Enable keyboard options globally because we're going to interrupt
|
||||
getkey_opt() to answer USB requests synchronously */
|
||||
keydev_transform_t tr = keydev_transform(keydev_std());
|
||||
tr.enabled |= KEYDEV_TR_DELAYED_SHIFT | KEYDEV_TR_INSTANT_SHIFT;
|
||||
tr.enabled |= KEYDEV_TR_DELAYED_ALPHA | KEYDEV_TR_INSTANT_ALPHA;
|
||||
|
@ -260,7 +301,7 @@ int main(GUNUSED int isappli, GUNUSED int optnum)
|
|||
draw(menu);
|
||||
dupdate();
|
||||
|
||||
ev = getkey();
|
||||
ev = gintctl_getkey();
|
||||
key = ev.key;
|
||||
|
||||
if(key == KEY_F1)
|
||||
|
|
22
src/util.c
22
src/util.c
|
@ -212,25 +212,3 @@ void fkey_menu(int position, char const *text)
|
|||
}
|
||||
|
||||
#endif /* FXCG50 */
|
||||
|
||||
//---
|
||||
// Screenshot saving
|
||||
//---
|
||||
|
||||
void switch_screen_mono(uint16_t const *path)
|
||||
{
|
||||
int size = 1024;
|
||||
|
||||
BFile_Remove(path);
|
||||
BFile_Create(path, BFile_File, &size);
|
||||
|
||||
int fd = BFile_Open(path, BFile_WriteOnly);
|
||||
BFile_Write(fd, gint_vram, 1024);
|
||||
BFile_Close(fd);
|
||||
}
|
||||
|
||||
/* screen_mono(): Take a screenshot of the mono VRAM */
|
||||
void screen_mono(uint16_t const *filepath)
|
||||
{
|
||||
gint_world_switch(GINT_CALL(switch_screen_mono, filepath));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue