File py3.13-buffers.patch of Package cwiid
Description: Fix build with python 3.13
Author: Vasyl Gello <vasek.gello@gmail.com>
Bug-Debian: https://bugs.debian.org/1092088
Forwarded: not-needed
---
--- a/python/Wiimote.c
+++ b/python/Wiimote.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/
@@ -38,26 +38,26 @@
Wiimote_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void Wiimote_dealloc(Wiimote *self);
static int Wiimote_init(Wiimote *self, PyObject *args, PyObject *kwds);
-static PyObject *Wiimote_close(Wiimote *self);
+static PyObject *Wiimote_close(Wiimote *self, PyObject *unused);
static PyObject *Wiimote_enable(Wiimote *self, PyObject *args, PyObject *kwds);
static PyObject *
Wiimote_disable(Wiimote *self, PyObject *args, PyObject *kwds);
static int
- Wiimote_set_mesg_callback(Wiimote *self, PyObject *args, void *closure);
-static PyObject *Wiimote_get_mesg(Wiimote *self);
-static PyObject *Wiimote_get_state(Wiimote *self, void *closure);
+ Wiimote_set_mesg_callback(Wiimote *self, PyObject *args, PyObject *closure);
+static PyObject *Wiimote_get_mesg(Wiimote *self, PyObject *unused);
+static PyObject *Wiimote_get_state(Wiimote *self, PyObject *closure);
static PyObject *Wiimote_get_acc_cal(Wiimote *self, PyObject *args,
PyObject *kwds);
-static PyObject *Wiimote_get_balance_cal(Wiimote *self);
+static PyObject *Wiimote_get_balance_cal(Wiimote *self, PyObject *unused);
-static PyObject *Wiimote_request_status(Wiimote *self);
-static int Wiimote_set_led(Wiimote *self, PyObject *PyLed, void *closure);
+static PyObject *Wiimote_request_status(Wiimote *self, PyObject *unused);
+static int Wiimote_set_led(Wiimote *self, PyObject *PyLed, PyObject *closure);
static int
- Wiimote_set_rumble(Wiimote *self, PyObject *PyRumble, void *closure);
+ Wiimote_set_rumble(Wiimote *self, PyObject *PyRumble, PyObject *closure);
static int
- Wiimote_set_rpt_mode(Wiimote *self, PyObject *PyRptMode, void *closure);
+ Wiimote_set_rpt_mode(Wiimote *self, PyObject *PyRptMode, PyObject *closure);
static PyObject *Wiimote_send_rpt(Wiimote *self, PyObject *args, PyObject *kwds);
static PyObject *Wiimote_read(Wiimote *self, PyObject *args, PyObject *kwds);
@@ -145,11 +145,26 @@
(initproc)Wiimote_init, /* tp_init */
0, /* tp_alloc */
Wiimote_new, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+ 0, /* tp_finalize */
+ 0, /* tp_vectorcall */
+ 0, /* tp_watched */
+ 0, /* tp_versions_used */
};
/* Allocate and deallocate functions */
static PyObject *
- Wiimote_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ Wiimote_new(PyTypeObject *type,
+ __attribute__ ((unused)) PyObject *args,
+ __attribute__ ((unused)) PyObject *kwds)
{
Wiimote* self;
@@ -208,10 +223,6 @@
bdaddr = *BDADDR_ANY;
}
- if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 5) {
- PyEval_InitThreads();
- }
-
Py_BEGIN_ALLOW_THREADS
wiimote = cwiid_open(&bdaddr, flags);
Py_END_ALLOW_THREADS
@@ -233,7 +244,8 @@
#define SET_CLOSED_ERROR PyErr_SetString(PyExc_ValueError, "Wiimote is closed")
-static PyObject *Wiimote_close(Wiimote *self)
+static PyObject *Wiimote_close(Wiimote *self,
+ __attribute__ ((unused)) PyObject *unused)
{
if (!self->wiimote) {
SET_CLOSED_ERROR;
@@ -299,7 +311,7 @@
static int
Wiimote_set_mesg_callback(Wiimote *self, PyObject *NewCallback,
- void *closure)
+ __attribute__ ((unused)) PyObject *closure)
{
PyObject *OldCallback;
@@ -336,7 +348,8 @@
return 0;
}
-static PyObject *Wiimote_get_mesg(Wiimote *self)
+static PyObject *Wiimote_get_mesg(Wiimote *self,
+ __attribute__ ((unused)) PyObject* unused)
{
union cwiid_mesg *mesg;
int mesg_count;
@@ -366,7 +379,8 @@
return PyMesg;
}
-static PyObject *Wiimote_get_state(Wiimote* self, void *closure)
+static PyObject *Wiimote_get_state(Wiimote* self,
+ __attribute__ ((unused)) PyObject *closure)
{
struct cwiid_state state;
PyObject *PyState;
@@ -625,7 +639,8 @@
return PyAccCal;
}
-static PyObject *Wiimote_get_balance_cal(Wiimote *self)
+static PyObject *Wiimote_get_balance_cal(Wiimote *self,
+ __attribute__ ((unused)) PyObject* unused)
{
struct balance_cal balance_cal;
PyObject *PyBalCal;
@@ -655,7 +670,8 @@
return PyBalCal;
}
-static PyObject *Wiimote_request_status(Wiimote *self)
+static PyObject *Wiimote_request_status(Wiimote *self,
+ __attribute__ ((unused)) PyObject *unused)
{
if (!self->wiimote) {
SET_CLOSED_ERROR;
@@ -670,7 +686,8 @@
Py_RETURN_NONE;
}
-static int Wiimote_set_led(Wiimote *self, PyObject *PyLed, void *closure)
+static int Wiimote_set_led(Wiimote *self, PyObject *PyLed,
+ __attribute__ ((unused)) PyObject *closure)
{
long led;
@@ -693,7 +710,9 @@
}
static int
- Wiimote_set_rumble(Wiimote *self, PyObject *PyRumble, void *closure)
+ Wiimote_set_rumble(Wiimote *self,
+ PyObject *PyRumble,
+ __attribute__ ((unused)) PyObject *closure)
{
long rumble;
@@ -716,7 +735,9 @@
}
static int
- Wiimote_set_rpt_mode(Wiimote *self, PyObject *PyRptMode, void *closure)
+ Wiimote_set_rpt_mode(Wiimote *self,
+ PyObject *PyRptMode,
+ __attribute__ ((unused)) PyObject *closure)
{
long rpt_mode;
@@ -738,22 +759,6 @@
return 0;
}
-/* static PyObject *Wiimote_command(Wiimote *self, PyObject *args, PyObject *kwds)
-{
- static char *kwlist[] = { "command", "flags", NULL };
- int command, flags;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwlist, &command,
- &flags)) {
- return NULL;
- }
-
- cwiid_command(self->wiimote, (enum cwiid_command)command, (uint8_t)flags);
-
- Py_RETURN_NONE;
-}
-*/
-
static PyObject *Wiimote_send_rpt(Wiimote *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = { "flags", "report", "buffer", NULL };
@@ -782,11 +787,11 @@
static PyObject *Wiimote_read(Wiimote *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = { "flags", "offset", "len", NULL };
- unsigned char flags;
- unsigned int offset;
- Py_ssize_t len;
- void *buf;
- PyObject *pyRetBuf;
+ unsigned char flags = 0;
+ unsigned int offset = 0;
+ Py_ssize_t len = 0;
+ void *buf = NULL;
+ PyObject *pyRetBuf = NULL;
if (!self->wiimote) {
SET_CLOSED_ERROR;
@@ -798,16 +803,19 @@
return NULL;
}
- if (!(pyRetBuf = malloc(len))) {
+ if (!(buf = malloc(len))) {
return NULL;
}
- if (PyObject_AsWriteBuffer(pyRetBuf, &buf, &len)) {
- Py_DECREF(pyRetBuf);
+
+ if (cwiid_read(self->wiimote, flags, offset, len, buf)) {
+ PyErr_SetString(PyExc_RuntimeError, "Error reading wiimote data");
+ free(buf);
return NULL;
}
- if (cwiid_read(self->wiimote,flags,offset,len,buf)) {
- PyErr_SetString(PyExc_RuntimeError, "Error reading wiimote data");
- Py_DECREF(pyRetBuf);
+
+ if (!(pyRetBuf = PyMemoryView_FromMemory((char*)buf, len, PyBUF_READ))) {
+ PyErr_SetString(PyExc_RuntimeError, "Error constructing PyMemoryView");
+ free(buf);
return NULL;
}
@@ -1014,7 +1022,6 @@
mesg[i].motionplus_mesg.low_speed[CWIID_PHI],
mesg[i].motionplus_mesg.low_speed[CWIID_THETA],
mesg[i].motionplus_mesg.low_speed[CWIID_PSI]);
-
break;
case CWIID_MESG_ERROR:
mesgVal = Py_BuildValue("i", mesg[i].error_mesg.error);
--- a/libcwiid/process.c
+++ b/libcwiid/process.c
@@ -40,7 +40,7 @@
}
int process_status(struct wiimote *wiimote, const unsigned char *data,
- struct mesg_array *ma)
+ __attribute__ ((unused)) struct mesg_array *ma)
{
struct cwiid_status_mesg status_mesg;
@@ -172,7 +172,8 @@
}
int process_ext(struct wiimote *wiimote, unsigned char *data,
- unsigned char len, struct mesg_array *ma)
+ __attribute__ ((unused)) unsigned char len,
+ struct mesg_array *ma)
{
struct cwiid_nunchuk_mesg *nunchuk_mesg;
struct cwiid_classic_mesg *classic_mesg;
--- a/wmdemo/wmdemo.c
+++ b/wmdemo/wmdemo.c
@@ -306,7 +306,8 @@
* The id is to distinguish between multiple wiimotes using the same callback.
* */
void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count,
- union cwiid_mesg mesg[], struct timespec *timestamp)
+ union cwiid_mesg mesg[],
+ __attribute__ ((unused)) struct timespec *timestamp)
{
int i, j;
int valid_source;
--- a/wminput/c_plugin.c
+++ b/wminput/c_plugin.c
@@ -171,7 +171,7 @@
return 0;
}
-void wmplugin_err(int id, char *str, ...)
+void wmplugin_err(__attribute__ ((unused)) int id, char *str, ...)
{
va_list ap;
--- a/wminput/main.c
+++ b/wminput/main.c
@@ -118,7 +118,7 @@
printf("\t-w, --wait\t\tWait indefinitely for wiimote to connect.\n");
}
-void cwiid_err_connect(struct wiimote *wiimote, const char *str, va_list ap)
+void cwiid_err_connect(__attribute__ ((unused)) struct wiimote *wiimote, const char *str, va_list ap)
{
/* TODO: temporary kludge to stifle error messages from cwiid_open */
if (errno != EHOSTDOWN) {
@@ -443,8 +443,10 @@
return 0;
}
-void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count,
- union cwiid_mesg mesg[], struct timespec *timestamp)
+void cwiid_callback(__attribute__ ((unused)) cwiid_wiimote_t *wiimote,
+ int mesg_count,
+ union cwiid_mesg mesg[],
+ __attribute__ ((unused)) struct timespec *timestamp)
{
int i;
@@ -759,7 +761,7 @@
/* Plugin Axis Events */
for (i=0; i < plugin->info->axis_count; i++) {
- if (plugin->amap[i].active && plugin->data->axes &&
+ if (plugin->amap[i].active &&
plugin->data->axes[i].valid) {
axis_value = plugin->data->axes[i].value;
if (plugin->amap[i].flags & CONF_INVERT) {
--- a/wminput/plugins/ir_ptr/ir_ptr.c
+++ b/wminput/plugins/ir_ptr/ir_ptr.c
@@ -104,10 +104,8 @@
{
static int src_index = -1;
static int debounce = 0;
- static uint8_t old_flag;
int i;
- uint8_t flag;
struct cwiid_ir_mesg *ir_mesg;
ir_mesg = NULL;
@@ -146,35 +144,6 @@
}
}
- /* LEDs */
- /* Commented out so it doesn't overide led plugin.
- * It shouldn't matter, since only one IR source
- * is used now anyways. If the pointer is moving,
- * it sees a source.
- switch (src_index) {
- case 0:
- flag = CWIID_LED1_ON;
- break;
- case 1:
- flag = CWIID_LED2_ON;
- break;
- case 2:
- flag = CWIID_LED3_ON;
- break;
- case 3:
- flag = CWIID_LED4_ON;
- break;
- default:
- flag = 0;
- break;
- }
-
- if (flag != old_flag) {
- cwiid_set_led(wiimote, flag);
- old_flag = flag;
- }
- */
-
if ((src_index == -1) || !ir_mesg->src[src_index].valid) {
data.axes[0].valid = data.axes[1].valid = 0;
}
--- a/wminput/plugins/nunchuk_kb/nunchuk_kb.c
+++ b/wminput/plugins/nunchuk_kb/nunchuk_kb.c
@@ -42,11 +42,6 @@
wmplugin_exec_t wmplugin_exec;
static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg);
-static float Roll_Scale = 1.0;
-static float Pitch_Scale = 1.0;
-static float X_Scale = 1.0;
-static float Y_Scale = 1.0;
-
struct wmplugin_info *wmplugin_info() {
if (!info_init) {
info.button_count = 4;
--- a/wminput/plugins/nunchuk_stick2btn/nunchuk_stick2btn.c
+++ b/wminput/plugins/nunchuk_stick2btn/nunchuk_stick2btn.c
@@ -48,7 +48,7 @@
return &info;
}
-int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote)
+int wmplugin_init(int id, __attribute__ ((unused)) cwiid_wiimote_t *arg_wiimote)
{
data.buttons = 0;
if (wmplugin_set_rpt_mode(id, CWIID_RPT_NUNCHUK)) {
--- a/wminput/py_plugin.c
+++ b/wminput/py_plugin.c
@@ -83,7 +83,7 @@
{NULL, 0}
};
-static PyMethodDef Module_Methods[] =
+static PyMethodDef Module_Methods[] =
{
{"set_rpt_mode", (PyCFunction)set_rpt_mode, METH_VARARGS | METH_KEYWORDS,
"set_rpt_mode(id, rpt_mode)\n\nset the plugin report mode"},
@@ -624,7 +624,9 @@
return 0;
}
-static PyObject *set_rpt_mode(PyObject *self, PyObject *args, PyObject *kwds)
+static PyObject *set_rpt_mode(__attribute__ ((unused)) PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
{
static char *kwlist[] = {"id", "rpt_mode", NULL};
int id, rpt_mode;