Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for autostart (SDL2) #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions src/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,38 @@ void kbd_handle_char(int scancode, int down){
put_rx_ring(active_console,outchar);
}

// Give an (ascii) string and length, stuff it into kbd input buffer and end with a Return.
void
kbd_simulate_input(char *str, int len)
{
int i;
SDL_Scancode c;
for (i = 0; i < len; i++) {
char k[20];
k[0] = str[i]; k[1] = '\0';
// this is a hack
if (str[i] == ' ')
strcpy(k, "space");
c = SDL_GetScancodeFromName(k);
if (c == SDL_SCANCODE_UNKNOWN) {
fprintf(stderr,"Bad key '%s' - can't find SDL scancode\n", k);
} else {
unsigned char out = map[c];
put_rx_ring(active_console, out);
// key down
put_rx_ring(active_console, 0x80 | 0x40);
put_rx_ring(active_console, out);
// key up
put_rx_ring(active_console, 0x80);
}
}
// end with an Enter
put_rx_ring(active_console, map[SDL_SCANCODE_RETURN]);
put_rx_ring(active_console, 0x80 | 0x40);
put_rx_ring(active_console, map[SDL_SCANCODE_RETURN]);
put_rx_ring(active_console, 0x80);
}

void sdl_system_shutdown_request(void){
exit(0);
}
Expand Down Expand Up @@ -4473,6 +4505,9 @@ void nubus_cycle(int sdu){

// Main
int main(int argc, char *argv[]){
#ifdef SDL2
int autostart = 0;
#endif
#ifndef HAVE_YAML_H
FILE *config;
#endif
Expand Down Expand Up @@ -4573,7 +4608,14 @@ int main(int argc, char *argv[]){
if(argc > 1){
int x = 1;
while(x < argc){


#ifdef SDL2
if (strcmp("-a",argv[x]) == 0) {
autostart = 1;
printf("Autostart enabled\n");
}
#endif

#ifdef BURR_BROWN
if(strcmp("-d",argv[x]) == 0){
debug_target_mode = 10;
Expand Down Expand Up @@ -4695,7 +4737,12 @@ int main(int argc, char *argv[]){
usleep(0);
}
}

#ifdef SDL2
else if (autostart) {
kbd_simulate_input("newboot -a", strlen("newboot -a"));
}
#endif

while(ld_die_rq == 0){
// New loop
icount -= 500000; // Don't clobber extra cycles if they happened
Expand Down