Re: [hatari-devel] Joystick buttons config and sdl gui patches |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Nicolas Pomarède <npomarede@xxxxxxxxxxxx>
- Subject: Re: [hatari-devel] Joystick buttons config and sdl gui patches
- From: Robin Sergeant <robin.sergeant@xxxxxxxxx>
- Date: Mon, 7 Aug 2023 13:06:49 +0100
- Cc: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691410021; x=1692014821; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DyFPorX0hdqcT/XXxCNBIVP8VSvb7D33aOKhXnCpSZE=; b=As/RxRT2H1359yg6Ktdrddbv3ga2klIOW0eI0EC/7EAaZpGhaQKQ4Vxg6TmHvfYcOK tjxtVUU016pU7g3Tb34c+S5M2JWmlSj90dqAO9BXUIY2l+sVldp5ZBvhB08Ch7rU61F/ N0WijG6ogVsWuhBGubGupqePvqELXbWOkQBlHi3z1zvKTSmn8YMSij6p55NiPi9NuPeJ T7CRqluBSR3nxLBGjcrfY/94y5t7ixlblhrUwu8l4WaAjet98OWmQzz7sSdqXMs/MHbd sTrFgWZhg9Bl3fs/ovLLfLPy00KT1Kv0iU2PO/6t/RrSmNuXPg7u/cMX7ym2G+MdMmGB 9ktQ==
Hi Nicolas,
Great, thank you. I actually noticed a small bug myself, which I've
now fixed with the attached follow up patch. If the joystick is used
to control the gui then the JOYBUTTON_UP event from the last press is
received before the user can choose "Button 1" on the new dialog. To
allow for that scenario I've added another boolean to ignore UP events
received before DOWN is handled. I should have thought of that
before, but had only been using the mouse and keyboard to start my new
dialog!
NB This is a repost to the list of a reply I sent directly to Nicolas
yesterday (forgot to reply to all).
Br,
Robin.
On Sun, 6 Aug 2023 at 20:50, Nicolas Pomarède <npomarede@xxxxxxxxxxxx> wrote:
>
> Le 30/07/2023 à 10:46, Robin Sergeant a écrit :
> > Hi,
> >
> > Please find the attached patches. The first just adds the config as
> > before, but with checks to allow for undefined buttons (with negative
> > indexes).
> >
> > The second adds a "Remap joystick buttons" button to the sdl joystick
> > dialog. This behaves like the existing "Define keys" button. The
> > user is guided to press each of the 3 buttons, but can also press the
> > ESC key for none (which results in a value of -1 being stored and the
> > button being ignored). The dialog looks like this:
> >
> > --------------------------------
> > Press joystick button 1
> > or ESC for none...
> >
> > (was: id 3)
> > --------------------------------
> >
> > And then after pressing button 0 (but before releasing):
> >
> > --------------------------------
> > Press joystick button 1
> > or ESC for none...
> >
> > (now: id 0)
> > --------------------------------
> >
> > So as I said, basically consistent with how "Define keys" currently works.
> >
> > Does this look ok, and can the patches be included? Obviously happy
> > to make any further tweaks or change the UI etc. I should probably
> > have sent the proposal first, but I got carried away with the coding
> > and wanted to figure out how the dialogs worked :-)
> >
> > Any feedback welcome!
>
> Hi
>
> both patches look ok to me , so unless someone require some changes to
> them or have some remarks then I can commit them to main sources.
>
> Nicolas
>
From 283679804c1e6f7f5f6dc7ed9d7334c502246512 Mon Sep 17 00:00:00 2001
From: Robin Sergeant <robin.sergeant@gmail.com>
Date: Sun, 6 Aug 2023 21:17:11 +0100
Subject: [PATCH 3/3] Fix event handling order in button remapping gui
---
src/gui-sdl/dlgJoystick.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/gui-sdl/dlgJoystick.c b/src/gui-sdl/dlgJoystick.c
index bd31de5a..37d2f6d0 100644
--- a/src/gui-sdl/dlgJoystick.c
+++ b/src/gui-sdl/dlgJoystick.c
@@ -169,6 +169,7 @@ static void DlgJoystick_MapOneButton(int button, int *pButton)
{
SDL_Event sdlEvent;
bool bDone = false;
+ bool bSet = false;
if (bQuitProgram)
return;
@@ -192,16 +193,18 @@ static void DlgJoystick_MapOneButton(int button, int *pButton)
{
case SDL_JOYBUTTONDOWN:
*pButton = sdlEvent.jbutton.button;
+ bSet = true;
snprintf(sKeyName, sizeof(sKeyName), "(now: id %d)", *pButton);
SDLGui_DrawDialog(joybuttondlg);
break;
case SDL_JOYBUTTONUP:
- bDone = true;
+ bDone = bSet;
break;
case SDL_KEYDOWN:
if (sdlEvent.key.keysym.sym == SDLK_ESCAPE)
{
*pButton = -1;
+ bSet = true;
strcpy(sKeyName, "(now: none)");
SDLGui_DrawDialog(joybuttondlg);
}
@@ -209,7 +212,7 @@ static void DlgJoystick_MapOneButton(int button, int *pButton)
case SDL_KEYUP:
if (sdlEvent.key.keysym.sym == SDLK_ESCAPE)
{
- bDone = true;
+ bDone = bSet;
}
break;
case SDL_QUIT:
--
2.37.1 (Apple Git-137.1)