#include
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
29, 0, // Button Count, Hat Switch Count ここに使いたいボタン数、ハットスイッチの数を指定しないとダメ
true, true, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, false, // No rudder or throttle
false, false, false); // No accelerator, brake, or steering
//Joystick.setButton(割り当てたいボタンの番号,1でon状態、2でoff状態);
#include
//#include "Keyboard.h"
void setup()
{
PSX.mode(PSX_PAD1, MODE_DIGITAL, MODE_LOCK);
PSX.mode(PSX_PAD2, MODE_DIGITAL, MODE_LOCK);
// Poll current state once.
PSX.updateState(PSX_PAD1);
PSX.updateState(PSX_PAD2);
//Keyboard.begin();
Joystick.begin();
Joystick.setXAxisRange(-1, 1);
Joystick.setYAxisRange(-1, 1);
Joystick.setYAxis(0);
Joystick.setXAxis(0);
/*Joystick.setButton(0, 0);
Joystick.setButton(1, 0);
Joystick.setButton(2, 0);
Joystick.setButton(3, 0);*/
}
void loop()
{
PSX.updateState(PSX_PAD1);
//Left
if (PRESSED_LEFT(PSX_PAD1)) {
Joystick.setButton(1, 1);
}
if (RELEASED_LEFT(PSX_PAD1)) {
Joystick.setButton(1, 0);
}
//Down
if (PRESSED_DOWN(PSX_PAD1)) {
Joystick.setButton(2, 1);
}
if (RELEASED_DOWN(PSX_PAD1)) {
Joystick.setButton(2, 0);
}
//Up
if (PRESSED_UP(PSX_PAD1)) {
Joystick.setButton(3, 1);
}
if (RELEASED_UP(PSX_PAD1)) {
Joystick.setButton(3, 0);
}
//Right iidxコントローラでは未使用
if (PRESSED_RIGHT(PSX_PAD1)) {
Joystick.setButton(4, 1);
}
if (RELEASED_RIGHT(PSX_PAD1)) {
Joystick.setButton(4, 0);
}
//□
if (PRESSED_SQUARE(PSX_PAD1)) {
Joystick.setButton(5, 1);
}
if (RELEASED_SQUARE(PSX_PAD1)) {
Joystick.setButton(5, 0);
}
//×
if (PRESSED_CROSS(PSX_PAD1)) {
Joystick.setButton(6, 1);
}
if (RELEASED_CROSS(PSX_PAD1)) {
Joystick.setButton(6, 0);
}
//△ iidxコントローラでは未使用
if (PRESSED_TRIANGLE(PSX_PAD1)) {
Joystick.setButton(7, 1);
}
if (RELEASED_TRIANGLE(PSX_PAD1)) {
Joystick.setButton(7, 0);
}
//〇
if (PRESSED_CIRCLE(PSX_PAD1)) {
Joystick.setButton(8, 1);
}
if (RELEASED_CIRCLE(PSX_PAD1)) {
Joystick.setButton(8, 0);
}
//Start
if (PRESSED_START(PSX_PAD1)) {
Joystick.setButton(9, 1);
}
if (RELEASED_START(PSX_PAD1)) {
Joystick.setButton(9, 0);
}
//Select
if (PRESSED_SELECT(PSX_PAD1)) {
Joystick.setButton(10, 1);
}
if (RELEASED_SELECT(PSX_PAD1)) {
Joystick.setButton(10, 0);
}
//L1
if (PRESSED_L1(PSX_PAD1)) {
Joystick.setButton(11, 1);
}
if (RELEASED_L1(PSX_PAD1)) {
Joystick.setButton(11, 0);
}
//L2
if (PRESSED_L2(PSX_PAD1)) {
Joystick.setButton(12, 1);
}
if (RELEASED_L2(PSX_PAD1)) {
Joystick.setButton(12, 0);
}
//R1
if (PRESSED_R1(PSX_PAD1)) {
Joystick.setButton(13, 1);
}
if (RELEASED_R1(PSX_PAD1)) {
Joystick.setButton(13, 0);
}
//R2 未使用
if (PRESSED_R2(PSX_PAD1)) {
Joystick.setButton(14, 1);
}
if (RELEASED_R2(PSX_PAD1)) {
Joystick.setButton(14, 0);
}
PSX.updateState(PSX_PAD2);
//Left
if (PRESSED_LEFT(PSX_PAD2)) {
Joystick.setButton(15, 1);
}
if (RELEASED_LEFT(PSX_PAD2)) {
Joystick.setButton(15, 0);
}
//Down
if (PRESSED_DOWN(PSX_PAD2)) {
Joystick.setButton(16, 1);
}
if (RELEASED_DOWN(PSX_PAD2)) {
Joystick.setButton(16, 0);
}
//Up
if (PRESSED_UP(PSX_PAD2)) {
Joystick.setButton(17, 1);
}
if (RELEASED_UP(PSX_PAD2)) {
Joystick.setButton(17, 0);
}
//Right iidxコントローラでは未使用
if (PRESSED_RIGHT(PSX_PAD2)) {
Joystick.setButton(18, 1);
}
if (RELEASED_RIGHT(PSX_PAD2)) {
Joystick.setButton(18, 0);
}
//□
if (PRESSED_SQUARE(PSX_PAD2)) {
Joystick.setButton(19, 1);
}
if (RELEASED_SQUARE(PSX_PAD2)) {
Joystick.setButton(19, 0);
}
//×
if (PRESSED_CROSS(PSX_PAD2)) {
Joystick.setButton(20, 1);
}
if (RELEASED_CROSS(PSX_PAD2)) {
Joystick.setButton(20, 0);
}
//△ iidxコントローラでは未使用
if (PRESSED_TRIANGLE(PSX_PAD2)) {
Joystick.setButton(21, 1);
}
if (RELEASED_TRIANGLE(PSX_PAD2)) {
Joystick.setButton(21, 0);
}
//〇
if (PRESSED_CIRCLE(PSX_PAD2)) {
Joystick.setButton(22, 1);
}
if (RELEASED_CIRCLE(PSX_PAD2)) {
Joystick.setButton(22, 0);
}
//Start
if (PRESSED_START(PSX_PAD2)) {
Joystick.setButton(23, 1);
}
if (RELEASED_START(PSX_PAD2)) {
Joystick.setButton(23, 0);
}
//Select
if (PRESSED_SELECT(PSX_PAD2)) {
Joystick.setButton(24, 1);
}
if (RELEASED_SELECT(PSX_PAD2)) {
Joystick.setButton(24, 0);
}
//L1
if (PRESSED_L1(PSX_PAD2)) {
Joystick.setButton(25, 1);
}
if (RELEASED_L1(PSX_PAD2)) {
Joystick.setButton(25, 0);
}
//L2
if (PRESSED_L2(PSX_PAD2)) {
Joystick.setButton(26, 1);
}
if (RELEASED_L2(PSX_PAD2)) {
Joystick.setButton(26, 0);
}
//R1
if (PRESSED_R1(PSX_PAD2)) {
Joystick.setButton(27, 1);
}
if (RELEASED_R1(PSX_PAD2)) {
Joystick.setButton(27, 0);
}
//R2 未使用
if (PRESSED_R2(PSX_PAD2)) {
Joystick.setButton(28, 1);
}
if (RELEASED_R2(PSX_PAD2)) {
Joystick.setButton(28, 0);
}
}