diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-12-16 14:52:54 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-12-16 14:52:54 +1300 |
commit | 0d9978228b9226d16ba8272a03dd7e6c9ad83b3d (patch) | |
tree | 442ce8a1d37f2f9a0e9e655d3250849e874c2d41 /arm9/source/main.c | |
parent | dbe8171815ea3b51c3ac87dae1996ae0d8f6eb04 (diff) | |
download | bedrock-nds-0d9978228b9226d16ba8272a03dd7e6c9ad83b3d.zip |
Implement a toggleable keyboard on the lower screen
Diffstat (limited to 'arm9/source/main.c')
-rw-r--r-- | arm9/source/main.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/arm9/source/main.c b/arm9/source/main.c index 095e089..239c1de 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -6,6 +6,7 @@ #include "devices/screen.h" #include "bang.h" #include "core.h" +#include "main.h" #define NUM_BR 5 @@ -21,13 +22,41 @@ u8 main_program[] = { #include "../include/cobalt.br.inc" }; u8 keyboard_program[] = { - 00 //#include "../include/sysinfo.br.inc" + #include "../include/keyboard.br.inc" }; + // Change to the next screen layout. void change_layout(void) { lcdSwap(); main_on_bottom = !main_on_bottom; + if (main_on_bottom) { + scr_unmake(&br_sub->scr); + } else { + scr_make_sub(&br_sub->scr); + } +} + +void receive_keyboard_byte(u8 byte) { + if (br_main) { + inp_receive_byte(&br_main->inp, byte); + } +} + +bool is_keyboard_open(void) { + return !main_on_bottom; +} + +void open_keyboard(void) { + if (main_on_bottom) { + change_layout(); + } +} + +void close_keyboard(void) { + if (!main_on_bottom) { + change_layout(); + } } // Scan for input and handle emulator-specific keys. @@ -63,7 +92,6 @@ int main(void) { br_main = &br[0]; br_sub = &br[1]; scr_make_main(&br_main->scr); - scr_make_sub(&br_sub->scr); while (1) { if (AWAKE(br_main)) run_br(br_main); @@ -77,15 +105,15 @@ int main(void) { rouse: receive_input(); - if (ALIVE(br_main)) { + if (ALIVE(br_main) && main_on_bottom) { inp_read_navigation(&br_main->inp); inp_read_gamepad(&br_main->inp); - if (main_on_bottom) inp_read_touch(&br_main->inp); + inp_read_touch(&br_main->inp); } - if (ALIVE(br_sub)) { + if (ALIVE(br_sub) && !main_on_bottom) { inp_read_navigation(&br_sub->inp); inp_read_gamepad(&br_sub->inp); - if (!main_on_bottom) inp_read_touch(&br_sub->inp); + inp_read_touch(&br_sub->inp); } if (ASLEEP(br_main)) rouse_br(br_main); if (ASLEEP(br_sub)) rouse_br(br_sub); |