Skip to content

Commit

Permalink
Tweak some key mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Sep 17, 2019
1 parent 388ff8a commit 1e39c24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion inc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int printk(const char *format, ...)
#define htobe32(x) _rev32(x)

/* Amiga keyboard */
#define AMI_HELP 0x5f
#define AMI_F1 0x50
#define AMI_L_CTRL 0x63
#define AMI_L_ALT 0x64
#define AMI_LEFT 0x4f
Expand Down
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void config_init(void)

config_printk(&config);

printk("\nKeys:\n Space: Select\n P: Up\n L: Down\n");
printk("\nKeys:\n Space: Select\n O: Down\n P: Up\n");

lcd_display_update();
(void)usart1->dr;
Expand Down Expand Up @@ -147,7 +147,7 @@ void config_process(uint8_t b)
switch (tolower(c)) {
case ' ': b |= B_SELECT; break;
case 'p': b |= B_RIGHT; break;
case 'l': b |= B_LEFT; break;
case 'o': b |= B_LEFT; break;
}
}

Expand Down
20 changes: 9 additions & 11 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,18 @@ static void render_line(unsigned int y, const struct display *display)
/* We snapshot the relevant Amiga keys so that we can scan the keymap (and
* clear the sticky bits) in one place in the main loop. */
static uint8_t keys;
#define K_LEFT 1
#define K_RIGHT 2
#define K_UP 4
#define K_HELP 8
#define K_LEFT B_LEFT
#define K_RIGHT B_RIGHT
#define K_SELECT B_SELECT
#define K_MENU 8

static void update_amiga_keys(void)
{
keys = 0;
if (amiga_key_pressed(AMI_LEFT)) keys |= K_LEFT;
if (amiga_key_pressed(AMI_RIGHT)) keys |= K_RIGHT;
if (amiga_key_pressed(AMI_UP)) keys |= K_UP;
if (amiga_key_pressed(AMI_HELP)) keys |= K_HELP;
if (amiga_key_pressed(AMI_UP)) keys |= K_SELECT;
if (amiga_key_pressed(AMI_F1)) keys |= K_MENU;
}

struct gotek_button {
Expand Down Expand Up @@ -347,7 +347,7 @@ static void emulate_gotek_buttons(void)
gotek_active = TRUE; /* only after keys are released */
emulate_gotek_button(K_LEFT, &gl, 13);
emulate_gotek_button(K_RIGHT, &gr, 14);
emulate_gotek_button(K_UP, &gs, 15);
emulate_gotek_button(K_SELECT, &gs, 15);
}

int main(void)
Expand Down Expand Up @@ -513,11 +513,9 @@ int main(void)
IRQ_restore(oldpri);
/* Fold in keyboard presses. */
if (config_active) {
if (keys & K_LEFT) b |= B_LEFT;
if (keys & K_RIGHT) b |= B_RIGHT;
if (keys & K_UP) b |= B_SELECT;
b |= keys & (B_LEFT | B_RIGHT | B_SELECT);
} else {
if (keys & K_HELP) b |= B_SELECT;
if (keys & K_MENU) b |= B_SELECT;
}
/* Pass button presses to config subsystem for processing. */
config_process(b & ~B_PROCESSED);
Expand Down

0 comments on commit 1e39c24

Please sign in to comment.