2001-04-26 16:45:43 +00:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2011-12-31 09:28:07 -05:00
|
|
|
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
2011-04-08 13:03:26 -07:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2006-02-21 08:46:50 +00:00
|
|
|
#include "SDL_config.h"
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-04-14 04:46:47 +00:00
|
|
|
#ifdef SDL_JOYSTICK_LINUX
|
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
/* This is the system specific header for the SDL joystick API */
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
2006-07-10 21:04:37 +00:00
|
|
|
#include <limits.h> /* For the definition of PATH_MAX */
|
2001-04-26 16:45:43 +00:00
|
|
|
#include <linux/joystick.h>
|
|
|
|
|
|
|
|
#include "SDL_joystick.h"
|
2006-02-16 10:11:48 +00:00
|
|
|
#include "../SDL_sysjoystick.h"
|
|
|
|
#include "../SDL_joystick_c.h"
|
2008-08-25 09:55:03 +00:00
|
|
|
#include "SDL_sysjoystick_c.h"
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2002-12-02 03:11:36 +00:00
|
|
|
/* Special joystick configurations */
|
2006-07-10 21:04:37 +00:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int naxes;
|
|
|
|
int nhats;
|
|
|
|
int nballs;
|
2002-12-02 03:11:36 +00:00
|
|
|
} special_joysticks[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{
|
|
|
|
"MadCatz Panther XL", 3, 2, 1}, /* We don't handle rudder (axis 8) */
|
|
|
|
{
|
|
|
|
"SideWinder Precision Pro", 4, 1, 0}, {
|
|
|
|
"SideWinder 3D Pro", 4, 1, 0}, {
|
|
|
|
"Microsoft SideWinder 3D Pro", 4, 1, 0}, {
|
2007-06-14 13:21:29 +00:00
|
|
|
"Microsoft SideWinder Precision Pro", 4, 1, 0}, {
|
2006-07-10 21:04:37 +00:00
|
|
|
"Microsoft SideWinder Dual Strike USB version 1.0", 2, 1, 0}, {
|
|
|
|
"WingMan Interceptor", 3, 3, 0}, {
|
|
|
|
"WingMan Extreme Digital 3D", 4, 1, 0}, {
|
|
|
|
"Microsoft SideWinder Precision 2 Joystick", 4, 1, 0}, {
|
|
|
|
"Logitech Inc. WingMan Extreme Digital 3D", 4, 1, 0}, {
|
|
|
|
"Saitek Saitek X45", 6, 1, 0}
|
2001-04-26 16:45:43 +00:00
|
|
|
};
|
|
|
|
|
2009-09-29 00:42:21 +00:00
|
|
|
/* It looks like newer kernels have the logical mapping at the driver level */
|
|
|
|
#define NO_LOGICAL_JOYSTICKS
|
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
/*
|
|
|
|
Some USB HIDs show up as a single joystick even though they actually
|
|
|
|
control 2 or more joysticks.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
This code handles the MP-8800 (Quad) and MP-8866 (Dual), which can
|
|
|
|
be identified by their transparent blue design. It's quite trivial
|
|
|
|
to add other joysticks with similar quirky behavior.
|
|
|
|
-id
|
|
|
|
*/
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
struct joystick_logical_mapping
|
|
|
|
{
|
|
|
|
int njoy;
|
|
|
|
int nthing;
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
{logical joy, logical axis},
|
|
|
|
{logical joy, logical hat},
|
|
|
|
{logical joy, logical ball},
|
|
|
|
{logical joy, logical button}
|
|
|
|
*/
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
|
|
|
{0, 9}, {0, 10}, {0, 11}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
|
|
|
|
{1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
|
|
|
{0, 9}, {0, 10}, {0, 11},
|
|
|
|
{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
|
|
|
|
{1, 9}, {1, 10}, {1, 11}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
|
|
|
|
{1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3},
|
|
|
|
{0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
|
|
|
{0, 9}, {0, 10}, {0, 11},
|
|
|
|
{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
|
|
|
|
{1, 9}, {1, 10}, {1, 11},
|
|
|
|
{2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8},
|
|
|
|
{2, 9}, {2, 10}, {2, 11}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct joystick_logical_mapping mp88xx_4_logical_axismap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
|
|
|
|
{1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3},
|
|
|
|
{3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5},
|
|
|
|
{1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
|
|
|
{0, 9}, {0, 10}, {0, 11},
|
|
|
|
{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
|
|
|
|
{1, 9}, {1, 10}, {1, 11},
|
|
|
|
{2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8},
|
|
|
|
{2, 9}, {2, 10}, {2, 11},
|
|
|
|
{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8},
|
|
|
|
{3, 9}, {3, 10}, {3, 11}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
};
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
struct joystick_logical_layout
|
|
|
|
{
|
|
|
|
int naxes;
|
|
|
|
int nhats;
|
|
|
|
int nballs;
|
|
|
|
int nbuttons;
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct joystick_logical_layout mp88xx_1_logical_layout[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{6, 0, 0, 12}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_layout mp88xx_2_logical_layout[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_layout mp88xx_3_logical_layout[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12}
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
2008-08-27 15:10:03 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
static struct joystick_logical_layout mp88xx_4_logical_layout[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12},
|
|
|
|
{6, 0, 0, 12}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
This array sets up a means of mapping a single physical joystick to
|
|
|
|
multiple logical joysticks. (djm)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
|
|
|
njoys
|
|
|
|
the number of logical joysticks
|
|
|
|
|
|
|
|
layouts
|
|
|
|
an array of layout structures, one to describe each logical joystick
|
|
|
|
|
|
|
|
axes, hats, balls, buttons
|
|
|
|
arrays that map a physical thingy to a logical thingy
|
|
|
|
*/
|
2006-07-10 21:04:37 +00:00
|
|
|
struct joystick_logicalmap
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int nbuttons;
|
|
|
|
int njoys;
|
|
|
|
struct joystick_logical_layout *layout;
|
|
|
|
struct joystick_logical_mapping *axismap;
|
|
|
|
struct joystick_logical_mapping *hatmap;
|
|
|
|
struct joystick_logical_mapping *ballmap;
|
|
|
|
struct joystick_logical_mapping *buttonmap;
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct joystick_logicalmap joystick_logicalmap[] = {
|
2006-07-10 21:04:37 +00:00
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8866 Dual USB Joypad",
|
|
|
|
12,
|
|
|
|
1,
|
|
|
|
mp88xx_1_logical_layout,
|
|
|
|
mp88xx_1_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_1_logical_buttonmap},
|
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8866 Dual USB Joypad",
|
|
|
|
24,
|
|
|
|
2,
|
|
|
|
mp88xx_2_logical_layout,
|
|
|
|
mp88xx_2_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_2_logical_buttonmap},
|
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8800 Quad USB Joypad",
|
|
|
|
12,
|
|
|
|
1,
|
|
|
|
mp88xx_1_logical_layout,
|
|
|
|
mp88xx_1_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_1_logical_buttonmap},
|
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8800 Quad USB Joypad",
|
|
|
|
24,
|
|
|
|
2,
|
|
|
|
mp88xx_2_logical_layout,
|
|
|
|
mp88xx_2_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_2_logical_buttonmap},
|
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8800 Quad USB Joypad",
|
|
|
|
36,
|
|
|
|
3,
|
|
|
|
mp88xx_3_logical_layout,
|
|
|
|
mp88xx_3_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_3_logical_buttonmap},
|
|
|
|
{
|
|
|
|
"WiseGroup.,Ltd MP-8800 Quad USB Joypad",
|
|
|
|
48,
|
|
|
|
4,
|
|
|
|
mp88xx_4_logical_layout,
|
|
|
|
mp88xx_4_logical_axismap,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
mp88xx_4_logical_buttonmap}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* find the head of a linked list, given a point in it
|
|
|
|
*/
|
|
|
|
#define SDL_joylist_head(i, start)\
|
|
|
|
for(i = start; SDL_joylist[i].fname == NULL;) i = SDL_joylist[i].prev;
|
|
|
|
|
|
|
|
#define SDL_logical_joydecl(d) d
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define SDL_logical_joydecl(d)
|
|
|
|
|
|
|
|
#endif /* USE_LOGICAL_JOYSTICKS */
|
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
/* The maximum number of joysticks we'll detect */
|
|
|
|
#define MAX_JOYSTICKS 32
|
|
|
|
|
|
|
|
/* A list of available joysticks */
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
static struct
|
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
char *fname;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_Joystick *joy;
|
|
|
|
struct joystick_logicalmap *map;
|
|
|
|
int prev;
|
|
|
|
int next;
|
|
|
|
int logicalno;
|
|
|
|
#endif /* USE_LOGICAL_JOYSTICKS */
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
} SDL_joylist[MAX_JOYSTICKS];
|
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
CountLogicalJoysticks(int max)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
register int i, j, k, ret, prev;
|
|
|
|
const char *name;
|
|
|
|
int nbuttons, fd;
|
|
|
|
unsigned char n;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < max; i++) {
|
2012-11-26 16:37:54 -08:00
|
|
|
name = SDL_SYS_JoystickNameForIndex(i);
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
fd = open(SDL_joylist[i].fname, O_RDONLY, 0);
|
|
|
|
if (fd >= 0) {
|
|
|
|
if (ioctl(fd, JSIOCGBUTTONS, &n) < 0) {
|
|
|
|
nbuttons = -1;
|
|
|
|
} else {
|
|
|
|
nbuttons = n;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
} else {
|
|
|
|
nbuttons = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
for (j = 0; j < SDL_arraysize(joystick_logicalmap); j++) {
|
|
|
|
if (!SDL_strcmp(name, joystick_logicalmap[j].name)
|
|
|
|
&& (nbuttons == -1
|
|
|
|
|| nbuttons == joystick_logicalmap[j].nbuttons)) {
|
|
|
|
prev = i;
|
|
|
|
SDL_joylist[prev].map = &(joystick_logicalmap[j]);
|
|
|
|
|
|
|
|
for (k = 1; k < joystick_logicalmap[j].njoys; k++) {
|
|
|
|
SDL_joylist[prev].next = max + ret;
|
|
|
|
SDL_joylist[max + ret].prev = prev;
|
|
|
|
|
|
|
|
prev = max + ret;
|
|
|
|
SDL_joylist[prev].logicalno = k;
|
|
|
|
SDL_joylist[prev].map = &(joystick_logicalmap[j]);
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
return ret;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static void
|
|
|
|
LogicalSuffix(int logicalno, char *namebuf, int len)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
register int slen;
|
|
|
|
const static char suffixs[] =
|
|
|
|
"01020304050607080910111213141516171819" "20212223242526272829303132";
|
|
|
|
const char *suffix;
|
|
|
|
slen = SDL_strlen(namebuf);
|
|
|
|
suffix = NULL;
|
|
|
|
|
|
|
|
if (logicalno * 2 < sizeof(suffixs))
|
|
|
|
suffix = suffixs + (logicalno * 2);
|
|
|
|
|
|
|
|
if (slen + 4 < len && suffix) {
|
|
|
|
namebuf[slen++] = ' ';
|
|
|
|
namebuf[slen++] = '#';
|
|
|
|
namebuf[slen++] = suffix[0];
|
|
|
|
namebuf[slen++] = suffix[1];
|
|
|
|
namebuf[slen++] = 0;
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* USE_LOGICAL_JOYSTICKS */
|
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2001-04-26 16:45:43 +00:00
|
|
|
#define test_bit(nr, addr) \
|
2009-10-18 16:14:35 +00:00
|
|
|
(((1UL << ((nr) % (sizeof(long) * 8))) & ((addr)[(nr) / (sizeof(long) * 8)])) != 0)
|
|
|
|
#define NBITS(x) ((((x)-1)/(sizeof(long) * 8))+1)
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
EV_IsJoystick(int fd)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2009-10-18 16:14:35 +00:00
|
|
|
unsigned long evbit[NBITS(EV_MAX)] = { 0 };
|
|
|
|
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
|
|
|
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
|
|
|
|
(ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
|
|
|
|
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) {
|
|
|
|
return (0);
|
|
|
|
}
|
2009-02-21 18:02:55 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
|
2009-02-21 18:02:55 +00:00
|
|
|
test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) {
|
2006-07-10 21:04:37 +00:00
|
|
|
return 0;
|
2009-02-21 18:02:55 +00:00
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
return (1);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#endif /* SDL_INPUT_LINUXEV */
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2012-11-26 22:27:49 -08:00
|
|
|
static int SDL_SYS_numjoysticks = 0;
|
2012-11-26 16:37:54 -08:00
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
/* Function to scan the system for joysticks */
|
2006-07-10 21:04:37 +00:00
|
|
|
int
|
|
|
|
SDL_SYS_JoystickInit(void)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
/* The base path of the joystick devices */
|
|
|
|
const char *joydev_pattern[] = {
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
"/dev/input/event%d",
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
"/dev/input/js%d",
|
|
|
|
"/dev/js%d"
|
|
|
|
};
|
|
|
|
int numjoysticks;
|
|
|
|
int i, j;
|
|
|
|
int fd;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
dev_t dev_nums[MAX_JOYSTICKS]; /* major/minor device numbers */
|
|
|
|
struct stat sb;
|
|
|
|
int n, duplicate;
|
|
|
|
|
|
|
|
numjoysticks = 0;
|
|
|
|
|
2011-02-16 04:51:13 -08:00
|
|
|
/* First see if the user specified one or more joysticks to use */
|
2006-07-10 21:04:37 +00:00
|
|
|
if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) {
|
2011-02-16 04:51:13 -08:00
|
|
|
char *envcopy, *envpath, *delim;
|
|
|
|
envcopy = SDL_strdup(SDL_getenv("SDL_JOYSTICK_DEVICE"));
|
|
|
|
envpath = envcopy;
|
|
|
|
while (envpath != NULL) {
|
|
|
|
delim = SDL_strchr(envpath, ':');
|
|
|
|
if (delim != NULL) {
|
|
|
|
*delim++ = '\0';
|
|
|
|
}
|
|
|
|
if (stat(envpath, &sb) == 0) {
|
|
|
|
fd = open(envpath, O_RDONLY, 0);
|
|
|
|
if (fd >= 0) {
|
|
|
|
/* Assume the user knows what they're doing. */
|
|
|
|
SDL_joylist[numjoysticks].fname = SDL_strdup(envpath);
|
|
|
|
if (SDL_joylist[numjoysticks].fname) {
|
|
|
|
dev_nums[numjoysticks] = sb.st_rdev;
|
|
|
|
++numjoysticks;
|
|
|
|
}
|
|
|
|
close(fd);
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-16 04:51:13 -08:00
|
|
|
envpath = delim;
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
2011-02-16 04:51:13 -08:00
|
|
|
SDL_free(envcopy);
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < SDL_arraysize(joydev_pattern); ++i) {
|
|
|
|
for (j = 0; j < MAX_JOYSTICKS; ++j) {
|
|
|
|
SDL_snprintf(path, SDL_arraysize(path), joydev_pattern[i], j);
|
|
|
|
|
|
|
|
/* rcg06302000 replaced access(F_OK) call with stat().
|
|
|
|
* stat() will fail if the file doesn't exist, so it's
|
|
|
|
* equivalent behaviour.
|
|
|
|
*/
|
|
|
|
if (stat(path, &sb) == 0) {
|
|
|
|
/* Check to make sure it's not already in list.
|
|
|
|
* This happens when we see a stick via symlink.
|
|
|
|
*/
|
|
|
|
duplicate = 0;
|
|
|
|
for (n = 0; (n < numjoysticks) && !duplicate; ++n) {
|
|
|
|
if (sb.st_rdev == dev_nums[n]) {
|
|
|
|
duplicate = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (duplicate) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fd = open(path, O_RDONLY, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef DEBUG_INPUT_EVENTS
|
2006-07-10 21:04:37 +00:00
|
|
|
printf("Checking %s\n", path);
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
if ((i == 0) && !EV_IsJoystick(fd)) {
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
close(fd);
|
|
|
|
|
|
|
|
/* We're fine, add this joystick */
|
|
|
|
SDL_joylist[numjoysticks].fname = SDL_strdup(path);
|
|
|
|
if (SDL_joylist[numjoysticks].fname) {
|
|
|
|
dev_nums[numjoysticks] = sb.st_rdev;
|
|
|
|
++numjoysticks;
|
|
|
|
}
|
2007-12-29 06:17:31 +00:00
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
2002-12-02 03:11:36 +00:00
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
/* This is a special case...
|
|
|
|
If the event devices are valid then the joystick devices
|
|
|
|
will be duplicates but without extra information about their
|
|
|
|
hats or balls. Unfortunately, the event devices can't
|
|
|
|
currently be calibrated, so it's a win-lose situation.
|
2012-11-26 16:37:54 -08:00
|
|
|
So : /dev/input/eventX = /dev/input/jsY = /dev/js
|
2006-07-10 21:04:37 +00:00
|
|
|
*/
|
|
|
|
if ((i == 0) && (numjoysticks > 0))
|
|
|
|
break;
|
2002-12-02 03:11:36 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
numjoysticks += CountLogicalJoysticks(numjoysticks);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2002-12-02 03:11:36 +00:00
|
|
|
|
2012-11-26 16:37:54 -08:00
|
|
|
SDL_SYS_numjoysticks = numjoysticks;
|
2006-07-10 21:04:37 +00:00
|
|
|
return (numjoysticks);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to get the device-dependent name of a joystick */
|
2006-07-10 21:04:37 +00:00
|
|
|
const char *
|
2012-11-26 16:37:54 -08:00
|
|
|
SDL_SYS_JoystickNameForIndex(int index)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int fd;
|
|
|
|
static char namebuf[128];
|
2012-11-26 21:11:28 -08:00
|
|
|
const char *name;
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_logical_joydecl(int oindex = index);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_joylist_head(index, index);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
name = NULL;
|
|
|
|
fd = open(SDL_joylist[index].fname, O_RDONLY, 0);
|
|
|
|
if (fd >= 0) {
|
|
|
|
if (
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
(ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) &&
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
(ioctl(fd, JSIOCGNAME(sizeof(namebuf)), namebuf) <= 0)) {
|
|
|
|
name = SDL_joylist[index].fname;
|
|
|
|
} else {
|
|
|
|
name = namebuf;
|
|
|
|
}
|
|
|
|
close(fd);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
Fixed bug #4
[Note: I'm applying this patch since it's a cleaner version of what's already implemented, and supports this controller on older kernels. I'll ask to make sure this doesn't break on the new kernels where it's no longer necessary]
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson
Subject: SDL Patch
Hey, Ryan.
I submitted the following patch about a year ago. It's just a simple
patch for the linux port, to make multiple joysticks each appear to SDL
as their own device, if they are on the same USB port (specifically,
these guys
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,
which allow 4 Playstation2 controllers to be accessed via a single USB
port). Without this patch, SDL pretty much drops the ball, and reports
that there are 4 joysticks available when less than that number are
plugged in.
My work built upon the work of another person with the same device. When
I submitted the patch to the list, he tested it, but it didn't work for
him, so the patch was never accepted. Maybe about 3 times in the past
year, I've tried to email the guy, to see if he couldn't run my new
version, complete with debug code to diagnose the problem he was having.
He never got back to me.
So, I'm attaching the patch. I wish I knew why it didn't work for him,
but I've been using it for the last year with no problems. Let me know
if you need any more information, or have any ideas as to how I could
test it. I'd like to see it in the tree, but I want to make sure it works.
-Chris
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401555
2006-03-19 06:31:34 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (SDL_joylist[oindex].prev || SDL_joylist[oindex].next
|
|
|
|
|| index != oindex) {
|
|
|
|
LogicalSuffix(SDL_joylist[oindex].logicalno, namebuf, 128);
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
|
|
|
return name;
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
allocate_hatdata(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
joystick->hwdata->hats =
|
|
|
|
(struct hwdata_hat *) SDL_malloc(joystick->nhats *
|
|
|
|
sizeof(struct hwdata_hat));
|
|
|
|
if (joystick->hwdata->hats == NULL) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
for (i = 0; i < joystick->nhats; ++i) {
|
|
|
|
joystick->hwdata->hats[i].axis[0] = 1;
|
|
|
|
joystick->hwdata->hats[i].axis[1] = 1;
|
|
|
|
}
|
|
|
|
return (0);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
allocate_balldata(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
joystick->hwdata->balls =
|
|
|
|
(struct hwdata_ball *) SDL_malloc(joystick->nballs *
|
|
|
|
sizeof(struct hwdata_ball));
|
|
|
|
if (joystick->hwdata->balls == NULL) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
for (i = 0; i < joystick->nballs; ++i) {
|
|
|
|
joystick->hwdata->balls[i].axis[0] = 0;
|
|
|
|
joystick->hwdata->balls[i].axis[1] = 0;
|
|
|
|
}
|
|
|
|
return (0);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static SDL_bool
|
|
|
|
JS_ConfigJoystick(SDL_Joystick * joystick, int fd)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_bool handled;
|
|
|
|
unsigned char n;
|
2012-08-09 14:14:41 -04:00
|
|
|
int tmp_naxes, tmp_nhats, tmp_nballs;
|
2006-07-10 21:04:37 +00:00
|
|
|
const char *name;
|
|
|
|
char *env, env_name[128];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
handled = SDL_FALSE;
|
|
|
|
|
|
|
|
/* Default joystick device settings */
|
|
|
|
if (ioctl(fd, JSIOCGAXES, &n) < 0) {
|
|
|
|
joystick->naxes = 2;
|
|
|
|
} else {
|
|
|
|
joystick->naxes = n;
|
|
|
|
}
|
|
|
|
if (ioctl(fd, JSIOCGBUTTONS, &n) < 0) {
|
|
|
|
joystick->nbuttons = 2;
|
|
|
|
} else {
|
|
|
|
joystick->nbuttons = n;
|
|
|
|
}
|
|
|
|
|
2012-11-26 16:37:54 -08:00
|
|
|
name = SDL_SYS_JoystickNameForIndex(joystick->instance_id);
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* Generic analog joystick support */
|
|
|
|
if (SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat")) {
|
|
|
|
if (SDL_sscanf(name, "Analog %d-axis %*d-button %d-hat",
|
|
|
|
&tmp_naxes, &tmp_nhats) == 2) {
|
|
|
|
|
|
|
|
joystick->naxes = tmp_naxes;
|
|
|
|
joystick->nhats = tmp_nhats;
|
|
|
|
|
|
|
|
handled = SDL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Special joystick support */
|
|
|
|
for (i = 0; i < SDL_arraysize(special_joysticks); ++i) {
|
|
|
|
if (SDL_strcmp(name, special_joysticks[i].name) == 0) {
|
|
|
|
|
|
|
|
joystick->naxes = special_joysticks[i].naxes;
|
|
|
|
joystick->nhats = special_joysticks[i].nhats;
|
|
|
|
joystick->nballs = special_joysticks[i].nballs;
|
|
|
|
|
|
|
|
handled = SDL_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* User environment joystick support */
|
|
|
|
if ((env = SDL_getenv("SDL_LINUX_JOYSTICK"))) {
|
|
|
|
*env_name = '\0';
|
|
|
|
if (*env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1)
|
|
|
|
env += SDL_strlen(env_name) + 2;
|
|
|
|
else if (SDL_sscanf(env, "%s", env_name) == 1)
|
|
|
|
env += SDL_strlen(env_name);
|
|
|
|
|
|
|
|
if (SDL_strcmp(name, env_name) == 0) {
|
|
|
|
|
|
|
|
if (SDL_sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats,
|
|
|
|
&tmp_nballs) == 3) {
|
|
|
|
|
|
|
|
joystick->naxes = tmp_naxes;
|
|
|
|
joystick->nhats = tmp_nhats;
|
|
|
|
joystick->nballs = tmp_nballs;
|
|
|
|
|
|
|
|
handled = SDL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remap hats and balls */
|
|
|
|
if (handled) {
|
|
|
|
if (joystick->nhats > 0) {
|
|
|
|
if (allocate_hatdata(joystick) < 0) {
|
|
|
|
joystick->nhats = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (joystick->nballs > 0) {
|
|
|
|
if (allocate_balldata(joystick) < 0) {
|
|
|
|
joystick->nballs = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (handled);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static SDL_bool
|
|
|
|
EV_ConfigJoystick(SDL_Joystick * joystick, int fd)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int i, t;
|
2009-10-18 16:14:35 +00:00
|
|
|
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
|
|
|
|
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
|
|
|
|
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* See if this device uses the new unified event API */
|
|
|
|
if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
|
|
|
|
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
|
|
|
|
(ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0)) {
|
|
|
|
joystick->hwdata->is_hid = SDL_TRUE;
|
|
|
|
|
|
|
|
/* Get the number of buttons, axes, and other thingamajigs */
|
|
|
|
for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
|
|
|
|
if (test_bit(i, keybit)) {
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef DEBUG_INPUT_EVENTS
|
2006-07-10 21:04:37 +00:00
|
|
|
printf("Joystick has button: 0x%x\n", i);
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
|
|
|
|
++joystick->nbuttons;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
|
|
|
|
if (test_bit(i, keybit)) {
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef DEBUG_INPUT_EVENTS
|
2006-07-10 21:04:37 +00:00
|
|
|
printf("Joystick has button: 0x%x\n", i);
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons;
|
|
|
|
++joystick->nbuttons;
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 17:38:09 -07:00
|
|
|
for (i = 0; i < ABS_MISC; ++i) {
|
2006-07-10 21:04:37 +00:00
|
|
|
/* Skip hats */
|
|
|
|
if (i == ABS_HAT0X) {
|
|
|
|
i = ABS_HAT3Y;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (test_bit(i, absbit)) {
|
2011-01-24 14:36:12 -08:00
|
|
|
struct input_absinfo absinfo;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
2011-01-24 15:10:16 -08:00
|
|
|
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0)
|
2006-07-10 21:04:37 +00:00
|
|
|
continue;
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef DEBUG_INPUT_EVENTS
|
2006-07-10 21:04:37 +00:00
|
|
|
printf("Joystick has absolute axis: %x\n", i);
|
|
|
|
printf("Values = { %d, %d, %d, %d, %d }\n",
|
2011-01-24 14:36:12 -08:00
|
|
|
absinfo.value, absinfo.minimum, absinfo.maximum,
|
|
|
|
absinfo.fuzz, absinfo.flat);
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif /* DEBUG_INPUT_EVENTS */
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata->abs_map[i] = joystick->naxes;
|
2011-01-24 14:36:12 -08:00
|
|
|
if (absinfo.minimum == absinfo.maximum) {
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata->abs_correct[i].used = 0;
|
|
|
|
} else {
|
|
|
|
joystick->hwdata->abs_correct[i].used = 1;
|
|
|
|
joystick->hwdata->abs_correct[i].coef[0] =
|
2011-01-24 14:36:12 -08:00
|
|
|
(absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata->abs_correct[i].coef[1] =
|
2011-01-24 14:36:12 -08:00
|
|
|
(absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
|
|
|
|
t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
|
2006-07-10 21:04:37 +00:00
|
|
|
if (t != 0) {
|
|
|
|
joystick->hwdata->abs_correct[i].coef[2] =
|
|
|
|
(1 << 29) / t;
|
|
|
|
} else {
|
|
|
|
joystick->hwdata->abs_correct[i].coef[2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++joystick->naxes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
|
|
|
|
if (test_bit(i, absbit) || test_bit(i + 1, absbit)) {
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef DEBUG_INPUT_EVENTS
|
2006-07-10 21:04:37 +00:00
|
|
|
printf("Joystick has hat %d\n", (i - ABS_HAT0X) / 2);
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
++joystick->nhats;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (test_bit(REL_X, relbit) || test_bit(REL_Y, relbit)) {
|
|
|
|
++joystick->nballs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate data to keep track of these thingamajigs */
|
|
|
|
if (joystick->nhats > 0) {
|
|
|
|
if (allocate_hatdata(joystick) < 0) {
|
|
|
|
joystick->nhats = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (joystick->nballs > 0) {
|
|
|
|
if (allocate_balldata(joystick) < 0) {
|
|
|
|
joystick->nballs = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (joystick->hwdata->is_hid);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#endif /* SDL_INPUT_LINUXEV */
|
2001-04-26 16:45:43 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
static void
|
|
|
|
ConfigLogicalJoystick(SDL_Joystick * joystick)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct joystick_logical_layout *layout;
|
|
|
|
|
2012-11-26 16:37:54 -08:00
|
|
|
layout = SDL_joylist[joystick->instance_id].map->layout +
|
|
|
|
SDL_joylist[joystick->instance_id].logicalno;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
joystick->nbuttons = layout->nbuttons;
|
|
|
|
joystick->nhats = layout->nhats;
|
|
|
|
joystick->naxes = layout->naxes;
|
|
|
|
joystick->nballs = layout->nballs;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
/* Function to open a joystick for use.
|
|
|
|
The joystick to open is specified by the index field of the joystick.
|
|
|
|
This should fill the nbuttons and naxes fields of the joystick structure.
|
|
|
|
It returns 0, or -1 if there is an error.
|
|
|
|
*/
|
2006-07-10 21:04:37 +00:00
|
|
|
int
|
2012-11-26 16:37:54 -08:00
|
|
|
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int fd;
|
2008-08-25 09:55:03 +00:00
|
|
|
char *fname;
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_logical_joydecl(int realindex);
|
|
|
|
SDL_logical_joydecl(SDL_Joystick * realjoy = NULL);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* Open the joystick and set the joystick file descriptor */
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
|
|
|
SDL_joylist_head(realindex, joystick->instance_id);
|
2006-07-10 21:04:37 +00:00
|
|
|
realjoy = SDL_JoystickOpen(realindex);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (realjoy == NULL)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
fd = realjoy->hwdata->fd;
|
2008-08-25 09:55:03 +00:00
|
|
|
fname = realjoy->hwdata->fname;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
} else {
|
2012-11-26 16:37:54 -08:00
|
|
|
fd = open(SDL_joylist[joystick->instance_id].fname, O_RDONLY, 0);
|
|
|
|
fname = SDL_joylist[joystick->instance_id].fname;
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
2012-11-26 16:37:54 -08:00
|
|
|
SDL_joylist[joystick->instance_id].joy = joystick;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#else
|
2012-11-26 16:37:54 -08:00
|
|
|
fd = open(SDL_joylist[joystick->instance_id].fname, O_RDONLY, 0);
|
|
|
|
fname = SDL_joylist[joystick->instance_id].fname;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (fd < 0) {
|
2012-11-26 16:37:54 -08:00
|
|
|
SDL_SetError("Unable to open %s\n", SDL_joylist[joystick->instance_id]);
|
2006-07-10 21:04:37 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2012-11-26 22:27:49 -08:00
|
|
|
joystick->instance_id = device_index;
|
2006-07-10 21:04:37 +00:00
|
|
|
joystick->hwdata = (struct joystick_hwdata *)
|
|
|
|
SDL_malloc(sizeof(*joystick->hwdata));
|
|
|
|
if (joystick->hwdata == NULL) {
|
|
|
|
SDL_OutOfMemory();
|
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
|
|
|
joystick->hwdata->fd = fd;
|
2008-08-25 09:55:03 +00:00
|
|
|
joystick->hwdata->fname = fname;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* Set the joystick to non-blocking read mode */
|
|
|
|
fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
|
|
|
|
|
|
/* Get the number of buttons and axes on the joystick */
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (realjoy)
|
|
|
|
ConfigLogicalJoystick(joystick);
|
|
|
|
else
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!EV_ConfigJoystick(joystick, fd))
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
JS_ConfigJoystick(joystick, fd);
|
2002-12-02 03:11:36 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
return (0);
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static SDL_Joystick *
|
|
|
|
FindLogicalJoystick(SDL_Joystick * joystick,
|
|
|
|
struct joystick_logical_mapping *v)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_Joystick *logicaljoy;
|
|
|
|
register int i;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2012-11-26 16:37:54 -08:00
|
|
|
i = joystick->instance_id;
|
2006-07-10 21:04:37 +00:00
|
|
|
logicaljoy = NULL;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* get the fake joystick that will receive the event
|
|
|
|
*/
|
|
|
|
for (;;) {
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (SDL_joylist[i].logicalno == v->njoy) {
|
|
|
|
logicaljoy = SDL_joylist[i].joy;
|
|
|
|
break;
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (SDL_joylist[i].next == 0)
|
|
|
|
break;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
i = SDL_joylist[i].next;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
return logicaljoy;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
LogicalJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
|
|
|
|
{
|
|
|
|
struct joystick_logical_mapping *buttons;
|
|
|
|
SDL_Joystick *logicaljoy = NULL;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* if there's no map then this is just a regular joystick
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].map == NULL)
|
2006-07-10 21:04:37 +00:00
|
|
|
return 0;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* get the logical joystick that will receive the event
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
buttons = SDL_joylist[joystick->instance_id].map->buttonmap + button;
|
2006-07-10 21:04:37 +00:00
|
|
|
logicaljoy = FindLogicalJoystick(joystick, buttons);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (logicaljoy == NULL)
|
|
|
|
return 1;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickButton(logicaljoy, buttons->nthing, state);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
return 1;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static int
|
|
|
|
LogicalJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct joystick_logical_mapping *axes;
|
|
|
|
SDL_Joystick *logicaljoy = NULL;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* if there's no map then this is just a regular joystick
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].map == NULL)
|
2006-07-10 21:04:37 +00:00
|
|
|
return 0;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* get the logical joystick that will receive the event
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
axes = SDL_joylist[joystick->instance_id].map->axismap + axis;
|
2006-07-10 21:04:37 +00:00
|
|
|
logicaljoy = FindLogicalJoystick(joystick, axes);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (logicaljoy == NULL)
|
|
|
|
return 1;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickAxis(logicaljoy, axes->nthing, value);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
return 1;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
}
|
|
|
|
#endif /* USE_LOGICAL_JOYSTICKS */
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static __inline__ void
|
|
|
|
HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct hwdata_hat *the_hat;
|
|
|
|
const Uint8 position_map[3][3] = {
|
|
|
|
{SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP},
|
|
|
|
{SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT},
|
|
|
|
{SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN}
|
|
|
|
};
|
|
|
|
SDL_logical_joydecl(SDL_Joystick * logicaljoy = NULL);
|
|
|
|
SDL_logical_joydecl(struct joystick_logical_mapping *hats = NULL);
|
|
|
|
|
|
|
|
the_hat = &stick->hwdata->hats[hat];
|
|
|
|
if (value < 0) {
|
|
|
|
value = 0;
|
|
|
|
} else if (value == 0) {
|
|
|
|
value = 1;
|
|
|
|
} else if (value > 0) {
|
|
|
|
value = 2;
|
|
|
|
}
|
|
|
|
if (value != the_hat->axis[axis]) {
|
|
|
|
the_hat->axis[axis] = value;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
|
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
/* if there's no map then this is just a regular joystick
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[stick->instance_id].map != NULL) {
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* get the fake joystick that will receive the event
|
|
|
|
*/
|
2012-11-26 16:37:54 -08:00
|
|
|
hats = SDL_joylist[stick->instance_id].map->hatmap + hat;
|
2006-07-10 21:04:37 +00:00
|
|
|
logicaljoy = FindLogicalJoystick(stick, hats);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (logicaljoy) {
|
|
|
|
stick = logicaljoy;
|
|
|
|
hat = hats->nthing;
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif /* USE_LOGICAL_JOYSTICKS */
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickHat(stick, hat,
|
2009-01-10 21:50:26 +00:00
|
|
|
position_map[the_hat->
|
|
|
|
axis[1]][the_hat->axis[0]]);
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static __inline__ void
|
|
|
|
HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
stick->hwdata->balls[ball].axis[axis] += value;
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to update the state of a joystick - called as a device poll.
|
|
|
|
* This function shouldn't update the joystick structure directly,
|
|
|
|
* but instead should call SDL_PrivateJoystick*() to deliver events
|
|
|
|
* and update joystick device state.
|
|
|
|
*/
|
2006-07-10 21:04:37 +00:00
|
|
|
static __inline__ void
|
|
|
|
JS_HandleEvents(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct js_event events[32];
|
|
|
|
int i, len;
|
|
|
|
Uint8 other_axis;
|
2001-04-26 16:45:43 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
|
|
|
SDL_joylist_head(i, joystick->instance_id);
|
2006-07-10 21:04:37 +00:00
|
|
|
JS_HandleEvents(SDL_joylist[i].joy);
|
|
|
|
return;
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
|
|
|
|
len /= sizeof(events[0]);
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
switch (events[i].type & ~JS_EVENT_INIT) {
|
|
|
|
case JS_EVENT_AXIS:
|
|
|
|
if (events[i].number < joystick->naxes) {
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!LogicalJoystickAxis(joystick,
|
|
|
|
events[i].number,
|
|
|
|
events[i].value))
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickAxis(joystick,
|
|
|
|
events[i].number,
|
|
|
|
events[i].value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
events[i].number -= joystick->naxes;
|
|
|
|
other_axis = (events[i].number / 2);
|
|
|
|
if (other_axis < joystick->nhats) {
|
|
|
|
HandleHat(joystick, other_axis,
|
|
|
|
events[i].number % 2, events[i].value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
events[i].number -= joystick->nhats * 2;
|
|
|
|
other_axis = (events[i].number / 2);
|
|
|
|
if (other_axis < joystick->nballs) {
|
|
|
|
HandleBall(joystick, other_axis,
|
|
|
|
events[i].number % 2, events[i].value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JS_EVENT_BUTTON:
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!LogicalJoystickButton(joystick,
|
|
|
|
events[i].number, events[i].value))
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickButton(joystick,
|
|
|
|
events[i].number,
|
|
|
|
events[i].value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ?? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
static __inline__ int
|
|
|
|
EV_AxisCorrect(SDL_Joystick * joystick, int which, int value)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct axis_correct *correct;
|
|
|
|
|
|
|
|
correct = &joystick->hwdata->abs_correct[which];
|
|
|
|
if (correct->used) {
|
|
|
|
if (value > correct->coef[0]) {
|
|
|
|
if (value < correct->coef[1]) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
value -= correct->coef[1];
|
|
|
|
} else {
|
|
|
|
value -= correct->coef[0];
|
|
|
|
}
|
|
|
|
value *= correct->coef[2];
|
|
|
|
value >>= 14;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clamp and return */
|
|
|
|
if (value < -32768)
|
|
|
|
return -32768;
|
|
|
|
if (value > 32767)
|
|
|
|
return 32767;
|
|
|
|
|
|
|
|
return value;
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
static __inline__ void
|
|
|
|
EV_HandleEvents(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
struct input_event events[32];
|
|
|
|
int i, len;
|
|
|
|
int code;
|
2001-04-26 16:45:43 +00:00
|
|
|
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
|
|
|
SDL_joylist_head(i, joystick->instance_id);
|
2006-07-10 21:04:37 +00:00
|
|
|
return EV_HandleEvents(SDL_joylist[i].joy);
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
|
|
|
|
len /= sizeof(events[0]);
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
code = events[i].code;
|
|
|
|
switch (events[i].type) {
|
|
|
|
case EV_KEY:
|
|
|
|
if (code >= BTN_MISC) {
|
|
|
|
code -= BTN_MISC;
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!LogicalJoystickButton(joystick,
|
2009-01-10 21:50:26 +00:00
|
|
|
joystick->
|
|
|
|
hwdata->key_map[code],
|
2006-07-10 21:04:37 +00:00
|
|
|
events[i].value))
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickButton(joystick,
|
2009-01-10 21:50:26 +00:00
|
|
|
joystick->
|
|
|
|
hwdata->key_map[code],
|
2006-07-10 21:04:37 +00:00
|
|
|
events[i].value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EV_ABS:
|
2012-06-03 05:05:34 -04:00
|
|
|
if (code >= ABS_MISC) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
switch (code) {
|
|
|
|
case ABS_HAT0X:
|
|
|
|
case ABS_HAT0Y:
|
|
|
|
case ABS_HAT1X:
|
|
|
|
case ABS_HAT1Y:
|
|
|
|
case ABS_HAT2X:
|
|
|
|
case ABS_HAT2Y:
|
|
|
|
case ABS_HAT3X:
|
|
|
|
case ABS_HAT3Y:
|
|
|
|
code -= ABS_HAT0X;
|
|
|
|
HandleHat(joystick, code / 2, code % 2, events[i].value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
events[i].value =
|
|
|
|
EV_AxisCorrect(joystick, code, events[i].value);
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
if (!LogicalJoystickAxis(joystick,
|
2008-08-27 15:10:03 +00:00
|
|
|
joystick->hwdata->abs_map[code],
|
|
|
|
events[i].value))
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_PrivateJoystickAxis(joystick,
|
2009-01-10 21:50:26 +00:00
|
|
|
joystick->
|
|
|
|
hwdata->abs_map[code],
|
2006-07-10 21:04:37 +00:00
|
|
|
events[i].value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EV_REL:
|
|
|
|
switch (code) {
|
|
|
|
case REL_X:
|
|
|
|
case REL_Y:
|
|
|
|
code -= REL_X;
|
|
|
|
HandleBall(joystick, code / 2, code % 2, events[i].value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
2006-02-16 10:11:48 +00:00
|
|
|
#endif /* SDL_INPUT_LINUXEV */
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
void
|
|
|
|
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int i;
|
|
|
|
|
2006-02-16 10:11:48 +00:00
|
|
|
#if SDL_INPUT_LINUXEV
|
2006-07-10 21:04:37 +00:00
|
|
|
if (joystick->hwdata->is_hid)
|
|
|
|
EV_HandleEvents(joystick);
|
|
|
|
else
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
JS_HandleEvents(joystick);
|
|
|
|
|
|
|
|
/* Deliver ball motion updates */
|
|
|
|
for (i = 0; i < joystick->nballs; ++i) {
|
|
|
|
int xrel, yrel;
|
|
|
|
|
|
|
|
xrel = joystick->hwdata->balls[i].axis[0];
|
|
|
|
yrel = joystick->hwdata->balls[i].axis[1];
|
|
|
|
if (xrel || yrel) {
|
|
|
|
joystick->hwdata->balls[i].axis[0] = 0;
|
|
|
|
joystick->hwdata->balls[i].axis[1] = 0;
|
|
|
|
SDL_PrivateJoystickBall(joystick, (Uint8) i, xrel, yrel);
|
|
|
|
}
|
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to close a joystick after use */
|
2006-07-10 21:04:37 +00:00
|
|
|
void
|
|
|
|
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2006-07-10 21:04:37 +00:00
|
|
|
register int i;
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].fname == NULL) {
|
|
|
|
SDL_joylist_head(i, joystick->instance_id);
|
2006-07-10 21:04:37 +00:00
|
|
|
SDL_JoystickClose(SDL_joylist[i].joy);
|
|
|
|
}
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
if (joystick->hwdata) {
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#ifndef NO_LOGICAL_JOYSTICKS
|
2012-11-26 16:37:54 -08:00
|
|
|
if (SDL_joylist[joystick->instance_id].fname != NULL)
|
Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT)
From: David MacCormack
Subject: [SDL] Linux joystick patch
I recently got myself a PS2 -> USB converter (a super joybox 5). It
accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice
because it doesn't require its own driver, but the problem is that it's
implemented as a *single* HID -- that is, it shows up as a single
joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a
number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and
see only a single (physical) joystick even though there are really 4
(logical) joysticks. There are a number of these types of devices on the
market, and I've seen others post messages (in the zsnes forum, for
example) with the same problem, so I came up with what I think is a pretty
generic solution.
I patched src/joystick/linux/SDL_sysjoystic.c to include support for
logical joysticks; basically, it's a static array and supporting functions
that map a single physical joystick to multiple logical joysticks. The
attached patch has the new code. It's wrapped inside #ifndef
statements so that you can get the old behavior if you want.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40893
2004-05-16 18:46:24 +00:00
|
|
|
#endif
|
2006-07-10 21:04:37 +00:00
|
|
|
close(joystick->hwdata->fd);
|
|
|
|
if (joystick->hwdata->hats) {
|
|
|
|
SDL_free(joystick->hwdata->hats);
|
|
|
|
}
|
|
|
|
if (joystick->hwdata->balls) {
|
|
|
|
SDL_free(joystick->hwdata->balls);
|
|
|
|
}
|
|
|
|
SDL_free(joystick->hwdata);
|
|
|
|
joystick->hwdata = NULL;
|
|
|
|
}
|
2012-11-26 16:37:54 -08:00
|
|
|
joystick->closed = 1;
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to perform any system-specific joystick related cleanup */
|
2006-07-10 21:04:37 +00:00
|
|
|
void
|
|
|
|
SDL_SYS_JoystickQuit(void)
|
2001-04-26 16:45:43 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int i;
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
for (i = 0; SDL_joylist[i].fname; ++i) {
|
2009-03-06 05:53:33 +00:00
|
|
|
if (SDL_joylist[i].fname) {
|
|
|
|
SDL_free(SDL_joylist[i].fname);
|
|
|
|
SDL_joylist[i].fname = NULL;
|
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
}
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 16:37:54 -08:00
|
|
|
/* Function to perform the mapping from device index to the instance id for this index */
|
|
|
|
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
|
|
|
|
{
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Function to determine is this joystick is attached to the system right now */
|
|
|
|
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
|
|
|
{
|
2012-11-26 21:11:28 -08:00
|
|
|
return 1;
|
2012-11-26 16:37:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int SDL_SYS_NumJoysticks()
|
|
|
|
{
|
|
|
|
return SDL_SYS_numjoysticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDL_SYS_JoystickNeedsPolling()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDL_SYS_JoystickDetect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:11:28 -08:00
|
|
|
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
|
2012-11-26 16:37:54 -08:00
|
|
|
{
|
2012-11-26 21:11:28 -08:00
|
|
|
JoystickGUID guid;
|
2012-11-26 16:37:54 -08:00
|
|
|
// the GUID is just the first 16 chars of the name for now
|
|
|
|
const char *name = SDL_SYS_JoystickNameForIndex( device_index );
|
2012-11-26 21:11:28 -08:00
|
|
|
SDL_zero( guid );
|
|
|
|
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
|
2012-11-26 16:37:54 -08:00
|
|
|
return guid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
|
|
|
|
{
|
2012-11-26 21:11:28 -08:00
|
|
|
JoystickGUID guid;
|
2012-11-26 16:37:54 -08:00
|
|
|
// the GUID is just the first 16 chars of the name for now
|
2012-11-26 21:11:28 -08:00
|
|
|
const char *name = joystick->name;
|
|
|
|
SDL_zero( guid );
|
|
|
|
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
|
2012-11-26 16:37:54 -08:00
|
|
|
return guid;
|
|
|
|
}
|
|
|
|
|
2006-04-14 04:46:47 +00:00
|
|
|
#endif /* SDL_JOYSTICK_LINUX */
|
2012-11-26 21:11:28 -08:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|