Browse Source

[controller] Map mouse right button

- Fix retrofw build error
- Map right and left mouse click for retrofw
- Fix opening inventory/char sheet on retrofw
pull/897/head
Anders Jenbo 6 years ago
parent
commit
ef37f3de02
  1. 1
      CMake/retrofw_defs.cmake
  2. 1
      CMakeLists.txt
  3. 21
      Packaging/OpenDingux/devilutionx-retrofw.man.txt
  4. 23
      Packaging/OpenDingux/readme.gcw0.txt
  5. 84
      README.md
  6. 1
      SourceX/controls/README.md
  7. 8
      SourceX/controls/devices/kbcontroller.cpp
  8. 27
      SourceX/controls/game_controls.cpp

1
CMake/retrofw_defs.cmake

@ -15,5 +15,4 @@ set(KBCTRL_BUTTON_LEFTSHOULDER SDLK_TAB)
set(KBCTRL_BUTTON_START SDLK_RETURN)
set(KBCTRL_BUTTON_LEFTSTICK SDLK_END) # Suspend
set(KBCTRL_BUTTON_BACK SDLK_ESCAPE) # Select
set(KBCTRL_MODIFIER_KEY SDLK_ESCAPE) # Select
set(KBCTRL_IGNORE_1 SDLK_3) # Backlight

1
CMakeLists.txt

@ -360,7 +360,6 @@ foreach(
KBCTRL_BUTTON_LEFTSHOULDER
KBCTRL_BUTTON_START
KBCTRL_BUTTON_BACK
KBCTRL_MODIFIER_KEY
KBCTRL_IGNORE_1
JOY_AXIS_LEFTX
JOY_AXIS_LEFTY

21
Packaging/OpenDingux/devilutionx-retrofw.man.txt

@ -6,16 +6,17 @@ Game saves and diablo.ini are located at:
Controls:
- D-pad: move hero
- A: attack nearby enemies, talk to towns people and merchants, pickup & drop items in inventory, OK while in main menu
- B: Select spell, cancel while in main menu
- X: pickup gold, potions & equipment from ground, open chests and doors that are nearby, use item when in inventory (useful to read books etc.)
- Y: cast spell, go to previous screen when talking to people and in shops, delete character while in main menu
- R1: Drink health potion
- L1: Drink mana potion
- A: attack nearby enemies, talk to towns people and merchants, pickup/place items in the inventory, OK while in main menu
- B: Select spell, back while in menus
- X: pickup items, open chests and doors that are nearby, use item in the inventory
- Y: cast spell, delete character while in main menu
- R1: use mana potion from belt
- L1: use health item from belt
- Suspend: toggle automap
- Start: game Menu, skip movie
- Select + R1: inventory
- Select + R2: character
- Select + A/B/X/Y: hot spell
- Select + D-pad: Move map/cursor
- Select + A: Left click
- Select + Y: Quest log
- Suspend: Map
- Start: game Menu, skip intro
- Select + Suspend: left mouse click
- Select + Start: right mouse click

23
Packaging/OpenDingux/readme.gcw0.txt

@ -10,17 +10,20 @@ Controls:
- Left analog: move hero
- Right analog: simulate mouse
- A: attack nearby enemies, talk to towns people and merchants, pickup & drop items in inventory, OK while in main menu
- B: Select spell, cancel while in main menu
- X: pickup gold, potions & equipment from ground, open chests and doors that are nearby, use item when in inventory (useful to read books etc.)
- Y: cast spell, go to previous screen when talking to people and in shops, delete character while in main menu
- R1: drink mana potion
- L1: drink health potion
- A: attack nearby enemies, talk to towns people and merchants, pickup/place items in the inventory, OK while in main menu
- B: Select spell, back while in menus
- X: pickup items, open chests and doors that are nearby, use item in the inventory
- Y: cast spell, delete character while in main menu
- R1: use mana potion from belt
- L1: use health item from belt
- R2: inventory
- L2: character
- Left analog click: map
- L2: character sheet
- Left analog click: toggle automap
- Right analog click: left mouse click
- Select: quest log
- Start: game Menu, skip intro
- Start: game Menu, skip movie
- Select + L2: quest log
- Select + R2: spell book
- Select + Right analog click: right mouse click
- Select + A/B/X/Y: hot spell
Source: https://github.com/diasurgical/devilutionX/

84
README.md

@ -35,7 +35,7 @@ sudo dnf install cmake glibc-devel SDL2-devel SDL2_ttf-devel SDL2_mixer-devel li
```
cd build
cmake ..
cmake --build . -j $(nproc)
make -j$(nproc)
```
</details>
@ -91,7 +91,7 @@ sudo apt-get install cmake gcc-mingw-w64-i686 g++-mingw-w64-i686
```
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake ..
cmake --build . -j $(nproc)
make -j$(nproc)
```
</details>
<details><summary>Windows via Visual Studio</summary>
@ -212,18 +212,22 @@ Packaging/OpenDingux/build-rg350.sh
</details>
## CMake arguments
<details><summary><b>CMake build options</b></summary>
### General
The default build type is `Debug`. This can be changed with `-DBINARY_RELEASE=ON`. Independently of this, the debug mode of the Diablo engine is always enabled by default. It can be disabled with `-DDEBUG=OFF`. Finally, in debug builds the address sanitizer is enabled by default. This can be disabled with `-DASAN=OFF`.
You can also generate 32bit builds on 64bit platforms by setting `-DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake` (remember to use the `linux32` command if on Linux).
Network support can be disabled using `-DNONET=ON`, this also removes the need for the ASIO and Sodium dependencies.
You can compile the shareware version with `-DSPAWN=ON` this will allow you to try the game using spawn.mpq from the original shareware which can still be [downloaded](http://ftp.blizzard.com/pub/demos/diablosw.exe) for free.
- `-DBINARY_RELEASE=ON` changed build type to release and optimize for distribution.
- `-DNONET=ON` disable network support, this also removes the need for the ASIO and Sodium.
- `-DUSE_SDL1=ON` build for SDL v1 instead of v2, not all features are supported under SDL v1, notably upscaling.
- `-DSPAWN=ON` build the shareware version, using spawn.mpq from the original shareware; which can still be [downloaded](http://ftp.blizzard.com/pub/demos/diablosw.exe) for free.
- `-DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake` generate 32bit builds on 64bit platforms (remember to use the `linux32` command if on Linux).
- `-DCROSS_PREFIX=/path/to/prefix` set the path to the `i686-w64-mingw32` directory.
### Debug builds
- `-DDEBUG=OFF` disable debug mode of the Diablo engine.
- `-DASAN=OFF` disable address sanitizer.
- `-DUBSAN=OFF` disable undefined behavior sanitizer.
### mingw32
Use `-DCROSS_PREFIX=/path/to/prefix` if the `i686-w64-mingw32` directory is not in `/usr`.
### Use SDL v1 instead of SDL v2.
Pass `-DUSE_SDL1=ON` to build with SDL v1 instead of v2.
Note that some features are not yet supported in SDL v1, notably upscaling, and fullscreen.
</details>
# Multiplayer
- TCP/IP only requires the host to expose port 6112
@ -239,18 +243,21 @@ Default controller mappings (A/B/X/Y as in Nintendo layout, so the rightmost but
- Left analog / DPad: move hero
- Right analog: simulate mouse
- A: attack nearby enemies, talk to towns people and merchants, pickup & place items in the inventory, OK while in main menu
- B: Select spell, cancel while in main menu
- X: pickup gold, potions & equipment from ground, open chests and doors that are nearby, use item when in inventory (useful to read books etc.)
- Y: cast spell, go to previous screen when talking to people and in shops, delete character while in main menu
- A: attack nearby enemies, talk to towns people and merchants, pickup/place items in the inventory, OK while in main menu
- B: Select spell, back while in menus
- X: pickup items, open chests and doors that are nearby, use item in the inventory
- Y: cast spell, delete character while in main menu
- R1: use mana potion from belt
- L1: use health item from belt
- R2: inventory
- L2: character sheet
- Left analog click: toggle automap
- Right analog click: left mouse click
- Select: quest log
- Start: game Menu, skip intro
- Start: game Menu, skip movie
- Select + L2: quest log
- Select + R2: spell book
- Select + Right analog click: right mouse click
- Select + A/B/X/Y: hot spell
For now, they can be re-mapped by changing `SourceX/controls` or by setting the `SDL_GAMECONTROLLERCONFIG` environment
variable (see
@ -259,47 +266,34 @@ variable (see
# Contributing
[Guidelines](docs/CONTRIBUTING.md)
# Modding
Below are a few examples of some simple improvements made to the game. It is planned in the future to create tools for designing dungeons and graphics.
![Screenshot 1: Monster lifebar+items](https://github.com/diasurgical/scalpel/blob/master/screens/mod1.png)
![Screenshot 2: New trade screen](https://github.com/diasurgical/scalpel/blob/master/screens/mod2.png)
# F.A.Q.
<details><summary>Click to reveal</summary>
> Wow, does this mean I can download and play Diablo for free now?
No, you'll need access to the data from the original game. If you don't have an original CD then you can [buy Diablo from GoG.com](https://www.gog.com/game/diablo). Alternatively you can also use `spawn.mpq` from the [http://ftp.blizzard.com/pub/demos/diablosw.exe](shareware) version and compile the with the SPAWN flag defined.
> Cool, so I fired your mod up, but there's no 1080p or new features?
> What game changes does Deviuions provide
DeviltuionX's main focuse is to making the game work on multiple platforms and making the engine mod frindly. As such there are not change to the gameplay, but we will be making some enhancments to the engine it self. To give some examples there is now upscaling, unlocked fps and controller support and multiplayer via TCP.
> Is 1080p supported?
We're working on it.
Currently the game simply scales the original 640x480 to beset fit, but we are working on widescreen support.
> What about Hellfire?
Hellfire was a bit of a flop on the developer's part. Support may come in the future once the base game is finished.
</details>
Hellfire is being worked on and is mostly done though not fully playable at the moment.
> Does it work with Battle.net?
Battle.net is a service provided by Blizzard, as we are not associated with them we have not worked on intergrating with there service.
</details>`
# Credits
- Reverse engineered by GalaXyHaXz in 2018
- [sanctuary](https://github.com/sanctuary) - extensively documenting Diablo's game engine
- [BWAPI Team](https://github.com/bwapi) - providing library API to work with Storm
- [Ladislav Zezula](https://github.com/ladislav-zezula) - reversing PKWARE library, further documenting Storm
- [fearedbliss](https://github.com/fearedbliss) - being awe-inspiring
- Diablodin - providing additional info about the PSX release
- Climax Studios & Sony - secretly helping with their undercover QA :P
- Blizzard North - wait, this was a typo!
- Depression - reason to waste four months of my life doing this ;)
And a special thanks to all the support and people who work on this project to make it possible! <3
- The original Devilution project [Devilution](https://github.com/diasurgical/devilution#credits)
- [Everyone](https://github.com/diasurgical/devilutionX/graphs/contributors) who worked on Devilution/DevilutionX
- And a thanks to all who support the project, report bugs and help spread the word <3
# Changelog
[From the beginning until release](docs/CHANGELOG.md)
# Legal
Devilution is released to the Public Domain. The documentation and function provided by Devilution may only be utilized with assets provided by ownership of Diablo.
Battle.net(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Battle.net and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.
DevilutionX is released to the Public Domain. The documentation and function provided by Devilution may only be utilized with assets provided by ownership of Diablo.
Diablo(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Diablo and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.

1
SourceX/controls/README.md

@ -36,5 +36,4 @@ cmake .. -DUSE_SDL1=ON -DHAS_KBCTRL=1 -DPREFILL_PLAYER_NAME=ON \
-DKBCTRL_BUTTON_LEFTSTICK=SDLK_TAB \
-DKBCTRL_BUTTON_START=SDLK_RETURN \
-DKBCTRL_BUTTON_BACK=SDLK_LSHIFT
-DKBCTRL_MODIFIER_KEY=SDLK_LSHIFT
```

8
SourceX/controls/devices/kbcontroller.cpp

@ -13,8 +13,8 @@ namespace {
bool IsModifierKey()
{
#ifdef KBCTRL_MODIFIER_KEY
return SDLC_GetKeyState()[KBCTRL_MODIFIER_KEY];
#ifdef KBCTRL_BUTTON_BACK
return SDLC_GetKeyState()[KBCTRL_BUTTON_BACK];
#else
return false;
#endif
@ -32,10 +32,6 @@ ControllerButton KbCtrlToControllerButton(const SDL_Event &event)
case KBCTRL_IGNORE_1:
return ControllerButton::IGNORE;
#endif
#ifdef KBCTRL_MODIFIER_KEY
case KBCTRL_MODIFIER_KEY:
return ControllerButton::IGNORE;
#endif
#ifdef KBCTRL_BUTTON_A
case KBCTRL_BUTTON_A:
return ControllerButton::BUTTON_A;

27
SourceX/controls/game_controls.cpp

@ -48,18 +48,36 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
switch (ctrl_event.button) {
case ControllerButton::AXIS_TRIGGERLEFT: // ZL (aka L2)
if (!ctrl_event.up)
#if HAS_KBCTRL == 0
if (IsControllerButtonPressed(ControllerButton::BUTTON_BACK))
*action = GameAction(GameActionType::TOGGLE_QUEST_LOG);
else
#endif
*action = GameAction(GameActionType::TOGGLE_CHARACTER_INFO);
return true;
case ControllerButton::AXIS_TRIGGERRIGHT: // ZR (aka R2)
if (!ctrl_event.up)
#if HAS_KBCTRL == 0
if (IsControllerButtonPressed(ControllerButton::BUTTON_BACK))
*action = GameAction(GameActionType::TOGGLE_SPELL_BOOK);
else
#endif
*action = GameAction(GameActionType::TOGGLE_INVENTORY);
return true;
#if HAS_KBCTRL == 1
case ControllerButton::BUTTON_LEFTSTICK:
if (IsControllerButtonPressed(ControllerButton::BUTTON_BACK)) {
*action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up };
return true;
}
break;
case ControllerButton::BUTTON_START:
if (IsControllerButtonPressed(ControllerButton::BUTTON_BACK)) {
*action = GameActionSendMouseClick { GameActionSendMouseClick::RIGHT, ctrl_event.up };
return true;
}
break;
#endif
}
if (!questlog && !sbookflag) {
switch (ctrl_event.button) {
@ -108,7 +126,10 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
// The rest is handled in charMovement() on every game_logic() call.
return true;
case ControllerButton::BUTTON_RIGHTSTICK:
*action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up };
if (IsControllerButtonPressed(ControllerButton::BUTTON_BACK))
*action = GameActionSendMouseClick { GameActionSendMouseClick::RIGHT, ctrl_event.up };
else
*action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up };
return true;
default:
break;
@ -116,6 +137,10 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
}
}
if (ctrl_event.button == ControllerButton::BUTTON_BACK) {
return true; // Ignore mod button
}
// By default, map to a keyboard key.
if (ctrl_event.button != ControllerButton::NONE) {
*action = GameActionSendKey { translate_controller_button_to_key(ctrl_event.button),

Loading…
Cancel
Save