Skip to content

Commit e998682

Browse files
committed
merge branch 'master' into release
2 parents 985d885 + 64e5dff commit e998682

File tree

7 files changed

+84
-36
lines changed

7 files changed

+84
-36
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2024-09-08 Olivier Poncet <[email protected]>
2+
3+
* Better Linux joystick support
4+
* BSD compilation fixed
5+
16
2024-08-09 Olivier Poncet <[email protected]>
27

38
* Full support for french keyboard

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ AX_CHECK_BYTE_ORDER
7878

7979
AX_CHECK_HEADERS
8080
AX_CHECK_FUNCTIONS
81+
AX_CHECK_PTHREAD
82+
AX_CHECK_LIBDL
8183
AX_CHECK_ZLIB
8284
AX_CHECK_BZLIB
8385
AX_CHECK_GUI_TOOLKIT

lib/miniaudio/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ libminiaudio_la_LDFLAGS = \
4141
$(NULL)
4242

4343
libminiaudio_la_LIBADD = \
44-
-ldl -lpthread -lm \
44+
-lm \
4545
$(NULL)
4646

4747
# ----------------------------------------------------------------------------

lib/xcpc/amstrad/cpc/cpc-settings.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void Settings::parse(int& argc, char**& argv)
274274
::xcpc_log_debug("xcpc.settings.drive0 = %s", opt_drive0.c_str() );
275275
::xcpc_log_debug("xcpc.settings.drive1 = %s", opt_drive1.c_str() );
276276
::xcpc_log_debug("xcpc.settings.snapshot = %s", opt_snapshot.c_str());
277-
::xcpc_log_debug("xcpc.settings.speedup = %d", opt_speedup );
277+
::xcpc_log_debug("xcpc.settings.speedup = %s", opt_speedup.c_str() );
278278
::xcpc_log_debug("xcpc.settings.xshm = %d", opt_xshm );
279279
::xcpc_log_debug("xcpc.settings.scanlines = %d", opt_scanlines );
280280
::xcpc_log_debug("xcpc.settings.help = %d", opt_help );

m4/acinclude.m4

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ AC_CHECK_FUNCS([fork])
9999
AC_CHECK_FUNCS([GetTempFileName])
100100
])
101101

102+
# ----------------------------------------------------------------------------
103+
# AX_CHECK_PTHREAD
104+
# ----------------------------------------------------------------------------
105+
106+
AC_DEFUN([AX_CHECK_PTHREAD], [
107+
AC_CHECK_HEADERS(pthread.h)
108+
AC_CHECK_LIB(pthread, pthread_create)
109+
])
110+
111+
# ----------------------------------------------------------------------------
112+
# AX_CHECK_LIBDL
113+
# ----------------------------------------------------------------------------
114+
115+
AC_DEFUN([AX_CHECK_LIBDL], [
116+
AC_CHECK_HEADERS(dlfcn.h)
117+
AC_CHECK_LIB(dl, dlopen)
118+
])
119+
102120
# ----------------------------------------------------------------------------
103121
# AX_CHECK_ZLIB
104122
# ----------------------------------------------------------------------------

src/gtk3ui/gtkemulator.c

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ GemJoystick* gem_joystick_construct(GtkWidget* widget, GemJoystick* joystick, co
981981
joystick->js_axis_y = 0;
982982
joystick->js_button0 = 0;
983983
joystick->js_button1 = 0;
984+
joystick->js_axes = 0;
984985
joystick->js_buttons = 0;
985986
}
986987
/* check device name */ {
@@ -1008,17 +1009,23 @@ GemJoystick* gem_joystick_construct(GtkWidget* widget, GemJoystick* joystick, co
10081009
}
10091010
}
10101011
}
1011-
/* get the joystick mapping */ {
1012-
unsigned char count = 0;
1012+
/* get the joystick axis count and mapping */ {
10131013
if(joystick->fd != -1) {
1014-
if(ioctl(joystick->fd, JSIOCGBUTTONS, &count) == -1) {
1015-
(void) memset(joystick->js_mapping, 0, sizeof(joystick->js_mapping));
1014+
if(ioctl(joystick->fd, JSIOCGAXES, &joystick->js_axes) == -1) {
1015+
joystick->js_axes = 0;
10161016
}
1017-
if(ioctl(joystick->fd, JSIOCGBTNMAP, joystick->js_mapping) == -1) {
1018-
(void) memset(joystick->js_mapping, 0, sizeof(joystick->js_mapping));
1017+
if(ioctl(joystick->fd, JSIOCGAXMAP, joystick->js_axmap) == -1) {
1018+
(void) memset(joystick->js_axmap, 0, sizeof(joystick->js_axmap));
10191019
}
1020-
if(count != 0) {
1021-
joystick->js_buttons = count;
1020+
}
1021+
}
1022+
/* get the joystick buttons count and mapping */ {
1023+
if(joystick->fd != -1) {
1024+
if(ioctl(joystick->fd, JSIOCGBUTTONS, &joystick->js_buttons) == -1) {
1025+
joystick->js_buttons = 0;
1026+
}
1027+
if(ioctl(joystick->fd, JSIOCGBTNMAP, joystick->js_btnmap) == -1) {
1028+
(void) memset(joystick->js_btnmap, 0, sizeof(joystick->js_btnmap));
10221029
}
10231030
}
10241031
}
@@ -1030,10 +1037,12 @@ GemJoystick* gem_joystick_destruct(GtkWidget* widget, GemJoystick* joystick)
10301037
{
10311038
/* finalize */ {
10321039
joystick->js_id = 0;
1040+
joystick->js_axes = 0;
10331041
joystick->js_axis_x = 0;
10341042
joystick->js_axis_y = 0;
10351043
joystick->js_button0 = 0;
10361044
joystick->js_button1 = 0;
1045+
joystick->js_axes = 0;
10371046
joystick->js_buttons = 0;
10381047
}
10391048
/* destroy input_id */ {
@@ -1102,26 +1111,23 @@ gboolean gem_joystick_handler(gint fd, GIOCondition condition, GtkWidget* widget
11021111
case JS_EVENT_BUTTON:
11031112
{
11041113
XEvent x11_event;
1105-
/* check for special button */ {
1106-
if(js_event.value != 0) {
1107-
unsigned short code = joystick->js_mapping[js_event.number];
1108-
if(code == BTN_SELECT) {
1109-
return TRUE;
1110-
}
1111-
if(code == BTN_START) {
1112-
return TRUE;
1113-
}
1114-
if(code == BTN_MODE) {
1115-
return TRUE;
1116-
}
1117-
}
1118-
}
11191114
/* update joystick */ {
1120-
if((js_event.number &= 1) == 0) {
1121-
joystick->js_button0 = js_event.value;
1122-
}
1123-
else {
1124-
joystick->js_button1 = js_event.value;
1115+
switch(joystick->js_btnmap[js_event.number]) {
1116+
case BTN_A:
1117+
case BTN_X:
1118+
case BTN_TL:
1119+
case BTN_THUMBL:
1120+
joystick->js_button0 = js_event.value;
1121+
break;
1122+
case BTN_B:
1123+
case BTN_Y:
1124+
case BTN_TR:
1125+
case BTN_THUMBR:
1126+
joystick->js_button1 = js_event.value;
1127+
break;
1128+
default:
1129+
return TRUE;
1130+
break;
11251131
}
11261132
}
11271133
/* initialize button event */ {
@@ -1150,11 +1156,26 @@ gboolean gem_joystick_handler(gint fd, GIOCondition condition, GtkWidget* widget
11501156
{
11511157
XEvent x11_event;
11521158
/* update joystick */ {
1153-
if((js_event.number &= 1) == 0) {
1154-
joystick->js_axis_x = js_event.value;
1155-
}
1156-
else {
1157-
joystick->js_axis_y = js_event.value;
1159+
switch(joystick->js_axmap[js_event.number]) {
1160+
case ABS_X:
1161+
case ABS_RX:
1162+
case ABS_HAT0X:
1163+
case ABS_HAT1X:
1164+
case ABS_HAT2X:
1165+
case ABS_HAT3X:
1166+
joystick->js_axis_x = js_event.value;
1167+
break;
1168+
case ABS_Y:
1169+
case ABS_RY:
1170+
case ABS_HAT0Y:
1171+
case ABS_HAT1Y:
1172+
case ABS_HAT2Y:
1173+
case ABS_HAT3Y:
1174+
joystick->js_axis_y = js_event.value;
1175+
break;
1176+
default:
1177+
return TRUE;
1178+
break;
11581179
}
11591180
}
11601181
/* initialize motion event */ {

src/gtk3ui/gtkemulatortypes.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ struct _GemJoystick
7272
int js_axis_y;
7373
int js_button0;
7474
int js_button1;
75-
int js_buttons;
76-
unsigned short js_mapping[1024];
75+
uint8_t js_axes;
76+
uint8_t js_axmap[128];
77+
uint8_t js_buttons;
78+
uint16_t js_btnmap[512];
7779
};
7880

7981
extern GemVideo* gem_video_construct (GtkWidget* widget, GemVideo* video);

0 commit comments

Comments
 (0)