Add touch support
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
## REcounter
|
## REcounter
|
||||||
Why? Because, in an era where a simple counter app would likely be left up to the AI overlords, I'd rather just fork [something some guy made in 2014](https://github.com/matthewbauer/counter) and add touch support.
|
Why? Because, in an era where a simple counter app would likely be left up to the AI overlords, I'd rather just fork [something some guy made in 2014](https://github.com/matthewbauer/counter) and add touch support.
|
||||||
|
|
||||||
This ended up being a pretty cool mini-project, as I learned about how the Pebble SDK has changed over the years. Immediately upon porting to the new SDK, there were various things that didn't quite look like they used to. This includes the lack of a status bar, the lack of margin&rounded corners on the action bar, the inability to render the previously valid menu icon, and the weird way bitmaps used to work regarding color and translucency. I addressed all of these to preserve the legacy Pebble SDK look with this app!
|
This fork of the original adds support for all current and past Pebbles and enables touch support for incrementing the counter.
|
||||||
|
|
||||||
|
This ended up being a pretty cool micro-project, as I learned about how the Pebble SDK has changed over the years. Immediately upon porting to the new SDK, there were various things that didn't quite look like they used to. This includes the lack of a status bar, the lack of margin&rounded corners on the action bar, the inability to render the previously valid menu icon, and the weird way bitmaps used to work regarding color and translucency. I addressed all of these to preserve the legacy Pebble SDK look with this app!
|
||||||
|
|
||||||
In addition to Emery+touch support, this version of the app also supports all other Pebbles.
|
In addition to Emery+touch support, this version of the app also supports all other Pebbles.
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ void reset() {
|
|||||||
s_count = 0;
|
s_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PBL_TOUCH
|
||||||
|
static void touch_handler(const TouchEvent *event, void *context) {
|
||||||
|
if (event->type == TouchEvent_Touchdown) {
|
||||||
|
increment();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
void select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
||||||
increment();
|
increment();
|
||||||
update();
|
update();
|
||||||
@@ -134,9 +143,16 @@ void init() {
|
|||||||
s_count = persist_exists(COUNT_PKEY) ? persist_read_int(COUNT_PKEY) : 0;
|
s_count = persist_exists(COUNT_PKEY) ? persist_read_int(COUNT_PKEY) : 0;
|
||||||
|
|
||||||
window_stack_push(s_window, true);
|
window_stack_push(s_window, true);
|
||||||
|
|
||||||
|
#if PBL_TOUCH
|
||||||
|
touch_service_subscribe(touch_handler, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void deinit() {
|
void deinit() {
|
||||||
|
#if PBL_TOUCH
|
||||||
|
touch_service_unsubscribe();
|
||||||
|
#endif
|
||||||
persist_write_int(COUNT_PKEY, s_count);
|
persist_write_int(COUNT_PKEY, s_count);
|
||||||
window_destroy(s_window);
|
window_destroy(s_window);
|
||||||
gbitmap_destroy(s_action_icon_plus);
|
gbitmap_destroy(s_action_icon_plus);
|
||||||
|
|||||||
Reference in New Issue
Block a user