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

Joystick to keyboard mapping and secondary BBC joystick support #95

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1048f7a
Assigning Joystick to BBC Keyboard
monkeyman79 Feb 1, 2021
9e82e9d
Separate fire buttons on BBC joystick
monkeyman79 Feb 1, 2021
abbbe53
Fixed typo in JoystickMap.txt
monkeyman79 Feb 2, 2021
c34f5b7
Fixed joystick map file dialog filter string
chrisn Feb 2, 2021
dce19b4
Fix typo in Help file
chrisn Feb 2, 2021
050f860
Refactored to remove code duplication
chrisn Feb 4, 2021
6b05829
Renamed variables and simplified code
chrisn Feb 4, 2021
5511881
Removed unnecessary struct typedef
chrisn Feb 4, 2021
7620530
Code cleanup after review
monkeyman79 Feb 5, 2021
8b2642c
Some more updates
chrisn Feb 5, 2021
d663bf7
Fixed enabling and disabling Joystick and Joystick to Keyboard
monkeyman79 Feb 6, 2021
d280d59
Changed wording in JoystickMap.txt
chrisn Feb 7, 2021
9e979de
Renamed variable
chrisn Feb 7, 2021
3ede0c7
Added const
chrisn Feb 7, 2021
146ef17
More consts
monkeyman79 Feb 7, 2021
5cf12f9
Update checkmark in menu even if joystick initialization failed
monkeyman79 Feb 7, 2021
7b30aef
Checkmark next to 'Initialise Joystick' menu item
monkeyman79 Feb 7, 2021
5e2f85c
Added second BBC joystick support
monkeyman79 Feb 20, 2021
99d8c5e
Removed "Basic Hardware Only" option
chrisn Feb 20, 2021
dd89799
Removed "Basic Hardware Only" option
chrisn Feb 21, 2021
c006350
Map additional joystick buttons to analogue port PB0 and PB1
chrisn Feb 21, 2021
39c9a91
Change Digital Mousestick handling
chrisn Feb 21, 2021
16cfa75
More Joysticks
monkeyman79 Feb 23, 2021
72a14bd
Changed stick prefs to avoid menu id in prefs file
monkeyman79 Feb 23, 2021
c652921
Save joystick order in preferences file
monkeyman79 Feb 24, 2021
d764172
Moved JoystickHandler details out of header file, left only interface
monkeyman79 Feb 24, 2021
e8db25e
Added Reset Mapping to dialog and fixed Shift keys colours
monkeyman79 Feb 24, 2021
8189cf5
Added JoystickGain parameter (no UI for it)
monkeyman79 Feb 24, 2021
6bec0d4
Moved most joystick handling back to BeebWin class
monkeyman79 Feb 26, 2021
e5f2e80
Switched from WinMM to DirectInput
monkeyman79 Feb 27, 2021
c133d9e
Merged PCJoystickState with JoystickDev
monkeyman79 Feb 28, 2021
e1d4762
Added Change Joystick Order dialog
monkeyman79 Feb 28, 2021
0ce00c0
Restored copyright notice in beebemrc.h
monkeyman79 Mar 2, 2021
9950ee8
Restored copyright notice in beebemrc.h
monkeyman79 Mar 2, 2021
19597fa
Limited use of auto keyword to make code more readable
monkeyman79 Mar 3, 2021
77b8fae
Fixed enabling mousestick
monkeyman79 Mar 3, 2021
c1ddf85
Move joystick configuration to separate menu
monkeyman79 May 21, 2021
0f489c3
Add joystick sensitivity and threshold to menu
monkeyman79 May 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.user
.vs
Src/.vs
Src/BeebEm.aps
Src/BeebEm.VC.db
Expand Down
70 changes: 70 additions & 0 deletions Documents/JoystickMap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
*** BeebEm Joystick Map ***

# Joystick map file begins with special marker line as above.
# All empty lines and lines starting with '#' are ignored.

# Remaining lines must consist of two or three tokens separated with
# whitespace.
# All names are case insensitive except for the marker in the first line.

# Two-token lines are:
# <Joystick input> <BBC Key>
# Three-token lines are:
# <Joystick input> <BBC Key for unshifted> <BBC Key for shifted>

# These two lines define the same mapping:
# Joy1Up A
# Joy1Up A SH+A

# BBC Key names prefixed with 'SH+' indicate shifted key press.
# In the two-token lines, the 'SH+' prefix is allowed, but ignored.

# Special BBC key names are:
# LEFT, RIGHT, UP, DOWN, BREAK, COPY, DELETE, CAPS-LOCK, TAB, CTRL
# SPACE, RETURN, ESCAPE, SHIFT, SHIFT-LOCK
# Allowed aliases:
# DEL, CAPS, CAPSLOCK, CONTROL, ESC, SHIFTLOCK

# All other BBC keys are named by their unshifted character (i.e. 'SH+[' not '{')
# Function keys are named, as one would expect, 'F0' to 'F9'

# Joystick inputs have the form Joy[X][Act] where [X] is the joystick number
# and [Act] is the action name. Axis and button assignments differ between
# joystick or gamepad models.

# Xbox 360 controller has following assignments
# (with DIJOYSTATE2 fields in the middle column):
# Left, Right, Up, Down - lX, lY - Left Analog Left, Right, Up, Down
# Z+,Z- - lZ - Left Trigger, Right Trigger
# RLeft, RRight, RUp, RDown - lRx, lRy - Right Analog Left, Right, Up, Down
# HatLeft, HatRight, HatUp, HatDown - rgdwPOV[0] - Hat Up, Down, Left, Right
# Btn1-4 - A, B, X, Y
# Btn5,6 - Left Shoulder, Right Shoulder
# Btn7,8 - Back, Start
# Btn9,10 - Left Thumbstick, Right Thumbstick

# Other common layout:
# Left, Right, Up, Down - lX, lY - Left Analog Left, Right, Up, Down
# RLeft, RRight, RUp, RDown - lZ, lRz - Right Analog Left, Right, Up, Down
# HatLeft, HatRight, HatUp, HatDown - rgdwPOV[0] - Hat Up, Down, Left, Right
# Btn1-4 - Y, B, A, X
# Btn5,6 - Left Shoulder, Right Shoulder
# Btn7,8 - Left Trigger, Right Trigger
# Btn9,10 - Select/Back, Start
# Btn11,12 - Left Thumbstick, Right Thumbstick
# Btn13 - Home

# Sample mapping for Chuckie Egg

Joy1Up A
Joy1Down Z
Joy1Left ,
Joy1Right .
Joy1HatUp A
Joy1HatDown Z
Joy1HatLeft ,
Joy1HatRight .
Joy1Btn1 SPACE
Joy1Btn6 RETURN
Joy1Btn7 1
Joy1Btn8 S
98 changes: 93 additions & 5 deletions Help/keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="100">
<p align="center"><img src="beeb.gif" name="BeebEm" alt="BBC Micro"
<p align="center"><img src="beeb.gif" name="BeebEm" alt="BBC Micro"
align="middle" width="48" height="48" border="0" /></p>
</td>

Expand Down Expand Up @@ -204,7 +204,7 @@ <h2>Custom Key Mappings</h2>
<ol>
<li>If you are in full screen mode then switch back to Windowed mode.</li>

<li>Select menu item "Options -> Define User Key Mapping". A graphic
<li>Select menu item "Options &rarr; Define User Key Mapping". A graphic
showing the BBC keyboard layout will appear within the BeebEm
interface.</li>

Expand All @@ -228,16 +228,104 @@ <h2>Custom Key Mappings</h2>

<li>Repeat from step 3 for other keys you want to map.</li>

<li>Save your mapping using menu item "Options -> Save User Key Mapping".
<li>Save your mapping using menu item "Options &rarr; Save User Key Mapping".
You can write over the default user key mapping file (DefaultUser.kmap)
or save a new file.</li>

<li>Select your mapping using menu item "Options -> User Defined Mapping".
<li>Select your mapping using menu item "Options &rarr; User Defined Mapping".
You can also use the "Save Preferences" option to save the default user
key mapping file that gets loaded when BeebEm starts up.</li>
</ol>

<!-- End of content -->
<h2>Mapping PC Joystick to BBC Keys</h2>

<p>To enable translating PC joystick actions to BBC keys, use menu item
"Options &rarr; Joystick To Keyboard &rarr; Enable Joystick To Keyboard".
BeemEm supports mapping up to four joysticks or gamepads to BBC keys,
with each joystick actions (button presses or stick movements)
mapped separately.</p>

<p>Creating mapping of PC joystick movements and buttons to BBC keys is
similar to creating custom key mappings:</p>

<ol>
<li>If you are in full screen mode then switch back to Windowed mode.</li>

<li>Select menu item "Options &rarr; Joystick To Keyboard &rarr; Define Joystick Mapping".
A graphic showing the BBC keyboard layout will appear within the BeebEm
interface. BBC keys which already have assigned joystick actions will be
highlighted with light blue colour.</li>

<li>Use your mouse pointer to click once on the BBC key that you are
attempting to map to your joystick or gamepad.</li>

<li>Press the joystick button or move the joystick in the direction that you want
to map to the unshifted BBC key press, or click "OK" to skip that part.
If you want to map shifted joystick action to unshifted BBC key press, enable
the "Shift" checkbox before moving the joystick.</li>

<li>Press the joystick button or move the joystick in the direction that you want
to map to the shifted BBC key press, or click "OK" to skip that part.
If you want to map unshifted joystick action to shifted BBC key press, disable
the "Shift" checkbox before moving the joystick.</li>

<li>Repeat from step 3 for other keys you want to map.</li>

<li>Save your mapping using menu item
"Options &rarr; Joystick To Keyboard &rarr; Save Joystick Mapping...".
You can save your mapping as the default user joystick mapping file
(DefaultUser.jmap) or save to a different file. If you are creating
a game-specific joystick mapping, save the mapping in the same
directory and with the same name as your game disk image, with extension
changed to ".jmap". This will make BeebEm automatically use the joystick
mapping for that disk image, if that is enabled with menu item
"Options &rarr; Joystick To Keyboard &rarr; Autoload Joystick Mapping".</li>
</ol>

<p>As with PC keys, you can map joystick actions to BBC keys in shifted and
unshifted state separately. The most common scenario is to assign a
joystick action to the same BBC key in both shifted and unshifted state.
To do that, just click on the BBC key that you want to map, and move
joystick or press button twice - once for unshifted and second time for
shifted state.</p>

<p>Additionally, you can assign one or more joystick buttons to the SHIFT key.
This can be used to assign one joystick button as a modifier for
other joystick actions, which can be useful for games that have a lot of
keyboard contols.</p>

<p>PC joystick to BBC keyboard mapping is independent from enabling PC joystick
acting as BBC joystick. If you enable both, primary PC joystick axes
(primary stick up, down, left and right) and first two buttons are mapped
to BBC joystick. You can map other axes and buttons to BBC keys. You can
map those axes and buttons which are acting as BBC joystick to BBC
keys as well. In that case, the PC joystick action will be seen as both BBC
joystick action and BBC key press.</p>

<p>To remove mapping from previously mapped joystick action, click on the
'Unassign' button. It will display small window and wait for the
joystick action. Press the joystick button or move the joystick in the
direction that you want to unmap. The same window will be displayed again,
giving you the opportunity to unmap the joystick action in both unshifted
and shifted state at one go. You can press the "OK" button to skip the
second unassignment.</p>

<p>At start up BeebEm loads DefaultUser.jmap from the User Data Folder, if such
file was created by user. If this file is not present, all joystick actions
start unassigned.</p>

<p>Menu item "Options &rarr; Joystick To Keyboard &rarr; Autoload Joystick Mapping"
toggles Autoload Joystick Mapping option. If this option is enabled, BeebEm
will automatically look for joystick mapping file based on name of image
file started from "File &rarr; Run Disc.." or "File &rarr; Load Tape..." menu item,
or from command-line. The sought mapping file has the same name and
directory as loaded image, but extension changed to ".jmap". If no such
file is found, joystick mapping is reset to default - either empty, or that
from "DefaultUser.jmap" file. If the Autoload Joystick Mapping option is
enabled, the "Save Joystick Mapping..." dialog will automatically suggest
correct file name for currently loaded image file.</p>

<!-- End of content -->
</td>

<td width="10%"></td>
Expand Down
Loading