Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning Joystick to BBC Keyboard #87

Closed
wants to merge 38 commits into from

Conversation

monkeyman79
Copy link
Contributor

  • Assigning host joystick axes and buttons to BBC keyboard (up to 2 joysticks or gamepads separately).
  • New human readable file format for joystick mapping (see Documents/JoystickMap.txt)
  • Option to automatically load image-specific joystick mapping file (same as disk name, but with .jmap extension)
  • Fixed displaying keys assigned to Shift in User Mapping dialog
  • Added "unassign" to keyboard and joystick mapping dialog
  • Joystick mapping table is separate from key mapping table
  • Mapping joysticks is done separately from keyboard (but using the same dialog code)
  • Highlight assigned keys in joystick mapping dialog

This is redo of PR #44

- Assigning host joystick axes and buttons to BBC keyboard
  (up to 2 joysticks or gamepads separately).
- New human readable file format for joystick mapping
  (see Documents/JoystickMap.txt)
- Option to automatically load image-specific joystick mapping file
  (same as disk name, but .jmap extension)
- Fixed displaying keys assigned to Shift in User Mapping dialog
- Added "Unassign" to keyboard and joystick mapping dialog
- Joystick mapping table is separate from key mapping table
- Mapping joysticks is done separately from keyboard
  (but using the same dialog code)
- Highlight assigned keys in joystick mapping dialog

Squashed commit of the following:

commit 2385678
commit b4933de
commit c79db73
commit caf3afa
commit a3f332c
commit cad97af
commit fe0adbf
commit 33be28f
commit 7aed289
commit ddd2a6c
commit 0362437
commit da6c911
commit 2c8ee02
commit ebe5247
commit 25fcda4
commit 3ae3f27
commit 79b300b
commit 8d6b625
commit 5b1ae01
commit a1b76c8
commit 0f53c4d
commit cc09240
commit 2568d2a
commit 9924f48
commit aa51f77
commit 926e6c4
commit c680917
commit ae74380
commit 1eac76b
@monkeyman79
Copy link
Contributor Author

It's been waiting a long time, but finally it's 100% done. Joystick mapping is completely separate from user keyboard mapping, loaded, saved and configured separately. Grab it while it's hot.

Code reviews are welcome.

Don't hesitate to change or rewrite my additions to help pages - I'm not a native speaker and I may have made some stylistic or other mistakes.

Map first two PC joystick or gamepad fire buttons to two BBC joystick
buttons separately.

Fixes stardot#74
Documents/JoystickMap.txt Outdated Show resolved Hide resolved
Src/beebwin.cpp Outdated Show resolved Hide resolved
Src/beebwin.cpp Outdated Show resolved Hide resolved
Src/beebwin.h Outdated Show resolved Hide resolved
Src/beebwin.h Outdated Show resolved Hide resolved
monkeyman79 and others added 4 commits February 5, 2021 03:07
- Moved joystick state to JoystickState struct
- Removed ResetJoystick
- Fixed some signedness warnings
- Unmute when keyboard mapping dialog is closed
- Simplfied code a bit
- Added CaptureJoystick() function to remove duplication
- Renamed MaybeEnableInitJoystick() function for consistency
Src/userkybd.cpp Outdated Show resolved Hide resolved
Src/userkybd.cpp Outdated Show resolved Hide resolved
chrisn and others added 6 commits February 7, 2021 16:13
Long names are OK, and this makes it easier to search
the code for related variables
- Maps from ... to BBCKey are now const
- Functions GetBBCKeyBy... return pointer instead of reference
- Display checkmark next to 'Initialise Joystick' menu item if first joystick initialised OK.
- Display warning message only if explicit initialisation failed.
@richard-broadhurst
Copy link

I didn't see q mapping for the POV, which on my current favourite arcade stick (PS3 HORI Fighting stick mini) is where the digital joystick maps.

@monkeyman79
Copy link
Contributor Author

@richard-broadhurst Hello :), It's there, named "hat" in the JoystickMap.txt, Axis7 and Axis8. Diagonals work too.

	if (joyInfoEx.dwPOV != JOY_POVCENTERED)
	{
		if (joyInfoEx.dwPOV >= 29250 || joyInfoEx.dwPOV < 6750)
			axes |= (1 << BEEB_JOY_AX_HAT_UP);
		if (joyInfoEx.dwPOV >= 2250 && joyInfoEx.dwPOV < 15750)
			axes |= (1 << BEEB_JOY_AX_HAT_RIGHT);
		if (joyInfoEx.dwPOV >= 11250 && joyInfoEx.dwPOV < 24750)
			axes |= (1 << BEEB_JOY_AX_HAT_DOWN);
		if (joyInfoEx.dwPOV >= 20250 && joyInfoEx.dwPOV < 33750)
			axes |= (1 << BEEB_JOY_AX_HAT_LEFT);
	}

@richard-broadhurst
Copy link

I'm really sorry, I missed that, next time I'll do it on the PC, not a phone!

@chrisn
Copy link
Collaborator

chrisn commented Feb 20, 2021

Sorry for the delay. An interesting question was raised on Stardot about the joystick numbering. If we have different joysticks connected, is there a way to know which one maps to Joy1 or Joy2 in the config? Or I wonder if we should add UI to allow the user to easily remap them?

@monkeyman79
Copy link
Contributor Author

Yeah, I was thinking about it too. It's just like Coeus said - windows will assign joystick number based on the order in which they appear in the system, so they can change between reboots, or just by disconnecting and reconnecting usb joysticks. I think that we could store joystick order in preferences e.g. like this:

JoystickOrder1=<mid1>:<pid1>
JoystickOrder2=<mid2>:<pid2>
JoystickOrder3=<mid3>:<pid3>
...

and provide simple UI to change the order. You just have to keep in mind that there may be several joysticks with the same manufacturer and product id connected.

Actually I'm thinking that maybe I should just go ahead and merge two-joysticks branch to this, because there is already part of the functionality there and otherwise I will just duplicate the job and will have to fix the conflicts later.

@chrisn
Copy link
Collaborator

chrisn commented Feb 20, 2021

Yes, let's do that. It'll be easier to work on a single branch, I think.

- Added second BBC joystick support
- Select PC joystick and axes for each BBC joystick
chrisn and others added 18 commits February 20, 2021 22:42
This option disabled the ADC and Serial interface,
presumably to make the emulator run faster.

I've removed this option as it doesn't affect
performance particularly, and simplifies joystick
handling.
This fixes an issue where the joystick position would
never be centred. With this change, the joystick
is centred when the mouse is in the centre of the
BeebEm window.
- Moved joystick handling to separate class and files
- Up to 4 joysticks mapped to keyboard
This is somewhat experimental and may be changed or removed in the future
- Autodetect secondary thumbstick axes
- Display joystick names in menu
- More user friendly axis names
- Map right thumbstick axes Z/RZ to RX/RY in joystick to keyboard mapping if those axes are not present to make mapping files more portable
- Changed axes order, old mapping files may need to be updated
and removed unneeded backward compatiblity for jmap files
@monkeyman79
Copy link
Contributor Author

Summary of changes so far:

Second joystick and Joystick to keyboard mapping

  • Assigning host joystick axes and buttons to BBC keyboard (up to 4 joysticks or gamepads separately).

  • New human readable file format for joystick to keyboard mapping (see Documents/JoystickMap.txt)

  • Changed joystick API from WinMM to DirectInput

  • Display joystick names in menu

  • Option to automatically load image-specific joystick mapping file (same as disk name, but with .jmap extension)

  • Added "unassign" to keyboard and joystick mapping dialog

  • Highlight assigned keys in joystick mapping dialog

  • Added second BBC joystick support

  • Select PC joystick and axes for each BBC joystick

  • Save joystick order in preferences file

  • Added "Change Joystick Order" dialog

  • Added JoystickSensitivity parameter (only in preferences.cfg, no UI)

  • Change Digital Mousestick handling

    This fixes an issue where the joystick position would never be centred. With this change, the joystick is centred when the mouse is in the centre of the BeebEm window.

  • Map additional joystick buttons to analogue port PB0 and PB1

  • Removed "Basic Hardware Only" option

    This option disabled the ADC and Serial interface, presumably to make the emulator run faster.

    This option was removed as it doesn't affect performance particularly, and simplifies joystick handling.

  • Checkmark next to "Rescan Joysticks" menu item

    Display checkmark next to "Rescan Joysticks" menu item if first joystick initialised OK.

    Display warning message only if initialisation for "Rescan Joysticks" fails.

  • Unmute when keyboard mapping dialog is closed

  • Separate fire buttons on BBC joystick

    Map first two PC joystick or gamepad fire buttons to two BBC joystick buttons separately when only one BBC joystick is configured, . Fixes Supporting the second fire button #74

@monkeyman79
Copy link
Contributor Author

Moving to PR #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants