AmatCoder / mednaffe

A front-end (GUI) for mednafen emulator
GNU General Public License v3.0
429 stars 35 forks source link

Fix joystick support on 32 bit linux #126

Closed not-a-user closed 3 years ago

not-a-user commented 3 years ago

The compiler warned about this:

widgets/joystick_linux.c: In function ‘init_joys’:
widgets/joystick_linux.c:223:40: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘guint64’ {aka ‘long long unsigned int’} [-Wformat=]
  223 |     joy->id = g_strdup_printf ("0x%016lx%04x%04x%08x", GetBVPV (number), num_axes, num_buttons, 0);
      |                                   ~~~~~^               ~~~~~~~~~~~~~~~~
      |                                        |               |
      |                                        |               guint64 {aka long long unsigned int}
      |                                        long unsigned int
      |                                   %016llx
AmatCoder commented 3 years ago

Oh yes, when I wrote that I remember thinking: "This is not portable..." but later I forget about it. :(

The patch is correct but I would rather use macros from glib.

Can you confirm if this works? joy->id = g_strdup_printf ("0x%016"G_GINT64_MODIFIER"x%04x%04x%08x", GetBVPV (number), num_axes, num_buttons, 0);

not-a-user commented 3 years ago

Confirmed working, PR updated.

AmatCoder commented 3 years ago

Merged. Thanks very much!