Skip to content

Commit 713bcd0

Browse files
committed
Added STARTMOUSE/Mouse mode; default double w.
1 parent d67bbfc commit 713bcd0

File tree

6 files changed

+27
-89
lines changed

6 files changed

+27
-89
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ This project aims to significantly enhance the typing experience for Tap Strap u
1717
* (Optional) Tap Cycling: If you keep double-triple-etc tapping, after you go past the end of what's configured, it wraps back around to single-tap again, so you can "go back" without getting the wrong output first.
1818
* Does All the Keys: You know the list of like a thousand Android KeyCodes? Well, we do! ( See /config/DEFAULT_1 )
1919
* Multiple Configuration Profiles: Supports switching between unlimited chording configurations to suit different use cases.
20+
* Easier Switching Between Mouse and Not: You can set a tap command to activate the mouse instead of all the fiddling about with trying to get the firmware to recognize you want mouse mode. In the default keymap, double-tap w to activate mouse mode. There is no AirMouse.
2021
* Super Untested And Unfinished Code: You won't see that from Tap Systems!
2122

2223
## Upcoming Features:
2324

2425
* Hopefully nothing -- it would be infintely prefereable to see Tap Systems make these features available on-device, most particularly the elimination of the backspace behavior and the ability to program chords offline. But until they do...
25-
* Mouse mode
2626
* Better UI/In-app Configuration
2727
* System service to make it useful even when Android doesn't want to use the IME (anytime you're not in a text entry, basically) -- work more like a hardware keyboard.
2828
* I'd still like to add a HID "passthrough" that allows you to connect your phone to another device and actually use the Tap Strap with these IME features on any bluetooth device. But so far, no luck.
@@ -50,7 +50,10 @@ It's full of bugs and will probably set your phone on fire. I can't take any re
5050
* If you use mulitple maps, they can be named whatever you like, but still must end in \_1.csv for the first tap, \_2 for the second, etc.
5151
* Comments in DEFAULT\_1.csv in the /config directory here will give you some clues.
5252

53-
## USAGE NOTE:
53+
## USAGE NOTES:
54+
55+
* The only way to activate mouse mode when using the IME is to use the tap command to start it. By default it's double-tap w, 10101. But you can set STARTMOUSE to any tap you like in your own config.
56+
* Even more importantly, the only way to get out of mouse mode is by tapping all four fingers, think 'h' or 01111.
5457

5558
### JUST KEEP TAPPING. // Hey, is this an app name?
5659

app/src/main/java/com/scribblej/tapstrapapp/TapInputMethodService.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.scribblej.tapstrapapp.presentation.TapInputView
2929

3030
import com.scribblej.tapstrapapp.presentation.TapInputViewModel
3131
import com.tapwithus.sdk.mode.TapInputMode
32+
import com.tapwithus.sdk.mouse.MousePacket
3233

3334
// For managing the timeouts without race conditions
3435
import java.util.concurrent.Executors
@@ -62,12 +63,17 @@ class TapInputMethodService : LifecycleInputMethodService(),
6263
return arrayOf()
6364
}
6465

66+
var inMouseMode = false
67+
6568
private fun tapMouseStart() : Array<KeyEvent> {
6669
sdk.connectedTaps.forEach() { sdk.startControllerWithMouseHIDMode(it) }
70+
inMouseMode = true;
6771
return arrayOf()
6872
}
73+
6974
private fun tapMouseStop() : Array<KeyEvent> {
7075
sdk.connectedTaps.forEach() { sdk.startControllerMode(it) }
76+
inMouseMode = false;
7177
return arrayOf()
7278
}
7379

@@ -76,7 +82,7 @@ class TapInputMethodService : LifecycleInputMethodService(),
7682
private val actionMap: Map<String, () -> Array<KeyEvent>> = mapOf(
7783
"MAPSWITCH" to { prepareMapSwitch() },
7884
"STARTMOUSE" to { tapMouseStart() },
79-
"STOPMOUSE" to { tapMouseStop() },
85+
"STOPMOUSE" to { tapMouseStop() }, // There's not actually any way to use this right now, it's hardcoded 01111 in mouse mode gets you out.
8086
"CTRL" to { toggleModifier(KeyEvent.META_CTRL_ON) },
8187
"ALT" to { toggleModifier(KeyEvent.META_ALT_ON) },
8288
"SHIFT" to { toggleModifier(KeyEvent.META_SHIFT_ON) },
@@ -244,6 +250,8 @@ class TapInputMethodService : LifecycleInputMethodService(),
244250
)
245251
}
246252

253+
254+
247255
var mapSwitchFlag: Boolean = false
248256
// TODO: check whether input is even wanted?
249257
private fun sendKeys(commandList: CommandList) {
@@ -320,6 +328,17 @@ class TapInputMethodService : LifecycleInputMethodService(),
320328
val tapPattern: TapPattern = data
321329
tapInputViewModel.updateTapPattern(tapPattern)
322330

331+
//TODO: this better
332+
if (inMouseMode) {
333+
// We have to continue to listen to taps, but we don't want to respond to any of them until we see the secret
334+
// stop mousing code. Which for purposes of testing, I guess we could use the distance in the mouse packets,
335+
// or we could have a particular tap, or IDK IDK. Today's not a day for thinking.
336+
val secretStop = "01111".reversed().toInt(2) // whynot?
337+
if (tapPattern == secretStop)
338+
tapMouseStop()
339+
340+
return
341+
}
323342
val commandLists = getCommandListsForTapPattern(tapPattern)
324343
tapInputViewModel.setCommandLists(commandLists)
325344

config/DEFAULT_2.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
01001,[
2020
# looks like y and w
2121
10001,z
22-
10101,
22+
10101,STARTMOUSE
2323
# one finger up
2424
01111,.
2525
10111,:

config/testconfig/DEFAULT_1.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
11001,ENTER
3636
10011,p
3737
#
38-
11100,MAPSWITCH,MOUSEMAP,STARTMOUSE
38+
11100,STARTMOUSE
3939
01110,BACKSPACE
4040
00111,MAPSWITCH,SWITCHMAP
4141
# all fingers together

config/testconfig/MOUSEMAP.csv

Lines changed: 0 additions & 42 deletions
This file was deleted.

config/testconfig/SHIFTMAP_1.csv

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)