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

C128 keyboard corrections #531

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions libretro/libretro-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,11 @@ void autodetect_drivetype(int unit)
set_drive_type = DRIVE_TYPE_1571;
/* Force 1541 to 1541-II */
else if (diskimg->type == DRIVE_TYPE_1541)
#if defined(__X128__)
set_drive_type = DRIVE_TYPE_DEFAULT;
#else
set_drive_type = DRIVE_TYPE_1541II;
#endif
else
set_drive_type = diskimg->type;

Expand Down Expand Up @@ -8009,8 +8013,6 @@ void retro_reset(void)

/* Trigger autostart-reset in retro_run() */
request_restart = true;
/* Do full reload */
request_reload_restart = true;
}

static void fallback_log(enum retro_log_level level, const char *fmt, ...)
Expand Down Expand Up @@ -8684,7 +8686,7 @@ void retro_run(void)
/* VDC toggle key enforcing */
{
static unsigned column_key_state = 0;
unsigned toggle_state = retro_key_state_internal[RETROK_F7];
unsigned toggle_state = retro_key_state_internal[key_ctrl_column4080];

if (toggle_state && toggle_state != column_key_state)
set_vdc(!c128_vdc);
Expand Down
11 changes: 11 additions & 0 deletions libretro/libretro-mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "datasette.h"
#include "tapeport.h"
#include "kbd.h"
#include "keymap.h"
#include "mousedrv.h"
#include "cartridge.h"

Expand Down Expand Up @@ -52,6 +53,9 @@ int mapper_keys[RETRO_MAPPER_LAST] = {0};
static long mapper_keys_pressed_time = 0;
static int mapper_flag[RETRO_DEVICES][128] = {0};
bool retro_capslock = false;
#if defined(__X128__)
bool c128_capslock = false;
#endif
unsigned int retro_warpmode = 0;

unsigned int cur_port = 2;
Expand Down Expand Up @@ -426,6 +430,13 @@ void retro_key_down(int key)
kbd_handle_keydown(RETROK_LSHIFT);
retro_capslock = !retro_capslock;
}
#if defined(__X128__)
else if (key == key_ctrl_caps)
{
c128_capslock = !c128_capslock;
kbd_handle_keydown(key);
}
#endif
else
kbd_handle_keydown(key);
}
Expand Down
6 changes: 5 additions & 1 deletion libretro/libretro-vkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "libretro-mapper.h"

#include "kbd.h"
#include "keyboard.h"
#include "keymap.h"

bool retro_vkbd = false;
static bool retro_vkbd_page = false;
Expand All @@ -13,6 +15,7 @@ static int vkflag[10] = {0};

#ifdef __X128__
extern int c128_vdc;
extern bool c128_capslock;
#endif

#define POINTER_DEBUG 0
Expand Down Expand Up @@ -740,7 +743,8 @@ void print_vkbd(void)
||(retro_capslock && vkeys[(y * VKBDX) + x + page].value == VKBD_SHIFTLOCK)
||(retro_key_state_internal[current_key])
#ifdef __X128__
||(c128_vdc && vkeys[(y * VKBDX) + x + page].value == RETROK_F7) /* 40/80 display toggle */
||(c128_vdc && vkeys[(y * VKBDX) + x + page].value == key_ctrl_column4080) /* 40/80 display toggle */
||(c128_capslock && vkeys[(y * VKBDX) + x + page].value == key_ctrl_caps) /* Caps Lock toggle */
#endif
||(vkflag[RETRO_DEVICE_ID_JOYPAD_START] && vkeys[(y * VKBDX) + x + page].value == RETROK_RETURN)
||(vkflag[RETRO_DEVICE_ID_JOYPAD_X] && vkeys[(y * VKBDX) + x + page].value == RETROK_SPACE)
Expand Down
2 changes: 2 additions & 0 deletions retrodep/arch_keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,8 @@ static void libretro_keyboard()

keyboard_parse_set_pos_row(RETROK_HELP, 8, 0, 8); /* Help -> HELP */
keyboard_parse_set_pos_row(RETROK_END, 9, 3, 8); /* End -> LINE FEED */
keyboard_parse_set_neg_row(RETROK_F9, -4, 0, 0); /* F9 -> 40/80 */
keyboard_parse_set_pos_row(RETROK_F10, 10, 7, 8); /* F10 -> NO SCROLL */

keyboard_parse_set_pos_row(RETROK_BACKQUOTE, 7, 1, 32); /* ` -> Left Arrow */
keyboard_parse_set_pos_row(RETROK_BACKQUOTE, 6, 6, 1); /* ~ -> Pi */
Expand Down
35 changes: 21 additions & 14 deletions retrodep/uistatusbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extern unsigned int opt_joyport_type;
extern unsigned int opt_autoloadwarp;
extern int RGBc(int r, int g, int b);
extern bool retro_statusbar;
extern bool retro_capslock;
extern bool c128_capslock;
extern float retro_refresh;
extern int runstate;
extern dc_storage *dc;
Expand Down Expand Up @@ -587,34 +589,39 @@ static void display_joyport(void)
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 3, joystick_value_human(get_joystick_value(3-1), 0));
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 4, joystick_value_human(get_joystick_value(4-1), 0));
}
else
{
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
}
#elif defined(__XVIC__)
if (vice_opt.UserportJoyType != -1)
{
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 2, joystick_value_human(get_joystick_value(2-1), 0));
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 3, joystick_value_human(get_joystick_value(3-1), 0));
}
else
{
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
}
#elif defined(__XPET__) || defined(__XCBM2__)
if (vice_opt.UserportJoyType != -1)
{
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 1, joystick_value_human(get_joystick_value(1-1), 0));
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "J%d%3s ", 2, joystick_value_human(get_joystick_value(2-1), 0));
}
else
#endif

if (vice_opt.UserportJoyType == -1)
{
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%5s", "");
}
#if defined(__X128__)
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%6s %2s %2s", "", "CL", "SL");

if (c128_capslock)
{
tmpstr[6+6+6+1] |= 0x80;
tmpstr[6+6+6+2] |= 0x80;
}
#else
snprintf(tmpstr + strlen(tmpstr), sizeof(tmpstr), "%6s %2s %2s", "", "", "SL");
#endif
if (retro_capslock)
{
tmpstr[6+6+6+3+1] |= 0x80;
tmpstr[6+6+6+3+2] |= 0x80;
}
}

if (opt_statusbar & STATUSBAR_BASIC)
snprintf(tmpstr, sizeof(tmpstr), "%24s", "");
Expand Down