[retro-gtk] input: Simplify the accessors
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] input: Simplify the accessors
- Date: Mon, 30 Oct 2017 06:26:57 +0000 (UTC)
commit ec01044709c8571e07fdc32ba3ad1fe7147fa99e
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Oct 29 23:21:11 2017 +0100
input: Simplify the accessors
Drop the _id and _index suffixes, merge accessors of the same controller
type and specify the out direction of the parameters.
retro-gtk/retro-core-view.c | 6 ++--
retro-gtk/retro-input.c | 76 +++++++++++++++++-------------------------
retro-gtk/retro-input.h | 23 ++++++-------
3 files changed, 45 insertions(+), 60 deletions(-)
---
diff --git a/retro-gtk/retro-core-view.c b/retro-gtk/retro-core-view.c
index c4cf2b5..cd50d37 100644
--- a/retro-gtk/retro-core-view.c
+++ b/retro-gtk/retro-core-view.c
@@ -638,12 +638,12 @@ retro_core_view_get_input_state (RetroCoreView *self,
switch (retro_input_get_controller_type (input)) {
case RETRO_CONTROLLER_TYPE_JOYPAD:
- if (!retro_input_get_joypad_id (input, &id))
+ if (!retro_input_get_joypad (input, &id))
return 0;
return retro_core_view_get_joypad_button_state (self, id) ? G_MAXINT16 : 0;
case RETRO_CONTROLLER_TYPE_MOUSE:
- if (!retro_input_get_mouse_id (input, &id))
+ if (!retro_input_get_mouse (input, &id))
return 0;
switch (id) {
@@ -665,7 +665,7 @@ retro_core_view_get_input_state (RetroCoreView *self,
return 0;
}
case RETRO_CONTROLLER_TYPE_POINTER:
- if (!retro_input_get_pointer_id (input, &id))
+ if (!retro_input_get_pointer (input, &id))
return 0;
switch (id) {
diff --git a/retro-gtk/retro-input.c b/retro-gtk/retro-input.c
index 052c084..cfd99e4 100644
--- a/retro-gtk/retro-input.c
+++ b/retro-gtk/retro-input.c
@@ -103,19 +103,20 @@ retro_input_get_controller_type (RetroInput *self)
}
/**
- * retro_input_get_joypad_id:
+ * retro_input_get_joypad:
* @self: a #RetroInput
- * @id: return location for the id
+ * @id: (out): return location for the id
*
* Gets the joypad id of %self, if any.
*
* Returns: whether the id was retrieved
*/
gboolean
-retro_input_get_joypad_id (RetroInput *self,
- RetroJoypadId *id)
+retro_input_get_joypad (RetroInput *self,
+ RetroJoypadId *id)
{
g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
if (self->any.type != RETRO_CONTROLLER_TYPE_JOYPAD)
return FALSE;
@@ -129,19 +130,20 @@ retro_input_get_joypad_id (RetroInput *self,
}
/**
- * retro_input_get_mouse_id:
+ * retro_input_get_mouse:
* @self: a #RetroInput
- * @id: return location for the id
+ * @id: (out): return location for the id
*
* Gets the mouse id of %self, if any.
*
* Returns: whether the id was retrieved
*/
gboolean
-retro_input_get_mouse_id (RetroInput *self,
- RetroMouseId *id)
+retro_input_get_mouse (RetroInput *self,
+ RetroMouseId *id)
{
g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
if (self->any.type != RETRO_CONTROLLER_TYPE_MOUSE)
return FALSE;
@@ -155,19 +157,20 @@ retro_input_get_mouse_id (RetroInput *self,
}
/**
- * retro_input_get_lightgun_id:
+ * retro_input_get_lightgun:
* @self: a #RetroInput
- * @id: return location for the id
+ * @id: (out): return location for the id
*
* Gets the lightgun id of %self, if any.
*
* Returns: whether the id was retrieved
*/
gboolean
-retro_input_get_lightgun_id (RetroInput *self,
- RetroLightgunId *id)
+retro_input_get_lightgun (RetroInput *self,
+ RetroLightgunId *id)
{
g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
if (self->any.type != RETRO_CONTROLLER_TYPE_LIGHTGUN)
return FALSE;
@@ -181,19 +184,23 @@ retro_input_get_lightgun_id (RetroInput *self,
}
/**
- * retro_input_get_analog_id:
+ * retro_input_get_analog:
* @self: a #RetroInput
- * @id: return location for the id
+ * @id: (out): return location for the id
+ * @index: (out): return location for the index
*
- * Gets the analog id of %self, if any.
+ * Gets the analog id and index of %self, if any.
*
- * Returns: whether the id was retrieved
+ * Returns: whether the id and the index were retrieved
*/
gboolean
-retro_input_get_analog_id (RetroInput *self,
- RetroAnalogId *id)
+retro_input_get_analog (RetroInput *self,
+ RetroAnalogId *id,
+ RetroAnalogIndex *index)
{
g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
+ g_return_val_if_fail (index != NULL, FALSE);
if (self->any.type != RETRO_CONTROLLER_TYPE_ANALOG)
return FALSE;
@@ -201,51 +208,30 @@ retro_input_get_analog_id (RetroInput *self,
if (self->analog.id >= RETRO_ANALOG_ID_COUNT)
return FALSE;
- *id = self->analog.id;
-
- return TRUE;
-}
-
-/**
- * retro_input_get_analog_index:
- * @self: a #RetroInput
- * @index: return location for the index
- *
- * Gets the analog index of %self, if any.
- *
- * Returns: whether the index was retrieved
- */
-gboolean
-retro_input_get_analog_index (RetroInput *self,
- RetroAnalogIndex *index)
-{
- g_return_val_if_fail (self != NULL, FALSE);
-
- if (self->any.type != RETRO_CONTROLLER_TYPE_ANALOG)
- return FALSE;
-
if (self->analog.index >= RETRO_ANALOG_INDEX_COUNT)
return FALSE;
+ *id = self->analog.id;
*index = self->analog.index;
return TRUE;
}
/**
- * retro_input_get_pointer_id:
+ * retro_input_get_pointer:
* @self: a #RetroInput
- * @id: return location for the id
+ * @id: (out): return location for the id
*
* Gets the pointer id of %self, if any.
*
* Returns: whether the id was retrieved
*/
gboolean
-retro_input_get_pointer_id (RetroInput *self,
- RetroPointerId *id)
+retro_input_get_pointer (RetroInput *self,
+ RetroPointerId *id)
{
g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
if (self->any.type != RETRO_CONTROLLER_TYPE_POINTER)
return FALSE;
diff --git a/retro-gtk/retro-input.h b/retro-gtk/retro-input.h
index cfcb577..d8e1de7 100644
--- a/retro-gtk/retro-input.h
+++ b/retro-gtk/retro-input.h
@@ -23,18 +23,17 @@ RetroInput *retro_input_new (void);
RetroInput *retro_input_copy (RetroInput *self);
void retro_input_free (RetroInput *self);
RetroControllerType retro_input_get_controller_type (RetroInput *self);
-gboolean retro_input_get_joypad_id (RetroInput *self,
- RetroJoypadId *id);
-gboolean retro_input_get_mouse_id (RetroInput *self,
- RetroMouseId *id);
-gboolean retro_input_get_lightgun_id (RetroInput *self,
- RetroLightgunId *id);
-gboolean retro_input_get_analog_id (RetroInput *self,
- RetroAnalogId *id);
-gboolean retro_input_get_analog_index (RetroInput *self,
- RetroAnalogIndex *index);
-gboolean retro_input_get_pointer_id (RetroInput *self,
- RetroPointerId *id);
+gboolean retro_input_get_joypad (RetroInput *self,
+ RetroJoypadId *id);
+gboolean retro_input_get_mouse (RetroInput *self,
+ RetroMouseId *id);
+gboolean retro_input_get_lightgun (RetroInput *self,
+ RetroLightgunId *id);
+gboolean retro_input_get_analog (RetroInput *self,
+ RetroAnalogId *id,
+ RetroAnalogIndex *index);
+gboolean retro_input_get_pointer (RetroInput *self,
+ RetroPointerId *id);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RetroInput, retro_input_free)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]