# \[Guide\] Enabling Touchscreen Support for Watchfaces on PebbleOS

**URL:** <https://forum.repebble.com/t/guide-enabling-touchscreen-support-for-watchfaces-on-pebbleos/1741>\
**Category:** Watchapp/Face Developers Corner\
**Created:** [September 28, 2026, 5:28pm UTC](https://forum.repebble.com/t/guide-enabling-touchscreen-support-for-watchfaces-on-pebbleos/1741 "2026-09-28T17:28:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_B](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_B](https://forum.repebble.com/u/J_B)\
**Post date:** [September 28, 2026, 5:28pm UTC](https://forum.repebble.com/t/guide-enabling-touchscreen-support-for-watchfaces-on-pebbleos/1741/1 "2026-09-28T17:28:00Z")

</div>

Hi everyone! I wanted to turn one of my apps into a watchface but this requires touch to be enabled on watchfaces. By default, the PebbleOS AppLib restricts watchfaces from subscribing to the touch service to preserve battery life, and the kernel aggressively drops touch events that don’t trigger native UI scrolling. If you’re building a watchface for the Pebble Time 2 and want to utilize the touchscreen, you’ll need to bypass these restrictions.

I was able to patch the OS and my watchface works with touchscreen now! But I thought I could share here what I did so others can try developing watchfaces with touch capability. Below is a complete guide on how to fork the OS, apply the necessary kernel patches, compile the firmware in our Nix environment, and safely sideload it to your watch via Recovery Mode.

I forked PebbleOS on my own github and also provided the [flashable OS](https://github.com/JunderscoreB/PebbleOS/releases/download/v4.38.0-73-patched/normal_obelix_pvt_v4.38.0-73-g9ca5706b8-dirty_slot0.pbz) I built there too. But if you want to do it yourself you can follow these instructions. Not that I’m developing in Linux, I’m not sure if these instructions will apply 1:1 with Mac/Windows so if you use these, YMMV.

**TL;DR** , if you don’t want to patch PebbloOS yourself, you can download the build from my github repo and flash it.

⚠ **DISCLAIMER:** Please be aware that the changes to this code may break your system! This new touch interface modification has not been thoroughly tested for watchfaces or OS stability. Because we are intentionally bypassing the idle wake-gate, the touch digitizer will remain fully powered while your watchface is active. Potential issues that may arise include:

- **Severe Battery Drain:** The watch will not be able to enter its deepest sleep states.

- **Kernel Panics:** Unexpected touch inputs during system modal transitions (like incoming calls or alarms) could cause memory faults.

- **AppLib Routing Conflicts:** Other background workers or system services may intercept your touch payloads unexpectedly. Please proceed with caution and flash at your own risk!

### Step 1: Fork and Clone the Repository

Since PebbleOS is fully open-source (Apache 2 / GPL3), the best way to develop is by creating your own fork. This allows you to safely modify, compile, and distribute your custom firmware.

1. Navigate to the official repository at [`https://github.com/coredevices/PebbleOS`](https://github.com/coredevices/PebbleOS) and click the **Fork** button.

2. Open your terminal, clone your new fork, and initialize the nested third-party dependencies (like CMSIS and Moddable):

```bash
git clone https://github.com/YOUR_USERNAME/PebbleOS.git 
cd PebbleOS 
git submodule update --init --recursive 
git checkout -b feature/touchscreen-watchfaces

```

### Step 2: Keep Your Fork Updated (Upstream Synchronization)

Before making your own modifications, ensure you are tracking the original Core Devices repository so you can easily pull in the latest OS changes in the future.

1. Add the official repository as a remote named `upstream`:

Bash

```bash
git remote add upstream https://github.com/coredevices/PebbleOS.git

```

1. When you want to pull the latest changes, fetch and merge them into your local `main`branch:

Bash

```bash
git checkout main
git fetch upstream
git merge upstream/main

```

1. **Critical:** Always update your submodules after syncing, as third-party dependencies like Moddable or CMSIS often update:

Bash

```bash
git submodule update --init --recursive

```

### Step 3: Create a Feature Branch

Isolate your modifications in a dedicated branch rather than committing directly to `main`.

Bash

```auto
git checkout -b feature/touchscreen-watchfaces

```

### Step 4: Apply the OS Kernel and AppLib C Patches

We need to modify three files in the OS source to route raw touch coordinate data to your watchface.

Below are the unabridged patches in our virtual Canvas workspace. Open these files in your preferred text editor and replace the target functions with the code below.

#### 🛠 Canvas Workspace: `src/fw/applib/touch_service.c`

_Purpose: Removes the application-level restriction preventing watchfaces from requesting touch data._

```c
static TouchServiceState *prv_get_state(void) {
  PebbleTask task = pebble_task_get_current();
  switch (task) {
    case PebbleTask_App:
      // Touch is reserved for watchapps; watchfaces must not consume it.
      // --- PATCH BEGIN ---
      // if (sys_app_is_watchface()) {
      // return NULL;
      // }
      // --- PATCH END ---
      return app_state_get_touch_service_state();
    case PebbleTask_KernelMain:
      return kernel_applib_get_touch_service_state();
    case PebbleTask_Worker:
      // Touch is not available to background workers — they have no UI.
      return NULL;
    default:
      WTF;
  }
}

```

#### 🛠 Canvas Workspace: `src/fw/services/touch/touch_session.c`

_Purpose: Bypasses strict idle-timeout management, ensuring the touch sensor remains powered while your watchface is actively displayed._

```c
bool touch_session_is_active(void) {
  #ifdef CONFIG_RECOVERY_FW
  // PRF has no touch navigation; keep the mfg touch test's touch-follows-light
  // behavior unconditional.
  return true;
  #else
  
  // --- PATCH BEGIN ---
  // Unconditionally keep the touch session active for custom watchfaces
  return true;
  // --- PATCH END ---
  
  /* ORIGINAL CODE DISABLED:
  if (rtc_get_ticks() < s_armed_until) {
    return true;
  }
  // Any UI the user deliberately entered is not guarded; only the idle
  // watchface needs arming.
  if (!app_manager_is_watchface_running()) {
    return true;
  }
  // A focused modal just demanded attention (notification, alarm): the
  // immediate touch response is intentional.
  if (modal_manager_get_enabled() && !(modal_manager_get_properties() & ModalProperty_Unfocused)) {
    return true;
  }
  // A lit backlight means something (button, shake, wake gesture) already
  // signalled engagement.
  return light_is_on();
  */
  #endif
}

```

#### 🛠 Canvas Workspace: `src/fw/services/touch/touch.c`

_Purpose: Protects the `non_navigational` flag so the kernel does not discard raw coordinate data before it reaches the watchface layer._

```c
void touch_wake_gate_stamp(TouchEvent *event, TouchWakeGateResult gate) {
  if (event->type == TouchEvent_Touchdown) {
    s_wake_gate_latch = gate.latch;
  }

  // --- PATCH BEGIN ---
  // Force non_navigational to true if we have raw subscriber tasks listening
  if (s_raw_subscriber_tasks != 0) {
    event->non_navigational = true;
  } else {
    event->non_navigational = s_wake_gate_latch;
  }
  // --- PATCH END ---
}

```

Once applied, commit and push your changes to your fork:

```bash
git add src/fw/applib/touch_service.c src/fw/services/touch/touch_session.c src/fw/services/touch/touch.c
git commit -m "Enable raw touchscreen events for custom watchfaces"
git push origin feature/touchscreen-watchfaces

```

### Step 5: Configure the Local Build Environment

Before entering the Nix build environment, Linux users need to strip an outdated `-latomic` flag from the Moddable JS engine makefiles. This prevents a Clang wrapper linker panic.

_Note: Do not commit these changes to GitHub, as removing this flag breaks compilation for older 32-bit architectures._

```bash
find third_party/moddable/moddable/xs/makefiles/lin/ -name "*.mk" -exec sed -i 's/-latomic//g' {} +
find third_party/moddable/moddable/build/makefiles/lin/ -name "*.mk" -exec sed -i 's/-latomic//g' {} +

```

### Step 6: Compile the Firmware

We use a Nix Flake development shell to ensure our toolchains are perfectly consistent. Enter the shell, configure your environment variables to prevent Waf threading hangs, and build for the `obelix@pvt` target.

```bash
# 1. Enter the Nix sandbox
nix --extra-experimental-features "nix-command flakes" develop --impure

# 2. Set build variables for Waf and Python parsing
export WAF_NO_PREFORK=1
export LC_ALL=C
export LANG=en_US.UTF-8

# 3. Clean, configure, and compile the firmware
pbl clean
pbl configure --board=obelix@pvt
pbl build
pbl bundle

```

Your compiled firmware will be generated at `build/normal_obelix_pvt-*.pbz`.

### Step 7: Sideloading the OS via Recovery Mode

The safest method is sideloading directly from your smartphone to the watch in Recovery Mode.

1. **Enter Recovery Mode** : Press and hold the **Back** , **Up** , and **Select** buttons simultaneously on your Pebble Time 2 until the screen turns off and the Pebble logo appears. The watch will boot into PRF (Pebble Recovery Firmware), creating a safe fallback sandbox to receive the new OS.

2. **Transfer the Firmware** : Send the `build/normal_obelix_pvt-*.pbz` file from your PC to your smartphone (via email, Google Drive, or a direct cable transfer).

3. **Sideload** : Open your phone’s file manager, tap the `normal_obelix_pvt-*.pbz` file, and select **Open with Pebble** (or share it directly to the Pebble app).

4. **Install** : The Pebble app will recognize the payload as a firmware update. Approve the prompt.

Once the Bluetooth transfer finishes, the watch will reboot into your newly patched firmware.

### Step 8: Implementing Touch in Your Watchface (SDK Usage)

Now that your hardware routing is unlocked, implementing it in your C app is straightforward. Here is how you interact with the API:

- **Subscribe:** Use `touch_service_subscribe` to register your callback handler, which will keep the touch sensor enabled while your watchface is subscribed.

- **Handle Data:** The callback you register will receive a `TouchEvent` struct containing the `x` and `y` coordinates of the user’s finger.

- **Detect Interaction Type:** You can evaluate the `TouchEventType` within that struct to trigger different logic for `TouchEvent_Touchdown`, `TouchEvent_Liftoff`, and `TouchEvent_PositionUpdate` events.

- **Graceful Degradation:** To ensure your UI still looks great on older non-touch Pebble models, you should poll `touch_service_is_enabled()` before trying to initialize any touch-specific elements.

- **Cleanup:** When your watchface exits, always call `touch_service_unsubscribe` to disable the touch sensor and conserve battery (provided no other subscribers remain active)

Now it’s time to create a touch-enabled watchface and see your PT2 operate in all its unfettered glory!

---

<div class="post-metadata">

**Author:** ![jpx](https://yyz1.discourse-cdn.com/flex033/user_avatar/forum.repebble.com/jpx/32/9_2.png) [@jpx](https://forum.repebble.com/u/jpx)\
**Post date:** [September 29, 2026, 5:44pm UTC](https://forum.repebble.com/t/guide-enabling-touchscreen-support-for-watchfaces-on-pebbleos/1741/2 "2026-09-29T17:44:16Z")

</div>

Please note that apps will only work correctly on that forked version of PebbleOS in that case and not on any other ““retail”” version. Also do note that we cannot support custom firmwares so keep that in mind when trying them
