Commit Graph

310 Commits

Author SHA1 Message Date
June Tate-Gans
ccca4b5016 ui: Add changeTriggers to complete the migration to them 2021-05-04 01:41:56 -05:00
June Tate-Gans
aecf1d0644 popover: Fix a bunch of things to be accessors now. 2021-05-04 01:41:14 -05:00
June Tate-Gans
a28a90f37b mainwindow: Fix the names of the analog stick buttons 2021-05-03 18:16:34 -05:00
June Tate-Gans
244368ede3 g13buttonpopover: Read from evdev to capture keys
Since GDK/GTK filter events through Xorg, libinput, and everything else in
between, we can't use their keypress detection code to actually figure out what
the linux key codes are, instead we read directly from all keyboard-like evdev
devices on the system.

This is less than ideal, but directly due to Linux/Xorg/libinput/XKB/GDK/GTK/GNOME's
completely batshit insane input model. On Wayland it gets better, but not by
much since most compositors still use XKB and libinput.

*sigh*
2021-05-03 18:14:32 -05:00
June Tate-Gans
240be20b63 g13button: Swap out the old notification mechanism for triggers
This is a bit cleaner, overall, but also this makes key binding in the UI
actually work again.
2021-05-03 18:12:51 -05:00
June Tate-Gans
003ab3b526 observer: Coerce scalar values in keys to sets
Unfortunately, strings are iterable in python, so without this a call with a
single string, or a construct of "('foo')" would result in creating keys for
each letter of the string 'foo'. "('foo',)" works, because , creates the tuple,
not the parens...
2021-05-03 18:11:28 -05:00
June Tate-Gans
4d11270a7c main: Since we use lots of crazy threads, ensure GDK is ready 2021-05-03 18:10:56 -05:00
June Tate-Gans
ce8a106ea3 input: Restructure to use GObject and io_watches
This isn't ideal, since opening all of the devices in /dev/input is slow, and
this runs on the UI thread, but it works for now. Ultimately, InputReader should
probably be restructured as a threading.Thread and use GLib.idle_add to send the
signals out.
2021-05-03 18:09:08 -05:00
June Tate-Gans
65c2580e45 manager: Use the key name, rather than its number
This allows us to be a bit more flexible in the way we define bindings. We still
have to use the scancodes for the actual bindings (since we're outputting to
uinput), but this should be a little easier to digest.

...also it fixed a bug... =op
2021-05-03 18:08:11 -05:00
June Tate-Gans
6ddee4ae88 g13gui: Actually finish the migration
Add an evdev listener for input so we can use linux "keysyms" for keyboard
events, since uinput uses it.
2021-05-02 23:48:52 -05:00
June Tate-Gans
0a0ecfc9bc observer: Finish migrating Subject 2021-05-02 23:48:20 -05:00
June Tate-Gans
9a9f504995 g13gui: bindings: Setup preliminaries for keycode decoding 2021-05-02 23:47:54 -05:00
June Tate-Gans
8a6fc4b0f0 g13gui: manager: Ensure both the header and buffer are bytes 2021-05-02 23:47:25 -05:00
June Tate-Gans
054d31033f g13gui: Rework the observer model
Subject was large enough to be in its own file.
2021-05-02 23:46:55 -05:00
June Tate-Gans
b3d0cb5f21 g13d: Remove the last few bits of g13d from the tree 2021-05-02 16:25:25 -05:00
June Tate-Gans
f4daed3148 g13d: Kill off the old daemon
We no longer need this -- g13gui.g13 does everything and more.
2021-05-02 16:23:37 -05:00
June Tate-Gans
8ebe1e2fc2 g13gui: bitwidgets: Add in button tests 2021-05-02 15:24:13 -05:00
June Tate-Gans
493206d552 g13gui: g13: Add a bitwidgets backend for displaying to the G13 2021-05-02 15:23:07 -05:00
June Tate-Gans
186f64c33f g13gui: observer: Add a helpful method for misnamed calls 2021-05-02 15:22:43 -05:00
June Tate-Gans
dfe9713011 g13gui: g13: Fix the header to be a series of bytes 2021-05-02 15:22:25 -05:00
June Tate-Gans
caa316c850 g13gui: bitwidgets: Fix a few bugs in widget 2021-05-02 15:22:08 -05:00
June Tate-Gans
5f5b1e0879 g13gui: bitwidgets: Make the buttonbar visible 2021-05-02 15:21:45 -05:00
June Tate-Gans
513928e57e g13gui: bitwidgets: Fix the naming of showAll 2021-05-02 15:21:26 -05:00
June Tate-Gans
95822a273d g13gui: bitwidgets: Adding a Rectangle class
So we can draw nice looking rects with curvy corners.
2021-05-02 15:00:02 -05:00
June Tate-Gans
e71d621ff7 g13gui: bitwidgets: Major work
This adds a whole bunch of tests and additional widgets we can use to draw up
interfaces on the g13's LCD. It also abstracts the backend a bit so we can draw
to X11 rather than a g13.

  - Added a Button and ButtonBar class so we can start making use of those great
    L* buttons
  - Added a Label class so we can stick text all over the screen
  - Added a Screen class to abstract away common display elements such as the
    button bar, as well as send along the next frame to the display.
  - Created the Widget class to make a lot of common boilerplate code live
    somewhere useful.
  - Added X11DisplayDevice so we can test on desktops without needing a G13.
2021-05-02 14:57:31 -05:00
June Tate-Gans
f257d8f11d g13gui: Add a toplevel unittest module
This gives us a one-stop-shop for running unit tests.
2021-05-02 12:52:37 -05:00
June Tate-Gans
32776db309 g13gui: Fix imports 2021-05-02 12:51:32 -05:00
June Tate-Gans
d2881a0e6e g13gui: Make observers use setProperty and properties
This makes them behave in a much more pythonic way.
2021-05-02 12:50:29 -05:00
June Tate-Gans
6daf662698 g13gui: First draft of the g13 manager
This is based upon most of the code written in g13d's device and manager classes
as a means to actually "manage" the g13 itself from the GUI. This eliminates the
silly daemon, fifos, bad protocol design, and overall a whole slew of security
issues.
2021-05-02 12:49:12 -05:00
June Tate-Gans
f9264c390e g13gui: Prep for the great g13d removal
Our key binds will now use actual key codes from evdev instead of using made up
key symbol names from G13D. This results in a *major* change, of which this is
just the start. Effectively, we're going to move away from using the old and
crufty g13d for everything, and just write our own g13 manager instead.
2021-05-02 12:47:54 -05:00
June Tate-Gans
dd21f7fb96 g13gui: Add a missing import 2021-05-02 12:46:30 -05:00
June Tate-Gans
861a85b1f0 g13gui: move _bindKey down 2021-05-02 12:46:11 -05:00
June Tate-Gans
8469fe1b8a g13gui: Use properties and setup init properly 2021-05-02 12:45:48 -05:00
June Tate-Gans
dc7f9211ec g13gui: Stop importing stuff into toplevel namespaces
This causes import errors later on as things get tangled.
2021-05-02 12:44:17 -05:00
June Tate-Gans
3830426302 etc: Add two bitmaps we can use to verify encodings with
The trick with the LPBM format is that it's actually just the native LCD format
used by the G13. Each byte of the buffer corresponds to a vertical strip of 8
pixels, all monochrome. This stretches across the screen, for a full buffer of
960 bytes.
2021-05-02 12:42:35 -05:00
June Tate-Gans
cc7232e580 g13gui: Fix the display height
Apparently I misunderstood the source of pbm2lpbm. There is no padding, despite
the count of rows being off in the source.
2021-04-29 20:29:42 -05:00
June Tate-Gans
aeced13908 g13gui: Add LPBM image conversion and tests
This is the first step to actually rendering to the G13's display by way of the
g13d daemon. The bitmap format is kinda weird: it's actually 860 bytes of
useable pixel data, but padded out to 960. Each byte corresponds with one
vertical column of 8-pixels, going from top to bottom.

The tests for this effectively check to make sure the length is correct, and
also dumps it out to a running g13d (if there is one). This should probably be
automated a bit more by checking the bytes directly, but given that this is a
visual task anyway, I'm being a bit lazy.
2021-04-29 20:20:15 -05:00
June Tate-Gans
a38048ea9f g13gui: Start on the LCD widget library
This makes use of pillow as a means for drawing up a bitmap. The overall idea is
to have applets send a series of widget draw commands over dbus to g13gui, which
then proxies it across to the actual g13.
2021-04-29 16:09:54 -05:00
June Tate-Gans
1a82ddd999 g13d: Decapitalize some typedefs 2021-04-29 00:47:28 -05:00
June Tate-Gans
b9000dd5a9 g13d: Add in the ability to unbind keys
This allows us to unbind keys and leave them natural in the GUI.
2021-04-28 23:31:29 -05:00
June Tate-Gans
b2576707ea g13gui: Make ProfileComboBox sensitive to profile changes
Have to latch it using _ignoreSelectionChange to prevent loops on application
start, but this does allow us to change the profile either from the main window
or from the appindicator menu.
2021-04-28 23:25:02 -05:00
June Tate-Gans
fb2330568c g13gui: Add in AppIndicator support
This allows us to quickly switch between profiles in a normal environment. It's
kinda a hack until we have proper applet support, though this will require
changes to g13d to be possible.
2021-04-28 23:24:19 -05:00
June Tate-Gans
4bc6ec0db8 g13gui: Missed a change relating to the SaveTask in MainWindow 2021-04-28 21:28:44 -05:00
June Tate-Gans
9e6ec22689 g13gui: Remove some silly things from G13Button 2021-04-28 21:28:29 -05:00
June Tate-Gans
20486af0d0 g13gui: Ensure Preferences stores the selected profile 2021-04-28 21:28:14 -05:00
June Tate-Gans
fce850f786 g13gui: Migrate preferences storage to a single class
Helps deal with separations of concerns.
2021-04-28 21:27:53 -05:00
June Tate-Gans
d9e391e90a g13gui: Remove some console spam 2021-04-28 21:25:00 -05:00
June Tate-Gans
da10da2830 g13gui: Fix a fairly major duplication problem
We weren't cloning the defaults from the bindings module, so when we went to go
modify those bindings, we'd change the defaults instead of just that instance.
yay for lack of immutability. :|
2021-04-28 20:53:48 -05:00
June Tate-Gans
476b43ed5f g13gui: Got a bit carried away, totally reworked things
So at this point, g13gui has quite a lot of functionality built into it now. We
can bind keys, we can unbind keys, we can upload whole profiles to g13d, we can
create and edit profiles, and we can even set LCD colors per-profile.

We're not loading the configuration from disk, sadly, since I had to rework
quite a lot of the UI infrastructure to get observer notifications to work with
GTK. Lots of simplifications in here, though, which reduces the complexity of
the code considerably.

  - Migrated all model related classes into the model module.
  - Migrated UI classes into the ui module.
  - Migrated observer-related stuff into observer.
  - Created the GtkObserver adaptor for GTK UI threading. This makes heavy use
    of GObject signals and queuing to dispatch to the UI thread.
  - Migrated all of the G13 buttons into their own class.
  - Renamed ButtonMenu into G13ButtonPopover.
  - Setup the profile combo box as its own class.
  - Created the profile popover so we can add/remove/edit profiles.
2021-04-28 18:25:47 -05:00
June Tate-Gans
91e62addb7 g13gui: Define a Preferences class
This centralizes the data we manage into a single model that can manage the
serialization to/from JSON before it hits disk more effectively.
2021-04-27 18:05:32 -05:00