Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fb.pnm
fb.raw
screen.*
output
kobo/
tags
tmp
*.o
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.kobo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ghcr.io/toltec-dev/python:v1.1
FROM ghcr.io/toltec-dev/python:v4.0

RUN pip3 install okp
RUN pip3 install --break-system-packages okp

WORKDIR /opt/
RUN apt update
Expand Down
4 changes: 4 additions & 0 deletions scripts/build/build_kobo_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ tar_files() {
make_remux_sh() {
cat > ${PLUGIN_DIR}/bin/remux.sh << REMUX_SH
#!/bin/sh
while [ \$(pgrep -f "sh /opt/bin/remux.sh" | wc -l) -gt 2 ]; do
kill \$(pgrep -f "sh /opt/bin/remux.sh" | head -n1)
done
killall remux
while true; do
sleep 1;
/opt/bin/apps/remux;
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ OUTDIR=artifacts
PACKAGE="${1}"
TARGET=${TARGET:-rm}
FBINK=${FBINK}
CROSS_TC=${CROSS_TC:-arm-linux-gnueabihf}
mkdir ${OUTDIR}
docker run -i --rm -v "${PWD}/${OUTDIR}:/mnt/artifacts" rmkit:${TARGET} /bin/bash << COMMANDS
mkdir -p src/build
FBINK=${FBINK} TARGET=${TARGET} make ${PACKAGE}
CROSS_TC=${CROSS_TC} FBINK=${FBINK} TARGET=${TARGET} make ${PACKAGE}
mkdir -p /mnt/artifacts/${TARGET}/
cp -r src/build/* /mnt/artifacts/${TARGET}/
chown -R $(id -u):$(id -u) /mnt/artifacts
Expand Down
7 changes: 4 additions & 3 deletions src/remux/launcher.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define DYNAMIC_BPP
#define HAS_ROTATION
#define PORTRAIT_ONLY
#define DRAW_APP_BEHIND_MODAL
#define GRAB_INPUT
#define USE_GRAYSCALE_32BIT
#endif

Expand Down Expand Up @@ -178,7 +180,7 @@ class AppBackground: public ui::Widget:
fb->set_rotation(vfb->rotation)
#endif

fb->perform_redraw(true)
fb->perform_redraw(true, true)
fb->dirty = 1

class AppDialog: public ui::Pager:
Expand Down Expand Up @@ -347,8 +349,7 @@ class App: public IApp:
ui::set_timeout([=]() {
ui::MainLoop::in.unmonitor(ui::MainLoop::in.wacom.fd)
}, 10)
if USE_KOREADER_WORKAROUND and CURRENT_APP != "KOReader":
ui::MainLoop::in.ungrab()
ui::MainLoop::in.ungrab()
;

app_bg = new AppBackground(0, 0, w, h)
Expand Down
17 changes: 11 additions & 6 deletions src/rmkit/fb/fb.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace framebuffer:
// function: redraw_screen
// if the framebuffer is dirty, redraws the dirty area
// of the framebuffer.
int redraw_screen(bool full_screen=false):
int redraw_screen(bool full_screen=false, bool flash=false):
if dirty == 0:
return 0

Expand All @@ -145,7 +145,10 @@ namespace framebuffer:
if dirty_area.y1 == 0 || dirty_area.x1 == 0:
return 0

return self.perform_redraw(full_screen)
return self.perform_redraw(full_screen, flash)

virtual int perform_redraw(bool, bool):
return 0

virtual int perform_redraw(bool):
return 0
Expand Down Expand Up @@ -704,7 +707,7 @@ namespace framebuffer:

return vinfo.xres, vinfo.yres

int perform_redraw(bool full_screen=false):
int perform_redraw(bool full_screen=false, bool flash=false):
um := 0
mxcfb_update_data update_data
mxcfb_rect update_rect
Expand Down Expand Up @@ -781,7 +784,7 @@ namespace framebuffer:
virtual tuple<int,int> get_virtual_size():
return self.width, self.height

int perform_redraw(bool):
int perform_redraw(bool, bool):
#ifndef PERF_BUILD
msync(self.fbmem, self.byte_size, MS_SYNC)
self.save_png()
Expand Down Expand Up @@ -920,8 +923,9 @@ namespace framebuffer:
mem := (remarkable_color*) fbink_get_fb_pointer(self.fd, &size)
return mem

int perform_redraw(bool full_screen=false):
int perform_redraw(bool full_screen=false, bool flash=false):
config_.wfm_mode = self.waveform_mode
config_.is_flashing = flash
if !full_screen:
fbink_refresh(self.fd,
dirty_area.y0,
Expand All @@ -931,6 +935,7 @@ namespace framebuffer:
&config_)
else:
fbink_refresh(self.fd, 0, 0, self.display_width, self.height, &config_)
config_.is_flashing = false
return 0

void wait_for_redraw(uint32_t update_marker):
Expand Down Expand Up @@ -979,7 +984,7 @@ namespace framebuffer:

return vinfo.xres, vinfo.yres

int perform_redraw(bool full_screen=false):
int perform_redraw(bool full_screen=false, bool flash=false):
um := 0
hwtcon_update_data update_data
hwtcon_rect update_rect
Expand Down
5 changes: 4 additions & 1 deletion src/rmkit/input/device_id.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// event2: gpio keys
// ev_key: home, left, right, power, wakeup
namespace input:
enum EV_TYPE { TOUCH, STYLUS, BUTTONS, UNKNOWN, INVALID }
enum EV_TYPE { TOUCH, STYLUS, BUTTONS, GPIO, UNKNOWN, INVALID }
static bool check_bit_set(int fd, int type, int i):
unsigned long bit[NBITS(KEY_MAX)]
ioctl(fd, EVIOCGBIT(type, KEY_MAX), bit);
Expand Down Expand Up @@ -55,6 +55,9 @@ namespace input:
if check_bit_set(fd, EV_KEY, BTN_TOOL_PEN):
return TOUCH

if check_bit_set(fd, EV_MSC, MSC_RAW):
return GPIO

return UNKNOWN

static bool supports_stylus(int fd):
Expand Down
33 changes: 24 additions & 9 deletions src/rmkit/input/input.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../defines.h"
#include "../fb/fb_info.h"
#include "../shared/proc.h"
#include "events.h"
#include "gestures.h"
#include "device_id.h"
Expand Down Expand Up @@ -100,6 +101,7 @@ namespace input:

class Input:
private:
ui::TimerPtr ungrab_interval = nullptr;

public:
int max_fd
Expand All @@ -109,6 +111,7 @@ namespace input:
InputClass<WacomEvent, SynMotionEvent> wacom
InputClass<TouchEvent, SynMotionEvent> touch
InputClass<ButtonEvent, SynKeyEvent> button
InputClass<ButtonEvent, SynKeyEvent> gpio

vector<SynMotionEvent> all_motion_events
vector<SynKeyEvent> all_key_events
Expand All @@ -133,6 +136,20 @@ namespace input:
self.open_device("/dev/input/event2")
self.open_device("/dev/input/event3")
self.open_device("/dev/input/event4")
self.grab()
std::function<void()> ungrab_task = [=]() {
debug "UNGRAB_TASK"
vector<string> bins = { "nickel" }
procs := proc::list_procs(bins)
if procs.size() > 0:
debug "UNGRABBING"
self.ungrab()
debug "UNGRABBED"
ui::cancel_timer(ungrab_interval)
else:
debug "RESCHEDULING"
}
ungrab_interval = ui::set_interval(ungrab_task, 500)
#else
if USE_RESIM:
debug "MONITORING RESIM"
Expand All @@ -155,7 +172,7 @@ namespace input:
return

void close_devices():
vector<IInputClass> fds = { self.touch, self.wacom, self.button}
vector<IInputClass> fds = { self.touch, self.wacom, self.button, self.gpio}
for auto in : fds:
if in.fd > 0:
close(in.fd)
Expand Down Expand Up @@ -183,6 +200,10 @@ namespace input:
self.touch.set_fd(fd)
debug "AS TOUCH"
break
case GPIO:
debug ": GPIO"
self.gpio.set_fd(fd)
break
case INVALID:
case UNKNOWN:
default:
Expand Down Expand Up @@ -252,17 +273,11 @@ namespace input:
return

void grab():
#ifndef REMARKABLE
return
#endif
for auto fd : { self.touch.fd, self.wacom.fd, self.button.fd }:
for auto fd : { self.touch.fd, self.wacom.fd, self.button.fd, self.gpio.fd }:
ioctl(fd, EVIOCGRAB, true)

void ungrab():
#ifndef REMARKABLE
return
#endif
for auto fd : { self.touch.fd, self.wacom.fd, self.button.fd }:
for auto fd : { self.touch.fd, self.wacom.fd, self.button.fd, self.gpio.fd }:
ioctl(fd, EVIOCGRAB, false)

void check_reopen():
Expand Down
3 changes: 3 additions & 0 deletions src/rmkit/rmkit.cpy
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "fb/fb.h"
#ifdef KOBO
#include "../shared/proc.h" // Needed to prevent nickel from grabbing inputs
#endif
#include "input/input.h"
#include "util/signals.h"
#include "ui/ui.h"
Expand Down
52 changes: 32 additions & 20 deletions src/rmkit/ui/task_queue.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,45 @@ namespace ui:
TaskQueue::wakeup()

static void run_tasks():
task_q.lock()
if TaskQueue::tasks.size() == 0:
task_q.unlock()
return
task_q.unlock()


thread *th = nullptr
try:
th = new thread([=]() {
count := 4
while tasks.size() > 0 and count > 0:
count--
task_q.lock()
t := TaskQueue::tasks.front()
TaskQueue::tasks.pop_front()
task_q.unlock()

if task_m.try_lock():
try:
std::thread* th = new thread([=]() {
task_m.lock()
t()
debug "TASK THREAD STARTED"
count := 4
while count > 0:
count--
task_q.lock()
if tasks.size() == 0:
task_q.unlock()
break
t := TaskQueue::tasks.front()
TaskQueue::tasks.pop_front()
task_q.unlock()

try:
t()
catch (const std::exception& e):
debug "TASK EXEC EXC", e.what()
debug "TASKS DONE"
TaskQueue::wakeup()
task_m.unlock()
})
th->detach()
task_m.unlock()
catch (const std::exception& e):
debug "NEW THREAD EXC", e.what()
TaskQueue::wakeup()
})
th->detach()
if th != nullptr
delete th
catch (const std::exception& e):
debug "NEW THREAD EXC", e.what()
TaskQueue::wakeup()

else:
debug "TASK QUEUE WAS RUNNING, NOT RELAUNCHING"


// class: ui::TaskQueue
// The task queue is a way of scheduling tasks from side threads to be run
Expand Down