Jump to content
  • 0
Alfa

Emulator Support for Joysticks

Question

I am just starting to work with the emulator, and was curious if the emulator supported joysticks connected to the host system?  If so, any particular model?

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

TL;DR: These command-line options:

-joy1 NES
-joy1 SNES
-joy2 NES
-joy2 SNES

More information about reading the gamepads can be found in the Commander X16 Programmer's Reference Guide on Github.

Note that the gamepad support does not include analog inputs of any sort. There is no support planned that I know of for controllers using analog input.

The emulator does not support any one particular brand of joystick or another, it generically supports gamepads through SDL2's input interface. It recognizes two gamepad inputs. You can enable these with the "-joy1" and "-joy2" command-line options. These options take a parameter "NES" or "SNES", which determines whether the gamepad is emulated as an NES controller or a SNES controller. The reason for "NES" and "SNES" is because the Commander X16 will have a pair of NES/SNES ports built into it.

I believe I read somewhere on Facebook that there was a decision made one way or the other between NES and SNES ports, but I forget which way this went. The decision between the two was up in the air for a very long time, so the emulator still supports both NES and SNES inputs. DE-9 controllers (Atari, Sega) will not be supported, are not being considered, and I remain traumatized by the staggering length and quantity of the Facebook threads arguing for them. You'll just have to make your own user port expansion card that potentially shorts out when you plug the wrong controller into it and press the wrong button. 😉

  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0

I use an extremely cheap SNES-style USB gamepad with the emulator. It works quite well, even if the buttons on the controller are not very nice.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0




I believe I read somewhere on Facebook that there was a decision made one way or the other between NES and SNES ports, but I forget which way this went.


We are going with SNES for some good reasons. More info in the FAQ.
  • Like 2

Share this post


Link to post
Share on other sites
  • 0
47 minutes ago, Perifractic said:

We are going with SNES for some good reasons. More info in the FAQ. emoji106.pngemoji973.png

Thanks for clarifying. I sometimes forget what's in the FAQ, guess I should re-check it every now and then. 😅 And I feel that the reasoning for SNES ports is solid. Fewer wires, more buttons! And someone else can always create a joystick adapter card for the user port that does ADC if they feel there's that much interest from the community. Heck, I wouldn't be surprised if someone were already working on a DE-9 card. (Actually, a DE-9 card doesn't sound too hard to design, on its own...)

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I wouldn't be surprised either.

Also, you should read the FAQ right though every morning before you get out of bed.

  • Haha 3

Share this post


Link to post
Share on other sites
  • 0
21 hours ago, StephenHorn said:

TL;DR: These command-line options:

-joy1 NES
-joy1 SNES
-joy2 NES
-joy2 SNES

More information about reading the gamepads can be found in the Commander X16 Programmer's Reference Guide on Github.

Note that the gamepad support does not include analog inputs of any sort. There is no support planned that I know of for controllers using analog input.

The emulator does not support any one particular brand of joystick or another, it generically supports gamepads through SDL2's input interface. It recognizes two gamepad inputs. You can enable these with the "-joy1" and "-joy2" command-line options. These options take a parameter "NES" or "SNES", which determines whether the gamepad is emulated as an NES controller or a SNES controller. The reason for "NES" and "SNES" is because the Commander X16 will have a pair of NES/SNES ports built into it.

I believe I read somewhere on Facebook that there was a decision made one way or the other between NES and SNES ports, but I forget which way this went. The decision between the two was up in the air for a very long time, so the emulator still supports both NES and SNES inputs. DE-9 controllers (Atari, Sega) will not be supported, are not being considered, and I remain traumatized by the staggering length and quantity of the Facebook threads arguing for them. You'll just have to make your own user port expansion card that potentially shorts out when you plug the wrong controller into it and press the wrong button. 😉

Thank you.  I am not familiar with the SDL2 library and wasn’t sure how well it supported Windows.

Share this post


Link to post
Share on other sites
  • 0
12 hours ago, SlithyMatt said:

I use an extremely cheap SNES-style USB gamepad with the emulator. It works quite well, even if the buttons on the controller are not very nice.

Thank you for the tip.  I saw the NES/SNES and didn’t know if any particular Windows joystick would work or did I need a special adapter.  

Share this post


Link to post
Share on other sites
  • 0

Does anyone know when all the buttons on the SNES controller are supported?  Looking at the documentation and the ROM code, I get conflicting information.

First, there's the documentation for the JOY BASIC command.  It tells me that only a single byte is returned as a bitmask for the pressed buttons.  Since the SNES controller has 12 buttons, it appears that X, A, R, and L are unsupported.

However, if I look at the ROM code, I find this documentation on the joystick_get subroutine which is used by the JOY BASIC command:

Quote

;---------------------------------------------------------------
; joystick_get
;
; Function:  Return the state of a given joystick.
;
; Pass:      a    number of joystick (0 or 1)
; Return:    a    byte 0:      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
;                         NES  | A | B |SEL|STA|UP |DN |LT |RT |
;                         SNES | B | Y |SEL|STA|UP |DN |LT |RT |
;
;            x    byte 1:      | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
;                         NES  | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
;                         SNES | A | X | L | R | 1 | 1 | 1 | 1 |
;            y    byte 2:
;                         $00 = joystick present
;                         $FF = joystick not present
;
; Notes:     * Presence can be detected by checking byte 2.
;            * The type of controller is encoded in bits 0-3 in
;              byte 1:
;              0000: NES
;              0001: keyboard (NES-like)
;              1111: SNES
;            * Bits 6 and 7 in byte 0 map to different buttons
;              on NES and SNES.
;---------------------------------------------------------------

 

This says that the A, X, L, and R buttons are returned, just in a second byte returned in the X register.  A quick test with the emulator shows that you can call joystick_get directly and receive the additional buttons in the X register, so I know for a fact the full controller is supported from assembly.

However, with even more investigation, I see that the joystick_from_ps2 kernal subroutine has no support whatsoever for the A, X, L, and R buttons of the SNES controller.  It appears that if using a keyboard as a joystick, no buttons map to the additional buttons of the SNES controller.

So far, my conclusions are:

  • the full SNES controller is supported from assembly using the joystick_get kernal routine
  • the X, A, L, and R buttons are not supported by BASIC's JOY command
  • the X, A, L, and R buttons are not supported when using a keyboard as a joystick

Can anyone here confirm or contradict these conclusions?

Sorry for continuing an old thread, but I thought this might be appropriate here for anyone searching the site about joysticks and gamepads.

Edited by Jestin

Share this post


Link to post
Share on other sites
  • 0

I think your conclusions are correct. I'm actually a little surprised the kernal is where support is implemented for using the keyboard as a joystick. I would have expected the emulator to pass along keyboard state data, but I can't recall ever looking into it too deeply.

I'm not all that surprised that the BASIC command does not support the second byte of data, especially after reading the documentation for JOY on BASIC 3.5. If the goal of BASIC was to maintain backwards-compatibility, then JOY will likely never support more than the D-pad and one additional button.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use