Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ペダルのある生活 / The Pedal
Search
Hiron
April 27, 2018
Programming
540
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ペダルのある生活 / The Pedal
Mobile Act OSAKA #4で発表したスライドです。
Hiron
April 27, 2018
Transcript
15 slides
ペダルのある生活 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() を使う
More Decks by Hiron
See All by Hiron
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
410
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
600
Swift on Windows ファーストインプレッション / Swift on Windows First Impression
hironytic
0
760
iPadOSDC: Multiple Windows
hironytic
5
3.8k
だったら、俺が代わりにやってやる / Swift Zoomin' Challenge
hironytic
0
270
SwiftのNeverとボトム型 / Never as a Bottom Type
hironytic
2
970
4000のワーニングと戦え!これは警告だ! / 4000 Warnings
hironytic
2
930
シンボリケート / Ore-con 2018 Summer
hironytic
3
1.3k
全部iOSにしゃべらせちゃえ! / iOSDC 2018 LT
hironytic
3
2.1k
Other Decks in Programming
See All in Programming
オーケストレーション記述言語 Katari
yukikurage
0
260
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
320
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
Spec-driven Development with AI
simas
PRO
0
2.3k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
150
Next.js: The final boss of Web Performance
guaca
0
400
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
100
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
Modernizing iOS Apps
seyfoyun
0
150
Distance field of Julia set
kinakomoti321
0
320
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
200
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
230
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.4k
WENDY [Excerpt]
tessaabrams
15
40k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
590
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
670
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
620
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
2
3.8k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520
Testing 201, or: Great Expectations
jmmastey
46
8.4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Being A Developer After 40
akosma
PRO
92
590k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
400