Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ペダルのある生活 / The Pedal
Search
Hiron
April 27, 2018
Programming
0
460
ペダルのある生活 / The Pedal
Mobile Act OSAKA #4で発表したスライドです。
Hiron
April 27, 2018
Tweet
Share
More Decks by Hiron
See All by Hiron
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
270
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
470
Swift on Windows ファーストインプレッション / Swift on Windows First Impression
hironytic
0
660
iPadOSDC: Multiple Windows
hironytic
5
3.2k
だったら、俺が代わりにやってやる / Swift Zoomin' Challenge
hironytic
0
200
SwiftのNeverとボトム型 / Never as a Bottom Type
hironytic
2
860
4000のワーニングと戦え!これは警告だ! / 4000 Warnings
hironytic
2
840
シンボリケート / Ore-con 2018 Summer
hironytic
3
1.1k
全部iOSにしゃべらせちゃえ! / iOSDC 2018 LT
hironytic
3
1.6k
Other Decks in Programming
See All in Programming
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
560
Is Xcode slowly dying out in 2025?
uetyo
1
170
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
270
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
290
関数型まつりレポート for JuliaTokai #22
antimon2
0
130
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
150
赤裸々に公開。 TSKaigiのオフシーズン
takezoux2
0
140
Select API from Kotlin Coroutine
jmatsu
1
180
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
1
110
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
130
XP, Testing and ninja testing
m_seki
2
110
生成AIで日々のエラー調査を進めたい
yuyaabo
0
610
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
329
21k
Designing Experiences People Love
moore
142
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
For a Future-Friendly Web
brad_frost
179
9.8k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Docker and Python
trallard
44
3.4k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Transcript
ペダルのある生活 2018/04/27 Mobile Act OSAKA #4
なぜか土曜日 エライ人
自己紹介 • ひろん(一宮 浩教) • Twitter、GitHub、Qiita、 SlideShare、Speaker Deck: ➡hironytic •
株式会社 MetaMoJi(徳島勤務)
None
音楽関係の法人様 • 楽譜の共有に利用したい
iRig BlueTurn http://hookup.co.jp/products/ik-multimedia/irig-blueturn お荷物の お届けでーす
iRig BlueTurn • Bluetooth接続のハードウェアキーボードとして 動作する - MODE 1: ↑/↓ -
MODE 2: Page Up/Page Down - MODE 3: ←/→
どうなるのか考える ハードウェアキーボードに対応すればよい /以上 http://amzn.asia/iPpfS6t
ハードウェアキーボード対応(iOS) • UIKeyCommand • ファーストレスポンダーでUIKeyCommandオブジェ クトの配列を返せばよい extension UIResponder { @available(iOS
7.0, *) open var keyCommands: [UIKeyCommand]? { get } }
UIKeyCommandを返す class ViewController: UIViewController { override var canBecomeFirstResponder: Bool {
return true } override var keyCommands: [UIKeyCommand]? { return [ UIKeyCommand(input: UIKeyInputUpArrow, modifierFlags: [], action: #selector(pageUp)), UIKeyCommand(input: UIKeyInputDownArrow, modifierFlags: [], action: #selector(pageDown)), UIKeyCommand(input: UIKeyInputLeftArrow, modifierFlags: [], action: #selector(pageUp)), UIKeyCommand(input: UIKeyInputRightArrow, modifierFlags: [], action: #selector(pageDown)), ] } @objc func pageDown() { /* ࣍ͷϖʔδ */ } @objc func pageUp() { /* લͷϖʔδ */ } }
PageUp、PageDownは? • APIで定義されていない • Stack Overflowに答えがあった(*) - 文字列 "UIKeyInputPageUp", "UIKeyInputPageDown"
- Undocumented APIの使用になるかどうかは 知らんけど * https://stackoverflow.com/a/44321674/4313724 (たぶん大丈夫。知らんけど)
UIKeyCommandを返す override var keyCommands: [UIKeyCommand]? { return [ UIKeyCommand(input: UIKeyInputUpArrow,
modifierFlags: [], action: #selector(pageUp)), UIKeyCommand(input: UIKeyInputDownArrow, modifierFlags: [], action: #selector(pageDown)), UIKeyCommand(input: UIKeyInputLeftArrow, modifierFlags: [], action: #selector(pageUp)), UIKeyCommand(input: UIKeyInputRightArrow, modifierFlags: [], action: #selector(pageDown)), UIKeyCommand(input: "UIKeyInputPageUp", modifierFlags: [], action: #selector(pageUp)), UIKeyCommand(input: "UIKeyInputPageDown", modifierFlags: [], action: #selector(pageDown)), ] }
ハードウェアキーボード対応(Android) class MainActivity : AppCompatActivity() { override fun onKeyDown(keyCode: Int,
event: KeyEvent?): Boolean { when (keyCode) { KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_PAGE_UP -> { pageDown() return true } KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT, KeyEvent.KEYCODE_PAGE_DOWN -> { pageUp() return true } else -> { return super.onKeyDown(keyCode, event) } } } private fun pageDown() { /* ࣍ͷϖʔδ */ } private fun pageUp() { /* લͷϖʔδ */ } }
報告 ぼく「このペダルの場合、追加のSDKも特に必 要ありませんでした。お客様はこのペダルを使わ れるんですよね?」 エライ人「さあ?Amazonで最初に見つかった のを買ってみただけ」 ぼく「えっ・・・!?」
まとめ • iRig BlueTurnはハードウェアキーボード • iOSでは UIKeyCommand を使う • Androidでは
onKeyDown() を使う