doc:appunti:android:bluetooth_keboard
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:android:bluetooth_keboard [2020/01/31 15:26] – [Using OsmAnd with a Remote Controller] niccolo | doc:appunti:android:bluetooth_keboard [2020/02/04 10:38] (current) – removed niccolo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Using OsmAnd with a Remote Controller ====== | ||
- | I'm an early joiner of the **OpenStreetMap** project, so I'm a big fan of the **OsmAnd** app. It is my preferred choice for **motorbike on-board navigation**. | ||
- | |||
- | A long-standing issue was the impossiblity to operate the map while **wearing gloves**. To be clear: panning and zooming on the Android touchscreen is impossibile. Here we explore the possibility to use a little Bluetooth remote controller to get at least the **basic pan/zoom functions**; | ||
- | |||
- | [{{.: | ||
- | |||
- | In OsmAnd you have to enable: Hamburger menu => **Configure profile** => General settings => **External input devices** => **Keyboard**. | ||
- | |||
- | | {{: | ||
- | | {{: | ||
- | ===== The Mocute Universal Wireless Remote Controller ===== | ||
- | |||
- | It is a low-cost (5-10 euros) **Bluetooth** device. It has an internal **rechargeable battery** which should last about 10 hours. the small size is quite convenient for using it on the **handlebar** of a motorbike, the biggest problem being to be **not water-proof**. | ||
- | |||
- | Once paired with the Android device, you can get some information using **cat / | ||
- | |||
- | < | ||
- | I: Bus=0005 Vendor=ffff Product=0000 Version=0000 | ||
- | N: Name=" | ||
- | P: Phys= | ||
- | S: Sysfs=/ | ||
- | U: Uniq=E6: | ||
- | H: Handlers=sysrq gpufreq_ib event9 | ||
- | B: PROP=0 | ||
- | B: EV=10001f | ||
- | B: KEY=3f0003007f 0 0 483ffff17aff32d bf54444600000000 6fdb0000001f0001 | ||
- | | ||
- | B: REL=143 | ||
- | B: ABS=100030627 | ||
- | B: MSC=10 | ||
- | </ | ||
- | |||
- | ===== Android ScanCodes and KeyCodes ===== | ||
- | |||
- | Generally speaking, an Android input device generates a different hardware **ScanCode** when you press each different key. Using an appropriate **keylayout file**, each ScanCode is translated into an **Android KeyCode**, which is sent to the application. For example: the Mocute controller generates the **ScanCode 114** when you press the **A button**, looking at **/ | ||
- | |||
- | ===== Default key mapping ===== | ||
- | |||
- | The Mocute-032 controller has a little slide switch with two positions: **GAME** and **KEY**. Each mode generates different **ScanCodes** for the four buttons. Also **the joystick operates differently**: | ||
- | |||
- | [{{.: | ||
- | |||
- | ==== The joystick in GAME mode ==== | ||
- | |||
- | In **GAME mode**, each **axis position** is reported as a **floating point number** ragining from **-1.0** to **1.0**, where the **zero** is at the **central position**. When the joystick is pushed near to one side, an **Android KeyCode** is generated. This means that beside the axes position, an appropriate KEYCODE_DPAD_UP, | ||
- | |||
- | You can see **joystick axes values** with apps like **[[https:// | ||
- | |||
- | ^ ^ KEY Mode ^^^ GAME Mode ^^^ | ||
- | ^ ^ ScanCode | ||
- | ^ UP | ||
- | ^ DOWN | ||
- | ^ LEFT | ||
- | ^ RIGHT | 168 | 89 | KEYCODE_MEDIA_REWIND | ||
- | ^ A | 114 | 25 | KEYCODE_VOLUME_DOWN | ||
- | ^ B | 28 | 66 | KEYCODE_ENTER | ||
- | ^ X | 115 | 24 | KEYCODE_VOLUME_UP | ||
- | ^ Y | 158 | 4 | KEYCODE_BACK | ||
- | |||
- | ===== Key Layout ===== | ||
- | |||
- | Many key layouts exists into an Android device, they are stored into the **/ | ||
- | |||
- | < | ||
- | ... | ||
- | key 10 9 | ||
- | key 11 0 | ||
- | key 12 MINUS | ||
- | key 13 EQUALS | ||
- | key 14 DEL | ||
- | key 15 TAB | ||
- | key 16 Q | ||
- | key 17 W | ||
- | key 18 E | ||
- | ... | ||
- | key 113 | ||
- | key 114 | ||
- | key 115 | ||
- | ... | ||
- | </ | ||
- | |||
- | **OsmAnd 3.5.5** supports some external input devices, to use the Mocute controller we need to enable the **keyboard external input device**. At the moment the only recognized KeyCodes are: | ||
- | |||
- | ^ OsmAnd KeyCodes | ||
- | ^ KEYCODE_DPAD_RIGHT | Scroll right | | ||
- | ^ KEYCODE_DPAD_LEFT | ||
- | ^ KEYCODE_DPAD_UP | ||
- | ^ KEYCODE_DPAD_DOWN | ||
- | ^ KEYCODE_PLUS | ||
- | ^ KEYCODE_MINUS | ||
- | |||
- | ===== Remapping the controller keys (root required) ===== | ||
- | |||
- | The **GAME mode** is somewhat working out-of-the-box, | ||
- | |||
- | - **Swap the X with the Y axis** and **invert the X**. This is because we want to use the controller in vertical position. | ||
- | - Associate the **X** button to **zoom in**, and **Y** button to **zoom out**. | ||
- | |||
- | In theory - to remap the functions of our controller - it should be possible to provide a **specific keylayout file** for just this controller, just giving it the name **Vendor_ffff_Product_0000.kl** (see the vendor and product read from the ''/ | ||
- | |||
- | So we have to change the **Generic.kl** file, redefining some ScanCodes and axis (the rest of the file must remain untouched): | ||
- | |||
- | < | ||
- | key 305 MINUS | ||
- | key 307 PLUS | ||
- | axis 0x00 Y | ||
- | axis 0x01 invert X | ||
- | </ | ||
- | |||
- | ===== Key Mapping Test ===== | ||
- | |||
- | Using the **[[https:// | ||
- | |||
- | Using the **[[https:// | ||
- | |||
- | Using the **[[https:// | ||
- | |||
- | ===== Web References ===== | ||
- | |||
- | * **[[https:// | ||
- | * **{{mocute-032_s23-auto_manual_en.pdf|MOCUTE 032 S23 User Manual}}** (original link: [[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// | ||
- | * **[[https:// |