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.

ProcessingでPC Engine miniのコントローラを使う

Last updated at Posted at 2020-05-27

#本記事はProcessingでPC Engine miniのコントローラ使う方法のサンプルです。複数台使う記事はこちらです。
https://qiita.com/hextomino/items/83918f9d603157f64421

はじめに

2020年3月にPC Engine miniが発売されました。付属のコントローラは本体とUSB接続するタイプなので、パソコンでも使えるだろうとやってみた次第です。

結果としては、普通に使えました。

よくあるゲームコントローラのように、アナログスティックやLRがなく、ボタンの数も最低限しかないので、一般向けではないですが、シンプルなコントローラがほぼ販売されていない中で、貴重な存在です。追加で購入できるコントローラには連射機能がついており、連射無しタイプは販売されていないようです。当時のコントローラは、使っているうちに表面のビニールが剥がれてきてしまったのですが、これの耐久性が気になります。

テスト環境

windows 8
processing 3.5.3
Game Control Plusライブラリ1.2.2
http://lagers.org.uk/gamecontrol/ref/index.html

Game Control Plusライブラリ

①コントローラをパソコンに接続します。
②Processingのライブラリ追加機能からインストールします。
③付属サンプルのGcp_Configuratorや、Gcp_ShowDevicesを実行して、認識されていることを確認します。
 ライブラリには、ボタン押下時にイベント発生させて、関数を呼び出す機能がありますが、私は使わないので省略し、最低限のソースコードにしました。

ソースコード

PCEnginePAD.pde
import net.java.games.input.*;
import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;

ControlIO control;
ControlDevice pad;

ControlButton b1, b2;
ControlHat hat;

void setup() {
  control = ControlIO.getInstance(this);
  pad = control.getDevice("PCEngine PAD");

  b2 = pad.getButton(1);
  b1 = pad.getButton(2);
  hat = pad.getHat(14);

  size(200, 200);
}

void draw() {
  println(
    "  Ⅰ:",b1.pressed(),
    ", Ⅱ:",b2.pressed(),
    ", ↓:",hat.down(),
    ", →:",hat.right(),
    ", ←:",hat.left(),
    ", ↑:",hat.up()
  );
}
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?