Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send keypresses when a text input is submitted (Linux only) #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

georgefst
Copy link
Owner

This needs some cleaning up.

@@ -27,7 +30,7 @@ import Monpad
import Orphans.Evdev ()

type E = Map LayoutID (Device, LayoutMeta)
type S = (Device, LayoutMeta)
type S = ((Device, LayoutMeta), Text)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a record.

'7' -> Just Key7
'8' -> Just Key8
'9' -> Just Key9
'a' -> Just KeyA
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle capitals by inserting KeyShift?

@@ -87,6 +96,18 @@ conf = ServerConfig
lookup' #stickMap i \(x', y') -> onAxis x x' <> onAxis y y'
ClientUpdate (SliderMove i x) ->
lookup' #sliderMap i . onAxis $ x * 2 - 1
ClientUpdate (InputText _ t) -> do
(#extra % _2) .= t
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should track each text input element separately. In fact, really the frontend should track this state anyway - see #35.

_ -> Nothing

keyToChar :: Key -> Maybe Char
keyToChar = \case
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY this with the above. Maybe by constructing a top level list of pairs, and two maps.

@@ -159,3 +180,107 @@ data Axis

keyUnknown :: Key
keyUnknown = KeyUnknown

charToKey :: Char -> Maybe Key
charToKey = \case
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably incomplete. Complete it and maybe upstream to evdev?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant