pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Moddable API (Alloy)
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • Alloy
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
      • TouchService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

The APIs on this page will only work with SDK 4.9+.

TouchService

Function Documentation

void touch_service_subscribe(TouchServiceHandler handler, void * context)

Subscribe to touch events. The touch sensor is enabled while subscribed.

Parameters

handler

Callback invoked for each touch event

context

User context passed to the callback

void touch_service_unsubscribe(void)

Unsubscribe from touch events. The touch sensor is disabled if no other subscribers remain.

bool touch_service_is_enabled(void)

Returns

true if touch input is currently being delivered to apps. Returns false on platforms without a touchscreen, or when touch has been disabled system-wide (future feature). Apps can poll this (for example on window appear) to avoid looking broken when touch is unavailable.

Data Structure Documentation

struct TouchEvent

Touch event data, carried directly in PebbleTouchEvent.

Data Fields

TouchEventType type
int16_t x
int16_t y

Enum Documentation

enum TouchEventType

Touch event type.

Enumerators

TouchEvent_Touchdown
TouchEvent_Liftoff
TouchEvent_PositionUpdate

Typedef Documentation

typedef void(* TouchServiceHandler)(const TouchEvent *event, void *context)

Callback for touch events.

Parameters

event

The touch event data

context

User-provided context

Need some help?

Functions

  • touch_service_subscribe
  • touch_service_unsubscribe
  • touch_service_is_enabled

Data Structures

  • TouchEvent

Enums

  • TouchEventType

Typedefs

  • TouchServiceHandler

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can join us on the Discord!