Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: GP-Wiz40 with linux?  (Read 6938 times)

0 Members and 1 Guest are viewing this topic.

migraineman

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:July 01, 2016, 02:56:35 pm
GP-Wiz40 with linux?
« on: November 03, 2011, 08:15:01 pm »
I'm trying to get my recently acquired GP-Wiz40 to work with MAME under linux.  The GP-Wiz is identified properly, shows up in lsusb, and works great with jstest.  However, linux MAME doesn't seem to accept input from it, in spite of identifying it and mapping Physical id 0 to Logical id 0.  I can run jstest in a terminal window, and invoke MAME from another terminal using "mame -v -w" so it runs verbose in a window.  I can see jstest identify the button inputs from the GP-Wiz40, but MAME doesn't respond.

I even went so far as to install the windows port of MAME in a VM on the same machine (linux as the host system.)  The windows version accepted input from the GP-Wiz40 just fine.

I've tried to get this working on both a FC15 and Ubuntu 11.10 distro, and neither seems to like my GP-Wiz40.  Am I missing something?  Anybody have one working under linux?  Oh, MAME is 0.143 in all cases.

Quinny

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 47
  • Last login:June 08, 2014, 07:52:07 am
Re: GP-Wiz40 with linux?
« Reply #1 on: November 04, 2011, 02:06:58 pm »
Is there a setting in mame.ini to turn on joysticks or mouses or something?

Sorry just going from a vague memory.

migraineman

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:July 01, 2016, 02:56:35 pm
Re: GP-Wiz40 with linux?
« Reply #2 on: November 04, 2011, 02:30:53 pm »
Yep.  The "joystick" option is turned on.  It works fine when I plug in a Logitech gamepad. 

While doing a comparison between the Logitech gamepad and the GP-Wiz40 using jstest, I noticed that the GP-Wiz axis control values range from 127 to -127, where the Logitech values were 32767 to -32767.  I'm wondering if I have an 8-bit versus 16-bit parameter issue.  I poked around in the MAME source code, and the MAX_VALUE declaration for the analog joystick input is 65536, and the MIN_VALUE is -65536.  There is a deadzone and saturation scale factor in the mame.ini file which defaults to 0.3 and 0.85 of full scale, respectively.  I suspected that my teeny 8-bit values might be stuck in the deadzone, but I changed the deadzone to 0.0 and didn't appear to make a difference.  I also set the saturation value to 0.0015 which should cause an input of 127 to be considered "full scale," but that didn't change anything either.   

I'll continue digging through the source.  I haven't found the place where they actually take a control input and convert that to a command for the emulator.  Gotta make sure I can build MAME from source, too.  If I can do both of these, I can make a butchered version that prints the joystick values at the point where they're converted to commands, and maybe I'll be able to figure out what the heck is going on here.  Note - software engineer, I am not.

Quinny

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 47
  • Last login:June 08, 2014, 07:52:07 am
Re: GP-Wiz40 with linux?
« Reply #3 on: November 05, 2011, 10:47:50 am »
Good luck! I haven't had any issues with MAME not detecting any hardware controls that Linux knows about.

What module is the GP-Wiz using compared to the gamepad? Maybe the wrong module is being used for the GP-Wiz.

migraineman

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:July 01, 2016, 02:56:35 pm
Re: GP-Wiz40 with linux?
« Reply #4 on: March 02, 2012, 09:47:03 am »
I did some more digging, and I need to correct my previous post.  The GP-Wiz40 is properly recognized by the Linux system, and is mounted using the joydev module.  However, the reported joystick values are 0, 127, and 255 (the previous -127 to 127 is just plain wrong.  Sorry about that.)  So in addition to being small compared to the Logitech gamepad values, there's a fixed offset.  I also built a better test fixture, and confirmed that Button1 and Button2 for Player 1 respond properly.   So at least part of the GP-Wiz40 is being handled properly.

I was hoping I could manually edit the code in the GP-Wiz40, but the Cypress CY7C63513 low-speed USB microcontroller doesn't appear to be in-circuit programmable.  I could have handled a Microchip or Atmel device.  Dang.

So I've been bashing away at the MAME and SDL sources.  I've been able to build both from source (which ain't an easy task.)  I've added diagnostic print messages to try to figure out where the MAME code decides what kind of joystick is present, how it scales and limits the input values, and then hands that data off to the emulator core.  Honestly, I'm an embedded guy, and the C++++ infinite-layers-of-abstraction are making my head asplode.

From the Linux command line, I can run jscal and properly calibrate the joystick.  Once calibrated, jstest reports values of -32767, 0, and 32767.  That's encouraging, but MAME doesn't seem to be using the calibrated joystick values.  I've read about SDL ignoring the /dev/input/js0 device in favor of the event interface (which can't be calibrated.)  I poked at the libSDL package and re-built it from source, commenting out the event driver path.  Didn't make a difference, though at this point I'm not convinced that what I changed was comprehensive enough to do what I want.

SDL calibration issues are referenced here:
http://superuser.com/questions/17959/linux-joystick-seems-mis-calibrated-in-an-sdl-game-freespace-2-open

migraineman

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:July 01, 2016, 02:56:35 pm
Re: GP-Wiz40 with linux?
« Reply #5 on: May 23, 2012, 10:25:43 am »
SUCCESS!  After several weeks of beating my head against the SDL wall, I decided to approach from a different angle.  I added the environment variable "SDL_JOYSTICK_DEVICE=/dev/input/js0" to /etc/environment.  After a reboot, the variable appeared in the env list (it wouldn't stay persistent when manually added.)  I calibrated the GPWiz40 using "jscal -c /dev/input/js0".  MAME now uses the calibrated joystck values through SDL. 

I'm not out of the woods yet, but I'm past a major tech hurdle.  I need to cal four joysticks, make sure the calibrations are persistent, and make sure the usb device assignments are consistent through power cycling. 

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:June 25, 2023, 02:23:57 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: GP-Wiz40 with linux?
« Reply #6 on: May 23, 2012, 11:05:23 am »
I'd love to hear what you find out about the device assignments being persistent through a reboot.

Also, do they stay consistent as you add and remove devices?

Windows is notorious about not handling that situation very well. That's why I wrote ControllerRemap. I'm just curious if Linux handles things better.