A browser-based simulator for PocketBook e-reader applications. Write or port real PocketBook C/C++ apps using the InkView SDK, compile them to WebAssembly with Emscripten, and run them directly in the browser — no device needed.
screencast.webm
PocketBook apps are written against the InkView API (inkview.h), which provides drawing primitives, font handling, event dispatching, timers, and UI widgets. This simulator has three layers:
PocketBook app (C/C++)
│ calls
▼
src/inkview.c — thin C shim, bridges each InkView function to JS via EM_JS macros
│ calls
▼
simulator/inkview-emu.mjs — JavaScript implementation of the InkView API using Canvas 2D
The C/C++ source is compiled to WebAssembly by Emscripten. The resulting .mjs + .wasm files are loaded in the browser, where the JS simulator handles all drawing, input, and events.
- Emscripten SDK (emsdk)
- A local HTTP server (e.g.
python3 -m http.server 8080)
Install emsdk:
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
cd ~/emsdk
./emsdk install latest
./emsdk activate latest
source ~/emsdk/emsdk_env.sh# Build the shared InkView object (required before any app)
make lib/inkview.o
# Build individual apps
make demo01
make calc
make touch
make helloworld
make game2048
# Rebuild inkview.o after changing src/inkview.c
rm lib/inkview.o && make lib/inkview.oServe the project root with any HTTP server:
python3 -m http.server 8080Open http://localhost:8080 — you will see the app launcher. Click an app to run it. The URL hash reflects the active app (#calc, #helloworld, etc.), so you can bookmark or link directly to an app. The Home button (or Escape key) exits back to the launcher.
pocketbook-simulator/
├── include/
│ └── inkview.h Real PocketBook InkView API header
├── src/
│ └── inkview.c C shim — EM_JS bridges to JS simulator
├── simulator/
│ ├── inkview-emu.mjs JavaScript InkView implementation (Canvas 2D)
│ ├── css/index.css UI styles
│ └── fonts/ LiberationSans font files
├── lib/
│ └── inkview.o Compiled shim (generated by make)
├── projects/
│ ├── demo01/ Simple drawing demo
│ ├── calc/ Calculator app
│ ├── touch/ Touch/pointer demo
│ ├── helloworld/ Multi-file C++ app with menu
│ └── 2048/ 2048 puzzle game
├── index.html Main page — launcher + app shell
└── Makefile
-
Create
projects/<name>/and put your source files there. -
Add a Makefile target:
myapp: projects/myapp/myapp.c lib/inkview.o
$(CC) $(CFLAGS) projects/myapp/myapp.c lib/inkview.o \
-o projects/$@/index.mjs \
$(EXPORTED_FUNCTIONS) $(EXPORTED_RUNTIME) $(ADDITIONAL_LIBS) $(MODULARIZE)For C++ projects with multiple files, list all sources and add -I flags for subdirectory headers.
-
Register the app in
index.html— add it toPROJECTS, the sidebar<ul>, and the launcher grid. -
make myappand reload the browser.
| Category | Functions |
|---|---|
| Screen | OpenScreen, ScreenWidth, ScreenHeight, ClearScreen |
| Drawing | DrawPixel, DrawLine, DrawRect, FillArea, FillAreaRect, DrawCircle, InvertAreaBW |
| Fonts | OpenFont, CloseFont, SetFont, StringWidth, CharWidth |
| Text | DrawString, DrawTextRect, DrawTextRect2 |
| Events | EVT_INIT, EVT_SHOW, EVT_EXIT, EVT_POINTERDOWN/UP/MOVE, EVT_KEYPRESS, EVT_ORIENTATION — browser arrow/Enter keys mapped to InkView KEY_* constants |
| Timers | SetHardTimer |
| UI | OpenMenu, DialogSynchro |
| Orientation | SetOrientation, GetOrientation — 0°/90°/180°/270° |
| Updates | FullUpdate, PartialUpdate, PartialUpdateBW |
| Misc | GetDeviceModel, GetLangText, PanelHeight, DrawPanel, CloseApp, IsInRect, iRect |
The simulated device is 600×800 pixels (portrait), matching a PocketBook 6" screen. The Rotate button cycles through all four orientations.
| App | Description |
|---|---|
| demo01 | Original project demo |
| calc | Calculator — fonts, drawing, keyboard input |
| touch | Pointer tracking — circle following the cursor |
| helloworld | Multi-file C++ app with title bar, touch drawing, and dropdown menu (source) |
| 2048 | 2048 puzzle game — swipe/arrow-key input, slide+pop animations, grayscale palette with tile patterns, best score in localStorage |