return 0;
}
+XKB_EXPORT xkb_keycode_t
+xkb_keymap_min_keycode(struct xkb_keymap *keymap)
+{
+ return keymap->min_key_code;
+}
+
+XKB_EXPORT xkb_keycode_t
+xkb_keymap_max_keycode(struct xkb_keymap *keymap)
+{
+ return keymap->max_key_code;
+}
+
+XKB_EXPORT void
+xkb_keymap_key_for_each(struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter,
+ void *data)
+{
+ struct xkb_key *key;
+
+ xkb_foreach_key(key, keymap)
+ iter(keymap, key->keycode, data);
+}
+
/**
* Simple boolean specifying whether or not the key should repeat.
*/
xkb_state_unref(state);
}
+static void
+key_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data)
+{
+ int *counter = (int *) data;
+
+ assert(*counter == key);
+ (*counter)++;
+}
+
+static void
+test_range(struct xkb_keymap *keymap)
+{
+ int counter;
+
+ assert(xkb_keymap_min_keycode(keymap) == 9);
+ assert(xkb_keymap_max_keycode(keymap) == 253);
+
+ counter = xkb_keymap_min_keycode(keymap);
+ xkb_keymap_key_for_each(keymap, key_iter, &counter);
+ assert(counter == xkb_keymap_max_keycode(keymap) + 1);
+}
+
int
main(void)
{
test_serialisation(keymap);
test_repeat(keymap);
test_consume(keymap);
+ test_range(keymap);
xkb_keymap_unref(keymap);
xkb_context_unref(context);
* @{
*/
+/**
+ * Get the minimum keycode in the keymap.
+ *
+ * @sa xkb_keycode_t
+ * @memberof xkb_keymap
+ */
+xkb_keycode_t
+xkb_keymap_min_keycode(struct xkb_keymap *keymap);
+
+/**
+ * Get the maximum keycode in the keymap.
+ *
+ * @sa xkb_keycode_t
+ * @memberof xkb_keymap
+ */
+xkb_keycode_t
+xkb_keymap_max_keycode(struct xkb_keymap *keymap);
+
+/**
+ * The iterator used by xkb_keymap_key_for_each().
+ *
+ * @sa xkb_keymap_key_for_each
+ * @memberof xkb_keymap
+ */
+typedef void
+(*xkb_keymap_key_iter_t)(struct xkb_keymap *keymap, xkb_keycode_t key,
+ void *data);
+
+/**
+ * Run a specified function for every valid keycode in the keymap. If a
+ * keymap is sparse, this function may be called fewer than
+ * (max_keycode - min_keycode + 1) times.
+ *
+ * @sa xkb_keymap_min_keycode() xkb_keymap_max_keycode() xkb_keycode_t
+ * @memberof xkb_keymap
+ */
+void
+xkb_keymap_key_for_each(struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter,
+ void *data);
+
/**
* Get the number of modifiers in the keymap.
*