・2021/11/07
QMK firmwareで Analog Stick機能で PSP2000用アナログ ジョイスティックを試してみる
(QMK firmware test Analog Joystick function with PSP2000 Analog Stick)
Tags: [電子工作], [QMK]
● QMK firmwareの関連記事
・2021/08/23
QMK firmwareの開発環境を ラズパイや Windows WSLにセットアップする方法
ラズパイや Windows WSL環境でカスタマイズ キーボードのファームウェア QMK firmwareの開発環境を構築
・2022/01/09
BUFFALOの USB テンキーを Pro Microと QMKを使って VIAカスタマイズ キーボードに改造する方法
BUFFALO USB 10-Key keyboard BSTK100 modification by Pro Micro and QMK firmware VIA
・2021/08/11
社畜のキーボード「新入社員の同期」を購入してみた!! VIA、QMK、Remapでのカスタマイズに対応
キー内容が Remap等でカスタマイズ可能な社畜のキーボード「新入社員の同期」を 3500円で購入
● QMK firmwareの Joystick機能を使って PSP-2000で Gameコントローラを実装してみるテスト
QMK - Joystick
PSP-1000、PSP-2000、PSP-3000とで接続部分が異なります。
PSP-2000の物が一番簡単だと思います。
● Switchのジョイコンを使う場合は MicroUSBの変換基板を接続用として転用します
Switchのジョイコンを使う場合は MicroUSBの変換基板の USBコネクタ部分を 0.5mmピッチの FPCコネクタに載せ換えて変換基板として代用します。
※ 0.5mmピッチのフレキシブルケーブルに直接の半田付けは不可能です
● QMK firmwareの Joystick機能を使って PSP-2000で Gameコントローラを実装してみるテストの回路図
・QMK firmwareの Joystick機能を使って PSP-2000で Gameコントローラを実装してみるテストの回路図
● QMK firmwareの Joystick機能を使って PSP-2000で Gameコントローラを実装してみるテストのソースリスト
handwired/freewing/test_qmk
rules.mk
JOYSTICK_ENABLE = yes # Joystick Game controller HID Interface
JOYSTICK_DRIVER = analog # Stick mode analog or digital
SRC += analog.c
config.h
#ifdef JOYSTICK_ENABLE
#define JOYSTICK_BUTTON_COUNT 0
#define JOYSTICK_AXES_COUNT 2
#define JOYSTICK_AXES_RESOLUTION 10
#endif
●その1
test_qmk.c
#ifdef JOYSTICK_ENABLE
#include "joystick.h"
#include "analog.h"
/* joystick config */
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
[0] = JOYSTICK_AXIS_IN(B4, 1023, 512, 0),
[1] = JOYSTICK_AXIS_IN(B5, 0, 512, 1023)
};
/* joystick button code (thumbstick pressed) */
void keyboard_pre_init_kb(void) {
// setPinInputHigh(F6);
}
#endif
●その2
その2の方がスティックの変位が自然。
#ifdef JOYSTICK_ENABLE
#include "joystick.h"
#include "analog.h"
void joystick_task(){
joystick_status.axes[0] = analogReadPin(B4)/4 - 128;
joystick_status.axes[1] = analogReadPin(B5)/4 - 128;
joystick_status.status |= JS_UPDATED;
send_joystick_packet(&joystick_status);
}
#endif
・QMK firmwareの Joystick機能を使って PSP-2000で Gameコントローラを実装してみるテスト
●その他の QMK キーボードの試作品
Quantum Mechanical Keyboard
・Piezo Buzzer = Passive
他励振タイプ(パッシブ、受身)の圧電ブザーの Audio機能の確認
・Analog Joystick = PSP-2000 compatible
PSP-2000互換のアナログ ジョイスティックによるマウス操作、ゲームコントローラ操作
・OLED Display = I2C SSD1306 128x32
I2C接続の有機 LEDディスプレイ SSD1306 128x32の表示確認
Hand Wired QMK Firmware test with Pro Micro and Buzzer Analog Joystick OLED SSD1306
● QMK firmwareの Joystick機能を使って PSP-2000でマウスカーソルを動かすテストのソースリスト
handwired/freewing/test_qmk
qmk_firmware/keyboards/40percentclub/nano/keymaps/drashna/keymap.c
を参考にした(マルパク)。
rules.mk
# JOYSTICK_ENABLE = yes # Joystick Game controller HID Interface
# JOYSTICK_DRIVER = analog # Stick mode analog or digital
SRC += analog.c
POINTING_DEVICE_ENABLE = yes # Generic Pointer
test_qmk.c
#include "analog.h"
#include "pointing_device.h"
// Set Parameters
uint16_t minAxisValue = 0;
uint16_t maxAxisValue = 1023;
uint8_t maxCursorSpeed = 2;
uint8_t precisionSpeed = 1;
uint8_t speedRegulator = 20; // Lower Values Create Faster Movement
int8_t xPolarity = 1;
int8_t yPolarity = 1;
uint8_t cursorTimeout = 10;
int16_t xOrigin, yOrigin;
uint16_t lastCursor = 0;
int16_t axisCoordinate(uint8_t pin, uint16_t origin) {
int8_t direction;
int16_t distanceFromOrigin;
int16_t range;
int16_t position = analogReadPin(pin);
if (origin == position) {
return 0;
} else if (origin > position) {
distanceFromOrigin = origin - position;
range = origin - minAxisValue;
direction = -1;
} else {
distanceFromOrigin = position - origin;
range = maxAxisValue - origin;
direction = 1;
}
float percent = (float)distanceFromOrigin / range;
int16_t coordinate = (int16_t)(percent * 100);
if (coordinate < 0) {
return 0;
} else if (coordinate > 100) {
return 100 * direction;
} else {
return coordinate * direction;
}
}
int8_t axisToMouseComponent(uint8_t pin, int16_t origin, uint8_t maxSpeed, int8_t polarity) {
int coordinate = axisCoordinate(pin, origin);
if (coordinate != 0) {
float percent = (float)coordinate / 100;
if (get_mods() & MOD_BIT(KC_LSFT)) {
return percent * precisionSpeed * polarity * (abs(coordinate) / speedRegulator);
} else {
return percent * maxCursorSpeed * polarity * (abs(coordinate) / speedRegulator);
}
} else {
return 0;
}
}
void pointing_device_init(void) {
// init pin? Is needed?
// setPinInputHigh(E6);
// Account for drift
xOrigin = analogReadPin(B4);
yOrigin = analogReadPin(B5);
}
void pointing_device_task(void) {
report_mouse_t report = pointing_device_get_report();
// todo read as one vector
if (timer_elapsed(lastCursor) > cursorTimeout) {
lastCursor = timer_read();
report.x = axisToMouseComponent(B4, xOrigin, maxCursorSpeed, xPolarity);
report.y = axisToMouseComponent(B5, yOrigin, maxCursorSpeed, yPolarity);
}
//
// if (!readPin(E6)) {
// report.buttons |= MOUSE_BTN1;
// } else {
// report.buttons &= ~MOUSE_BTN1;
// }
pointing_device_set_report(report);
pointing_device_send();
}
Tags: [電子工作], [QMK]
●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)
【自由工作】市販のキーボードを無改造で VIA QMK化する Keyboard Quantizerを自作する【夏休み】
夏休みが明けたら 僕のキーボードが最強になって クラスのみんなから MMK 大作戦
BUFFALOの USB テンキーを Pro Microと QMKを使って VIAカスタマイズ キーボードに改造する方法
BUFFALO USB 10-Key keyboard BSTK100 modification by Pro Micro and QMK firmware VIA
QMK firmwareの開発環境を ラズパイや Windows WSLにセットアップする方法
ラズパイや Windows WSL環境でカスタマイズ キーボードのファームウェア QMK firmwareの開発環境を構築
QMK firmwareでプログラムのサイズを小さくするテクニック、ケチケチ プログラミングの方法
QMK firmware How to Reduce Program Size、Reducing QMK firmware size
QMK firmwareで I/Oピンが足りない場合にデコーダ、デマルチプレクサを使用して IOを拡張する解決方法
QMK firmware expand I/O for many matrix keyboard、How to use IO Expander Multiplexer / Demultiplexer / Decoder
QMK firmwareで I/Oピンが足りない場合に I2Cの GPIOエキスパンダを使用して IOを拡張する解決方法
QMK firmware expand I/O for many matrix keyboard、How to use I2C GPIO Expander PCF8574 and PCF8575
QMK firmwareで Audio機能を試してみる
QMK firmware test Audio function with Piezo buzzer
QMK firmwareで OLED機能で SSD1306を試してみる
QMK firmware test OLED Driver with SSD1306
最新の QMK firmwareで new_keyboard.shのコマンドが動かなくなったのを修正する方法
QMK Bugfix Create New Keyboard new_keyboard.sh command No such file or directory Error
QMK firmwareの Githubを forkした自分のリモートに pushすると怒られて pushできない場合の対応方法
refusing to allow an OAuth App to create or update workflow `.github/workflows/api.yml` without `workflow` scope
中華製の格安なプログラマブル USBキーボードを買ってみた QMK VIAとは別物
中華製のプログラマブル USBキーボード KeyboardSetter.exe
社畜のキーボード「新入社員の同期」を購入してみた!! VIA、QMK、Remapでのカスタマイズに対応
キー内容が Remap等でカスタマイズ可能な社畜のキーボード「新入社員の同期」を 3500円で購入
[HOME]
|
[BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c)
2021 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator
http://www.neko.ne.jp/~freewing/hardware/qmk_firmware_test_analog_joystick_function_psp2000/