Skip to content

Commit 684cbdb

Browse files
committed
Update masterkeys Python wrapper
1 parent 4bee76d commit 684cbdb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

masterkeys/masterkeys.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,42 @@ static PyObject* masterkeys_get_device_ident(PyObject* self, PyObject* args) {
234234
}
235235

236236

237+
static PyObject* masterkeys_get_active_profile(PyObject* self, PyObject* args) {
238+
/** Return the active profile on the keyboard */
239+
char profile;
240+
int r = libmk_get_active_profile(NULL, &profile);
241+
if (r != LIBMK_SUCCESS)
242+
return NULL;
243+
return PyInt_FromLong(profile);
244+
}
245+
246+
247+
static PyObject* masterkeys_set_active_profile(PyObject* self, PyObject* args) {
248+
/** Set the active profile on the keyboard */
249+
char profile;
250+
if (!PyArg_ParseTuple(args, "i", &profile))
251+
return NULL;
252+
int r = libmk_set_active_profile(NULL, profile);
253+
return PyInt_FromLong(r);
254+
}
255+
256+
257+
static PyObject* masterkeys_save_profile(PyObject* self, PyObject* args) {
258+
/** Save changes made to the active profile */
259+
int r = libmk_save_profile(NULL);
260+
return PyInt_FromLong(r);
261+
}
262+
263+
264+
static PyObject* masterkeys_set_control_mode(PyObject* self, PyObject* args) {
265+
/** Set the control mode on the keyboard */
266+
LibMK_ControlMode mode;
267+
if (!PyArg_ParseTuple(args, "i", &mode))
268+
return NULL;
269+
return PyInt_FromLong(libmk_set_control_mode(NULL, mode));
270+
}
271+
272+
237273
static struct PyMethodDef masterkeys_funcs[] = {
238274
{
239275
"detect_devices",

0 commit comments

Comments
 (0)