Keybow KitのショートカットでPS4とDBDを起動する

Keybow KitのショートカットでPS4とDBDを起動する
公開日時

近頃、友達とDead by Daylightで鬼ごっこをやるのにハマっているので、Keybowのショートカット一発でPS4の起動とソフトの起動ができるようにしてみた。

nodejs設定

sudo apt install -y nodejs npm
sudo npm install n -g
sudo n stable
sudo apt purge -y nodejs npm
exec $SHELL -l

ps4の自動起動

mkdir ps4
cd ps4
npm init
npm install --save ps4-waker
npx ps4-waker
  • PS4でモバイルデバイスの登録を行い、表示されるPINコードを入力

  • PS4をスタンバイモードに変更

  • 再度ps4-wakerを実行すると、自動でPS4が起動する

npx ps4-waker

Dead by Daylightの自動起動

ps4-waker Wikiを参考にDead by DaylightのTitleIDを調べる。

PlayStation StoreでDead by Daylightを開くと、URLに[[CUSA08444]]とあるのでこれがTitleIDになる。

npx ps4-waker start CUSA08444

で自動起動できる。

Keybow設定

最後にKeybowのショートカットにコマンドを割り当てる。

  • ベースになるluaファイルをコピー
sudo cp /boot/layouts/mini.lua /boot/layouts/custom.lua
  • [[/boot/keys.lua]]がcustom layoutを読み込むように変更
require "keybow"
-- require "layouts/default" -- Numberpad
require "layouts/custom" -- Keybow MINI custom layout
  • [[/boot/layouts/custom.lua]]にPS4起動コマンドを設定
require "keybow"

-- Keybow MINI --

function setup()
    keybow.use_mini()
    keybow.auto_lights(false)
    keybow.clear_lights()
end

-- Key mappings --

function handle_minikey_00(pressed)
    keybow.set_key("0", pressed)
    if pressed then
        keybow.set_pixel(0, 255, 0, 0)
    else
        keybow.set_pixel(0, 0, 0, 0)
    end
end

function handle_minikey_01(pressed)
    keybow.set_key("1", pressed)
    if pressed then
        keybow.set_pixel(1, 0, 255, 0)
        os.execute("cd /home/pi/ps4 && sudo -u pi npx ps4-waker standby")
    else
        keybow.set_pixel(1, 0, 0, 0)
    end
end

function handle_minikey_02(pressed)
    keybow.set_key("2", pressed)
    if pressed then
        keybow.set_pixel(2, 0, 0, 255)
        os.execute("cd /home/pi/ps4 && sudo -u pi npx ps4-waker start CUSA08444")
    else
        keybow.set_pixel(2, 0, 0, 0)
    end
end

これでキーを一回押すだけで、Dead by Daylightの起動が自動でできるようになった。

ついでにスタンバイモードのショートカットも設定しておいた。

参考


Related #raspberry pi