Github messages for voidlinux
 help / color / mirror / Atom feed
From: joshuakraemer <joshuakraemer@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] dosbox: patch to support full mapping of joysticks
Date: Sat, 02 May 2020 16:15:53 +0200	[thread overview]
Message-ID: <20200502141553.ALBXrVwiSzrq-iq_4O_OxqM0fVaHLx1ur2s2RGegVgE@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-14474@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

There is an updated pull request by joshuakraemer against master on the void-packages repository

https://github.com/joshuakraemer/void-packages dosbox-joystick-patch
https://github.com/void-linux/void-packages/pull/14474

dosbox: patch to support full mapping of joysticks
Without this patch, dosbox is only able to use:
- either 2 joysticks/gamepads with 1 analog stick each (no hat switches/d-pads)
- or 1 joystick/gamepad with 1 analog stick and 1 hat switch/d-pad (with `joysticktype=fcs`)

This patch allows full mapping of 2 joysticks/gamepads with 2 analog sticks and 1 hat switch/d-pad, which means modern joysticks and gamepads can be fully used to play dos games in 2-player mode.

This patch is also used by Recalbox OS, see https://github.com/recalbox/recalbox-buildroot/blob/master/package/dosbox/dosbox-003-joystick-8axis.patch

A patch file from https://github.com/void-linux/void-packages/pull/14474.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-dosbox-joystick-patch-14474.patch --]
[-- Type: text/x-diff, Size: 4764 bytes --]

From 15082ba4ab18a07044018adbdc06dd7a734280da Mon Sep 17 00:00:00 2001
From: Joshua Kraemer <joshua@kraemer.link>
Date: Sun, 15 Sep 2019 20:29:45 +0200
Subject: [PATCH] dosbox: patch to support full mapping of joysticks

---
 .../patches/fully-mappable-joystick.patch     | 125 ++++++++++++++++++
 srcpkgs/dosbox/template                       |   2 +-
 2 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/dosbox/patches/fully-mappable-joystick.patch

diff --git a/srcpkgs/dosbox/patches/fully-mappable-joystick.patch b/srcpkgs/dosbox/patches/fully-mappable-joystick.patch
new file mode 100644
index 00000000000..ae4e40e3daa
--- /dev/null
+++ b/srcpkgs/dosbox/patches/fully-mappable-joystick.patch
@@ -0,0 +1,125 @@
+This patch by cfoesch allows mapping of up to 8 axes and 2 hat switches.
+The emulated joystick remains unchanged.
+Discussion: https://www.vogons.org/viewtopic.php?t=27452
+
+--- src/gui/sdl_mapper.cpp	2010-10-30 05:10:05.000000000 -0600
++++ src/gui/sdl_mapper.cpp	2011-02-14 09:29:43.251163300 -0700
+@@ -68,6 +68,8 @@
+ #define MAXACTIVE 16
+ #define MAXBUTTON 32
+ #define MAXBUTTON_CAP 16
++#define MAXAXIS 8
++#define MAXHAT 2
+
+ class CEvent;
+ class CHandlerEvent;
+@@ -521,10 +523,11 @@
+ };
+
+ #define MAX_VJOY_BUTTONS 8
++#define MAX_VJOY_AXES 8
+
+ static struct {
+ 	bool button_pressed[MAX_VJOY_BUTTONS];
+-	Bit16s axis_pos[8];
++	Bit16s axis_pos[MAX_VJOY_AXES];
+ 	bool hat_pressed[16];
+ } virtual_joysticks[2];
+
+@@ -615,8 +618,8 @@
+ 		if (_dummy) return;
+
+ 		// initialize binding lists and position data
+-		pos_axis_lists=new CBindList[4];
+-		neg_axis_lists=new CBindList[4];
++		pos_axis_lists=new CBindList[MAXAXIS];
++		neg_axis_lists=new CBindList[MAXAXIS];
+ 		button_lists=new CBindList[MAXBUTTON];
+ 		hat_lists=new CBindList[4];
+ 		Bitu i;
+@@ -625,7 +628,7 @@
+ 			old_button_state[i]=0;
+ 		}
+ 		for(i=0;i<16;i++) old_hat_state[i]=0;
+-		for (i=0; i<4; i++) {
++		for (i=0; i<MAXAXIS; i++) {
+ 			old_pos_axis_state[i]=false;
+ 			old_neg_axis_state[i]=false;
+ 		}
+@@ -643,8 +646,16 @@
+ 		}
+
+ 		axes=SDL_JoystickNumAxes(sdl_joystick);
+-		buttons=SDL_JoystickNumButtons(sdl_joystick);
++		if (axes > MAXAXIS) axes = MAXAXIS;
++		axes_cap=emulated_axes;
++		if (axes_cap>axes) axes_cap=axes;
++
+ 		hats=SDL_JoystickNumHats(sdl_joystick);
++		if (hats > MAXHAT) hats = MAXHAT;
++		hats_cap=emulated_hats;
++		if (hats_cap>hats) hats_cap=hats;
++
++		buttons=SDL_JoystickNumButtons(sdl_joystick);
+ 		button_wrap=buttons;
+ 		button_cap=buttons;
+ 		if (button_wrapping_enabled) {
+@@ -652,10 +663,7 @@
+ 			if (buttons>MAXBUTTON_CAP) button_cap = MAXBUTTON_CAP;
+ 		}
+ 		if (button_wrap > MAXBUTTON) button_wrap = MAXBUTTON;
+-		axes_cap=emulated_axes;
+-		if (axes_cap>axes) axes_cap=axes;
+-		hats_cap=emulated_hats;
+-		if (hats_cap>hats) hats_cap=hats;
++
+ 		LOG_MSG("Using joystick %s with %d axes, %d buttons and %d hat(s)",SDL_JoystickName(stick),axes,buttons,hats);
+ 	}
+ 	~CStickBindGroup() {
+@@ -688,7 +696,7 @@
+ 		if (event->type==SDL_JOYAXISMOTION) {
+ 			if (event->jaxis.which!=stick) return 0;
+ #if defined (REDUCE_JOYSTICK_POLLING)
+-			if (event->jaxis.axis>=emulated_axes) return 0;
++			if (event->jaxis.axis>=axes) return 0;
+ #endif
+ 			if (abs(event->jaxis.value)<25000) return 0;
+ 			return CreateAxisBind(event->jaxis.axis,event->jaxis.value>0);
+@@ -780,7 +788,7 @@
+ 			}
+ 		}
+
+-		for (i=0; i<axes_cap; i++) {
++		for (i=0; i<axes; i++) {
+ 			Sint16 caxis_pos=SDL_JoystickGetAxis(sdl_joystick,i);
+ 			/* activate bindings for joystick position */
+ 			if (caxis_pos>1) {
+@@ -812,7 +820,7 @@
+ 			}
+ 		}
+
+-		for (i=0; i<hats_cap; i++) {
++		for (i=0; i<hats; i++) {
+ 			Uint8 chat_state=SDL_JoystickGetHat(sdl_joystick,i);
+
+ 			/* activate binding if hat state has changed */
+@@ -838,7 +846,7 @@
+
+ private:
+ 	CBind * CreateAxisBind(Bitu axis,bool positive) {
+-		if (axis<emulated_axes) {
++		if (axis<axes) {
+ 			if (positive) return new CJAxisBind(&pos_axis_lists[axis],this,axis,positive);
+ 			else return new CJAxisBind(&neg_axis_lists[axis],this,axis,positive);
+ 		}
+@@ -877,8 +885,8 @@
+ 	char configname[10];
+ 	Bitu button_autofire[MAXBUTTON];
+ 	bool old_button_state[MAXBUTTON];
+-	bool old_pos_axis_state[16];
+-	bool old_neg_axis_state[16];
++	bool old_pos_axis_state[MAXAXIS];
++	bool old_neg_axis_state[MAXAXIS];
+ 	Uint8 old_hat_state[16];
+ 	bool is_dummy;
+ };
diff --git a/srcpkgs/dosbox/template b/srcpkgs/dosbox/template
index 4518697790a..e2f4ba586c8 100644
--- a/srcpkgs/dosbox/template
+++ b/srcpkgs/dosbox/template
@@ -1,7 +1,7 @@
 # Template file for 'dosbox'
 pkgname=dosbox
 version=0.74.3
-revision=1
+revision=2
 wrksrc=${pkgname}-0.74-3
 build_style=gnu-configure
 hostmakedepends="pkg-config"

  parent reply	other threads:[~2020-05-02 14:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 18:41 [PR PATCH] " voidlinux-github
2019-09-15 19:02 ` [PR PATCH] [Updated] " voidlinux-github
2019-09-15 19:02 ` voidlinux-github
2019-09-16 14:30 ` voidlinux-github
2019-09-20 20:11 ` voidlinux-github
2020-05-02 14:15 ` joshuakraemer [this message]
2020-05-06 19:30 ` ericonr
2020-05-07  2:05 ` abenson
2020-05-07  9:55 ` pullmoll
2020-05-07 10:49 ` abenson
2020-05-07 11:25 ` pullmoll
2020-05-09 11:27 ` joshuakraemer
2020-05-09 11:44 ` joshuakraemer
2021-07-16 15:29 ` ericonr
2021-07-16 15:29 ` [PR PATCH] [Closed]: " ericonr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200502141553.ALBXrVwiSzrq-iq_4O_OxqM0fVaHLx1ur2s2RGegVgE@z \
    --to=joshuakraemer@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).