0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

#Shiromino の #XBOX360 ジョイスティック(RAP VX-SA)対応

Last updated at Posted at 2020-01-22

本内容を利用した場合の一切の責任を私は負いません。

#概要
ShirominoとはTETRISである。
私は下記からダウンロードした。
https://tetrisconcept.net/threads/shiromino-tgm-practice-tool-pentominoes.3000/
デフォルトではスティックだけ正常動作し、ボタン割り当てが異常になる。
RAPのボタン配置は下記である。

BXY[LB]
A

デフォルトだとAが左回転、Yが右回転、BとXが無反応になってしまう。
当然、BとYを左回転、Xを右回転にしたい。
ソースを見るとスティック処理のボタンの部分が数値になっている。
Shirominoのボタン配置は下記である。

ABCD

その数値は下記になっている。

A(左回転) 0
B(右回転) 3
C(左回転) 5
D 1

そういえば、Nullpominoの入力テストで数値が表示されたと思い、RAPで確認すると、下記だった。

A 0
B 1
X 2
Y 3
LB 4

デフォルト動作とソースの値を比較すると、この値がボタンを表しているっぽい。
ということで、ソースを下記のように変更すると対応できた。

A(左回転) 1
B(右回転) 2
C(左回転) 3
D 4

#環境

  • OS
    OS 名: Microsoft Windows 10 Home
    OS バージョン: 10.0.18362 N/A ビルド 18362
    システムの種類: x64-based PC

  • MSYS2
    20190524(コントロールパネルの「プログラムと機能」での表示上)

  • pacman(環境作成後に-Qeオプションで出力)
    bash 4.4.023-1
    bash-completion 2.10-1
    bsdcpio 3.4.1-1
    bsdtar 3.4.1-1
    bzip2 1.0.8-1
    coreutils 8.31-1
    curl 7.68.0-1
    dash 0.5.10.2-1
    dtc 1.5.1-1
    file 5.38-1
    filesystem 2020.01-1
    findutils 4.7.0-1
    flex 2.6.4-1
    gawk 5.0.1-1
    gcc-libs 9.1.0-2
    getent 2.18.90-2
    grep 3.0-2
    gzip 1.10-1
    inetutils 1.9.4-2
    info 6.6-1
    less 551-1
    libargp 20110921-2
    lndir 1.0.3-1
    make 4.2.1-1
    mingw-w64-i686-SDL2 2.0.10-1
    mingw-w64-i686-SDL2_image 2.0.5-1
    mingw-w64-i686-SDL2_mixer 2.0.4-1
    mingw-w64-i686-gcc 9.2.0-2
    mingw-w64-i686-pkg-config 0.29.2-1
    mintty 1~3.1.0-1
    msys2-keyring r9.397a52e-1
    msys2-launcher-git 0.3.32.56c2ba7-2
    msys2-runtime 3.0.7-6
    ncurses 6.1.20191228-1
    pacman 5.2.1-6
    pacman-mirrors 20180604-2
    pactoys-git r2.07ca37f-1
    pax-git 20161104.2-1
    pkgfile 21-1
    rebase 4.4.4-1
    sed 4.8-1
    tftp-hpa 5.2-3
    time 1.9-1
    ttyrec 1.0.8-2
    tzcode 2019.a-1
    util-linux 2.34-1
    which 2.21-2

#手順
64ビット環境なのに32ビット環境にしているのはMakefileを読むと32ビット環境に見えたため。
「[MSYS2]」で始まるものはMSYS2上での操作を表す。

  1. MSYS2をインストール
    下記で「msys2-i686-20190524.exe」を選ぶ。
    https://www.msys2.org/

  2. スタートメニューからMSYS2 MinGW-32bitを起動

  3. [MSYS2]パッケージデータベースダウンロード
    pacman -Sy

  4. [MSYS2]パッケージアップデート
    pacman -Su
    MSYS2の参考のように停まるので開きなおして終わるまで。

  5. [MSYS2]mingw-w64-i686-gccパッケージインストール
    pacman -S mingw-w64-i686-gcc

  6. [MSYS2]makeパッケージインストール
    pacman -S make

  7. [MSYS2]mingw-w64-i686-pkg-configパッケージインストール
    pacman -S mingw-w64-i686-pkg-config

  8. [MSYS2]mingw-w64-i686-SDL2パッケージインストール
    pacman -S mingw-w64-i686-SDL2

  9. [MSYS2]mingw-w64-i686-SDL2_mixerパッケージインストール
    pacman -S mingw-w64-i686-SDL2_mixer

  10. [MSYS2]mingw-w64-i686-SDL2_imageパッケージインストール
    pacman -S mingw-w64-i686-SDL2_image

  11. Shirominoソースダウンロード
    https://github.com/FelicityVi/shiromino
    commit ab921e7371766a997b44672c1514ae7db144d032

  12. ダウンロードしたものをMSYS2のインストールディレクトリ下のtmp下に展開

  13. RAP対応
    下記のようにソースを変更する。

src\core.cpp
899c899
<                     rc = SDL_JoystickGetButton(joy, 0);
---
>                     rc = SDL_JoystickGetButton(joy, 1);
905c905
<                     rc = SDL_JoystickGetButton(joy, 3);
---
>                     rc = SDL_JoystickGetButton(joy, 2);
911c911
<                     rc = SDL_JoystickGetButton(joy, 5);
---
>                     rc = SDL_JoystickGetButton(joy, 3);
917c917
<                     rc = SDL_JoystickGetButton(joy, 1);
---
>                     rc = SDL_JoystickGetButton(joy, 4);
  1. [MSYS2]展開したディレクトリに移動
    ※これ以降、Markdownが誤動作しているためか手順が連番になっていないが14からである。

  2. [MSYS2]make
    make
    makeが終わるとbinディレクトリにgame.exeができあがる。

  3. [MSYS2]binディレクトリにあるgame.exeを展開した場所にコピー

  4. [MSYS2]Shiromino実行
    ./game.exe

#備考
ソースをざっと読んだら下記で設定化できるかもしれない。
変更した辺りがcs->settingsで設定情報を持っているため、下記が良さそう。

  • game.cfgに設定追加
    例えば、
game.cfg
...
P1D         /
# ADD START
P1JA        K0
P1JB        K3
P1JC        K5
P1JD        K1
# ADD END

MASTERVOLUME    80
...
  • struct bindings(src\core.h)にジョイスティックの各ボタン値のメンバを追加
    例えば、
src\core.h
...
struct bindings
{
    SDL_Keycode left;
    ...
    SDL_Keycode escape;
    int ja; //ADD
    int jb; //ADD
    int jc; //ADD
    int jd; //ADD
};
...
  • 設定のパース処理追加
    get_cfg_bindings(src\file_io.cpp)で行っていそうなので上記の設定の記載に合わせて。
    パースしたものを上記のstruct bindingsに追加したメンバに格納させる。
    なんとなく、下記でできそう。
     keystringsを9から13
     要素にP%dJA~P%dJDを追加
     keyptrsも同様
     最後の格納ループ数を9から13

  • 設定を使用するように変更
    RAP対応で変更した場所を、cs->settings->keybinds->jaとする等。

#参考

追記

[2022/05/12]
githubのこれが最新ぽい。
https://github.com/shiromino/shiromino
これのリリース0.2.1だと、コンフィグ変更だけで対応できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?