Previous Thread
Next Thread
Print Thread
#109858 - 06/09/17 09:46 PM Joystick on apple2e not working on Ubuntu 16.04  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
I have a CH products mach 3 PC joystick on an Alfadata USB to Gameport adapter so I can play games with that "old apple2 feel."

lsusb tells me that it's:
Bus 001 Device 007: ID 079d:0201 Alfadata Computer Corp. GamePort Adapter

I installed jstest-gtk and it comes up fine with that, (on /dev/input/js1 ) and I see that it's named "USB ADAPTOR" so I figure that is the name I use.

So I invoke mame with:
./mame64 apple2e -joy_idx1 "USB ADAPTOR"

I hit CTRL+F12 to halt the boot process, and from an applesoft prompt do:

100 ? PDL(0),PDL(1):GOTO 100
RUN

and I get very strange results, from all the way left to center, I get zeros. Moving from center to the right, I get some values other than zero. But the numbers don't seem to correspond very much with the position of the joystick, though it's clear that it's responding to the movement.

Is there something that I need to specify?

[Linked Image]

so Axis 0 and 1 work, along with button 0 and 1 (pulled the joystick down to the lower right in the picture)

[Linked Image]

trying autoboot with apple2e won't type PDL(0) properly (hitting CTRL+F12 immediately after boot so I get an applesoft prompt):
./mame64 apple2e -joy_idx1 "USB ADAPTOR" -autoboot_command '100 ? pdl(0),pdl(1):goto 100\nrun\n' -autoboot_delay 5


[Linked Image]


./mame64 apple2p -joy_idx1 "USB ADAPTOR" -autoboot_command '100 ? pdl(0),pdl(1):goto 100\nrun\n' -autoboot_delay 5

autoboot_command with apple2p will type PDL(0) properly:

[Linked Image]

It starts off with reading 142 and 154, then if you move the joystick, reads 0 mostly.

[Linked Image]

Last edited by Golden Child; 06/09/17 11:34 PM.
#109861 - 06/10/17 02:12 PM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
More fiddling with the apple2p driver and the joystick:

There seems to be interaction between the "keyboard joystick" and my usb joystick.

When I start the apple2p driver (and don't move the joystick) the numeric keypad joystick will work fine:

./mame64 apple2p -autoboot_command '100 ? pdl(0),pdl(1):goto 100\nrun\n' -autoboot_delay 5 -joy_idx1 "USB ADAPTOR"

So when it starts, you can see that it gets 142 (centered on the horizontal) and 154 (centered on the vertical)

[Linked Image]

Here you can see that I can get values from 0 to 255 on the vertical and 0 to 255 on the horizontal

Pressing the 8/2/4/6 on the numeric keypad quickly:

[Linked Image]

But once I start moving the USB joystick around, it starts giving me zero:

[Linked Image]

And if I hold down keypad 2, I can get the USB joystick to register proper values from 0 to 255 on the vertical axis.

If I hold down keypad 6 (for right), I can get the USB joystick to register values from 0 to 80 on the horizontal axis, but I only get values from the joystick center to joystick right.

Also, the joystick will sort of work in the user interface, but very strangely, it only wants to go in one direction, up and pulling down "centers" it.

#109863 - 06/10/17 05:15 PM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Mar 2001
Posts: 15,734
R. Belmont Offline
R. Belmont  Offline

Very Senior Member

Joined: Mar 2001
Posts: 15,734
USA
Switch the keyboard mode to the one where MAME keys work, hit Tab, go into the Analog settings, and make sure that your joysticks axes are associated with the Apple joystick's axes and (IMPORTANT) that the "INC" and "DEC" for each axis is blank. If it's not, select it, press Enter, and press Esc.

#109868 - 06/10/17 10:34 PM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
ok, I cleared the settings for the joystick under Input/This Machine

[Linked Image]

I also did this too under Input (General)/Player 1 controls

[Linked Image]

but it still doesn't seem to give me the proper range of values (horiz only 0 to 80 from center to right) and (0 to 155 in vertical axis)

#109869 - 06/11/17 03:52 AM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
So I found an SDL joystick test program at: https://github.com/Grumbel/sdl-jstest

git clone https://github.com/Grumbel/sdl-jstest.git

running sdl1 joystick test with pulling the joystick all the way to lower right:

./sdl-jstest --test 0

[Linked Image]

running sdl2 joystick test with joystick at lower right:

./sdl2-jstest --test 1

[Linked Image]



The sdl1 test looks a lot more "sane" since it goes from -32768 to 32767
and the sdl2 test only goes up to -32768 to -17309 for the xaxis, and -32768 to 0 for the yaxis.

Running
jstest /dev/input/js1
looks sane:

and I can "calibrate" it:
jscal -c /dev/input/js1

#109870 - 06/11/17 05:05 AM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
Doing a bunch of reading on the internet on the subject, apparently there's two different joystick systems on linux. One is /dev/input/js* and the other is /dev/input/event*.

https://www.reddit.com/r/linux_gami...oblem_with_joysticks_in_linux_right_now/

What I need on ubuntu 16.04 is the evdev-joystick program that will do the calibration.

There's a version of joystick in 17.04 that has the evdev-joystick calibration.
joystick 1:1.5.1-2 (amd64 binary) in ubuntu zesty (17.04)

evdev-joystick(1) - joystick calibration tool

but the newest version on 16.04 is 1.4.9-1

sudo apt-get install joystick
joystick is already the newest version (1:1.4.9-1).

According to https://wiki.archlinux.org/index.php/Gamepad

While SDL1 defaults to 'evdev' interface you can force it to use the old 'Joystick' API by setting the environment variable SDL_JOYSTICK_DEVICE=/dev/input/js0. This can help many games such as X3. SDL2 supports only the new 'evdev' interface.

#109872 - 06/11/17 01:08 PM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Feb 2014
Posts: 85
Golden Child Online content
Member
Golden Child  Online Content
Member

Joined: Feb 2014
Posts: 85
Ok, well I decided to upgrade my ubuntu 16.04 system to ubuntu 16.10 and try the evdev-joystick program.

evdev-joystick
Usage:

--help, --h The message you're now reading
--listdevs, --l List all joystick devices found
--showcal, --s [path] Show current calibration for joystick device
--evdev, --e [path] Set the joystick device to modify
--deadzone, --d [val] Change deadzone for current joystick
--fuzz, --f [val] Change fuzz for current joystick
--axis, --a [val] The axis to modify for current joystick (by default, all axes)

To see calibration information:
evdev-joystick [ --s /path/to/event/device/file ]

To set the deadzone values:
evdev-joystick [ --e /path/to/event/device/file --d deadzone_value [ --a axis_index ] ]

Example:

I want to see the calibration values of my event managed joystick:
evdev-joystick --s /dev/input/event6

Supported Absolute axes:
Absolute axis 0x00 (0) (X Axis) (min: 0, max: 16383, flatness: 1023 (=6.24%), fuzz: 63)
Absolute axis 0x01 (1) (Y Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x02 (2) (Z Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x05 (5) (Z Rate Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x10 (16) (Hat zero, x axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)
Absolute axis 0x11 (17) (Hat zero, y axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)

I want to get rid of the deadzone on all axes on my joystick:
evdev-joystick --e /dev/input/event6 --d 0


So I can configure dead zones and "fuzz" but it doesn't do a "full calibration".

Running ./sdl2-jstest --test 0 gives me a little bit more sane values for the range,
but now it's running from -32767 to 0 on both axes. At least they both look consistent.

upper left
[Linked Image]
centered
[Linked Image]
lower right
[Linked Image]



evdev-joystick --s /dev/input/by-id/usb-079d_USB_ADAPTOR-event-joystick
Supported Absolute axes:
Absolute axis 0x00 (0) (X Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x01 (1) (Y Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x05 (5) (Z Rate Axis) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x06 (6) (Throttle) (min: 0, max: 255, flatness: 15 (=5.88%), fuzz: 0)
Absolute axis 0x10 (16) (Hat zero, x axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)
Absolute axis 0x11 (17) (Hat zero, y axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)


This is a RadioShack 26-164 USB to Gameport adapter, which says in the USB that it's Alfadata
Bus 001 Device 007: ID 079d:0201 Alfadata Computer Corp. GamePort Adapter

[Linked Image]

To satisfy my curiosity, I'm going to try upgrading to 17.04 and see what happens.

edit:

Ok, updated to 17.04 and it still doesn't give the full range, just -32768 to 0 on both axes. I wish I knew how to set some calibration values. Maybe I'll try some horrible hack on the joystick code. It would seem straightforward enough, just take the values -32768 to 0 and map that to -32768 to 32767.

Last edited by Golden Child; 06/11/17 04:41 PM.
#109873 - 06/11/17 01:23 PM Re: Joystick on apple2e not working on Ubuntu 16.04 [Re: Golden Child]  
Joined: Mar 2001
Posts: 15,734
R. Belmont Offline
R. Belmont  Offline

Very Senior Member

Joined: Mar 2001
Posts: 15,734
USA
I just re-verified that MAME works right if the joypad does; I used the left analog stick on an Xbox 360 controller and got correct values from the BASIC program. I then booted up Dung Beetles and it played fine (or as fine as a maze game does on an analog joystick).


Moderated by  R. Belmont 

Who's Online Now
4 registered members (Reznor007, ssj, Golden Child, plgDavid), 32 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Shout Box
Forum Statistics
Forums9
Topics8,426
Posts109,198
Members4,759
Most Online225
May 26th, 2014
Powered by UBB.threads™ PHP Forum Software 7.6.0
Page Time: 0.026s Queries: 14 (0.009s) Memory: 4.9938 MB (Peak: 5.2041 MB) Zlib enabled. Server Time: 2017-10-18 16:48:25 UTC