Refactored game controller input

This commit is contained in:
Dimitris Panokostas 2017-02-28 13:21:37 +01:00
parent 914ff5daa1
commit e52239ccf3
18 changed files with 193 additions and 206 deletions

View file

@ -69,6 +69,7 @@
<ProjectFile>Amiberry.vcxproj</ProjectFile>
<RemoteBuildEnvironment>
<Records />
<EnvironmentSetupFiles />
</RemoteBuildEnvironment>
<ParallelJobCount>1</ParallelJobCount>
</Build>

View file

@ -1191,17 +1191,6 @@ void cfgfile_save_options(struct zfile* f, struct uae_prefs* p, int type)
cfgfile_write_str(f, _T("gfx_api"), filterapi[p->gfx_api]);
cfgfile_dwrite(f, _T("gfx_horizontal_tweak"), _T("%d"), p->gfx_extrawidth);
#ifdef AMIBERRY
cfgfile_write(f, _T("gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
cfgfile_write(f, _T("kbd_led_num"), _T("%d"), p->kbd_led_num);
cfgfile_write(f, _T("kbd_led_scr"), _T("%d"), p->kbd_led_scr);
cfgfile_write(f, _T("scaling_method"), _T("%d"), p->scaling_method);
cfgfile_write(f, _T("key_for_menu"), _T("%d"), p->key_for_menu);
cfgfile_write(f, _T("key_for_quit"), _T("%d"), p->key_for_quit);
cfgfile_write(f, _T("button_for_menu"), _T("%d"), p->button_for_menu);
cfgfile_write(f, _T("button_for_quit"), _T("%d"), p->button_for_quit);
#endif
cfgfile_write_bool(f, _T("immediate_blits"), p->immediate_blits);
cfgfile_dwrite_str(f, _T("waiting_blits"), waitblits[p->waiting_blits]);
cfgfile_write_bool(f, _T("ntsc"), p->ntscmode);
@ -2321,26 +2310,6 @@ static int cfgfile_parse_host(struct uae_prefs *p, TCHAR *option, TCHAR *value)
return 1;
}
#ifdef AMIBERRY
if (cfgfile_intval(option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_num", &p->kbd_led_num, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_scr", &p->kbd_led_scr, 1))
return 1;
if (cfgfile_intval(option, value, "scaling_method", &p->scaling_method, 1))
return 1;
if (cfgfile_intval(option, value, "key_for_menu", &p->key_for_menu, 1))
return 1;
if (cfgfile_intval(option, value, "key_for_quit", &p->key_for_quit, 1))
return 1;
if (cfgfile_intval(option, value, "button_for_menu", &p->button_for_menu, 1))
return 1;
if (cfgfile_intval(option, value, "button_for_quit", &p->button_for_quit, 1))
return 1;
#endif
if (cfgfile_string(option, value, _T("config_version"), tmpbuf, sizeof(tmpbuf) / sizeof(TCHAR))) {
TCHAR *tmpp2;
tmpp = _tcschr(value, '.');
@ -5011,16 +4980,6 @@ void default_prefs(struct uae_prefs *p, int type)
p->input_magic_mouse = 0;
p->input_magic_mouse_cursor = 0;
#ifdef AMIBERRY
p->kbd_led_num = -1; // No status on numlock
p->kbd_led_scr = -1; // No status on scrollock
p->scaling_method = -1; //Default is Auto
p->key_for_menu = SDLK_F12;
p->key_for_quit = 0;
p->button_for_menu = -1;
p->button_for_quit = -1;
#endif
inputdevice_default_prefs(p);
blkdev_default_prefs(p);

View file

@ -21,10 +21,7 @@ extern uae_u32 p96_rgbx16[65536];
extern int graphics_setup (void);
extern int graphics_init (bool);
extern void graphics_leave (void);
extern void graphics_reset(void);
extern bool handle_events(void);
extern int handle_msgpump (void);
extern void setup_brkhandler (void);
extern bool vsync_switchmode (int);
extern void flush_screen (void);
extern int isvsync_chipset(void);

View file

@ -6490,9 +6490,9 @@ void setmousestate(int mouse, int axis, int data, int isabs)
if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive())
return;
}
v = (int)d;
v = int(d);
fract[mouse][axis] += d - v;
diff = (int)fract[mouse][axis];
diff = int(fract[mouse][axis]);
v += diff;
fract[mouse][axis] -= diff;
for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)

View file

@ -41,6 +41,7 @@
#include "SDL.h"
#include "amiberry_rp9.h"
#include <map>
#include "scsidev.h"
extern void signal_segv(int signum, siginfo_t* info, void* ptr);
extern void gui_force_rtarea_hdchange();
@ -245,21 +246,38 @@ void target_default_options(struct uae_prefs* p, int type)
{
p->amiberry_customControls = 0;
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
p->kbd_led_num = -1; // No status on numlock
p->kbd_led_scr = -1; // No status on scrollock
p->scaling_method = -1; //Default is Auto
p->key_for_menu = SDLK_F12;
p->key_for_quit = 0;
p->button_for_menu = -1;
p->button_for_quit = -1;
}
void target_save_options(struct zfile* f, struct uae_prefs* p)
{
cfgfile_write(f, _T("gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
cfgfile_write(f, _T("kbd_led_num"), _T("%d"), p->kbd_led_num);
cfgfile_write(f, _T("kbd_led_scr"), _T("%d"), p->kbd_led_scr);
cfgfile_write(f, _T("scaling_method"), _T("%d"), p->scaling_method);
cfgfile_write(f, _T("key_for_menu"), _T("%d"), p->key_for_menu);
cfgfile_write(f, _T("key_for_quit"), _T("%d"), p->key_for_quit);
cfgfile_write(f, _T("button_for_menu"), _T("%d"), p->button_for_menu);
cfgfile_write(f, _T("button_for_quit"), _T("%d"), p->button_for_quit);
cfgfile_write(f, "amiberry.custom_controls", "%d", p->amiberry_customControls);
cfgfile_write(f, "amiberry.custom_up", "%d", customControlMap[VK_UP]);
cfgfile_write(f, "amiberry.custom_down", "%d", customControlMap[VK_DOWN]);
cfgfile_write(f, "amiberry.custom_left", "%d", customControlMap[VK_LEFT]);
cfgfile_write(f, "amiberry.custom_right", "%d", customControlMap[VK_RIGHT]);
cfgfile_write(f, "amiberry.custom_a", "%d", customControlMap[VK_A]);
cfgfile_write(f, "amiberry.custom_b", "%d", customControlMap[VK_B]);
cfgfile_write(f, "amiberry.custom_x", "%d", customControlMap[VK_X]);
cfgfile_write(f, "amiberry.custom_y", "%d", customControlMap[VK_Y]);
cfgfile_write(f, "amiberry.custom_l", "%d", customControlMap[VK_L]);
cfgfile_write(f, "amiberry.custom_r", "%d", customControlMap[VK_R]);
cfgfile_write(f, "amiberry.custom_a", "%d", customControlMap[VK_Green]);
cfgfile_write(f, "amiberry.custom_b", "%d", customControlMap[VK_Blue]);
cfgfile_write(f, "amiberry.custom_x", "%d", customControlMap[VK_Red]);
cfgfile_write(f, "amiberry.custom_y", "%d", customControlMap[VK_Yellow]);
cfgfile_write(f, "amiberry.custom_l", "%d", customControlMap[VK_LShoulder]);
cfgfile_write(f, "amiberry.custom_r", "%d", customControlMap[VK_RShoulder]);
}
void target_restart()
@ -268,23 +286,42 @@ void target_restart()
TCHAR* target_expand_environment(const TCHAR* path)
{
if (!path)
return nullptr;
return strdup(path);
}
int target_parse_option(struct uae_prefs* p, const char* option, const char* value)
{
int result = (cfgfile_intval(option, value, "custom_controls", &p->amiberry_customControls, 1)
|| cfgfile_intval(option, value, "custom_up", &customControlMap[VK_UP], 1)
|| cfgfile_intval(option, value, "custom_down", &customControlMap[VK_DOWN], 1)
|| cfgfile_intval(option, value, "custom_left", &customControlMap[VK_LEFT], 1)
|| cfgfile_intval(option, value, "custom_right", &customControlMap[VK_RIGHT], 1)
|| cfgfile_intval(option, value, "custom_a", &customControlMap[VK_A], 1)
|| cfgfile_intval(option, value, "custom_b", &customControlMap[VK_B], 1)
|| cfgfile_intval(option, value, "custom_x", &customControlMap[VK_X], 1)
|| cfgfile_intval(option, value, "custom_y", &customControlMap[VK_Y], 1)
|| cfgfile_intval(option, value, "custom_l", &customControlMap[VK_L], 1)
|| cfgfile_intval(option, value, "custom_r", &customControlMap[VK_R], 1)
);
if (cfgfile_intval(option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_num", &p->kbd_led_num, 1))
return 1;
if (cfgfile_intval(option, value, "kbd_led_scr", &p->kbd_led_scr, 1))
return 1;
if (cfgfile_intval(option, value, "scaling_method", &p->scaling_method, 1))
return 1;
if (cfgfile_intval(option, value, "key_for_menu", &p->key_for_menu, 1))
return 1;
if (cfgfile_intval(option, value, "key_for_quit", &p->key_for_quit, 1))
return 1;
if (cfgfile_intval(option, value, "button_for_menu", &p->button_for_menu, 1))
return 1;
if (cfgfile_intval(option, value, "button_for_quit", &p->button_for_quit, 1))
return 1;
int result = cfgfile_intval(option, value, "custom_controls", &p->amiberry_customControls, 1)
|| cfgfile_intval(option, value, "custom_up", &customControlMap[VK_UP], 1)
|| cfgfile_intval(option, value, "custom_down", &customControlMap[VK_DOWN], 1)
|| cfgfile_intval(option, value, "custom_left", &customControlMap[VK_LEFT], 1)
|| cfgfile_intval(option, value, "custom_right", &customControlMap[VK_RIGHT], 1)
|| cfgfile_intval(option, value, "custom_a", &customControlMap[VK_Green], 1)
|| cfgfile_intval(option, value, "custom_b", &customControlMap[VK_Blue], 1)
|| cfgfile_intval(option, value, "custom_x", &customControlMap[VK_Red], 1)
|| cfgfile_intval(option, value, "custom_y", &customControlMap[VK_Yellow], 1)
|| cfgfile_intval(option, value, "custom_l", &customControlMap[VK_LShoulder], 1)
|| cfgfile_intval(option, value, "custom_r", &customControlMap[VK_RShoulder], 1);
return result;
}
@ -749,23 +786,22 @@ int handle_msgpump()
break;
case SDL_KEYDOWN:
if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_APPLICATION]))
{
uae_reset(0, 1);
break;
}
switch (rEvent.key.keysym.scancode)
switch (rEvent.key.keysym.sym)
{
case SDL_SCANCODE_NUMLOCKCLEAR:
case SDLK_NUMLOCKCLEAR:
if (currprefs.keyboard_leds[KBLED_NUMLOCKB] > 0)
{
//oldleds ^= KBLED_NUMLOCKM;
//ch = true;
}
break;
case SDL_SCANCODE_CAPSLOCK: // capslock
case SDLK_CAPSLOCK: // capslock
if (currprefs.keyboard_leds[KBLED_CAPSLOCKB] > 0)
{
//oldleds ^= KBLED_CAPSLOCKM;
@ -792,7 +828,7 @@ int handle_msgpump()
ioctl(0, KDSKBLED, kbd_flags);
break;
case SDL_SCANCODE_SCROLLLOCK:
case SDLK_SCROLLLOCK:
if (currprefs.keyboard_leds[KBLED_SCROLLLOCKB] > 0)
{
//oldleds ^= KBLED_SCROLLLOCKM;
@ -810,7 +846,7 @@ int handle_msgpump()
SimulateMouseOrJoy(keycode, 1);
break;
}
else if (keycode > 0)
if (keycode > 0)
{
// Send mapped key press
inputdevice_do_keyboard(keycode, 1);
@ -823,9 +859,6 @@ int handle_msgpump()
break;
case SDL_KEYUP:
switch (rEvent.key.keysym.scancode)
{
default:
if (currprefs.amiberry_customControls)
{
keycode = customControlMap[rEvent.key.keysym.sym];
@ -835,7 +868,7 @@ int handle_msgpump()
SimulateMouseOrJoy(keycode, 0);
break;
}
else if (keycode > 0)
if (keycode > 0)
{
// Send mapped key release
inputdevice_do_keyboard(keycode, 0);
@ -845,8 +878,6 @@ int handle_msgpump()
translate_amiberry_keys(rEvent.key.keysym.sym, 0);
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE)

View file

@ -10,6 +10,7 @@ static int joyYviaCustom = 0;
static int joyButXviaCustom[7] = {0, 0, 0, 0, 0, 0, 0};
static int mouseBut1viaCustom = 0;
static int mouseBut2viaCustom = 0;
static int joystick_inited;
#define MAX_MOUSE_BUTTONS 2
#define MAX_MOUSE_AXES 2
@ -42,17 +43,15 @@ static int get_mouse_num()
static const char* get_mouse_friendlyname(int mouse)
{
if (mouse == 0)
return "Nubs as mouse";
else
return "dPad as mouse";
return "Mouse";
return "dPad as mouse";
}
static const char* get_mouse_uniquename(int mouse)
{
if (mouse == 0)
return "MOUSE0";
else
return "MOUSE1";
return "MOUSE1";
}
static int get_mouse_widget_num(int mouse)
@ -125,13 +124,12 @@ static void read_mouse()
setmousestate(1, 1, mouseScale, 0);
if (!mouseBut1viaCustom)
setmousebuttonstate(1, 0, keystate[VK_A]); // A button -> left mouse
setmousebuttonstate(1, 0, keystate[VK_Green]); // A button -> left mouse
if (!mouseBut2viaCustom)
setmousebuttonstate(1, 1, keystate[VK_B]); // B button -> right mouse
setmousebuttonstate(1, 1, keystate[VK_Blue]); // B button -> right mouse
}
}
static int get_mouse_flags(int num)
{
return 0;
@ -276,19 +274,18 @@ static char IsPS3Controller[MAX_INPUT_DEVICES];
static SDL_Joystick* Joysticktable[MAX_INPUT_DEVICES];
static int get_joystick_num()
{
// Keep joystick 0 as Pandora implementation...
return (nr_joysticks + 1);
// Keep joystick 0 as builtin implementation...
return nr_joysticks + 1;
}
static int init_joystick()
{
//This function is called too many times... we can filter if number of joy is good...
if (nr_joysticks == SDL_NumJoysticks())
if (joystick_inited)
return 1;
joystick_inited = 1;
nr_joysticks = SDL_NumJoysticks();
if (nr_joysticks > MAX_INPUT_DEVICES)
nr_joysticks = MAX_INPUT_DEVICES;
@ -296,9 +293,10 @@ static int init_joystick()
{
Joysticktable[cpt] = SDL_JoystickOpen(cpt);
strncpy(JoystickName[cpt], SDL_JoystickNameForIndex(cpt), 80);
printf("Joystick %i : %s\n", cpt, JoystickName[cpt]);
printf(" Buttons: %i Axis: %i Hats: %i\n", SDL_JoystickNumButtons(Joysticktable[cpt]), SDL_JoystickNumAxes(Joysticktable[cpt]), SDL_JoystickNumHats(Joysticktable[cpt]));
//printf("Joystick %i : %s\n", cpt, JoystickName[cpt]);
//printf(" Buttons: %i Axis: %i Hats: %i\n", SDL_JoystickNumButtons(Joysticktable[cpt]), SDL_JoystickNumAxes(Joysticktable[cpt]), SDL_JoystickNumHats(Joysticktable[cpt]));
//TODO: check if this is still needed
if (strcmp(JoystickName[cpt], "Sony PLAYSTATION(R)3 Controller") == 0 ||
strcmp(JoystickName[cpt], "PLAYSTATION(R)3 Controller") == 0)
{
@ -314,13 +312,15 @@ static int init_joystick()
static void close_joystick()
{
if (!joystick_inited)
return;
joystick_inited = 0;
for (int cpt = 0; cpt < nr_joysticks; cpt++)
{
SDL_JoystickClose(Joysticktable[cpt]);
}
}
static int acquire_joystick(int num, int flags)
{
return 1;
@ -333,9 +333,8 @@ static void unacquire_joystick(int num)
static const char* get_joystick_friendlyname(int joy)
{
if (joy == 0)
return "dPad as joystick";
else
return JoystickName[joy - 1];
return "Built-in joystick";
return JoystickName[joy - 1];
}
static const char* get_joystick_uniquename(int joy)
@ -411,7 +410,7 @@ static int get_joystick_widget_type(int joy, int num, TCHAR* name, uae_u32* code
}
return IDEV_WIDGET_BUTTON;
}
else if (num < MAX_JOY_AXES)
if (num < MAX_JOY_AXES)
{
if (name)
{
@ -432,51 +431,42 @@ static int get_joystick_flags(int num)
return 0;
}
static void read_joystick()
{
for (int joyid = 0; joyid < MAX_JPORTS; joyid++)
// First handle fake joystick from pandora...
// First handle fake joystick arrow keys...
if (currprefs.jports[joyid].id == JSEM_JOYS)
{
//const Uint8* keystate = SDL_GetKeyboardState(nullptr);
const Uint8* keystate = SDL_GetKeyboardState(nullptr);
//if (!keystate[VK_R])
//{ // Right shoulder + dPad -> cursor keys
// int axis = (keystate[VK_LEFT] ? -32767 : (keystate[VK_RIGHT] ? 32767 : 0));
// if (!joyXviaCustom)
// setjoystickstate(0, 0, axis, 32767);
// axis = (keystate[VK_UP] ? -32767 : (keystate[VK_DOWN] ? 32767 : 0));
// if (!joyYviaCustom)
// setjoystickstate(0, 1, axis, 32767);
//}
//if (!joyButXviaCustom[0])
// setjoybuttonstate(0, 0, keystate[VK_X]);
//if (!joyButXviaCustom[1])
// setjoybuttonstate(0, 1, keystate[VK_B]);
//if (!joyButXviaCustom[2])
// setjoybuttonstate(0, 2, keystate[VK_A]);
//if (!joyButXviaCustom[3])
// setjoybuttonstate(0, 3, keystate[VK_Y]);
int axis = keystate[VK_LEFT] ? -32767 : keystate[VK_RIGHT] ? 32767 : 0;
if (!joyXviaCustom)
setjoystickstate(0, 0, axis, 32767);
//int cd32_start = 0, cd32_ffw = 0, cd32_rwd = 0;
//if (keystate[SDL_SCANCODE_LALT])
//{ // Pandora Start button
// if (keystate[VK_L]) // Left shoulder
// cd32_rwd = 1;
// else if (keystate[VK_R]) // Right shoulder
// cd32_ffw = 1;
// else
// cd32_start = 1;
//}
//if (!joyButXviaCustom[6])
// setjoybuttonstate(0, 6, cd32_start);
//if (!joyButXviaCustom[5])
// setjoybuttonstate(0, 5, cd32_ffw);
//if (!joyButXviaCustom[4])
// setjoybuttonstate(0, 4, cd32_rwd);
axis = keystate[VK_UP] ? -32767 : keystate[VK_DOWN] ? 32767 : 0;
if (!joyYviaCustom)
setjoystickstate(0, 1, axis, 32767);
if (!joyButXviaCustom[0])
setjoybuttonstate(0, 0, keystate[VK_Red]);
if (!joyButXviaCustom[1])
setjoybuttonstate(0, 1, keystate[VK_Blue]);
if (!joyButXviaCustom[2])
setjoybuttonstate(0, 2, keystate[VK_Green]);
if (!joyButXviaCustom[3])
setjoybuttonstate(0, 3, keystate[VK_Yellow]);
int cd32_start = 0;
if (!joyButXviaCustom[6])
setjoybuttonstate(0, 6, cd32_start);
if (!joyButXviaCustom[5])
setjoybuttonstate(0, 5, keystate[VK_RShoulder]);
if (!joyButXviaCustom[4])
setjoybuttonstate(0, 4, keystate[VK_LShoulder]);
}
else if (jsem_isjoy(joyid, &currprefs) != -1)
else
if (jsem_isjoy(joyid, &currprefs) != -1)
{
// Now we handle real SDL joystick...
int hostjoyid = currprefs.jports[joyid].id - JSEM_JOYS - 1;

View file

@ -7,68 +7,68 @@
*/
/*
* Virtual Key for (A) button
* Virtual Key for CD32 Green button
* default: HOME (278)
*/
#pragma once
#define VK_A SDL_SCANCODE_HOME
#define VK_Green SDL_SCANCODE_HOME
/*
* Virtual Key for (B) button
* Virtual Key for CD32 Blue button
* default: END (279)
*/
#define VK_B SDL_SCANCODE_END
#define VK_Blue SDL_SCANCODE_PAGEDOWN
/*
* Virtual Key for (X) button
* Virtual Key for CD32 Red button
* default: PAGEDOWN (281)
*/
#define VK_X SDL_SCANCODE_PAGEDOWN
#define VK_Red SDL_SCANCODE_END
/*
* Virtual Key for (Y) button
* default: PAGEUP (280)
*/
#define VK_Y SDL_SCANCODE_PAGEUP
#define VK_Yellow SDL_SCANCODE_PAGEUP
/*
* Virtual Key for (Left shoulder) button
* default: RSHIFT (303)
*/
#define VK_L SDL_SCANCODE_RSHIFT
#define VK_LShoulder SDL_SCANCODE_RSHIFT
/*
* Virtual Key for (Right shoulder) button
* default: RCTRL (305)
*/
#define VK_R SDL_SCANCODE_RCTRL
#define VK_RShoulder SDL_SCANCODE_RCTRL
/*
* Virtual Key for (up) button
* default: UP (273)
*/
#define VK_UP SDLK_UP
#define VK_UP SDL_SCANCODE_UP
/*
* Virtual Key for (down) button
* default: DOWN (274)
*/
#define VK_DOWN SDLK_DOWN
#define VK_DOWN SDL_SCANCODE_DOWN
/*
* Virtual Key for (right) button
* default: RIGHT (275)
*/
#define VK_RIGHT SDLK_RIGHT
#define VK_RIGHT SDL_SCANCODE_RIGHT
/*
* Virtual Key for (left) button
* default: LEFT (276)
*/
#define VK_LEFT SDLK_LEFT
#define VK_LEFT SDL_SCANCODE_LEFT
/*
* Virtual Key for (ESC) button
* default: ESC (27)
*/
#define VK_ESCAPE SDLK_ESCAPE
#define VK_ESCAPE SDL_SCANCODE_ESCAPE

View file

@ -209,7 +209,7 @@ static void CreateFilesysHardfileLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -235,12 +235,14 @@ static void CreateFilesysHardfileLoop()
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -280,7 +280,7 @@ static void EditFilesysHardfileLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -306,12 +306,14 @@ static void EditFilesysHardfileLoop()
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -217,7 +217,7 @@ static void EditFilesysVirtualLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -243,12 +243,14 @@ static void EditFilesysVirtualLoop()
continue; // Don't change value when enter Slider -> don't send event to control
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -101,8 +101,8 @@ void InGameMessage(const char *msg)
{
switch (event.key.keysym.sym)
{
case VK_X:
case VK_A:
case VK_Red:
case VK_Green:
case SDLK_RETURN:
msg_done = 1;
break;

View file

@ -82,7 +82,7 @@ public:
}
};
static const char* inputport_list[] = {"Nubs as mouse", "dPad as mouse", "dPad as joystick", "dPad as CD32 contr.", "none"};
static const char* inputport_list[] = {"Mouse", "Arrow keys as mouse", "Arrow keys as joystick", "Arrow keys as CD32 contr.", "none"};
StringListModel ctrlPortList(inputport_list, 5);
const char* autofireValues[] = {"Off", "Slow", "Medium", "Fast"};
@ -235,22 +235,22 @@ public:
changed_prefs.amiberry_customControls = chkCustomCtrl->isSelected() ? 1 : 0;
else if (actionEvent.getSource() == cboA)
customControlMap[VK_A] = amigaKey[cboA->getSelected()];
customControlMap[VK_Green] = amigaKey[cboA->getSelected()];
else if (actionEvent.getSource() == cboB)
customControlMap[VK_B] = amigaKey[cboB->getSelected()];
customControlMap[VK_Blue] = amigaKey[cboB->getSelected()];
else if (actionEvent.getSource() == cboX)
customControlMap[VK_X] = amigaKey[cboX->getSelected()];
customControlMap[VK_Red] = amigaKey[cboX->getSelected()];
else if (actionEvent.getSource() == cboY)
customControlMap[VK_Y] = amigaKey[cboY->getSelected()];
customControlMap[VK_Yellow] = amigaKey[cboY->getSelected()];
else if (actionEvent.getSource() == cboL)
customControlMap[VK_L] = amigaKey[cboL->getSelected()];
customControlMap[VK_LShoulder] = amigaKey[cboL->getSelected()];
else if (actionEvent.getSource() == cboR)
customControlMap[VK_R] = amigaKey[cboR->getSelected()];
customControlMap[VK_RShoulder] = amigaKey[cboR->getSelected()];
else if (actionEvent.getSource() == cboUp)
customControlMap[VK_UP] = amigaKey[cboUp->getSelected()];
@ -575,12 +575,12 @@ void RefreshPanelInput()
chkCustomCtrl->setSelected(changed_prefs.amiberry_customControls);
cboA->setSelected(GetAmigaKeyIndex(customControlMap[VK_A]));
cboB->setSelected(GetAmigaKeyIndex(customControlMap[VK_B]));
cboX->setSelected(GetAmigaKeyIndex(customControlMap[VK_X]));
cboY->setSelected(GetAmigaKeyIndex(customControlMap[VK_Y]));
cboL->setSelected(GetAmigaKeyIndex(customControlMap[VK_L]));
cboR->setSelected(GetAmigaKeyIndex(customControlMap[VK_R]));
cboA->setSelected(GetAmigaKeyIndex(customControlMap[VK_Green]));
cboB->setSelected(GetAmigaKeyIndex(customControlMap[VK_Blue]));
cboX->setSelected(GetAmigaKeyIndex(customControlMap[VK_Red]));
cboY->setSelected(GetAmigaKeyIndex(customControlMap[VK_Yellow]));
cboL->setSelected(GetAmigaKeyIndex(customControlMap[VK_LShoulder]));
cboR->setSelected(GetAmigaKeyIndex(customControlMap[VK_RShoulder]));
cboUp->setSelected(GetAmigaKeyIndex(customControlMap[VK_UP]));
cboDown->setSelected(GetAmigaKeyIndex(customControlMap[VK_DOWN]));
cboLeft->setSelected(GetAmigaKeyIndex(customControlMap[VK_LEFT]));

View file

@ -288,7 +288,7 @@ static void SelectFileLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -330,12 +330,14 @@ static void SelectFileLoop()
}
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -200,7 +200,7 @@ static void SelectFolderLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -232,12 +232,14 @@ static void SelectFolderLoop()
}
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -104,7 +104,7 @@ static void ShowMessageLoop()
{
if (event.type == SDL_KEYDOWN)
{
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case VK_ESCAPE:
dialogFinished = true;
@ -122,12 +122,14 @@ static void ShowMessageLoop()
}
break;
case VK_X:
case VK_A:
event.key.keysym.sym = SDLK_RETURN;
case VK_Red:
case VK_Green:
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
default:
break;
}
}

View file

@ -229,9 +229,9 @@ namespace sdl
}
}
else
switch (event.key.keysym.sym)
switch (event.key.keysym.scancode)
{
case SDLK_q:
case SDL_SCANCODE_Q:
//-------------------------------------------------
// Quit entire program via Q on keyboard
//-------------------------------------------------
@ -246,20 +246,15 @@ namespace sdl
break;
case VK_ESCAPE:
case VK_R:
//-------------------------------------------------
// Reset Amiga
//-------------------------------------------------
uae_reset(1, 1);
gui_running = false;
break;
case VK_X:
case VK_A:
case VK_Red:
case VK_Green:
//------------------------------------------------
// Simulate press of enter when 'X' pressed
//------------------------------------------------
event.key.keysym.sym = SDLK_RETURN;
event.key.keysym.scancode = SDL_SCANCODE_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
@ -283,6 +278,8 @@ namespace sdl
if (HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
default:
break;
}
}
else if (event.type == SDL_QUIT)

View file

@ -470,16 +470,16 @@ void translate_amiberry_keys(int scancode, int newstate)
int translatedScancode = scancode;
switch (scancode)
{
case VK_UP:
case SDLK_UP:
translatedScancode = AK_UP;
break;
case VK_DOWN:
case SDLK_DOWN:
translatedScancode = AK_DN;
break;
case VK_LEFT:
case SDLK_LEFT:
translatedScancode = AK_LF;
break;
case VK_RIGHT:
case SDLK_RIGHT:
translatedScancode = AK_RT;
break;
case SDLK_F1:

View file

@ -485,12 +485,12 @@ int loadconfig_old(struct uae_prefs* p, const char* orgpath)
fscanf(f, "custom_down=%d\n", &customControlMap[VK_DOWN]);
fscanf(f, "custom_left=%d\n", &customControlMap[VK_LEFT]);
fscanf(f, "custom_right=%d\n", &customControlMap[VK_RIGHT]);
fscanf(f, "custom_A=%d\n", &customControlMap[VK_A]);
fscanf(f, "custom_B=%d\n", &customControlMap[VK_B]);
fscanf(f, "custom_X=%d\n", &customControlMap[VK_X]);
fscanf(f, "custom_Y=%d\n", &customControlMap[VK_Y]);
fscanf(f, "custom_L=%d\n", &customControlMap[VK_L]);
fscanf(f, "custom_R=%d\n", &customControlMap[VK_R]);
fscanf(f, "custom_A=%d\n", &customControlMap[VK_Green]);
fscanf(f, "custom_B=%d\n", &customControlMap[VK_Blue]);
fscanf(f, "custom_X=%d\n", &customControlMap[VK_Red]);
fscanf(f, "custom_Y=%d\n", &customControlMap[VK_Yellow]);
fscanf(f, "custom_L=%d\n", &customControlMap[VK_LShoulder]);
fscanf(f, "custom_R=%d\n", &customControlMap[VK_RShoulder]);
fscanf(f, "cpu=%d\n", &cpu_level);
if (cpu_level > 0) // M68000
// Was old format