Commit Graph

130 Commits

Author SHA1 Message Date
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
June Tate-Gans
577865c69e g13gui: Make stick regions and stick modes enums
This simplifies quite a bit, and reduces coding errors by using symbols instead
of "stringified" types.
2021-04-27 18:04:51 -05:00
June Tate-Gans
91d88b3a83 g13gui: Tests for BindingProfile and a bunch of code cleanups
The BindingProfile class had a bunch of untested code that was assigning to
things by the wrong name, or making logic errors all throughout. With the added
unit tests, that cleans it up considerably.
2021-04-27 18:03:50 -05:00
June Tate-Gans
8f46071239 g13gui: Make observers capable of subscribing to keys
This reduces some of the notifications during changes by reducing the scope of
changes that are monitored by other components in the system. IOW, this allows
keys to only care about their particular changes, rather than all key binding
changes in a BindingProfile.
2021-04-27 18:02:24 -05:00
June Tate-Gans
3183ae8b2b g13gui: Fix param names and migrate ObserverTestCase
ObserverTestCase is code, not test stuff, so migrate that into the observer
module properly.
2021-04-27 14:57:19 -05:00
June Tate-Gans
d5b4957916 gitignore: Stop committing pyc files 2021-04-27 13:46:58 -05:00
June Tate-Gans
eb816c8acb g13gui: Add in an observer pattern
We'll need this as complexity of the GUI grows. This allows us to queue up
change notifications and pass them to observing objects more cleanly.
2021-04-27 13:45:57 -05:00
June Tate-Gans
bac31a772a g13gui: Major functionality additions
This gets us nearly to a proper profile manager and keybinding tool! Very very
close, despite the messiness of the codebase. There's lots of low hanging fruit
for those who are interested in contributing.

  - Made BindingProfile serializable to a python dict
  - Fixed a bug in BindingProfile that named keys in the g13d command stream
    incorrectly.
  - Made ButtonMenu attempt to grab the keyboard when it shows so we can get
    more correct keypresses. This is only half the battle -- need to stop GTK's
    event loop for other widgets from catching events and handling them.
  - Added a g13d communications worker thread, including saving of profiles to
    disk as well as uploading profile configurations to g13d. This uses a Queue
    for incoming tasks from the GUI thread, and dispatches results back by way
    of GObject signals. Could use some work to make this less clunky.
  - Made MainWindow load the profiles from disk. This is done on the GUI thread,
    which isn't ideal.
  - Added an Upload button to push changes over to g13d. This reacts to the
    worker thread's connected/disconnected signals.
2021-04-27 00:00:16 -05:00
June Tate-Gans
cdc8fe5139 g13gui: First rough draft
This represents a full day of work just to get the binding behaviors correct and
the profile behaviors correct. At this point, this should be possible to turn
into something useful for controlling g13d with.

Things left to do:

  - Setup a thread for communicating with g13d with
  - Setup a worker queue to send profile changes or updates to the g13d daemon

Once those are in there, we can consider this to be feature complete for 1.0.
Additional functionality, such as LED colors, drawing to the LCD, and things
like supporting dbus IPC so we can handle applets on the LCD will come later.
2021-04-26 19:13:19 -05:00
June Tate-Gans
e97cb2c6c3 stick: Fix a logic error I introduced
Late night hacking causes all kinds of silliness. We only want to stop running
an action when the key is not pressed now, but was prior pressed. My logic
caused it to fire when not pressed and not prior pressed, erroneously, leading
to stuck keys.
2021-04-25 23:16:03 -05:00
June Tate-Gans
4d964dd0c0 device: Revert another warning "fix" due to lack of sleep
Totally misunderstood what I was doing here and broke stickzone additions.
2021-04-25 22:31:13 -05:00
June Tate-Gans
390995bf03 action: Revert my unsigned vs. signed "fix"
Totally misread the code in the Action_keys::act method -- the code actually
reverse sends events in an up condition. Still, keeping the C++11 iteration and
improving by using boost::adaptors::reverse.
2021-04-25 22:28:22 -05:00
June Tate-Gans
b81ec75c82 g13d: More cleanups
Double underbars are reserved for the compiler and system, so we shouldn't use
them for header guards. Additionally, remove a bunch of these line breaks.
2021-04-25 21:12:26 -05:00
June Tate-Gans
22cd1c9351 g13d: Get rid of some of the G13_ prefixing for classes 2021-04-25 21:04:01 -05:00
June Tate-Gans
1918d6875c g13d: Reformat all the files to Google style
This is closer to what I'm looking for, and gives us a style guide to boot.
2021-04-25 20:30:56 -05:00
June Tate-Gans
234b5aac7f tools: Add a small reformatting tool to ease the burden 2021-04-25 20:13:25 -05:00
June Tate-Gans
73f10be688 g13d: Migrate string_repr_out into a cc file and fix the deps
This was a mistake I made accidentally -- meant to have the function in the C++
file, not in the header.
2021-04-25 17:27:07 -05:00
June Tate-Gans
073860faad g13d: Fix build dependendies 2021-04-25 17:24:47 -05:00
June Tate-Gans
dee05bc790 license: Clarifying original licenses and copyrights 2021-04-25 17:23:47 -05:00
June Tate-Gans
358fb509db g13d: Final-final cleanups to the codebase
- Removing a bunch of silly star comment separates
  - Moving font8x8 back into its own header
  - Move string_repr_out into repr.cc
2021-04-25 17:22:34 -05:00
June Tate-Gans
a05dcb04c8 g13d: More symbol relocations and cleanups
Lots of cross-translation unit messes in here cleaned up finally. This should be
the last change necessary to clean up these refs between translation units.
2021-04-25 17:09:19 -05:00
June Tate-Gans
95b137f3db g13d: Fix the font translation unit name 2021-04-25 16:53:50 -05:00
June Tate-Gans
648c14690f g13d: More cleanups and migrations
Second part of the big refactor. Migrating all of the relevant method bodies to
their respective translation units.
2021-04-25 16:51:41 -05:00
June Tate-Gans
ae6cf5084a g13d: Rework and cleanup namespaces and files
This is the first half of some major rework of the g13d codebase to make things
a bit more manageable. This splits out a great deal of stuff from helper.h into
separate translation units, and also breaks out a great deal of the g13.h header
into separate translation units as well.

Doing this saves in compilation time as we make changes to the system, and also
helps to clean up a whole bunch of leaking symbols.
2021-04-25 16:35:44 -05:00
June Tate-Gans
efe01fb850 g13d: Remove switch and handle all switch cases 2021-04-25 14:40:31 -05:00
June Tate-Gans
9c15e935a7 g13d: Add a blank line 2021-04-25 14:40:16 -05:00
June Tate-Gans
b7f784563c g13d: Fix initialization order 2021-04-25 14:39:54 -05:00
June Tate-Gans
47d876b4cb g13d: Fix a bunch of sign comparisons 2021-04-25 14:39:40 -05:00
June Tate-Gans
9bf95336cc g13d: Remove a bunch of unused vars and definitions 2021-04-25 14:38:41 -05:00
June Tate-Gans
8e14f1f853 g13d: Clean up initialization order 2021-04-25 14:38:08 -05:00
June Tate-Gans
f289bdf850 g13d: Style fixes and remove an unused variable 2021-04-25 14:37:00 -05:00