Skip to content

Commit

Permalink
cleanup/ add task switcher shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
ddvk committed Sep 18, 2019
1 parent 55385c9 commit 27f6473
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Makefile
.qmake.stash
tags
obj/
*.user
16 changes: 16 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
//todo: get from touch device
#define SCREEN_WIDTH 1404
#define SCREEN_HEIGHT 1872

//todo: param or config
#define TOUCHSCREEN "/dev/input/event1"
#define TOUCH_WIDTH 767
#define TOUCH_HEIGHT 1023

#define BUTTONS "/dev/input/event2"
#define WACOM "/dev/input/event0"

#define MAX_SLOTS 7 //max touch points to track
#define TWOTAP_DISTANCE 700 //distance between the fingers to enable disable
#define JITTER 20 //finger displacement to be consideded a swipe
3 changes: 2 additions & 1 deletion eventreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/input.h>
#include "eventreader.h"
#include "ui.h"
#include "config.h"

struct Finger {
int x;
Expand Down Expand Up @@ -106,7 +107,7 @@ void process_touch(void(*process)(struct TouchEvent *)){
}

if (f->status == Up){
f->status = Untracked;;
f->status = Untracked;
}

}
Expand Down
4 changes: 3 additions & 1 deletion gestures.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "gestures.h"
#include "keyinjector.h"
#include "gesture_definition.h"
#include "eventreader.h"
#include "config.h"

static int keys_down = 0;
static int segment_count = 0;
Expand Down Expand Up @@ -104,7 +106,7 @@ void recognize_gestures(struct TouchEvent *f) {
case 2:
dx = segments[0].end.x - segments[1].end.x;
dy = segments[0].end.y - segments[1].end.y;
distance = sqrt(dx*dx+dy*dy);
distance = (int)sqrt(dx*dx+dy*dy);
if (distance > TWOTAP_DISTANCE) {
gesture.type = TwoTapWide;
interpret_gesture(&gesture);
Expand Down
7 changes: 2 additions & 5 deletions gestures.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once
#include "eventreader.h"
#define TWOTAP_DISTANCE 700


void recognize_gestures(struct TouchEvent *f);
struct Gesture;
struct TouchEvent;
void recognize_gestures(struct TouchEvent *f);
void interpret_gesture(struct Gesture *g);
1 change: 1 addition & 0 deletions keyinjector.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "keyinjector.h"
#include "gestures.h"
#include "gesture_definition.h"
#include "config.h"

enum Key {Left=105, Right=106, Home=102,Power=116};

Expand Down
9 changes: 7 additions & 2 deletions remarkable-touchgestures.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
######################################################################
# Automatically generated by qmake (3.0) Tue Apr 9 11:36:23 2019
######################################################################
system(./makeversion.sh) QMAKE_EXTRA_TARGETS += version
system(./makeversion.sh) QMAKE_EXTRA_TARGETS += version.h
PRE_TARGETDEPS += version.h
QT = gui
TEMPLATE = app
Expand All @@ -15,6 +15,11 @@ QMAKE_CXXFLAGS_RELEASE = -fvisibility=hidden
# Input
SOURCES += *.cpp
SOURCES += *.c
HEADERS += *.h \
config.h
# FB stuff
LIBS += -lqsgepaper
linux-oe-g++{
LIBS += -lqsgepaper
DEFINES += REMARKABLE
}

23 changes: 23 additions & 0 deletions scripts/swipeup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
DRAFT_PID="/tmp/draft"
DRAFT_KILL="/tmp/draft_kill"
if [ -f $DRAFT_PID ]; then
if [ -f $DRAFT_KILL ]; then
sh $DRAFT_KILL
rm $DRAFT_KILL
fi
pid=$(cat $DRAFT_PID)
rm $DRAFT_PID
kill $pid
#todo find a better way
killall chess
killall fingerterm
killall plato
killall edit
killall draft
systemctl start xochitl
else
systemctl stop xochitl
~/draft &
echo $! > $DRAFT_PID
fi
54 changes: 32 additions & 22 deletions ui.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
#include <QGuiApplication>
#include <QPainter>
#include <QImage>
#include <epframebuffer.h>
#include "ui.h"

#include "config.h"
#ifdef REMARKABLE
#include <epframebuffer.h>
//segfault if it does not exist
QGuiApplication *app;
static QGuiApplication *app=nullptr;
#endif

extern "C" {
void ui_init(){
#ifdef REMARKABLE
qputenv("QMLSCENE_DEVICE", "epaper");
qputenv("QT_QPA_PLATFORM", "epaper:enable_fonts");
qputenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS", "rotate=180");
qputenv("QT_QPA_GENERIC_PLUGINS", "evdevtablet");

void ui_init(){
qputenv("QMLSCENE_DEVICE", "epaper");
qputenv("QT_QPA_PLATFORM", "epaper:enable_fonts");
qputenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS", "rotate=180");
qputenv("QT_QPA_GENERIC_PLUGINS", "evdevtablet");
char *argv [0];
int argc = 0;
app = new QGuiApplication(argc,argv);
#endif
}

char *argv [0];
int argc = 0;
app = new QGuiApplication(argc,argv);
}
void show(const char *str){

void show(const char *str){
QPainter painter(EPFrameBuffer::framebuffer());
int x = SCREEN_WIDTH / 3;
int y = SCREEN_HEIGHT - 20;
QRect rect(x - 50,y - 50, 600, 100);
painter.eraseRect(rect);
painter.drawText(x,y, str);
painter.end();
EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Grayscale, EPFrameBuffer::PartialUpdate);
}
#ifdef REMARKABLE
QPainter painter(EPFrameBuffer::framebuffer());
int x = SCREEN_WIDTH / 3;
int y = SCREEN_HEIGHT - 20;
QRect rect(x - 50,y - 50, 600, 100);
painter.eraseRect(rect);
painter.drawText(x,y, str);
painter.end();
EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Grayscale, EPFrameBuffer::PartialUpdate);
#else
printf("show: %s\n", str);

#endif
}
}
13 changes: 0 additions & 13 deletions ui.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#pragma once
#include <stdbool.h>

#define SCREEN_WIDTH 1404
#define SCREEN_HEIGHT 1872
#define TOUCH_WIDTH 767
#define TOUCH_HEIGHT 1023

#define TOUCHSCREEN "/dev/input/event1"
#define BUTTONS "/dev/input/event2"
#define WACOM "/dev/input/event0"

#define MAX_SLOTS 7 //max touch points to track
#define MULTITOUCH_DISTANCE 500 //distance between the fingers to enable disable

#define JITTER 20 //finger displacement to be consideded a swipe

#define DEBUG 0
#define debug_print(fmt, ...) \
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION "0.0.2-18-g8f73256"
#define VERSION "0.0.2-19-g55385c9"

0 comments on commit 27f6473

Please sign in to comment.