vice-emu-commit Mailing List for VICE (Page 11)
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(38) |
May
(60) |
Jun
(122) |
Jul
(148) |
Aug
(178) |
Sep
(151) |
Oct
(131) |
Nov
(208) |
Dec
(129) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(193) |
Feb
(209) |
Mar
(221) |
Apr
(243) |
May
(165) |
Jun
(168) |
Jul
(198) |
Aug
(161) |
Sep
(103) |
Oct
(98) |
Nov
(168) |
Dec
(99) |
| 2010 |
Jan
(263) |
Feb
(156) |
Mar
(57) |
Apr
(93) |
May
(85) |
Jun
(124) |
Jul
(57) |
Aug
(58) |
Sep
(113) |
Oct
(148) |
Nov
(114) |
Dec
(193) |
| 2011 |
Jan
(200) |
Feb
(207) |
Mar
(91) |
Apr
(91) |
May
(142) |
Jun
(104) |
Jul
(115) |
Aug
(137) |
Sep
(266) |
Oct
(91) |
Nov
(85) |
Dec
(186) |
| 2012 |
Jan
(98) |
Feb
(146) |
Mar
(160) |
Apr
(99) |
May
(59) |
Jun
(257) |
Jul
(84) |
Aug
(103) |
Sep
(169) |
Oct
(206) |
Nov
(90) |
Dec
(296) |
| 2013 |
Jan
(294) |
Feb
(130) |
Mar
(36) |
Apr
(14) |
May
(51) |
Jun
(74) |
Jul
(180) |
Aug
(85) |
Sep
(26) |
Oct
(45) |
Nov
(29) |
Dec
(21) |
| 2014 |
Jan
(56) |
Feb
(40) |
Mar
(57) |
Apr
(30) |
May
(31) |
Jun
(11) |
Jul
(107) |
Aug
(135) |
Sep
(142) |
Oct
(195) |
Nov
(139) |
Dec
(133) |
| 2015 |
Jan
(293) |
Feb
(161) |
Mar
(146) |
Apr
(85) |
May
(139) |
Jun
(51) |
Jul
(21) |
Aug
(24) |
Sep
(29) |
Oct
(136) |
Nov
(212) |
Dec
(118) |
| 2016 |
Jan
(119) |
Feb
(165) |
Mar
(229) |
Apr
(219) |
May
(134) |
Jun
(119) |
Jul
(134) |
Aug
(236) |
Sep
(203) |
Oct
(215) |
Nov
(300) |
Dec
(140) |
| 2017 |
Jan
(188) |
Feb
(20) |
Mar
(147) |
Apr
(198) |
May
(26) |
Jun
(21) |
Jul
(67) |
Aug
(219) |
Sep
(209) |
Oct
(194) |
Nov
(144) |
Dec
(99) |
| 2018 |
Jan
(139) |
Feb
(122) |
Mar
(116) |
Apr
(85) |
May
(232) |
Jun
(181) |
Jul
(190) |
Aug
(105) |
Sep
(92) |
Oct
(178) |
Nov
(105) |
Dec
(86) |
| 2019 |
Jan
(119) |
Feb
(79) |
Mar
(74) |
Apr
(117) |
May
(115) |
Jun
(307) |
Jul
(107) |
Aug
(131) |
Sep
(103) |
Oct
(60) |
Nov
(118) |
Dec
(70) |
| 2020 |
Jan
(114) |
Feb
(103) |
Mar
(77) |
Apr
(121) |
May
(193) |
Jun
(110) |
Jul
(214) |
Aug
(210) |
Sep
(179) |
Oct
(260) |
Nov
(237) |
Dec
(334) |
| 2021 |
Jan
(163) |
Feb
(186) |
Mar
(58) |
Apr
(81) |
May
(108) |
Jun
(175) |
Jul
(154) |
Aug
(180) |
Sep
(217) |
Oct
(204) |
Nov
(232) |
Dec
(190) |
| 2022 |
Jan
(253) |
Feb
(134) |
Mar
(229) |
Apr
(190) |
May
(125) |
Jun
(70) |
Jul
(8) |
Aug
(22) |
Sep
(19) |
Oct
(33) |
Nov
(94) |
Dec
(164) |
| 2023 |
Jan
(158) |
Feb
(366) |
Mar
(272) |
Apr
(109) |
May
(198) |
Jun
(226) |
Jul
(200) |
Aug
(94) |
Sep
(108) |
Oct
(62) |
Nov
(175) |
Dec
(116) |
| 2024 |
Jan
(35) |
Feb
(40) |
Mar
(51) |
Apr
(89) |
May
(24) |
Jun
(26) |
Jul
(53) |
Aug
(71) |
Sep
(23) |
Oct
(11) |
Nov
(22) |
Dec
(58) |
| 2025 |
Jan
(26) |
Feb
(40) |
Mar
(107) |
Apr
(39) |
May
(35) |
Jun
(20) |
Jul
(11) |
Aug
(24) |
Sep
(35) |
Oct
(28) |
Nov
(12) |
Dec
|
|
From: <emp...@us...> - 2025-03-23 15:00:55
|
Revision: 45570
http://sourceforge.net/p/vice-emu/code/45570
Author: empathicqubit
Date: 2025-03-23 15:00:41 +0000 (Sun, 23 Mar 2025)
Log Message:
-----------
Reformat some binary monitor examples which overflow the PDF
Modified Paths:
--------------
trunk/vice/doc/vice.texi
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-03-23 06:47:32 UTC (rev 45569)
+++ trunk/vice/doc/vice.texi 2025-03-23 15:00:41 UTC (rev 45570)
@@ -21831,7 +21831,11 @@
Command body:
@example
-MS | RC RC [ IS[0] @{ RI[0] RV[0] RV[0] @} ... IS[RC-1] @{ RI[RC-1] RV[RC-1] RV[RC-1] @} ]
+MS | RC RC [
+ IS[0] @{ RI[0] | RV[0] RV[0] @}
+ ...
+ IS[RC-1] @{ RI[RC-1] | RV[RC-1] RV[RC-1] @}
+]
@end example
@*
@@ -22170,7 +22174,11 @@
Response body:
@example
-BC BC [ IS[0] @{ BI[0] BI[0] | NL[0] | BN[0][0] BN[0][1] ... BN[0][NL[0]-1] @} ... IS[BC-1] @{ ... @} ]
+BC BC [
+ IS[0] @{ BI[0] BI[0] | NL[0] | BN[0][0] BN[0][1] ... BN[0][NL[0]-1] @}
+ ...
+ IS[BC-1] @{ ... @}
+]
@end example
@*
@@ -22293,7 +22301,8 @@
Response body:
@example
-FL FL FL FL | DW DW | DH DH | XO XO | YO YO | IW IW | IH IH | BP | BL BL BL BL | BD[0] BD[1] ... BD[BL-1]
+FL FL FL FL | DW DW | DH DH | XO XO | YO YO | IW IW | IH IH | BP |
+ BL BL BL BL | BD[0] BD[1] ... BD[BL-1]
@end example
@*
@@ -22759,7 +22768,8 @@
Response body:
@example
-CN CN CN CN | CH | SA SA | EA EA | ST | EN | OP | TM | HC HC HC HC | IC IC IC IC | CE | MS
+CN CN CN CN | CH | SA SA | EA EA | ST | EN | OP | TM |
+ HC HC HC HC | IC IC IC IC | CE | MS
@end example
@*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-23 06:47:49
|
Revision: 45569
http://sourceforge.net/p/vice-emu/code/45569
Author: compyx
Date: 2025-03-23 06:47:32 +0000 (Sun, 23 Mar 2025)
Log Message:
-----------
Joystick: Windows: remove deprecated code, disable debug log message
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-23 06:41:11 UTC (rev 45568)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-23 06:47:32 UTC (rev 45569)
@@ -375,85 +375,6 @@
return DIENUM_CONTINUE;
}
-#if 0
-/** \brief Callback for EnumObjects to enumerate axes
- *
- * \param[in] lpddoi direct input device object instance
- * \param[in] pvref joystick device
- *
- * \return \c DIENUM_CONTINUE
- */
-static BOOL enum_axes_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
-{
- joystick_device_t *joydev = pvref;
- joy_priv_t *priv = joydev->priv;
- joystick_axis_t *axis;
- DIPROPRANGE range;
- HRESULT result;
-
- axis = joystick_axis_new(lpddoi->tszName);
- axis->code = DIDFT_GETINSTANCE(lpddoi->dwType);
-
- /* get logical range */
- range.diph.dwSize = sizeof(DIPROPRANGE);
- range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- range.diph.dwObj = lpddoi->dwType;
- range.diph.dwHow = DIPH_BYID;
- result = IDirectInputDevice8_GetProperty(priv->didev,
- DIPROP_LOGICALRANGE,
- &range.diph);
- if (SUCCEEDED(result)) {
- axis->minimum = (int32_t)range.lMin;
- axis->maximum = (int32_t)range.lMax;
- }
-
- /* add axis and continue */
- joystick_device_add_axis(joydev, axis);
- // log_message(winjoy_log, "axis %d: %s (%u): [%d - %d]",
- // joydev->num_axes - 1, axis->name, axis->code, axis->minimum, axis->maximum);
- return DIENUM_CONTINUE;
-}
-
-/** \brief Callback for EnumObjects to enumerate buttons
- *
- * \param[in] lpddoi direct input device object instance
- * \param[in] pvref joystick device
- *
- * \return \c DIENUM_CONTINUE
- */
-static BOOL enum_buttons_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
-{
- joystick_device_t *joydev = pvref;
- joystick_button_t *button;
-
- button = joystick_button_new(lpddoi->tszName);
- button->code = DIDFT_GETINSTANCE(lpddoi->dwType);
- joystick_device_add_button(joydev, button);
- // log_message(winjoy_log, "button %d: %s (%d)", joydev->num_buttons - 1, button->name, button->code);
- return DIENUM_CONTINUE;
-}
-
-/** \brief Callback for EnumObjects to enumerate hats (POVs)
- *
- * \param[in] lpddoi direct input device object instance
- * \param[in] pvref joystick device
- *
- * \return \c DIENUM_CONTINUE
- */
-static BOOL enum_hats_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
-{
- joystick_device_t *joydev = pvref;
- joystick_hat_t *hat;
-
- hat = joystick_hat_new(lpddoi->tszName);
- hat->code = DIDFT_GETINSTANCE(lpddoi->dwType);
-
- joystick_device_add_hat(joydev, hat);
- // log_message(winjoy_log, "POV %d: %s (%u)", joydev->num_hats - 1, hat->name, hat->code);
- return DIENUM_CONTINUE;
-}
-#endif
-
/** \brief Callback for IDirectInput8_EnumDevices()
*
*
@@ -469,9 +390,11 @@
joystick_device_t *joydev;
joy_priv_t *priv;
HRESULT result;
+#if 0
int raxes; /* reported number of axes */
int rbuttons; /* reported number of buttons */
int rpovs; /* reported number of POVs */
+#endif
/* create device instance */
result = IDirectInput8_CreateDevice(dinput_handle,
@@ -502,49 +425,35 @@
joydev->name = lib_strdup(lpddi->tszProductName);
joydev->vendor = (uint16_t)(lpddi->guidProduct.Data1 & 0xffff);
joydev->product = (uint16_t)((lpddi->guidProduct.Data1 > 16u) & 0xffff);
- /* don't set num axes etc here, the joystick_device_add_foo() functions
+ /* Don't set num axes etc here, the joystick_device_add_foo() functions
* update the number of inputs when called. */
+#if 0
raxes = caps.dwAxes;
rbuttons = caps.dwButtons;
rpovs = caps.dwPOVs;
+#endif
/* generate GUID as string for the node member */
joydev->node = lib_calloc(GUIDSTR_BUFSIZE, 1);
guid_to_str(&lpddi->guidInstance, joydev->node);
-
+#if 0
log_message(winjoy_log,
"got device \"%s\" [%04x:%04x] GUID: %s, axes: %d, buttons: %d, POVs: %d",
joydev->name, (unsigned int)joydev->vendor, (unsigned int)joydev->product,
joydev->node, raxes, rbuttons, rpovs);
-
+#endif
/* store arch-specific data */
priv = joy_priv_new();
priv->guid = lpddi->guidInstance;
priv->didev = didev;
joydev->priv = priv;
-#if 0
- /* enumerate (absolute) axes */
- IDirectInputDevice8_EnumObjects(didev,
- enum_axes_callback,
- (LPVOID)joydev,
- DIDFT_ABSAXIS);
- /* enumerate buttons */
+ /* enumerate axes, buttons and hats */
IDirectInputDevice8_EnumObjects(didev,
- enum_buttons_callback,
- (LPVOID)joydev,
- DIDFT_BUTTON);
- /* enumerate POVs */
- IDirectInputDevice8_EnumObjects(didev,
- enum_hats_callback,
- (LPVOID)joydev,
- DIDFT_POV);
-#else
- IDirectInputDevice8_EnumObjects(didev,
enum_objects_callback,
(LPVOID)joydev,
DIDFT_ABSAXIS|DIDFT_BUTTON|DIDFT_POV);
-#endif
+
/* Open device manually for polling, until the driver's open() method has
* been properly implemented and tested (changing resource "JoyDeviceN"
* should close the old device and open the new one)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-23 06:41:15
|
Revision: 45568
http://sourceforge.net/p/vice-emu/code/45568
Author: compyx
Date: 2025-03-23 06:41:11 +0000 (Sun, 23 Mar 2025)
Log Message:
-----------
Joystick: Windows: avoid needless calls to joy_foo_event()
Keep track of previous values of axes, buttons and POVs: if the raw value didn't
change the value interpreted by the common joystick event handlers certainly
won't change.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 21:43:07 UTC (rev 45567)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-23 06:41:11 UTC (rev 45568)
@@ -40,6 +40,15 @@
* New API
*/
+/** \brief Maximum number of axes in a DIJOYSTATE2 struct */
+#define DIJS2_MAX_AXES 24
+
+/** \brief Maximum number of buttons in a DIJOYSTATE2 struct */
+#define DIJS2_MAX_BUTTONS 128
+
+/** \brief Maximum number of hat (POVs) in a DIJOYSTATE2 struct */
+#define DIJS2_MAX_HATS 4
+
/** \brief Private data object
*
* Contains arch-specific data of a joystick device.
@@ -47,6 +56,9 @@
typedef struct joy_priv_s {
GUID guid; /**< GUID */
LPDIRECTINPUTDEVICE8 didev; /**< DirectInput device instance */
+ LONG prev_axes[DIJS2_MAX_AXES]; /**< prev state of axes */
+ BYTE prev_buttons[DIJS2_MAX_BUTTONS]; /**< prev state of buttons */
+ LONG prev_hats[DIJS2_MAX_HATS]; /**< prev state of POVs */
} joy_priv_t;
@@ -69,9 +81,7 @@
*/
static joy_priv_t *joy_priv_new(void)
{
- joy_priv_t *priv = lib_malloc(sizeof *priv);
-
- memset(&priv->guid, 0, sizeof(priv->guid));
+ joy_priv_t *priv = lib_calloc(sizeof *priv, 1);
priv->didev = NULL;
return priv;
}
@@ -160,7 +170,13 @@
/* buttons are simply listed in sequence, starting at 0 */
joystick_button_t *button = joydev->buttons[i];
int32_t value = jstate.rgbButtons[i] & 0x80;
+ BYTE prev = priv->prev_buttons[i];
+ if (prev == value) {
+ continue;
+ }
+ priv->prev_buttons[i] = (BYTE)value;
+
joy_button_event(joydev, button, value);
}
@@ -168,6 +184,7 @@
for (i = 0; i < joydev->num_axes; i++) {
joystick_axis_t *axis = joydev->axes[i];
uint32_t code = axis->code;
+ LONG prev = priv->prev_axes[i];
if (code < sizeof axis_map / sizeof axis_map[0]) {
int32_t minimum = axis->minimum;
@@ -175,6 +192,11 @@
int32_t range = maximum - minimum;
int32_t value = *(axis_map[code]);
+ if (value == prev) {
+ continue;
+ }
+ priv->prev_axes[i] = value;
+
//printf("axis %d raw value = %d\n", i, value);
if (value <= minimum + (range / 4)) {
@@ -193,7 +215,13 @@
joystick_hat_t *hat = joydev->hats[i];
int32_t value = LOWORD(jstate.rgdwPOV[i]);
int32_t direction = JOYSTICK_DIRECTION_NONE; /* neutral */
+ LONG prev = priv->prev_hats[i];
+ if (prev == value) {
+ continue;
+ }
+ priv->prev_hats[i] = prev;
+
/* POVs map to 360 degrees, in units of 1/100th of a degree, neutral
* is reported as -1 / 0xffffffff.
* Translate position on a circle to joystick directions, clockwise
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-22 21:43:22
|
Revision: 45567
http://sourceforge.net/p/vice-emu/code/45567
Author: compyx
Date: 2025-03-22 21:43:07 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Joystick: Windows: delete remnants of old joystick driver
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 18:02:55 UTC (rev 45566)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 21:43:07 UTC (rev 45567)
@@ -1,8 +1,7 @@
/** \file joystick_win32_directinput.c
* \brief Joystick support for Windows
*
- * \author Tibor Biczo <cr...@ma...>
- * \author Ettore Perazzoli <et...@co...>
+ * \author Bas Wassink <b.w...@zi...>
*/
/*
@@ -37,324 +36,6 @@
#define INITGUID
#include <dinput.h>
-#if 0
-typedef struct _JoyAxis {
- struct _JoyAxis *next;
- DWORD id;
- char *name;
-} JoyAxis;
-
-typedef struct _JoyButton {
- struct _JoyButton *next;
- DWORD id;
- char *name;
-} JoyButton;
-
-typedef struct _JoyInfo {
- GUID guid;
- JoyAxis *axes;
- JoyButton *buttons;
- int numaxes;
- int numbuttons;
- int numPOVs;
- LPDIRECTINPUTDEVICE8 di_device;
-} JoyInfo;
-
-
-static LPDIRECTINPUT8 di = NULL;
-
-
-static BOOL CALLBACK EnumJoyAxes(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
-{
- JoyAxis *axis;
- JoyInfo *joy;
-
- joy = (JoyInfo*)pvRef;
-
- /* Save info about axis */
- axis = lib_malloc(sizeof(JoyAxis));
- axis->next = NULL;
- axis->id = DIDFT_GETINSTANCE(lpddoi->dwType);
- axis->name = lib_strdup(lpddoi->tszName);
-
- /* Link axis into list for this joystick */
- if (joy->axes == NULL) {
- joy->axes = axis;
- } else {
- JoyAxis *s;
- s = joy->axes;
- while (s->next != NULL) {
- s = s->next;
- }
- s->next = axis;
- }
- joy->numaxes += 1;
- return DIENUM_CONTINUE;
-}
-
-static BOOL CALLBACK EnumJoyButtons(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
-{
- JoyButton *button;
- JoyInfo *joy;
-
- joy = (JoyInfo*)pvRef;
-
- /* Save info about button */
- button = lib_malloc(sizeof(JoyButton));
- button->next = NULL;
- button->id = DIDFT_GETINSTANCE(lpddoi->dwType);
- button->name = lib_strdup(lpddoi->tszName);
-
- /* Link button into list for this joystick */
- if (joy->buttons == NULL) {
- joy->buttons = button;
- } else {
- JoyButton *s;
- s = joy->buttons;
- while (s->next != NULL) {
- s = s->next;
- }
- s->next = button;
- }
- joy->numbuttons += 1;
- return DIENUM_CONTINUE;
-}
-
-static BOOL CALLBACK EnumJoyPOVs(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
-{
- JoyInfo *joy;
-
- joy = (JoyInfo*)pvRef;
-
- /* Save info about POV */
- joy->numPOVs += 1;
-
- return DIENUM_CONTINUE;
-}
-
-static void joystick_release_axes(JoyAxis *axis)
-{
- while (axis != NULL) {
- JoyAxis *next;
-
- next = axis->next;
- lib_free(axis->name);
- lib_free(axis);
- axis = next;
- }
-}
-static void joystick_release_buttons(JoyButton *button)
-{
- while (button != NULL) {
- JoyButton *next;
-
- next = button->next;
- lib_free(button->name);
- lib_free(button);
- button = next;
- }
-}
-
-static void joystick_di8_update(int joyport, void* priv)
-{
- BYTE value;
- int i;
- DIPROPRANGE prop;
- DIJOYSTATE js;
- JoyInfo *joy;
-
- value = 0;
- joy = priv;
-
- IDirectInputDevice8_Poll(joy->di_device);
- IDirectInputDevice8_GetDeviceState(joy->di_device, sizeof(DIJOYSTATE), &js);
-
- /* Get boundary values for X axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 0; /* Offset of X axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lX <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 0, JOY_AXIS_NEGATIVE);
- } else if (js.lX >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 0, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 0, JOY_AXIS_MIDDLE);
- }
-
- /* Get boundary values for Y axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 4; /* Offset of Y axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lY <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 1, JOY_AXIS_NEGATIVE);
- } else if (js.lY >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 1, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 1, JOY_AXIS_MIDDLE);
- }
-
- /* Get boundary values for X-rotation axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 0x0c; /* Offset of X-rotation axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lRx <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 2, JOY_AXIS_NEGATIVE);
- } else if (js.lRx >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 2, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 2, JOY_AXIS_MIDDLE);
- }
-
- /* Get boundary values for Y-rotation axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 0x10; /* Offset of Y-rotation axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lRy <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 3, JOY_AXIS_NEGATIVE);
- } else if (js.lRy >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 3, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 3, JOY_AXIS_MIDDLE);
- }
-
- /* Get boundary values for Z axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 8; /* Offset of Z axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lZ <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 4, JOY_AXIS_NEGATIVE);
- } else if (js.lZ >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 4, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 4, JOY_AXIS_MIDDLE);
- }
-
- /* Get boundary values for Z-rotation axis */
- prop.diph.dwSize = sizeof(DIPROPRANGE);
- prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- prop.diph.dwObj = 0x14; /* Offset of Z-rotation axis */
- prop.diph.dwHow = DIPH_BYOFFSET;
- IDirectInputDevice8_GetProperty(joy->di_device, DIPROP_RANGE, (DIPROPHEADER*)&prop);
- if (js.lRz <= prop.lMin + (prop.lMax - prop.lMin) / 4) {
- joy_axis_event(joyport, 5, JOY_AXIS_NEGATIVE);
- } else if (js.lRz >= prop.lMin + (prop.lMax - prop.lMin) / 4 * 3) {
- joy_axis_event(joyport, 5, JOY_AXIS_POSITIVE);
- } else {
- joy_axis_event(joyport, 5, JOY_AXIS_MIDDLE);
- }
-
- for (i = 0; i < joy->numPOVs; ++i) {
- if (LOWORD(js.rgdwPOV[i]) != 0xffff) {
- if (js.rgdwPOV[i] > 20250 && js.rgdwPOV[i] < 33750) {
- value |= JOYSTICK_DIRECTION_LEFT;
- }
- if (js.rgdwPOV[i] > 2250 && js.rgdwPOV[i] < 15750) {
- value |= JOYSTICK_DIRECTION_RIGHT;
- }
- if (js.rgdwPOV[i] > 29250 || js.rgdwPOV[i] < 6750) {
- value |= JOYSTICK_DIRECTION_UP;
- }
- if (js.rgdwPOV[i] > 11250 && js.rgdwPOV[i] < 24750) {
- value |= JOYSTICK_DIRECTION_DOWN;
- }
- }
- joy_hat_event(joyport, i, value);
- }
- for (i = 0; i < joy->numbuttons; ++i) {
- joy_button_event(joyport, i, (js.rgbButtons[i] & 0x80));
- }
-}
-
-static void joystick_release_joystick(void* priv)
-{
- JoyInfo *joystick = priv;
- joystick_release_axes(joystick->axes);
- joystick_release_buttons(joystick->buttons);
- IDirectInputDevice8_Unacquire(joystick->di_device);
- IDirectInputDevice8_Release(joystick->di_device);
- lib_free(joystick);
-}
-
-static joystick_driver_t win32_directinput_joystick_driver = {
- .poll = joystick_di8_update,
- .close = joystick_release_joystick
-};
-
-
-#ifdef HAVE_DEBUG_GTK3UI
-static void dump_guid(GUID guid)
-{
- printf(".Data1 (ulong) = %08lx\n", guid.Data1);
- printf(".Data2 (ushort) = %04x\n", guid.Data2);
- printf(".Data3 (ushort) = %04x\n", guid.Data3);
- printf(".Data4 (uchar[8]) =");
- for (size_t i = 0; i < sizeof guid.Data4; i++) {
- printf(" %02x", guid.Data4[i]);
- }
- printf("\n");
-}
-#endif
-
-static BOOL CALLBACK EnumCallBack(LPCDIDEVICEINSTANCE lpddi, LPVOID pvref)
-{
- JoyInfo *new_joystick;
- HINSTANCE ui_active_window = GetModuleHandle(NULL); /* FIXME */
-
- new_joystick = lib_malloc(sizeof(JoyInfo));
- memcpy(&new_joystick->guid, &lpddi->guidInstance, sizeof(GUID));
-
-#ifdef HAVE_DEBUG_GTK3UI
- printf("%s(): lpddi.guidProduct:\n", __func__);
- dump_guid(lpddi->guidProduct);
- printf("%s(): lpddi.guidInstance:\n", __func__);
- dump_guid(lpddi->guidInstance);
-#endif
-
- new_joystick->axes = NULL;
- new_joystick->buttons = NULL;
- new_joystick->numPOVs = 0;
- new_joystick->numaxes = 0;
- new_joystick->numbuttons = 0;
- IDirectInput8_CreateDevice(di, &new_joystick->guid, &new_joystick->di_device, NULL);
- IDirectInputDevice8_SetDataFormat(new_joystick->di_device, &c_dfDIJoystick);
- IDirectInputDevice8_SetCooperativeLevel(new_joystick->di_device,
- (HWND)ui_active_window, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
- IDirectInputDevice8_Acquire(new_joystick->di_device);
- IDirectInputDevice8_EnumObjects(new_joystick->di_device, EnumJoyAxes, (LPVOID)new_joystick, DIDFT_AXIS);
- IDirectInputDevice8_EnumObjects(new_joystick->di_device, EnumJoyButtons, (LPVOID)new_joystick, DIDFT_BUTTON);
- IDirectInputDevice8_EnumObjects(new_joystick->di_device, EnumJoyPOVs, (LPVOID)new_joystick, DIDFT_POV);
- register_joystick_driver(&win32_directinput_joystick_driver,
- lpddi->tszInstanceName,
- new_joystick,
- new_joystick->numaxes,
- new_joystick->numbuttons,
- new_joystick->numPOVs
- );
-
- return DIENUM_CONTINUE;
-}
-
-int win32_directinput_joystick_init(void)
-{
- HINSTANCE winmain_instance = GetModuleHandle(NULL); /* FIXME */
- if (DirectInput8Create(winmain_instance, DIRECTINPUT_VERSION, &IID_IDirectInput8, (LPVOID*)&di, NULL) != DI_OK) {
- return 0;
- }
- IDirectInput8_EnumDevices(di, DIDEVTYPE_JOYSTICK, EnumCallBack, NULL, DIEDFL_ALLDEVICES);
- return 1;
-}
-#endif
-
/*
* New API
*/
@@ -438,6 +119,10 @@
return false;
}
+/** \brief Joystick drive poll() method
+ *
+ * \param[in] joydev joystick device to poll
+ */
static void win32_joy_poll(joystick_device_t *joydev)
{
joy_priv_t *priv;
@@ -607,7 +292,15 @@
buffer[GUIDSTR_BUFSIZE - 1] = '\0';
}
-
+/** \brief Callback for IDirectInputDevice8::EnumObjects
+ *
+ * Callback function enumerating axes, buttons and hats (POVs).
+ *
+ * \param[in] lpddoi DirectInput device instance
+ * \param[in] pvref extra callback param (VICE joystick device instance)
+ *
+ * \return \c DIENUM_CONTINUE
+ */
static BOOL enum_objects_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
{
joystick_device_t *joydev = pvref;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 18:03:03
|
Revision: 45566
http://sourceforge.net/p/vice-emu/code/45566
Author: empathicqubit
Date: 2025-03-22 18:02:55 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Fix warnings
Modified Paths:
--------------
trunk/vice/src/monitor/monitor_binary.c
Modified: trunk/vice/src/monitor/monitor_binary.c
===================================================================
--- trunk/vice/src/monitor/monitor_binary.c 2025-03-22 17:57:16 UTC (rev 45565)
+++ trunk/vice/src/monitor/monitor_binary.c 2025-03-22 18:02:55 UTC (rev 45566)
@@ -430,8 +430,8 @@
#define MON_REGISTER_ITEM_SIZE 3
-static uint16_t *count_registers(mon_reg_list_t *regs) {
- uint16_t count;
+static uint16_t count_registers(mon_reg_list_t *regs) {
+ uint16_t count = 0;
for( ; regs->name ; regs++) {
if (!ignore_fake_register(regs)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 17:57:28
|
Revision: 45565
http://sourceforge.net/p/vice-emu/code/45565
Author: empathicqubit
Date: 2025-03-22 17:57:16 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Wrap binary monitor cpuhistory in FEATURE_CPUMEMHISTORY check
Modified Paths:
--------------
trunk/vice/src/monitor/monitor_binary.c
Modified: trunk/vice/src/monitor/monitor_binary.c
===================================================================
--- trunk/vice/src/monitor/monitor_binary.c 2025-03-22 17:37:18 UTC (rev 45564)
+++ trunk/vice/src/monitor/monitor_binary.c 2025-03-22 17:57:16 UTC (rev 45565)
@@ -1436,6 +1436,7 @@
monitor_binary_response(sizeof(response), e_MON_RESPONSE_VICE_INFO, e_MON_ERR_OK, command->request_id, response);
}
+#ifdef FEATURE_CPUMEMHISTORY
static void monitor_binary_process_cpuhistory(binary_command_t *command)
{
mon_reg_list_t *regs;
@@ -1576,8 +1577,13 @@
lib_free(templates);
lib_free(response);
}
+#else
+static void monitor_binary_process_cpuhistory(binary_command_t *command)
+{
+ monitor_binary_error(e_MON_ERR_CMD_FAILURE, command->request_id);
+}
+#endif /* FEATURE_CPUMEMHISTORY */
-
static void monitor_binary_process_mem_get(binary_command_t *command)
{
unsigned char *response;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 17:37:31
|
Revision: 45564
http://sourceforge.net/p/vice-emu/code/45564
Author: empathicqubit
Date: 2025-03-22 17:37:18 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Fix texi file formatting
Modified Paths:
--------------
trunk/vice/doc/vice.texi
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-03-22 17:02:13 UTC (rev 45563)
+++ trunk/vice/doc/vice.texi 2025-03-22 17:37:18 UTC (rev 45564)
@@ -9572,7 +9572,7 @@
@itemize @bullet
@item
-@file{.crt} images, as used by the CCS64 emulator by Per H�kan Sundell
+@file{.crt} images, as used by the CCS64 emulator by Per H\xE5kan Sundell
@item
raw @file{.bin} images, with or without load address
@end itemize
@@ -11646,7 +11646,7 @@
@item
@file{c64s.vpl} (``C64S''), palette taken from the shareware C64S emulator by Miha Peternel.
@item
-@file{ccs64.vpl} (``CCS64''), palette taken from the shareware CCS64 emulator by Per H�kan Sundell.
+@file{ccs64.vpl} (``CCS64''), palette taken from the shareware CCS64 emulator by Per H\xE5kan Sundell.
@item
@file{frodo.vpl} (``Frodo''), palette taken from the free Frodo emulator by Christian Bauer
(@uref{https://frodo.cebix.net/}).
@@ -24168,7 +24168,7 @@
Ettore Perazzoli.)
This format was defined in 1998 as a cooperative effort between several
-emulator people, mainly Per H�kan Sundell, author of the CCS64 C64
+emulator people, mainly Per H\xE5kan Sundell, author of the CCS64 C64
emulator, Andreas Boose of the VICE CBM emulator team and Joe
Forster/STA, the author of Star Commander. It was the first real public
attempt to create a format for the emulator community which removed
@@ -36502,7 +36502,7 @@
GP2X/Dingoo SDL UI issues.
@item
-@b{Istv�n F�bi�n}
+@b{Istv\xE1n F\xE1bi\xE1n}
Contributed a initial patch with the more correct 1541 bus
timing code and which gave us hints for to improving the 1541
emulation.
@@ -36613,7 +36613,7 @@
other patches.
@item
-@b{Frank K�nig}
+@b{Frank K\xF6nig}
Contributed the Win32 joystick autofire feature.
@item
@@ -36662,7 +36662,7 @@
Provided some monitor fixes.
@item
-@b{Marko M�kel�}
+@b{Marko M\xE4kel\xE4}
Wrote lots of CPU documentation. Wrote the VIC Flash Plugin
cartridge emulation in xvic. Wrote the Ultimem cartridge
emulation in xvic.
@@ -36729,7 +36729,7 @@
Digitalized the C64 colors used in the (old) default palette.
@item
-@b{Lasse ��rni}
+@b{Lasse \xD6\xF6rni}
Contributed the Windows Multimedia sound driver
@item
@@ -36976,7 +36976,7 @@
Last but not least, a very special thank to Andreas Arens, Lutz
Sammer, Edgar Tornig, Christian Bauer, Wolfgang Lorenz, Miha
-Peternel, Per H�kan Sundell, David Horrocks, Benjamin Rosseaux and William McCabe
+Peternel, Per H\xE5kan Sundell, David Horrocks, Benjamin Rosseaux and William McCabe
for writing cool emulators to compete with. @t{:-)}
@c end of file generation section.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 17:02:17
|
Revision: 45563
http://sourceforge.net/p/vice-emu/code/45563
Author: empathicqubit
Date: 2025-03-22 17:02:13 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Fix style issues
Modified Paths:
--------------
trunk/vice/src/monitor/mon_memmap.c
trunk/vice/src/monitor/monitor_binary.c
Modified: trunk/vice/src/monitor/mon_memmap.c
===================================================================
--- trunk/vice/src/monitor/mon_memmap.c 2025-03-22 16:47:31 UTC (rev 45562)
+++ trunk/vice/src/monitor/mon_memmap.c 2025-03-22 17:02:13 UTC (rev 45563)
@@ -224,7 +224,7 @@
|| (filter3 == current->origin)
|| (filter4 == current->origin)
|| (filter5 == current->origin))));
-
+
return current;
}
Modified: trunk/vice/src/monitor/monitor_binary.c
===================================================================
--- trunk/vice/src/monitor/monitor_binary.c 2025-03-22 16:47:31 UTC (rev 45562)
+++ trunk/vice/src/monitor/monitor_binary.c 2025-03-22 17:02:13 UTC (rev 45563)
@@ -1481,7 +1481,7 @@
monitor_binary_error(e_MON_ERR_INVALID_PARAMETER, command->request_id);
log_message(LOG_DEFAULT, "monitor binary cpuhistory: Invalid count %u", count);
return;
- }
+ }
current = mon_cpuhistory_seek(requested_count, memspace, memspace, memspace, memspace, memspace);
while ((current = mon_cpuhistory_next(current, memspace, memspace, memspace, memspace, memspace))) {
@@ -1545,7 +1545,7 @@
reg_pc->val = current->addr;
reg_lin->val = 0xffff;
reg_cyc->val = 0xffff;
-
+
*response_cursor = item_size;
++response_cursor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 16:47:45
|
Revision: 45562
http://sourceforge.net/p/vice-emu/code/45562
Author: empathicqubit
Date: 2025-03-22 16:47:31 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Added documentation for binary monitor CPUHISTORY_GET command. Made documentation more visual so that variable length responses are theoretically less confusing. Removed exact offset numbers and use byte sizes instead.
Modified Paths:
--------------
trunk/vice/doc/vice.texi
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-03-22 16:44:59 UTC (rev 45561)
+++ trunk/vice/doc/vice.texi 2025-03-22 16:47:31 UTC (rev 45562)
@@ -9572,7 +9572,7 @@
@itemize @bullet
@item
-@file{.crt} images, as used by the CCS64 emulator by Per H\xE5kan Sundell
+@file{.crt} images, as used by the CCS64 emulator by Per H�kan Sundell
@item
raw @file{.bin} images, with or without load address
@end itemize
@@ -11646,7 +11646,7 @@
@item
@file{c64s.vpl} (``C64S''), palette taken from the shareware C64S emulator by Miha Peternel.
@item
-@file{ccs64.vpl} (``CCS64''), palette taken from the shareware CCS64 emulator by Per H\xE5kan Sundell.
+@file{ccs64.vpl} (``CCS64''), palette taken from the shareware CCS64 emulator by Per H�kan Sundell.
@item
@file{frodo.vpl} (``Frodo''), palette taken from the free Frodo emulator by Christian Bauer
(@uref{https://frodo.cebix.net/}).
@@ -21472,6 +21472,7 @@
* MON_CMD_REGISTERS_AVAILABLE::
* MON_CMD_DISPLAY_GET::
* MON_CMD_VICE_INFO::
+* MON_CMD_CPUHISTORY_GET::
* MON_CMD_PALETTE_GET::
* MON_CMD_JOYPORT_SET::
* MON_CMD_USERPORT_SET::
@@ -21490,15 +21491,20 @@
Command body:
+@example
+FX | SA SA | EA EA | MS | BI BI
+@end example
+@*
+
@table @strong
-@item byte 0: side effects?
+@item FX: 1 byte: side effects?
Should the read cause side effects?
-@item byte 1-2: start address
+@item SA: 2 bytes: start address
-@item byte 3-4: end address
+@item EA: 2 bytes: end address
-@item byte 5: memspace
+@item MS: 1 byte: memspace
Describes which part of the computer you want to read:
@itemize
@@ -21509,7 +21515,7 @@
@item 0x04: drive 11
@end itemize
-@item byte 6-7: bank ID
+@item BI: 2 bytes: bank ID
Describes which bank you want. This is dependent on your
machine. @xref{MON_CMD_BANKS_AVAILABLE}. If the memspace selected
doesn't support banks, this value is ignored.
@@ -21522,10 +21528,16 @@
Response body:
+@example
+ML ML | MM[0] MM[1] ... MM[ML-1]
+@end example
+@*
+
@table @strong
-@item byte 0-1: The length of the memory segment. Will be zero for start 0x0000, end 0xffff.
+@item ML: 2 bytes: Memory segment length.
+ Will be zero for start 0x0000, end 0xffff.
-@item byte 2+: The memory at the address.
+@item MM: ML bytes: The memory at the address.
@end table
@@ -21538,15 +21550,20 @@
Command body:
+@example
+FX | SA SA | EA EA | MS | BI BI | MM[0] MM[1] ... MM[EA-SA]
+@end example
+@*
+
@table @strong
-@item byte 0: side effects?
+@item FX: 1 byte: side effects?
Should the write cause side effects?
-@item byte 1-2: start address
+@item SA: 2 bytes: start address
-@item byte 3-4: end address
+@item EA: 2 bytes: end address
-@item byte 5: memspace
+@item MS: 1 byte: memspace
Describes which part of the computer you want to write:
@itemize
@@ -21557,12 +21574,12 @@
@item 0x04: drive 11
@end itemize
-@item byte 6-7: bank ID
+@item BI: 2 bytes: bank ID
Describes which bank you want. This is dependent on your machine.
@xref{MON_CMD_BANKS_AVAILABLE}.
If the memspace selected doesn't support banks, this byte is ignored.
-@item byte 8+: Memory contents to write
+@item MM: 1+EA-SA bytes: Memory contents to write
@end table
@@ -21572,7 +21589,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_CHECKPOINT_GET
@subsection Checkpoint get (0x11)
@@ -21583,8 +21603,13 @@
Command body:
+@example
+CN CN CN CN
+@end example
+@*
+
@table @strong
-@item byte 0-3: checkpoint number
+@item CN: 4 bytes: checkpoint number
@end table
@@ -21600,25 +21625,30 @@
Command body:
+@example
+SA SA | EA EA | ST | EN | OP | TM | MS?
+@end example
+@*
+
@table @strong
-@item byte 0-1: start address
+@item SA: 2 bytes: start address
-@item byte 2-3: end address
+@item EA: 2 bytes: end address
-@item byte 4: stop when hit
+@item ST: 1 byte: stop when hit
>=0x01: true, 0x00: false
-@item byte 5: enabled
+@item EN: 1 byte: enabled
>=0x01: true, 0x00: false
-@item byte 6: CPU operation
+@item OP: 1 byte: CPU operation
>=0x01: load, 0x02: store, 0x04: exec
-@item byte 7: temporary
+@item TM: 1 byte: temporary
Deletes the checkpoint after it has been hit once. This is similar to
"until" command, but it will not resume the emulator.
-@item byte 8 (optional): memspace
+@item MS: 1 byte (optional): memspace
Describes which part of the computer to checkpoint:
@itemize
@@ -21642,8 +21672,13 @@
Command body:
+@example
+CN CN CN CN
+@end example
+@*
+
@table @strong
-@item byte 0-3: checkpoint number
+@item CN: 4 bytes: checkpoint number
@end table
@@ -21653,7 +21688,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_CHECKPOINT_LIST
@subsection Checkpoint list (0x14)
@@ -21662,7 +21700,10 @@
Command body:
+@example
Currently empty.
+@end example
+@*
Response type:
@@ -21673,8 +21714,13 @@
Response body:
+@example
+CC CC CC CC
+@end example
+@*
+
@table @strong
-@item byte 0-3: The total number of checkpoints
+@item CC: 4 bytes: The total count of checkpoints
@end table
@@ -21685,10 +21731,15 @@
Command body:
+@example
+CN CN CN CN | EN
+@end example
+@*
+
@table @strong
-@item byte 0-3: Checkpoint number
+@item CN: 4 bytes: Checkpoint number
-@item byte 4: Enabled?
+@item EN: 1 byte: Enabled?
0x00: disabled, 0x01: enabled
@end table
@@ -21699,7 +21750,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_CONDITION_SET
@subsection Condition set (0x22)
@@ -21711,13 +21765,18 @@
Command body:
+@example
+CN CN CN CN | EL | ES[0] ES[1] ... ES[EL-1]
+@end example
+@*
+
@table @strong
-@item byte 0-3: checkpoint number
+@item CN: 4 bytes: checkpoint number
-@item byte 4: condition expression length
+@item EL: 1 byte: condition expression length
-@item byte 5+: condition expression string
-This is the same format used on the command line. Not null terminated.
+@item ES: EL bytes: condition expression string
+This is the same format used in the text monitor. Not null terminated.
@end table
@@ -21727,7 +21786,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_REGISTERS_GET
@subsection Registers get (0x31)
@@ -21738,8 +21800,13 @@
Command body:
+@example
+MS
+@end example
+@*
+
@table @strong
-@item byte 0: memspace
+@item MS: 1 byte: memspace
Describes which part of the computer you want to read:
@itemize
@@ -21763,8 +21830,13 @@
Command body:
+@example
+MS | RC RC [ IS[0] @{ RI[0] RV[0] RV[0] @} ... IS[RC-1] @{ RI[RC-1] RV[RC-1] RV[RC-1] @} ]
+@end example
+@*
+
@table @strong
-@item byte 0: memspace
+@item MS: 1 byte: memspace
Describes which part of the computer you want to write:
@itemize
@@ -21775,14 +21847,24 @@
@item 0x04: drive 11
@end itemize
-@item byte 1-2: The count of the array items
+@item RC: 2 bytes: Register count
-@item byte 3+: An array with items of structure:
+@item Array: RC*(IS+1) bytes: An array with items of structure:
@table @strong
-@item byte 0: Size of the item, excluding this byte
-@item byte 1: ID of the register
-@item byte 2-3: register value
+
+@item
+
+[
+
+@item IS: 1 byte: Item size, excluding this byte
+@item RI: 1 byte: Register ID
+@item RV: 2 bytes: Register value
+
+@item
+
+]
+
@end table
@end table
@@ -21798,16 +21880,21 @@
Command body:
+@example
+SR | SD | FL | FN[0] FN[1] ... FN[FL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Save ROMs to snapshot file?
+@item SR: 1 byte: Save ROMs to snapshot file?
>=0x01: true, 0x00: false
-@item byte 1: Save disks to snapshot file?
+@item SD: 1 byte: Save disks to snapshot file?
>=0x01: true, 0x00: false
-@item byte 2: Length of filename
+@item FL: 1 byte: Length of filename
-@item byte 3+: Filename
+@item FN: FL bytes: Filename
The filename to save the snapshot to.
@end table
@@ -21818,7 +21905,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_UNDUMP
@subsection Undump (0x42)
@@ -21829,10 +21919,15 @@
Command body:
+@example
+FL | FN[0] FN[1] ... FN[FL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Length of filename
+@item FL: 1 byte: Length of filename
-@item byte 1+: Filename
+@item FN: FL bytes: Filename
The filename to load the snapshot from.
@end table
@@ -21843,8 +21938,13 @@
Response body:
+@example
+PC PC
+@end example
+@*
+
@table @strong
-@item byte 0-1: The current program counter position
+@item PC: 2 bytes: The current program counter position
@end table
@@ -21857,10 +21957,15 @@
Command body:
+@example
+NL | RN[0] RN[1] ... RN[NL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Length of resource name
+@item NL: 1 byte: Resource name length
-@item byte 1+: Resource name
+@item RN: NL bytes: Resource name
@end table
@@ -21870,13 +21975,18 @@
Response body:
+@example
+RT | VL | RV[0] RV[1] ... RV[VL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Type of the resource
+@item RT: 1 byte: Resource type
0x00: String, 0x01: Integer
-@item byte 1: Length of the value
+@item VL: 1 byte: Resource value length
-@item byte 2+: The value
+@item RV: VL bytes: The resource value
@end table
@@ -21889,18 +21999,23 @@
Command body:
+@example
+RT | NL | RN[0] RN[1] ... RN[NL-1] | VL | RV[0] RV[1] ... RV[VL-1]
+@end example
+@*
+
@table @strong
-@item 1 byte: Type of the resource value
+@item RT: 1 byte: Type of the resource value
0x00: String, 0x01: Integer@*
Strings will be interpreted if the destination is an Integer.
-@item 1 byte: Resource name length = (&name)
+@item NL: 1 byte: Resource name length
-@item (*name) bytes: The resource name
+@item RN: NL bytes: The resource name
-@item 1 byte: Resource value length = (&value)
+@item VL: 1 byte: Resource value length
-@item (*value) bytes: The resource value
+@item RV: VL bytes: The resource value
@end table
@@ -21910,7 +22025,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_ADVANCE_INSTRUCTIONS
@subsection Advance Instructions (0x71)
@@ -21921,11 +22039,16 @@
Command body:
+@example
+SO | IC IC
+@end example
+@*
+
@table @strong
-@item byte 0: Step over subroutines?
+@item SO: 1 byte: Step over subroutines?
Should subroutines count as a single instruction?
-@item byte 1-2: How many instructions to step over.
+@item IC: 2 bytes: How many instructions to step over.
@end table
@@ -21935,7 +22058,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_KEYBOARD_FEED
@subsection Keyboard feed (0x72)
@@ -21948,10 +22074,15 @@
Command body:
+@example
+TL | TC[0] TC[1] ... TC[TL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Length of text
+@item TL: 1 byte: Text Length
-@item byte 1+: The text, in PETSCII
+@item TC: TL bytes: The text content, in PETSCII
@end table
@@ -21961,7 +22092,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_EXECUTE_UNTIL_RETURN
@subsection Execute until return (0x73)
@@ -21974,7 +22108,10 @@
Command body:
+@example
Currently empty.
+@end example
+@*
Response type:
@@ -21982,7 +22119,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_PING
@subsection Ping (0x81)
@@ -21993,7 +22133,10 @@
Command body:
+@example
Always empty
+@end example
+@*
Response type:
@@ -22001,7 +22144,10 @@
Response body:
+@example
Always empty
+@end example
+@*
@node MON_CMD_BANKS_AVAILABLE
@subsection Banks available (0x82)
@@ -22012,7 +22158,10 @@
Command body:
+@example
Currently empty.
+@end example
+@*
Response type:
@@ -22020,19 +22169,33 @@
Response body:
+@example
+BC BC [ IS[0] @{ BI[0] BI[0] | NL[0] | BN[0][0] BN[0][1] ... BN[0][NL[0]-1] @} ... IS[BC-1] @{ ... @} ]
+@end example
+@*
+
@table @strong
-@item byte 0-1: The count of the array items
-@item byte 2+: An array with items of structure:
+@item BC: 2 bytes: Bank item count
+@item Array 1+BC*IS bytes: An array with items of structure:
@table @strong
-@item byte 0: Size of the item, excluding this byte
-@item byte 1-2: bank ID
+@item
-@item byte 3: Name length
+[
-@item byte 4+: Name
+@item IS: 1 byte: Item size, excluding this byte
+@item BI: 2 bytes: Bank ID
+
+@item NL: 1 byte: Name Length
+
+@item BN: NL bytes: Name
+
+@item
+
+]
+
@end table
@end table
@@ -22046,9 +22209,14 @@
Command body:
+@example
+MS
+@end example
+@*
+
@table @strong
-@item byte 0: memspace
+@item MS: 1 byte: memspace
Describes which part of the computer you want to read:
@itemize
@@ -22063,25 +22231,30 @@
Response type:
-0x82: MON_RESPONSE_REGISTERS_AVAILABLE
+0x83: MON_RESPONSE_REGISTERS_AVAILABLE
Response body:
+@example
+RC RC [ IS[0] @{ RI[0] | RS[0] | NL[0] | RN[0][0] RN[0][1] ... RN[0][NL[0]-1] @} ... IS[RC-1] @{ ... @} ]
+@end example
+@*
+
@table @strong
-@item byte 0-1: The count of the array items
-@item byte 2+: An array with items of structure:
+@item RC: 2 bytes: Register item count
+@item Array: RC*(IS+1) bytes: An array with items of structure:
@table @strong
-@item byte 0: Size of the item, excluding this byte
+@item IS: 1 byte: Item Size, excluding this byte
-@item byte 1: ID of the register
+@item RI: 1 byte: Register ID
-@item byte 2: Size of the register in bits
+@item RS: 1 byte: Register Size in bits
-@item byte 3: Length of name
+@item NL: 1 byte: Length of name
-@item byte 4+: Name
+@item RN: NL bytes : Register name
@end table
@@ -22098,12 +22271,17 @@
Command body:
+@example
+VC | FM
+@end example
+@*
+
@table @strong
-@item byte 0: USE VIC-II?
+@item VC: 1 byte: USE VIC-II?
Must be included, but ignored for all but the C128. If true, (>=0x01) the screen
returned will be from the VIC-II. If false (0x00), it will be from the VDC.
-@item byte 1: Format
+@item FM: 1 byte: Format
0x00: Indexed, 8 bit@*
@end table
@@ -22114,32 +22292,36 @@
Response body:
+@example
+FL FL FL FL | DW DW | DH DH | XO XO | YO YO | IW IW | IH IH | BP | BL BL BL BL | BD[0] BD[1] ... BD[BL-1]
+@end example
+@*
+
@table @strong
-@item 4 bytes: Length of the fields before the display buffer
+@item FL: 4 bytes: Length of the fields before the display buffer
-@item 2 bytes: Debug width of display buffer (uncropped)
+@item DW: 2 bytes: Debug width of display buffer (uncropped)
The largest width the screen gets.
-@item 2 bytes: Debug height of display buffer (uncropped)
+@item DH: 2 bytes: Debug height of display buffer (uncropped)
The largest height the screen gets.
-@item 2 bytes: X offset
+@item XO: 2 bytes: X offset
X offset to the inner part of the screen.
-@item 2 bytes: Y offset
+@item YO: 2 bytes: Y offset
Y offset to the inner part of the screen.
-@item 2 bytes: Width of the inner part of the screen.
+@item IW: 2 bytes: Width of the inner part of the screen.
-@item 2 bytes: Height of the inner part of the screen.
+@item IH: 2 bytes: Height of the inner part of the screen.
-@item 1 byte: Bits per pixel of display buffer, 8
+@item BP: 1 byte: Bits per pixel of display buffer, 8
+@item BL: 4 bytes: Length of display buffer
-@item 4 bytes: Length of display buffer = (&buffer)
+@item BD: BL bytes: Display buffer data
-@item (*buffer) bytes: Display buffer data
-
@end table
@node MON_CMD_VICE_INFO
@@ -22151,7 +22333,10 @@
Command body:
+@example
Always empty
+@end example
+@*
Response type:
@@ -22159,19 +22344,122 @@
Response body:
+@example
+ML | MV[0] MV[1] ... MV[ML-1] | SL | SV[0] SV[1] ... SV[SL-1]
+@end example
+@*
+
@table @strong
-@item 1 byte: Length of main version = (&main)
+@item ML: 1 byte: Length of main version
-@item (*main) bytes: Main version
+@item MV: ML bytes: Main version
In linear format. For example 0x03, 0x05, 0x00, 0x00 for 3.5.0.0
-@item 1 byte: Length of SVN revision = (&rev)
+@item SL: 1 byte: Length of SVN revision
-@item (*rev) bytes: SVN revision
+@item SV: SL bytes: SVN revision
In little endian format. Returns zero if it's not an SVN build.
@end table
+@node MON_CMD_CPUHISTORY_GET
+@subsection CPU History (0x86)
+
+Gets records of every instruction executed by an emulated CPU.
+
+Minimum VICE version: 3.10
+
+Command body:
+
+@example
+MS | HC HC HC HC
+@end example
+@*
+
+@table @strong
+@item MS: 1 byte: memspace
+
+@itemize
+@item 0x00: main memory
+@item 0x01: drive 8
+@item 0x02: drive 9
+@item 0x03: drive 10
+@item 0x04: drive 11
+@end itemize
+
+@item HC: 4 bytes: count of items to retrieve
+
+@end table
+
+Response type:
+
+0x86: MON_RESPONSE_CPUHISTORY_GET
+
+Response body:
+
+@example
+HC HC HC HC [
+ IS[0] @{
+ RC[0] RC[0] [
+ RS[0][0] @{ ... @}
+ ...
+ RS[0][RC-1] @{ ... @}
+ ]
+ @}
+ ...
+ IS[HC-1] @{ ... @}
+]
+CL CL CL CL CL CL CL CL | IL | IB[0] IB[1] ... IB[IL-1]
+@end example
+@*
+
+@table @strong
+@item HC: 4 bytes: CPU history item count
+
+@item Array: HC*(IS+1) bytes:
+An array with items of structure:
+
+@table @strong
+@item
+
+[
+
+@item IS: 1 bytes: Item size, excluding this byte
+
+@item RC: 2 bytes: Register item count
+
+@item Array: RC*(RS+1) bytes: Array items of structure:
+
+@table @strong
+@item
+
+[
+
+@item RS: 1 byte: Item size, excluding this byte
+
+@item @{...@}: RS bytes: The array item body from @ref{MON_RESPONSE_REGISTER_INFO}
+
+@item
+
+]
+
+@end table
+
+@item CL: 8 bytes: The CPU clock
+
+@item IL: 1 bytes: instruction bytes length
+
+@item IB: IL bytes: Instruction byte string.
+This is a fixed length and must be interpreted by the client.
+
+@end table
+
+@item
+
+]
+
+@end table
+
@node MON_CMD_PALETTE_GET
@subsection Palette get (0x91)
@@ -22181,8 +22469,13 @@
Command body:
+@example
+VC
+@end example
+@*
+
@table @strong
-@item byte 0: USE VIC-II?
+@item VC: 1 byte: USE VIC-II?
Must be included, but ignored for all but the C128. If true, (>=0x01) the screen
returned will be from the VIC-II. If false (0x00), it will be from the VDC.
@@ -22194,20 +22487,37 @@
Response body:
+@example
+PC PC [
+ IS[0] { RR[0] | GG[0] | BB[0] }
+ ...
+ IS[PC-1] { RR[PC-1] | GG[PC-1] | BB[PC-1] }
+]
+@end example
+@*
+
@table @strong
-@item byte 0-1: The number of palette items.
+@item PC: 2 bytes: The palette item count
-@item byte 2+: An array with items of structure:
+@item Array : PC*(IS+1): An array with items of structure:
@table @strong
-@item byte 0: Size of the item, excluding this byte
+@item
-@item byte 1: Red
+[
-@item byte 2: Green
+@item IS: 1 byte: Item size, excluding this byte
-@item byte 3: Blue
+@item RR: 1 byte: Red
+@item GG: 1 byte: Green
+
+@item BB: 1 byte: Blue
+
+@item
+
+]
+
@end table
@end table
@@ -22221,9 +22531,14 @@
Command body:
+@example
+PN PN | PV PV
+@end example
+@*
+
@table @strong
-@item byte 0-1: The port to set the value on
-@item byte 2-3: The value to set
+@item PN: 2 bytes: The port to set the value on
+@item PV: 2 bytes: The value to set
@end table
@@ -22233,9 +22548,11 @@
Response body:
+@example
Currently empty.
+@end example
+@*
-
@node MON_CMD_USERPORT_SET
@subsection Userport set (0xb2)
@@ -22245,8 +22562,13 @@
Command body:
+@example
+UV UV
+@end example
+@*
+
@table @strong
-@item byte 0-1: The value to set
+@item UV: 2 bytes: The value to set
@end table
@@ -22256,7 +22578,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_EXIT
@subsection Exit (0xaa)
@@ -22267,7 +22592,10 @@
Command body:
+@example
Currently empty.
+@end example
+@*
Response type:
@@ -22275,7 +22603,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_QUIT
@subsection Quit (0xbb)
@@ -22286,7 +22617,10 @@
Command body:
+@example
Currently empty.
+@end example
+@*
Response type:
@@ -22294,7 +22628,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_RESET
@subsection Reset (0xcc)
@@ -22305,8 +22642,13 @@
Command body:
+@example
+RS
+@end example
+@*
+
@table @strong
-@item byte 0: What to reset
+@item RS: 1 byte: What to reset
@itemize
@item 0x00: Reset system
@@ -22322,7 +22664,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node MON_CMD_AUTOSTART
@subsection Autostart / autoload (0xdd)
@@ -22333,16 +22678,21 @@
Command body:
+@example
+RL | FI FI | FL | FN[0] FN[1] ... FN[FL-1]
+@end example
+@*
+
@table @strong
-@item byte 0: Run after loading?
+@item RL: 1 byte: Run after loading?
>=0x01: true, 0x00: false
-@item byte 1-2: File index
+@item FI: 2 bytes: File index
The index of the file to execute, if a disk image. 0x00 is the default value.
-@item byte 3: Length of filename
+@item FL: byte 3: Length of filename
-@item byte 4+: Filename
+@item FN: FL bytes: Filename
The filename to autoload.
@end table
@@ -22353,7 +22703,10 @@
Response body:
+@example
Currently empty.
+@end example
+@*
@node Binary Responses
@section Responses
@@ -22382,7 +22735,10 @@
Response body:
+@example
Usually empty
+@end example
+@*
@node MON_RESPONSE_CHECKPOINT_INFO
@subsection Checkpoint Response (0x11)
@@ -22402,37 +22758,43 @@
Response body:
+@example
+CN CN CN CN | CH | SA SA | EA EA | ST | EN | OP | TM | HC HC HC HC | IC IC IC IC | CE | MS
+@end example
+@*
+
@table @strong
-@item byte 0-3: Checkpoint number
+@item CN: 4 bytes: Checkpoint number
-@item byte 4: Currently hit?
+@item CH: 1 byte: Currently hit?
>=0x01: true, 0x00: false
-@item byte 5-6: start address
+@item SA: 2 bytes: start address
-@item byte 7-8: end address
+@item EA: 2 bytes: end address
-@item byte 9: stop when hit
+@item ST: 1 byte: stop when hit
>=0x01: true, 0x00: false
-@item byte 10: enabled
+@item EN: 1 byte: enabled
>=0x01: true, 0x00: false
-@item byte 11: CPU operation
+@item OP: 1 byte: CPU operation
0x01: load, 0x02: store, 0x04: exec
-@item byte 12: temporary
-Deletes the checkpoint after it has been hit once. This is similar to
-"until" command, but it will not resume the emulator.
+@item TM: 1 byte: temporary
+ Deletes the checkpoint after it has been hit once. This is similar to
+ "until" command, but it will not resume the emulator.
-@item byte 13-16: hit count
+@item HC: 4 bytes: hit count
-@item byte 17-20: ignore count
+@item IC: 4 bytes: ignore count
-@item byte 21: Has condition?
+@item CE: 1 byte: Has condition?
>=0x01: true, 0x00: false
-@item byte 22: memspace
+@item MS: 1 byte: memspace
+Describes which part of the computer to checkpoint:
@itemize
@item 0x00: main memory
@@ -22453,18 +22815,35 @@
Response body:
+@example
+RC RC [
+ IS[0] @{ RI[0] | RV[0] RV[0] @}
+ ...
+ IS[RC-1] @{ RI[RC-1] | RV[RC-1] RV[RC-1] @}
+]
+@end example
+@*
+
@table @strong
-@item byte 0-1: The count of the array items
+@item RC: 2 bytes: The count of the array items
-@item byte 2+: An array with items of structure:
+@item Array: RC*(IS+1): An array with items of structure:
@table @strong
-@item byte 0: Size of the item, excluding this byte
+@item
-@item byte 1: ID of the register
+[
-@item byte 2-3: register value
+@item IS: 1 byte: Item size, excluding this byte
+@item RI: 1 byte: ID of the register
+
+@item RV: 2 bytes: register value
+
+@item
+
+]
+
@end table
@end table
@@ -22481,8 +22860,13 @@
Response body:
+@example
+PC PC
+@end example
+@*
+
@table @strong
-@item byte 0-1: The current program counter position
+@item PC: 2 bytes: The current program counter position
@end table
@@ -22498,8 +22882,13 @@
Response body:
+@example
+PC PC
+@end example
+@*
+
@table @strong
-@item byte 0-1: The current program counter position
+@item PC: 2 bytes: The current program counter position
@end table
@@ -22514,8 +22903,13 @@
Response body:
+@example
+PC PC
+@end example
+@*
+
@table @strong
-@item byte 0-1: The current program counter position
+@item PC: 2 bytes: The current program counter position
@end table
@@ -23774,7 +24168,7 @@
Ettore Perazzoli.)
This format was defined in 1998 as a cooperative effort between several
-emulator people, mainly Per H\xE5kan Sundell, author of the CCS64 C64
+emulator people, mainly Per H�kan Sundell, author of the CCS64 C64
emulator, Andreas Boose of the VICE CBM emulator team and Joe
Forster/STA, the author of Star Commander. It was the first real public
attempt to create a format for the emulator community which removed
@@ -36108,7 +36502,7 @@
GP2X/Dingoo SDL UI issues.
@item
-@b{Istv\xE1n F\xE1bi\xE1n}
+@b{Istv�n F�bi�n}
Contributed a initial patch with the more correct 1541 bus
timing code and which gave us hints for to improving the 1541
emulation.
@@ -36219,7 +36613,7 @@
other patches.
@item
-@b{Frank K\xF6nig}
+@b{Frank K�nig}
Contributed the Win32 joystick autofire feature.
@item
@@ -36268,7 +36662,7 @@
Provided some monitor fixes.
@item
-@b{Marko M\xE4kel\xE4}
+@b{Marko M�kel�}
Wrote lots of CPU documentation. Wrote the VIC Flash Plugin
cartridge emulation in xvic. Wrote the Ultimem cartridge
emulation in xvic.
@@ -36335,7 +36729,7 @@
Digitalized the C64 colors used in the (old) default palette.
@item
-@b{Lasse \xD6\xF6rni}
+@b{Lasse ��rni}
Contributed the Windows Multimedia sound driver
@item
@@ -36582,7 +36976,7 @@
Last but not least, a very special thank to Andreas Arens, Lutz
Sammer, Edgar Tornig, Christian Bauer, Wolfgang Lorenz, Miha
-Peternel, Per H\xE5kan Sundell, David Horrocks, Benjamin Rosseaux and William McCabe
+Peternel, Per H�kan Sundell, David Horrocks, Benjamin Rosseaux and William McCabe
for writing cool emulators to compete with. @t{:-)}
@c end of file generation section.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 16:45:01
|
Revision: 45561
http://sourceforge.net/p/vice-emu/code/45561
Author: empathicqubit
Date: 2025-03-22 16:44:59 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Add binary monitor CPUHISTORY_GET command. Refactored cpuhistory filtering into separate functions from the text monitor output. Refactored the binary monitor register writing into separate function.
Modified Paths:
--------------
trunk/vice/src/monitor/mon_memmap.c
trunk/vice/src/monitor/mon_memmap.h
trunk/vice/src/monitor/monitor_binary.c
Modified: trunk/vice/src/monitor/mon_memmap.c
===================================================================
--- trunk/vice/src/monitor/mon_memmap.c 2025-03-22 16:36:49 UTC (rev 45560)
+++ trunk/vice/src/monitor/mon_memmap.c 2025-03-22 16:44:59 UTC (rev 45561)
@@ -68,21 +68,6 @@
#define MEMMAP_ELEM uint16_t
-struct cpuhistory_s {
- CLOCK cycle;
- uint16_t addr;
- uint16_t reg_st;
- uint8_t op;
- uint8_t p1;
- uint8_t p2;
- uint8_t reg_a;
- uint8_t reg_x;
- uint8_t reg_y;
- uint8_t reg_sp;
- MEMSPACE origin;
-};
-typedef struct cpuhistory_s cpuhistory_t;
-
/* CPU history variables */
static cpuhistory_t *cpuhistory = NULL;
static int cpuhistory_buffer_lines = 0; /* actual size of the cyclic buffer */
@@ -122,7 +107,7 @@
if (lines < 10140) {
lines = 10140;
}
- lines *= 5;
+ lines = lines * 5 + 1;
cpuhistory = lib_realloc(cpuhistory, (size_t)lines * sizeof(cpuhistory_t));
@@ -181,40 +166,19 @@
cpuhistory[cpuhistory_i].p2 = p2;
}
-void mon_cpuhistory(int count, MEMSPACE filter1, MEMSPACE filter2, MEMSPACE filter3,
- MEMSPACE filter4, MEMSPACE filter5)
-{
- uint8_t op, p1, p2, p3 = 0;
- MEMSPACE mem;
- uint16_t loc, addr;
- int hex_mode = 1;
- const char *dis_inst;
- unsigned opc_size;
+cpuhistory_t *mon_cpuhistory_seek(int count, MEMSPACE filter1, MEMSPACE filter2,
+ MEMSPACE filter3, MEMSPACE filter4, MEMSPACE filter5) {
int i, pos;
- CLOCK cycle;
- char otext[10];
- /* if nothing passed, set the first filter to the default device */
- if ((filter1 == e_invalid_space) &&
- (filter2 == e_invalid_space) &&
- (filter3 == e_invalid_space) &&
- (filter4 == e_invalid_space) &&
- (filter5 == e_invalid_space)) {
- filter1 = default_memspace;
- }
-
- /* determine the actual maximum records to go through */
- if (count < 1) {
- count = cpuhistory_show_lines;
- } else if (count > cpuhistory_buffer_lines) {
- count = cpuhistory_buffer_lines;
- }
-
/* 'i' is the actual counter */
i = 0;
/* start looking at last entry */
pos = cpuhistory_i;
+ if (count >= cpuhistory_buffer_lines) {
+ count = cpuhistory_buffer_lines - 1;
+ }
+
/* find out where we need to start */
while (i < count) {
/* make sure the record matches */
@@ -234,51 +198,94 @@
/* this is totally possible since the emulation runs each CPU in
chunks and eventually syncs up. Syncing is more aggressive
when talking between devices. */
- if (pos == cpuhistory_i) {
+ if (pos == (cpuhistory_i + 1) % cpuhistory_buffer_lines) {
break;
}
}
+ return &cpuhistory[pos];
+}
+
+cpuhistory_t *mon_cpuhistory_next(cpuhistory_t *current, MEMSPACE filter1, MEMSPACE filter2,
+ MEMSPACE filter3, MEMSPACE filter4, MEMSPACE filter5) {
+ cpuhistory_t *wrap = &cpuhistory[cpuhistory_buffer_lines];
+ cpuhistory_t *head = &cpuhistory[(cpuhistory_i + 1) % cpuhistory_buffer_lines];
+ do {
+ current += 1;
+ if (current >= wrap) {
+ current = &cpuhistory[0];
+ } else if (current == head) {
+ return NULL;
+ }
+ /* make sure the record matches */
+ } while (!((current->origin != e_invalid_space)
+ && ((filter1 == current->origin)
+ || (filter2 == current->origin)
+ || (filter3 == current->origin)
+ || (filter4 == current->origin)
+ || (filter5 == current->origin))));
+
+ return current;
+}
+
+void mon_cpuhistory(int count, MEMSPACE filter1, MEMSPACE filter2, MEMSPACE filter3,
+ MEMSPACE filter4, MEMSPACE filter5)
+{
+ uint8_t op, p1, p2, p3 = 0;
+ MEMSPACE mem;
+ uint16_t loc, addr;
+ int hex_mode = 1;
+ const char *dis_inst;
+ cpuhistory_t *current;
+ unsigned opc_size;
+ CLOCK cycle;
+ char otext[10];
+
+ /* if nothing passed, set the first filter to the default device */
+ if ((filter1 == e_invalid_space) &&
+ (filter2 == e_invalid_space) &&
+ (filter3 == e_invalid_space) &&
+ (filter4 == e_invalid_space) &&
+ (filter5 == e_invalid_space)) {
+ filter1 = default_memspace;
+ }
+
+ /* determine the actual maximum records to go through */
+ if (count < 1) {
+ count = cpuhistory_show_lines;
+ }
+
+ current = mon_cpuhistory_seek(count, filter1, filter2, filter3, filter4, filter5);
+
/* loop through all entries until we find the number records requested */
- while (i > 0) {
- /* adjust our buffer circular reference */
- pos = ( pos + 1) % cpuhistory_buffer_lines;
- /* make sure the record matches */
- if ((cpuhistory[pos].origin != e_invalid_space)
- && ((filter1 == cpuhistory[pos].origin)
- || (filter2 == cpuhistory[pos].origin)
- || (filter3 == cpuhistory[pos].origin)
- || (filter4 == cpuhistory[pos].origin)
- || (filter5 == cpuhistory[pos].origin))) {
- cycle = cpuhistory[pos].cycle;
- addr = cpuhistory[pos].addr;
- op = cpuhistory[pos].op;
- p1 = cpuhistory[pos].p1;
- p2 = cpuhistory[pos].p2;
+ while ((current = mon_cpuhistory_next(current, filter1, filter2, filter3, filter4, filter5))) {
+ cycle = current->cycle;
+ addr = current->addr;
+ op = current->op;
+ p1 = current->p1;
+ p2 = current->p2;
- mem = cpuhistory[pos].origin;
- loc = addr_location(addr);
+ mem = current->origin;
+ loc = addr_location(addr);
- dis_inst = mon_disassemble_to_string_ex(mem, loc, op, p1, p2, p3, hex_mode, &opc_size);
+ dis_inst = mon_disassemble_to_string_ex(mem, loc, op, p1, p2, p3, hex_mode, &opc_size);
- strncpy(otext, mon_memspace_string[mem], 4);
+ strncpy(otext, mon_memspace_string[mem], 4);
- /* Print the disassembled instruction */
- mon_out(".%s:%04x %-26s A:%02x X:%02x Y:%02x SP:%02x %c%c-%c%c%c%c%c %12"PRIu64"\n",
- otext, loc, dis_inst,
- cpuhistory[pos].reg_a, cpuhistory[pos].reg_x,
- cpuhistory[pos].reg_y, cpuhistory[pos].reg_sp,
- ((cpuhistory[pos].reg_st & (1 << 7)) != 0) ? 'N' : '.',
- ((cpuhistory[pos].reg_st & (1 << 6)) != 0) ? 'V' : '.',
- ((cpuhistory[pos].reg_st & (1 << 4)) != 0) ? 'B' : '.',
- ((cpuhistory[pos].reg_st & (1 << 3)) != 0) ? 'D' : '.',
- ((cpuhistory[pos].reg_st & (1 << 2)) != 0) ? 'I' : '.',
- ((cpuhistory[pos].reg_st & (1 << 1)) != 0) ? 'Z' : '.',
- ((cpuhistory[pos].reg_st & (1 << 0)) != 0) ? 'C' : '.',
- cycle
- );
- i--;
- }
+ /* Print the disassembled instruction */
+ mon_out(".%s:%04x %-26s A:%02x X:%02x Y:%02x SP:%02x %c%c-%c%c%c%c%c %12"PRIu64"\n",
+ otext, loc, dis_inst,
+ current->reg_a, current->reg_x,
+ current->reg_y, current->reg_sp,
+ ((current->reg_st & (1 << 7)) != 0) ? 'N' : '.',
+ ((current->reg_st & (1 << 6)) != 0) ? 'V' : '.',
+ ((current->reg_st & (1 << 4)) != 0) ? 'B' : '.',
+ ((current->reg_st & (1 << 3)) != 0) ? 'D' : '.',
+ ((current->reg_st & (1 << 2)) != 0) ? 'I' : '.',
+ ((current->reg_st & (1 << 1)) != 0) ? 'Z' : '.',
+ ((current->reg_st & (1 << 0)) != 0) ? 'C' : '.',
+ cycle
+ );
}
}
Modified: trunk/vice/src/monitor/mon_memmap.h
===================================================================
--- trunk/vice/src/monitor/mon_memmap.h 2025-03-22 16:36:49 UTC (rev 45560)
+++ trunk/vice/src/monitor/mon_memmap.h 2025-03-22 16:44:59 UTC (rev 45561)
@@ -30,6 +30,21 @@
#include "montypes.h"
#include "types.h"
+struct cpuhistory_s {
+ CLOCK cycle;
+ uint16_t addr;
+ uint16_t reg_st;
+ uint8_t op;
+ uint8_t p1;
+ uint8_t p2;
+ uint8_t reg_a;
+ uint8_t reg_x;
+ uint8_t reg_y;
+ uint8_t reg_sp;
+ MEMSPACE origin;
+};
+typedef struct cpuhistory_s cpuhistory_t;
+
void mon_memmap_init(void);
void mon_memmap_shutdown(void);
@@ -36,9 +51,14 @@
int monitor_cpuhistory_allocate(int lines);
void mon_cpuhistory(int count, MEMSPACE filter1, MEMSPACE filter2, MEMSPACE filter3,
MEMSPACE filter4, MEMSPACE filter5);
+cpuhistory_t *mon_cpuhistory_seek(int count, MEMSPACE filter1, MEMSPACE filter2,
+ MEMSPACE filter3, MEMSPACE filter4, MEMSPACE filter5);
+cpuhistory_t *mon_cpuhistory_next(cpuhistory_t *current, MEMSPACE filter1, MEMSPACE filter2,
+ MEMSPACE filter3, MEMSPACE filter4, MEMSPACE filter5);
void mon_memmap_zap(void);
void mon_memmap_show(int mask, MON_ADDR start_addr, MON_ADDR end_addr);
void mon_memmap_save(const char* filename, int format);
+
#endif
Modified: trunk/vice/src/monitor/monitor_binary.c
===================================================================
--- trunk/vice/src/monitor/monitor_binary.c 2025-03-22 16:36:49 UTC (rev 45560)
+++ trunk/vice/src/monitor/monitor_binary.c 2025-03-22 16:44:59 UTC (rev 45561)
@@ -52,6 +52,7 @@
#include "machine-video.h"
#include "palette.h"
+#include "mon_memmap.h"
#include "mon_breakpoint.h"
#include "mon_file.h"
#include "mon_register.h"
@@ -110,6 +111,7 @@
e_MON_CMD_REGISTERS_AVAILABLE = 0x83,
e_MON_CMD_DISPLAY_GET = 0x84,
e_MON_CMD_VICE_INFO = 0x85,
+ e_MON_CMD_CPUHISTORY_GET = 0x86,
e_MON_CMD_PALETTE_GET = 0x91,
@@ -158,6 +160,7 @@
e_MON_RESPONSE_REGISTERS_AVAILABLE = 0x83,
e_MON_RESPONSE_DISPLAY_GET = 0x84,
e_MON_RESPONSE_VICE_INFO = 0x85,
+ e_MON_RESPONSE_CPUHISTORY_GET = 0x86,
e_MON_RESPONSE_PALETTE_GET = 0x91,
@@ -306,6 +309,15 @@
return output + 4;
}
+/*! \internal \brief Write uint64 to buffer and return pointer to byte after */
+static unsigned char *write_uint64(uint64_t input, unsigned char *output) {
+ for (int i = 0 ; i < 8 ; i++) {
+ output[i] = (uint8_t)(input >> (8 * i)) & 0xFFu;
+ }
+
+ return output + 8;
+}
+
/*! \internal \brief Write string to buffer and return pointer to byte after */
static unsigned char *write_string(uint8_t length, unsigned char *input, unsigned char *output) {
output[0] = length;
@@ -416,47 +428,58 @@
}
}
-static void monitor_binary_response_register_info(uint32_t request_id, MEMSPACE memspace)
-{
- mon_reg_list_t *regs;
- mon_reg_list_t *regs_cursor;
- unsigned char *response;
- unsigned char *response_cursor;
- uint32_t response_size = 2;
- uint16_t count = 0;
- uint8_t item_size = 3;
+#define MON_REGISTER_ITEM_SIZE 3
- regs = mon_register_list_get(memspace);
- regs_cursor = regs;
+static uint16_t *count_registers(mon_reg_list_t *regs) {
+ uint16_t count;
- for( ; regs_cursor->name ; regs_cursor++) {
- if (!ignore_fake_register(regs_cursor)) {
+ for( ; regs->name ; regs++) {
+ if (!ignore_fake_register(regs)) {
++count;
}
}
- response_size += count * (item_size + 1);
- response = lib_malloc(response_size);
- response_cursor = response;
+ return count;
+}
- regs_cursor = regs;
-
+static unsigned char *write_registers(mon_reg_list_t *regs, uint16_t count, unsigned char *response_cursor) {
response_cursor = write_uint16(count, response_cursor);
- for( ; regs_cursor->name ; regs_cursor++) {
- if (ignore_fake_register(regs_cursor)) {
+ for( ; regs->name ; regs++) {
+ if (ignore_fake_register(regs)) {
continue;
}
- *response_cursor = item_size;
+ *response_cursor = MON_REGISTER_ITEM_SIZE;
++response_cursor;
- *response_cursor = regs_cursor->id;
+ *response_cursor = regs->id;
++response_cursor;
- response_cursor = write_uint16((uint16_t)regs_cursor->val, response_cursor);
+ response_cursor = write_uint16((uint16_t)regs->val, response_cursor);
}
+ return response_cursor;
+}
+
+static void monitor_binary_response_register_info(uint32_t request_id, MEMSPACE memspace)
+{
+ mon_reg_list_t *regs;
+ unsigned char *response;
+ unsigned char *response_cursor;
+ uint16_t count;
+ uint32_t response_size = 2;
+
+ regs = mon_register_list_get(memspace);
+
+ count = count_registers(regs);
+
+ response_size += count * (MON_REGISTER_ITEM_SIZE + 1);
+ response = lib_malloc(response_size);
+ response_cursor = response;
+
+ response_cursor = write_registers(regs, count, response_cursor);
+
monitor_binary_response(response_size, e_MON_RESPONSE_REGISTER_INFO, e_MON_ERR_OK, request_id, response);
lib_free(response);
@@ -782,7 +805,7 @@
if(memspace == e_invalid_space) {
monitor_binary_error(e_MON_ERR_INVALID_MEMSPACE, command->request_id);
- log_message(LOG_DEFAULT, "monitor binary memset: Unknown memspace %u", requested_memspace);
+ log_message(LOG_DEFAULT, "monitor binary registers get: Unknown memspace %u", requested_memspace);
return;
}
@@ -1413,6 +1436,148 @@
monitor_binary_response(sizeof(response), e_MON_RESPONSE_VICE_INFO, e_MON_ERR_OK, command->request_id, response);
}
+static void monitor_binary_process_cpuhistory(binary_command_t *command)
+{
+ mon_reg_list_t *regs;
+ mon_reg_list_t *templates;
+ mon_reg_list_t *reg_a;
+ mon_reg_list_t *reg_x;
+ mon_reg_list_t *reg_y;
+ mon_reg_list_t *reg_sp;
+ mon_reg_list_t *reg_flags;
+ mon_reg_list_t *reg_pc;
+ mon_reg_list_t *reg_lin;
+ mon_reg_list_t *reg_cyc;
+ int i;
+ int registers_per_row = 8;
+ unsigned char *response;
+ unsigned char *response_cursor;
+ uint8_t instruction_length = 4;
+ uint16_t requested_count, count = 0;
+ uint32_t response_size;
+ int item_size = 2 + registers_per_row * (MON_REGISTER_ITEM_SIZE + 1) + 8 + 1 + instruction_length;
+
+ cpuhistory_t *current;
+
+ uint8_t requested_memspace = command->body[0];
+
+ MEMSPACE memspace;
+ if (command->length < 5) {
+ monitor_binary_error(e_MON_ERR_CMD_INVALID_LENGTH, command->request_id);
+ return;
+ }
+
+ memspace = get_requested_memspace(requested_memspace);
+
+ if (memspace == e_invalid_space) {
+ monitor_binary_error(e_MON_ERR_INVALID_MEMSPACE, command->request_id);
+ log_message(LOG_DEFAULT, "monitor binary cpuhistory: Unknown memspace %u", requested_memspace);
+ return;
+ }
+
+ requested_count = little_endian_to_uint32(&command->body[1]);
+
+ if (requested_count < 1) {
+ monitor_binary_error(e_MON_ERR_INVALID_PARAMETER, command->request_id);
+ log_message(LOG_DEFAULT, "monitor binary cpuhistory: Invalid count %u", count);
+ return;
+ }
+
+ current = mon_cpuhistory_seek(requested_count, memspace, memspace, memspace, memspace, memspace);
+ while ((current = mon_cpuhistory_next(current, memspace, memspace, memspace, memspace, memspace))) {
+ ++count;
+ response_size = 4 + count * (item_size + 1);
+ if (response_size >= UINT32_MAX) {
+ --count;
+ break;
+ }
+ }
+
+ response_size = 4 + count * (item_size + 1);
+ response = lib_malloc(response_size);
+ response_cursor = response;
+
+ regs = lib_calloc(1, sizeof(mon_reg_list_t) * (registers_per_row + 1));
+
+ templates = mon_register_list_get(memspace);
+
+ for (i = 0; templates[i].name != NULL; i++) {
+ unsigned int id = templates[i].id;
+ mon_reg_list_t *template = &templates[i];
+ if (ignore_fake_register(template)) {
+ continue;
+ } else if (id == e_PC) {
+ memcpy(®s[0], template, sizeof(mon_reg_list_t));
+ reg_pc = ®s[0];
+ } else if (id == e_A) {
+ memcpy(®s[1], template, sizeof(mon_reg_list_t));
+ reg_a = ®s[1];
+ } else if (id == e_X) {
+ memcpy(®s[2], template, sizeof(mon_reg_list_t));
+ reg_x = ®s[2];
+ } else if (id == e_Y) {
+ memcpy(®s[3], template, sizeof(mon_reg_list_t));
+ reg_y = ®s[3];
+ } else if (id == e_SP) {
+ memcpy(®s[4], template, sizeof(mon_reg_list_t));
+ reg_sp = ®s[4];
+ } else if (id == e_FLAGS) {
+ memcpy(®s[5], template, sizeof(mon_reg_list_t));
+ reg_flags = ®s[5];
+ } else if (id == e_Rasterline) {
+ memcpy(®s[6], template, sizeof(mon_reg_list_t));
+ reg_lin = ®s[6];
+ } else if (id == e_Cycle) {
+ memcpy(®s[7], template, sizeof(mon_reg_list_t));
+ reg_cyc = ®s[7];
+ }
+ }
+
+ response_cursor = write_uint32(count, response_cursor);
+
+ current = mon_cpuhistory_seek(count, memspace, memspace, memspace, memspace, memspace);
+ while ((current = mon_cpuhistory_next(current, memspace, memspace, memspace, memspace, memspace))) {
+ reg_a->val = current->reg_a;
+ reg_x->val = current->reg_x;
+ reg_y->val = current->reg_y;
+ reg_sp->val = current->reg_sp;
+ reg_flags->val = current->reg_st;
+ reg_pc->val = current->addr;
+ reg_lin->val = 0xffff;
+ reg_cyc->val = 0xffff;
+
+ *response_cursor = item_size;
+ ++response_cursor;
+
+ response_cursor = write_registers(regs, registers_per_row, response_cursor);
+
+ /* This is here so that the register array doesn't separate it from future fields. */
+ response_cursor = write_uint64(current->cycle, response_cursor);
+
+ *response_cursor = instruction_length;
+ ++response_cursor;
+
+ *response_cursor = current->op;
+ ++response_cursor;
+
+ *response_cursor = current->p1;
+ ++response_cursor;
+
+ *response_cursor = current->p2;
+ ++response_cursor;
+
+ /* Placeholder for third parameter, which exists on some machines */
+ *response_cursor = 0xff;
+ ++response_cursor;
+ }
+
+ monitor_binary_response(response_size, e_MON_RESPONSE_CPUHISTORY_GET, e_MON_ERR_OK, command->request_id, response);
+
+ lib_free(templates);
+ lib_free(response);
+}
+
+
static void monitor_binary_process_mem_get(binary_command_t *command)
{
unsigned char *response;
@@ -1628,6 +1793,8 @@
monitor_binary_process_display_get(&command);
} else if (command_type == e_MON_CMD_VICE_INFO) {
monitor_binary_process_vice_info(&command);
+ } else if (command_type == e_MON_CMD_CPUHISTORY_GET) {
+ monitor_binary_process_cpuhistory(&command);
} else if (command_type == e_MON_CMD_EXIT) {
monitor_binary_process_exit(&command);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <emp...@us...> - 2025-03-22 16:37:02
|
Revision: 45560
http://sourceforge.net/p/vice-emu/code/45560
Author: empathicqubit
Date: 2025-03-22 16:36:49 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Add test for CPUHISTORY_GET binary monitor command
Modified Paths:
--------------
testprogs/remotemonitor/binmontest/main.c
testprogs/remotemonitor/binmontest/util.c
testprogs/remotemonitor/binmontest/util.h
Modified: testprogs/remotemonitor/binmontest/main.c
===================================================================
--- testprogs/remotemonitor/binmontest/main.c 2025-03-22 16:02:07 UTC (rev 45559)
+++ testprogs/remotemonitor/binmontest/main.c 2025-03-22 16:36:49 UTC (rev 45560)
@@ -175,7 +175,72 @@
CuAssertIntEquals(tc, 7, assert_count);
}
+void cpuhistory_works(CuTest *tc) {
+ int length, count, i, j;
+ int assert_count = 0;
+ unsigned char* cursor;
+ // Get
+ unsigned char get_command[] = {
+ 0x02, API_VERSION,
+ 0xff, 0xff, 0xff, 0xff,
+ 0xa3, 0x1f, 0xd8, 0xc7,
+
+ 0x86,
+
+ // memspace
+ 0x00,
+
+ // record count
+ 0x0a, 0x00, 0x00, 0x00
+ };
+
+ connection_setup(tc);
+
+ send_command(get_command);
+
+ length = wait_for_response_id(tc, get_command);
+
+ CuAssertIntEquals(tc, 0x86, response[RESPONSE_TYPE]);
+
+ count = little_endian_to_uint32(&response[HEADER_LENGTH]);
+
+ // record count
+ CuAssertIntEquals(tc, 10, count);
+
+ cursor = &response[HEADER_LENGTH + 4];
+
+ for (i = 0 ; i < count ; i++) {
+ uint8_t item_size = cursor[0];
+ uint8_t reg_count = little_endian_to_uint16(&cursor[1]);
+ unsigned char *reg_cursor = &cursor[3];
+
+ CuAssertIntEquals(tc, 47, item_size);
+ CuAssertIntEquals(tc, 8, reg_count);
+
+ for (j = 0 ; j < reg_count ; j++) {
+ uint8_t reg_size = reg_cursor[0];
+ uint8_t id = reg_cursor[1];
+ uint16_t val = little_endian_to_uint16(®_cursor[2]);
+
+ fprintf(stderr, "%02x:%04x ", id, val);
+
+ reg_cursor += reg_size + 1;
+ }
+
+ fprintf(stderr, "CLK:%08lx ", little_endian_to_uint64(®_cursor[0]));
+ reg_cursor += 8;
+
+ fprintf(stderr, "INST:%02x %02x %02x %02x\n", reg_cursor[1], reg_cursor[2], reg_cursor[3], reg_cursor[4]);
+
+ reg_cursor += reg_cursor[0] + 1;
+
+ cursor += item_size + 1;
+
+ CuAssertTrue(tc, cursor == reg_cursor);
+ }
+}
+
void registers_get_works(CuTest *tc) {
int length, count, i;
int assert_count = 0;
@@ -238,7 +303,7 @@
) {
++assert_count;
} else if(id == 0x38) {
- CuAssertIntEquals(tc, 0x17, val);
+ CuAssertIntEquals(tc, 23, val);
++assert_count;
}
@@ -1237,6 +1302,8 @@
{
CuSuite* suite = CuSuiteNew();
+ SUITE_ADD_TEST(suite, little_endian_to_uint64_works);
+
SUITE_ADD_TEST(suite, request_id_is_set);
SUITE_ADD_TEST(suite, checkpoint_set_works);
@@ -1271,6 +1338,7 @@
SUITE_ADD_TEST(suite, registers_available_works);
SUITE_ADD_TEST(suite, display_get_works);
SUITE_ADD_TEST(suite, vice_info_works);
+ SUITE_ADD_TEST(suite, cpuhistory_works);
SUITE_ADD_TEST(suite, palette_get_works);
Modified: testprogs/remotemonitor/binmontest/util.c
===================================================================
--- testprogs/remotemonitor/binmontest/util.c 2025-03-22 16:02:07 UTC (rev 45559)
+++ testprogs/remotemonitor/binmontest/util.c 2025-03-22 16:36:49 UTC (rev 45560)
@@ -24,8 +24,18 @@
*
*/
+#include "util.h"
+
#include <stdint.h>
+uint64_t little_endian_to_uint64(unsigned char *input) {
+ uint64_t sum = 0;
+ for (int i = 0 ; i < 8 ; i++) {
+ sum += ((uint64_t)input[i]) << (8 * i);
+ }
+ return sum;
+}
+
uint32_t little_endian_to_uint32(unsigned char *input) {
return (input[3] << 24) + (input[2] << 16) + (input[1] << 8) + input[0];
}
@@ -48,4 +58,24 @@
output[3] = (uint8_t)(input >> 24) & 0xFFu;
return output + 4;
-}
\ No newline at end of file
+}
+
+void little_endian_to_uint64_works(CuTest *tc) {
+ unsigned char max[] = {
+ 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ };
+ unsigned char min[] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+ unsigned char asc[] = {
+ 0xf0, 0xde, 0xbc, 0x9a,
+ 0x78, 0x56, 0x34, 0x12,
+ };
+
+ CuAssertTrue(tc, 0 == little_endian_to_uint64(min));
+ CuAssertTrue(tc, 0xffffffffffffffff == little_endian_to_uint64(max));
+ CuAssertTrue(tc, 0x123456789abcdef0 == little_endian_to_uint64(asc));
+}
+
Modified: testprogs/remotemonitor/binmontest/util.h
===================================================================
--- testprogs/remotemonitor/binmontest/util.h 2025-03-22 16:02:07 UTC (rev 45559)
+++ testprogs/remotemonitor/binmontest/util.h 2025-03-22 16:36:49 UTC (rev 45560)
@@ -27,6 +27,10 @@
#ifndef BINMONTEST_UTIL_H
#define BINMONTEST_UTIL_H
+#include "CuTest.h"
+
+#include <stdint.h>
+
#define HEADER_LENGTH 12
#define RESPONSE_TYPE 6
#define RESPONSE_ERROR 7
@@ -37,9 +41,11 @@
#define COMMAND_LENGTH 2
#define API_VERSION 0x02
+void little_endian_to_uint64_works(CuTest *tc);
+uint64_t little_endian_to_uint64(unsigned char *input);
uint32_t little_endian_to_uint32(unsigned char *input);
uint16_t little_endian_to_uint16(unsigned char *input);
unsigned char *write_uint16(uint16_t input, unsigned char *output);
unsigned char *write_uint32(uint32_t input, unsigned char *output);
-#endif
\ No newline at end of file
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-22 16:02:16
|
Revision: 45559
http://sourceforge.net/p/vice-emu/code/45559
Author: compyx
Date: 2025-03-22 16:02:07 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Merge trunk (r45543:HEAD) into branch
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/userport/userport_wic64.c
Modified: branches/compyx/joymap-001/vice/src/userport/userport_wic64.c
===================================================================
--- branches/compyx/joymap-001/vice/src/userport/userport_wic64.c 2025-03-22 15:55:20 UTC (rev 45558)
+++ branches/compyx/joymap-001/vice/src/userport/userport_wic64.c 2025-03-22 16:02:07 UTC (rev 45559)
@@ -1063,7 +1063,7 @@
} else {
/* firmeare handles codes: 301, 302, 307, 308 - check if needed with libcurl */
char m[64];
- snprintf(m, 64, "Unhandled http response %ld, received %"PRI_SIZE_T" bytes", response, httpbufferptr);
+ snprintf(m, 64, "Unhandled http response %ld, received %llu bytes", response, (unsigned long long)httpbufferptr);
wic64_log(LOG_COL_LRED, m);
if (httpbufferptr > 0) {
send_reply_revised(SUCCESS, "Success", httpbuffer,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-22 15:55:22
|
Revision: 45558
http://sourceforge.net/p/vice-emu/code/45558
Author: compyx
Date: 2025-03-22 15:55:20 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
"Fix" Windows size_t printing
Somehow mingw refuses to accept Iu, I64u, and even at some point suggested
I64llu, so just cast to `unsigned long long`, use %llu and fuck it.
Modified Paths:
--------------
trunk/vice/src/userport/userport_wic64.c
Modified: trunk/vice/src/userport/userport_wic64.c
===================================================================
--- trunk/vice/src/userport/userport_wic64.c 2025-03-22 08:53:03 UTC (rev 45557)
+++ trunk/vice/src/userport/userport_wic64.c 2025-03-22 15:55:20 UTC (rev 45558)
@@ -1063,7 +1063,7 @@
} else {
/* firmeare handles codes: 301, 302, 307, 308 - check if needed with libcurl */
char m[64];
- snprintf(m, 64, "Unhandled http response %ld, received %"PRI_SIZE_T" bytes", response, httpbufferptr);
+ snprintf(m, 64, "Unhandled http response %ld, received %llu bytes", response, (unsigned long long)httpbufferptr);
wic64_log(LOG_COL_LRED, m);
if (httpbufferptr > 0) {
send_reply_revised(SUCCESS, "Success", httpbuffer,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-22 08:53:07
|
Revision: 45557
http://sourceforge.net/p/vice-emu/code/45557
Author: compyx
Date: 2025-03-22 08:53:03 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Joystick: Windows: implement `poll()` driver method
Implement polling for the DirectInput driver. Might require having the driver
keep a private 'prev' value to avoid unnecessary callbacks to `joy_*_event()`
in the common joystick system, DirectInput isn't event driven, so we get a lot
of (unchanged) data when polling each scanline.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
branches/compyx/joymap-001/vice/src/joyport/joystick.h
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 04:39:53 UTC (rev 45556)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 08:53:03 UTC (rev 45557)
@@ -440,7 +440,109 @@
static void win32_joy_poll(joystick_device_t *joydev)
{
- /* TODO */
+ joy_priv_t *priv;
+ DIJOYSTATE2 jstate;
+ /* map axis instance (dwType & 0xff) IDs to their position in the joystick
+ * state DIJOYSTATE2 struct: */
+ LONG *axis_map[] = {
+ &jstate.lX, &jstate.lY, &jstate.lZ,
+ &jstate.lRx, &jstate.lRy, &jstate.lRz,
+ &jstate.lVX, &jstate.lVY, &jstate.lVZ,
+ &jstate.lVRx, &jstate.lVRy, &jstate.lVRz,
+ &jstate.lAX, &jstate.lAY, &jstate.lAZ,
+ &jstate.lARx, &jstate.lARy, &jstate.lARz,
+ &jstate.lFX, &jstate.lFY, &jstate.lFZ,
+ &jstate.lFRx, &jstate.lFRy, &jstate.lFRz
+ };
+ int i;
+ HRESULT result;
+
+ /* poll device */
+ priv = joydev->priv;
+ result = IDirectInputDevice8_Poll(priv->didev);
+ if (result != DI_OK && result != DI_NOEFFECT) {
+ return;
+ }
+
+ /* get device state */
+ result = IDirectInputDevice8_GetDeviceState(priv->didev, sizeof(jstate), &jstate);
+ if (result != DI_OK) {
+ return;
+ }
+
+ /* handle buttons */
+ for (i = 0; i < joydev->num_buttons; i++) {
+ /* buttons are simply listed in sequence, starting at 0 */
+ joystick_button_t *button = joydev->buttons[i];
+ int32_t value = jstate.rgbButtons[i] & 0x80;
+
+ joy_button_event(joydev, button, value);
+ }
+
+ /* handle axes */
+ for (i = 0; i < joydev->num_axes; i++) {
+ joystick_axis_t *axis = joydev->axes[i];
+ uint32_t code = axis->code;
+
+ if (code < sizeof axis_map / sizeof axis_map[0]) {
+ int32_t minimum = axis->minimum;
+ int32_t maximum = axis->maximum;
+ int32_t range = maximum - minimum;
+ int32_t value = *(axis_map[code]);
+
+ //printf("axis %d raw value = %d\n", i, value);
+
+ if (value <= minimum + (range / 4)) {
+ joy_axis_event(joydev, axis, JOY_AXIS_NEGATIVE);
+ } else if (value >= maximum - (range / 4)) {
+ joy_axis_event(joydev, axis, JOY_AXIS_POSITIVE);
+ } else {
+ joy_axis_event(joydev, axis, JOY_AXIS_MIDDLE);
+ }
+ }
+ }
+
+ /* handle POVs */
+ for (i = 0; i < joydev->num_hats; i++) {
+ /* POVs are simply reported sequentially, so hat index is POV value index */
+ joystick_hat_t *hat = joydev->hats[i];
+ int32_t value = LOWORD(jstate.rgdwPOV[i]);
+ int32_t direction = JOYSTICK_DIRECTION_NONE; /* neutral */
+
+ /* POVs map to 360 degrees, in units of 1/100th of a degree, neutral
+ * is reported as -1 / 0xffffffff.
+ * Translate position on a circle to joystick directions, clockwise
+ * from North through to Northwest */
+ if (value < 0 || value >= 36000) {
+ /* invalid: report neutral position */
+ direction = JOYSTICK_DIRECTION_NONE;
+ } else if (value >= 33750 || value < 2250) {
+ /* North */
+ direction = JOYSTICK_DIRECTION_UP;
+ } else if (value >= 2250 && value < 6750) {
+ /* Northeast */
+ direction = JOYSTICK_DIRECTION_UP|JOYSTICK_DIRECTION_RIGHT;
+ } else if (value >= 6750 && value < 11250) {
+ /* East */
+ direction = JOYSTICK_DIRECTION_RIGHT;
+ } else if (value >= 11250 && value < 15750) {
+ /* Southeast */
+ direction = JOYSTICK_DIRECTION_DOWN|JOYSTICK_DIRECTION_RIGHT;
+ } else if (value >= 15750 && value < 20250) {
+ /* South */
+ direction = JOYSTICK_DIRECTION_DOWN;
+ } else if (value >= 20250 && value < 24750) {
+ /* Southwest */
+ direction = JOYSTICK_DIRECTION_DOWN|JOYSTICK_DIRECTION_LEFT;
+ } else if (value >= 24750 && value < 29250) {
+ /* West */
+ direction = JOYSTICK_DIRECTION_LEFT;
+ } else if (value >= 29250 && value < 33750) {
+ /* Northwest */
+ direction = JOYSTICK_DIRECTION_UP|JOYSTICK_DIRECTION_LEFT;
+ }
+ joy_hat_event(joydev, hat, direction);
+ }
}
/** \brief Close joystick device
@@ -521,13 +623,13 @@
axis = joystick_axis_new(lpddoi->tszName);
axis->code = DIDFT_GETINSTANCE(lpddoi->dwType);
- /* obtain logical range of axis */
+ /* obtain raw range of axis */
range.diph.dwSize = sizeof(DIPROPRANGE);
range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
range.diph.dwObj = lpddoi->dwType;
range.diph.dwHow = DIPH_BYID;
result = IDirectInputDevice8_GetProperty(priv->didev,
- DIPROP_LOGICALRANGE,
+ DIPROP_RANGE,
&range.diph);
if (SUCCEEDED(result)) {
axis->minimum = range.lMin;
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.h
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-22 04:39:53 UTC (rev 45556)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-22 08:53:03 UTC (rev 45557)
@@ -36,6 +36,7 @@
#include "lib.h"
+#define JOYSTICK_DIRECTION_NONE 0
#define JOYSTICK_DIRECTION_UP 1
#define JOYSTICK_DIRECTION_DOWN 2
#define JOYSTICK_DIRECTION_LEFT 4
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-22 04:40:09
|
Revision: 45556
http://sourceforge.net/p/vice-emu/code/45556
Author: compyx
Date: 2025-03-22 04:39:53 +0000 (Sat, 22 Mar 2025)
Log Message:
-----------
Joystick: Windows: implement driver's open() and close() methods
Implement `open()` and `close()` methods of the driver, for now just call
`open()` for each device (calling IDirectInputDevice8::Acquire() just like the
old code has done), once the "JoyDevice{N}" resource setters actually close()
their old device and open() their new one this can be removed.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-21 19:46:33 UTC (rev 45555)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-22 04:39:53 UTC (rev 45556)
@@ -406,8 +406,9 @@
{
joy_priv_t *pr = priv;
if (pr->didev != NULL) {
- IDirectInputDevice_Unacquire(pr->didev);
- IDirectInputDevice_Release(pr->didev);
+ /* it's safe to call Unacquire() on an unacquired device */
+ IDirectInputDevice8_Unacquire(pr->didev);
+ IDirectInputDevice8_Release(pr->didev);
}
lib_free(priv);
}
@@ -414,13 +415,46 @@
/*
- * Driver methods: NOPs for now
+ * Driver methods
*/
-static bool win32_joy_open(joystick_device_t *joydev) { return true; }
-static void win32_joy_poll(joystick_device_t *joydev) {}
-static void win32_joy_close(joystick_device_t *joydev) {}
+/** \brief Open joystick device for polling
+ *
+ * \param[in] joydev joystick device
+ *
+ * \return \c true on success, \c false on failure
+ */
+static bool win32_joy_open(joystick_device_t *joydev)
+{
+ joy_priv_t *priv = joydev->priv;
+ HRESULT result;
+ result = IDirectInputDevice8_Acquire(priv->didev);
+ if (SUCCEEDED(result)) {
+ return true;
+ }
+ log_error(winjoy_log, "failed to acquire device \"%s\": error 0x%08lx",
+ joydev->name, (unsigned long)result);
+ return false;
+}
+
+static void win32_joy_poll(joystick_device_t *joydev)
+{
+ /* TODO */
+}
+
+/** \brief Close joystick device
+ *
+ * \param[in] joydev joystick device
+ */
+static void win32_joy_close(joystick_device_t *joydev)
+{
+ joy_priv_t *priv = joydev->priv;
+
+ IDirectInputDevice8_Unacquire(priv->didev);
+}
+
+
/** \brief Driver definition */
static joystick_driver_t win32_joy_driver = {
.open = win32_joy_open,
@@ -688,8 +722,11 @@
(LPVOID)joydev,
DIDFT_ABSAXIS|DIDFT_BUTTON|DIDFT_POV);
#endif
- /* TODO: Open device for polling (until the driver's open() method has been
- * properly implemented and tested. */
+ /* Open device manually for polling, until the driver's open() method has
+ * been properly implemented and tested (changing resource "JoyDeviceN"
+ * should close the old device and open the new one)
+ */
+ win32_joy_open(joydev);
/* register device and continue */
joystick_device_register(joydev);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-21 19:46:40
|
Revision: 45555
http://sourceforge.net/p/vice-emu/code/45555
Author: compyx
Date: 2025-03-21 19:46:33 +0000 (Fri, 21 Mar 2025)
Log Message:
-----------
joystick: Windows still doesn't know "%z" *sigh*
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/joyport/joystick.c
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.c
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-21 19:39:37 UTC (rev 45554)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-21 19:46:33 UTC (rev 45555)
@@ -3630,7 +3630,7 @@
if (index < 0 || index >= num_joystick_devices) {
/* normally we wouldn't pass an invalid index, so log a warning */
log_warning(joy_log,
- "%s(): joystick index out of range (0-%zu)",
+ "%s(): joystick index out of range (0-%" PRI_SIZE_T ")",
__func__, num_joystick_devices);
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-21 19:39:50
|
Revision: 45554
http://sourceforge.net/p/vice-emu/code/45554
Author: compyx
Date: 2025-03-21 19:39:37 +0000 (Fri, 21 Mar 2025)
Log Message:
-----------
Joystick: make `joystick_device_register()` order its inputs on (event) code
Instead of relying on the drivers to provide us with ordered inputs, we have
`joystick_device_register()` order the axes, buttons and hats after they've
been added by the driver to the device and the device is registered.
Leads to less burden on the drivers: just add axes, buttons and hats in whatever
order the OS/library presents them, let the common joystick code sort (heh) it
out.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
branches/compyx/joymap-001/vice/src/joyport/joystick.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-21 12:52:24 UTC (rev 45553)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-21 19:39:37 UTC (rev 45554)
@@ -91,8 +91,6 @@
typedef struct joy_priv_s {
struct libevdev *evdev; /**< evdev instance */
int fd; /**< file descriptor */
- int32_t axis_index[NUM_AXES_MAX]; /**< axis indexes per code [0x00..0x28] */
- int32_t button_index[NUM_BUTTONS_MAX]; /**< button indexes per code [0x100-0x13e] */
} joy_priv_t;
@@ -111,9 +109,6 @@
priv = lib_malloc(sizeof *priv);
priv->fd = -1;
priv->evdev = NULL;
- memset(&priv->axis_index, -1, sizeof *priv->axis_index);
- memset(&priv->button_index, -1, sizeof *priv->button_index);
-
return priv;
}
@@ -141,28 +136,27 @@
*/
static void dispatch_event(joystick_device_t *joydev, struct input_event *event)
{
- joy_priv_t *priv = joydev->priv;
- int index;
+ if (event->type == EV_KEY) {
+ joystick_button_t *button;
- if (event->type == EV_KEY) {
-#if 0
printf("button %02x (%s): %d\n",
event->code, libevdev_event_code_get_name(EV_KEY, event->code),
event->value);
-#endif
- index = priv->button_index[event->code - BUTTON_CODE_MIN];
- if (index >= 0) {
- joy_button_event(joydev, joydev->buttons[index], event->value);
+
+ button = joystick_button_from_code(joydev, event->code);
+ if (button != NULL) {
+ joy_button_event(joydev, button, event->value);
}
+
} else if (event->type == EV_ABS) {
+ joystick_axis_t *axis;
#if 0
printf("axis %02x (%s): %d\n",
event->code, libevdev_event_code_get_name(EV_ABS, event->code),
event->value);
#endif
- index = priv->axis_index[event->code - AXIS_CODE_MIN];
- if (index >= 0) {
- joystick_axis_t *axis = joydev->axes[index];
+ axis = joystick_axis_from_code(joydev, event->code);
+ if (axis != NULL) {
int32_t minimum = axis->minimum;
int32_t maximum = axis->maximum;
int32_t range = maximum - minimum;
@@ -294,13 +288,10 @@
for (code = BUTTON_CODE_MIN; code <= BUTTON_CODE_MAX; code++) {
if (libevdev_has_event_code(evdev, EV_KEY, code)) {
- joy_priv_t *priv = joydev->priv;
joystick_button_t *button;
button = joystick_button_new(libevdev_event_code_get_name(EV_KEY, code));
button->code = code;
- /* store index in buttons array */
- priv->button_index[code - BUTTON_CODE_MIN] = joydev->num_buttons;
/* joydev takes ownership of button */
joystick_device_add_button(joydev, button);
}
@@ -316,8 +307,7 @@
static void scan_axes(joystick_device_t *joydev, struct libevdev *evdev)
{
if (libevdev_has_event_type(evdev, EV_ABS)) {
- joy_priv_t *priv = joydev->priv;
- uint32_t code;
+ uint32_t code;
for (code = AXIS_CODE_MIN; code <= AXIS_CODE_MAX; code++) {
if (libevdev_has_event_code(evdev, EV_ABS, code)) {
@@ -331,7 +321,6 @@
axis->minimum = info->minimum;
axis->maximum = info->maximum;
}
- priv->axis_index[code - AXIS_CODE_MIN] = joydev->num_axes;
/* joydev takes ownership of axis */
joystick_device_add_axis(joydev, axis);
}
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.c
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-21 12:52:24 UTC (rev 45553)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-21 19:39:37 UTC (rev 45554)
@@ -3471,6 +3471,101 @@
}
+#if 0
+static void dump_axes(joystick_device_t *joydev)
+{
+ for (int i = 0; i < joydev->num_axes; i++) {
+ joystick_axis_t *axis = joydev->axes[i];
+ printf("axis %02d: \"%s\" => %04x\n", i, axis->name, axis->code);
+ }
+}
+
+static void dump_buttons(joystick_device_t *joydev)
+{
+ for (int i = 0; i < joydev->num_buttons; i++) {
+ joystick_button_t *button = joydev->buttons[i];
+ printf("button %02d: \"%s\" => %04x\n", i, button->name, button->code);
+ }
+}
+
+static void dump_hats(joystick_device_t *joydev)
+{
+ for (int i = 0; i < joydev->num_hats; i++) {
+ joystick_hat_t *hat = joydev->hats[i];
+ printf("hat %02d: \"%s\" => %04x\n", i, hat->name, hat->code);
+ }
+}
+#endif
+
+static int cmp_axes(const void *a1, const void *a2)
+{
+ const joystick_axis_t *axis1 = *(const joystick_axis_t **)a1;
+ const joystick_axis_t *axis2 = *(const joystick_axis_t **)a2;
+
+ if (axis1->code < axis2->code) {
+ return -1;
+ } else if (axis1->code > axis2->code) {
+ return 1;
+ }
+ return 0;
+}
+
+static int cmp_buttons(const void *b1, const void *b2)
+{
+ const joystick_button_t *button1 = *(const joystick_button_t **)b1;
+ const joystick_button_t *button2 = *(const joystick_button_t **)b2;
+
+ if (button1->code < button2->code) {
+ return -1;
+ } else if (button1->code > button2->code) {
+ return 1;
+ }
+ return 0;
+}
+
+static int cmp_hats(const void *h1, const void *h2)
+{
+ const joystick_hat_t *hat1 = *(const joystick_hat_t **)h1;
+ const joystick_hat_t *hat2 = *(const joystick_hat_t **)h2;
+
+ if (hat1->code < hat2->code) {
+ return -1;
+ } else if (hat1->code > hat2->code) {
+ return 1;
+ }
+ return 0;
+}
+
+/** \brief Order axes, buttons and hats on event code
+ *
+ * \param[in] joydev joystick device
+ */
+static void order_inputs_on_code(joystick_device_t *joydev)
+{
+#if 0
+ printf("%s(): == BEFORE SORTING ==\n", __func__);
+ dump_axes(joydev);
+ dump_buttons(joydev);
+ dump_hats(joydev);
+#endif
+ if (joydev->num_axes > 1) {
+ qsort(joydev->axes, (size_t)(joydev->num_axes), sizeof joydev->axes[0], cmp_axes);
+ }
+ if (joydev->num_buttons > 1) {
+ qsort(joydev->buttons, (size_t)(joydev->num_buttons), sizeof joydev->buttons[0], cmp_buttons);
+ }
+ if (joydev->num_hats > 1) {
+ qsort(joydev->hats, (size_t)(joydev->num_hats), sizeof joydev->hats[0], cmp_hats);
+ }
+#if 0
+ printf("%s(): == AFTER SORTING ==\n", __func__);
+ dump_axes(joydev);
+ dump_buttons(joydev);
+ dump_hats(joydev);
+#endif
+}
+
+
/** \brief Register joystick device
*
* Add \a joydev to the list of available joystick devices.
@@ -3496,7 +3591,17 @@
sizeof *joystick_devices * max_joystick_devices);
}
+ /* Right-trim name: some drivers provide with padded strings, which will
+ * look weird in the UI */
joystick_device_trim_name(joydev);
+
+ /* Order axes, buttons and hats on event code: some drivers/APIs do not
+ * give us the inputs in a defined order (e.g. DirectInput reports my Saitek
+ * ST50' Y axis before the X axis), so the default mappings will fail.
+ */
+ order_inputs_on_code(joydev);
+
+ /* Now we can try to apply a default mapping */
joystick_device_apply_default_mapping(joydev);
joystick_devices[num_joystick_devices] = joydev;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-21 12:52:31
|
Revision: 45553
http://sourceforge.net/p/vice-emu/code/45553
Author: compyx
Date: 2025-03-21 12:52:24 +0000 (Fri, 21 Mar 2025)
Log Message:
-----------
Joystick: Win32: use single EnumObjectsCallback callback to enumerate inputs
Instead of using seperate callbacks and invocations of
`IDirectInputDevice8::EnumCallback()`, use a single invocation and pass a bitmask
of the objects required (axis, button, POV).
TODO: axes don't arrive inorder, so we need to order then for easier lookup
of event code (e.g. Saitek ST50 reports "X" (0), "Y" (1), "Throttle" (5), and
"Rudder" (2), in that order). Buttons and POVs *appear* to arrive in order and
have undescriptive names (e.g. "Button 0", "Button 1" and "POV 0").
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-21 11:04:22 UTC (rev 45552)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-21 12:52:24 UTC (rev 45553)
@@ -471,6 +471,54 @@
buffer[GUIDSTR_BUFSIZE - 1] = '\0';
}
+
+static BOOL enum_objects_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
+{
+ joystick_device_t *joydev = pvref;
+ joy_priv_t *priv = joydev->priv;
+ DWORD type = lpddoi->dwType;
+
+ if (type & DIDFT_ABSAXIS) {
+ /* Got (absolute) axis */
+ joystick_axis_t *axis;
+ DIPROPRANGE range;
+ HRESULT result;
+
+ axis = joystick_axis_new(lpddoi->tszName);
+ axis->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+
+ /* obtain logical range of axis */
+ range.diph.dwSize = sizeof(DIPROPRANGE);
+ range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ range.diph.dwObj = lpddoi->dwType;
+ range.diph.dwHow = DIPH_BYID;
+ result = IDirectInputDevice8_GetProperty(priv->didev,
+ DIPROP_LOGICALRANGE,
+ &range.diph);
+ if (SUCCEEDED(result)) {
+ axis->minimum = range.lMin;
+ axis->maximum = range.lMax;
+ }
+ joystick_device_add_axis(joydev, axis);
+
+ } else if (type & DIDFT_BUTTON) {
+ /* Got regular (non-toggle) button */
+ joystick_button_t *button = joystick_button_new(lpddoi->tszName);
+
+ button->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+ joystick_device_add_button(joydev, button);
+
+ } else if (type & DIDFT_POV) {
+ /* Got hat (POV) */
+ joystick_hat_t *hat = joystick_hat_new(lpddoi->tszName);
+
+ hat->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+ joystick_device_add_hat(joydev, hat);
+ }
+ return DIENUM_CONTINUE;
+}
+
+#if 0
/** \brief Callback for EnumObjects to enumerate axes
*
* \param[in] lpddoi direct input device object instance
@@ -547,6 +595,7 @@
// log_message(winjoy_log, "POV %d: %s (%u)", joydev->num_hats - 1, hat->name, hat->code);
return DIENUM_CONTINUE;
}
+#endif
/** \brief Callback for IDirectInput8_EnumDevices()
*
@@ -616,7 +665,7 @@
priv->guid = lpddi->guidInstance;
priv->didev = didev;
joydev->priv = priv;
-
+#if 0
/* enumerate (absolute) axes */
IDirectInputDevice8_EnumObjects(didev,
enum_axes_callback,
@@ -633,7 +682,12 @@
enum_hats_callback,
(LPVOID)joydev,
DIDFT_POV);
-
+#else
+ IDirectInputDevice8_EnumObjects(didev,
+ enum_objects_callback,
+ (LPVOID)joydev,
+ DIDFT_ABSAXIS|DIDFT_BUTTON|DIDFT_POV);
+#endif
/* TODO: Open device for polling (until the driver's open() method has been
* properly implemented and tested. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-21 11:04:32
|
Revision: 45552
http://sourceforge.net/p/vice-emu/code/45552
Author: compyx
Date: 2025-03-21 11:04:22 +0000 (Fri, 21 Mar 2025)
Log Message:
-----------
Joystick: reimplement Win32 DirectInput driver
Rewrite DirectInput8 joystick driver. So far the driver enumerates devices and
their axes, buttons and hats (POVs in MS parlance) and their capabilities. The
driver's `open()`, `poll()` and `close()` methods are stubs at the moment.
Also use `DIJOYSTATE2` rather than `DIJOYSTATE` as the data format for the
devices so we can use more axes, buttons and hats if a has them (e.g. XBOX360,
PS4/PS5 controllers).
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
branches/compyx/joymap-001/vice/src/joyport/joystick.c
branches/compyx/joymap-001/vice/src/joyport/joystick.h
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-20 08:37:23 UTC (rev 45551)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_win32_directinput.c 2025-03-21 11:04:22 UTC (rev 45552)
@@ -33,9 +33,11 @@
#include "lib.h"
#define DIRECTINPUT_VERSION 0x0800
+/* required for any GUID stuff, spectacular linker errors on MSYS2 without it */
#define INITGUID
#include <dinput.h>
+#if 0
typedef struct _JoyAxis {
struct _JoyAxis *next;
DWORD id;
@@ -351,3 +353,331 @@
IDirectInput8_EnumDevices(di, DIDEVTYPE_JOYSTICK, EnumCallBack, NULL, DIEDFL_ALLDEVICES);
return 1;
}
+#endif
+
+/*
+ * New API
+ */
+
+/** \brief Private data object
+ *
+ * Contains arch-specific data of a joystick device.
+ */
+typedef struct joy_priv_s {
+ GUID guid; /**< GUID */
+ LPDIRECTINPUTDEVICE8 didev; /**< DirectInput device instance */
+} joy_priv_t;
+
+
+/** \brief DirectInput8 handle
+ *
+ * Initialized during subsystem init.
+ */
+static LPDIRECTINPUT8 dinput_handle = NULL;
+
+/** \brief Window handle */
+static HINSTANCE window_handle = NULL;
+
+/** \brief Log destination for the driver */
+static log_t winjoy_log = LOG_DEFAULT;
+
+
+/** \brief Allocate and initialize private data object
+ *
+ * \return new private data object
+ */
+static joy_priv_t *joy_priv_new(void)
+{
+ joy_priv_t *priv = lib_malloc(sizeof *priv);
+
+ memset(&priv->guid, 0, sizeof(priv->guid));
+ priv->didev = NULL;
+ return priv;
+}
+
+/** \brief Free private data object and its resources
+ *
+ * Unacquire() and Release() the DirectInput device inside \a priv and free
+ * \a priv.
+ *
+ * \param[in] priv private data object
+ */
+static void joy_priv_free(void *priv)
+{
+ joy_priv_t *pr = priv;
+ if (pr->didev != NULL) {
+ IDirectInputDevice_Unacquire(pr->didev);
+ IDirectInputDevice_Release(pr->didev);
+ }
+ lib_free(priv);
+}
+
+
+/*
+ * Driver methods: NOPs for now
+ */
+static bool win32_joy_open(joystick_device_t *joydev) { return true; }
+static void win32_joy_poll(joystick_device_t *joydev) {}
+static void win32_joy_close(joystick_device_t *joydev) {}
+
+
+/** \brief Driver definition */
+static joystick_driver_t win32_joy_driver = {
+ .open = win32_joy_open,
+ .poll = win32_joy_poll,
+ .close = win32_joy_close,
+ .priv_free = joy_priv_free
+};
+
+
+/** \brief Helper for logging errors with DirectInput
+ *
+ * Log error message in the form "<tt>{msg}</tt>: error 0x<tt>{result}</tt>".
+ *
+ * \param[in] msg message
+ * \param[in] result error code
+ */
+static void log_err_helper(const char *msg, HRESULT result)
+{
+ log_error(winjoy_log, "%s: error 0x%08lx", msg, (unsigned long)result);
+}
+
+/** \brief Size of buffer required to store a GUID as string */
+#define GUIDSTR_BUFSIZE 37
+
+/** \brief Generate string from GUID
+ *
+ * Generate string of \a guid and place in \a buffer.
+ * The \a buffer is expected to be at least #GUIDSTR_BUFSIZE bytes, which allows
+ * for the string and its nul terminator.
+ * Format of the string is "01234567-89AB-CDEF-0123-456789ABCDEF".
+ *
+ * \param[in] guid GUID reference
+ * \param[out] buffer destination of GUID string
+ *
+ * \note There is a \c StringFromGUID2() function in \c combaseapi.h, but
+ * that function expects an OLE string, some kind of wide string thing,
+ * so we just do it ourselves here.
+ */
+static void guid_to_str(const GUID *guid, char *buffer)
+{
+ snprintf(buffer, GUIDSTR_BUFSIZE,
+ "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ guid->Data1,
+ guid->Data2,
+ guid->Data3,
+ guid->Data4[0], guid->Data4[1],
+ guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
+ buffer[GUIDSTR_BUFSIZE - 1] = '\0';
+}
+
+/** \brief Callback for EnumObjects to enumerate axes
+ *
+ * \param[in] lpddoi direct input device object instance
+ * \param[in] pvref joystick device
+ *
+ * \return \c DIENUM_CONTINUE
+ */
+static BOOL enum_axes_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
+{
+ joystick_device_t *joydev = pvref;
+ joy_priv_t *priv = joydev->priv;
+ joystick_axis_t *axis;
+ DIPROPRANGE range;
+ HRESULT result;
+
+ axis = joystick_axis_new(lpddoi->tszName);
+ axis->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+
+ /* get logical range */
+ range.diph.dwSize = sizeof(DIPROPRANGE);
+ range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ range.diph.dwObj = lpddoi->dwType;
+ range.diph.dwHow = DIPH_BYID;
+ result = IDirectInputDevice8_GetProperty(priv->didev,
+ DIPROP_LOGICALRANGE,
+ &range.diph);
+ if (SUCCEEDED(result)) {
+ axis->minimum = (int32_t)range.lMin;
+ axis->maximum = (int32_t)range.lMax;
+ }
+
+ /* add axis and continue */
+ joystick_device_add_axis(joydev, axis);
+ // log_message(winjoy_log, "axis %d: %s (%u): [%d - %d]",
+ // joydev->num_axes - 1, axis->name, axis->code, axis->minimum, axis->maximum);
+ return DIENUM_CONTINUE;
+}
+
+/** \brief Callback for EnumObjects to enumerate buttons
+ *
+ * \param[in] lpddoi direct input device object instance
+ * \param[in] pvref joystick device
+ *
+ * \return \c DIENUM_CONTINUE
+ */
+static BOOL enum_buttons_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
+{
+ joystick_device_t *joydev = pvref;
+ joystick_button_t *button;
+
+ button = joystick_button_new(lpddoi->tszName);
+ button->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+ joystick_device_add_button(joydev, button);
+ // log_message(winjoy_log, "button %d: %s (%d)", joydev->num_buttons - 1, button->name, button->code);
+ return DIENUM_CONTINUE;
+}
+
+/** \brief Callback for EnumObjects to enumerate hats (POVs)
+ *
+ * \param[in] lpddoi direct input device object instance
+ * \param[in] pvref joystick device
+ *
+ * \return \c DIENUM_CONTINUE
+ */
+static BOOL enum_hats_callback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvref)
+{
+ joystick_device_t *joydev = pvref;
+ joystick_hat_t *hat;
+
+ hat = joystick_hat_new(lpddoi->tszName);
+ hat->code = DIDFT_GETINSTANCE(lpddoi->dwType);
+
+ joystick_device_add_hat(joydev, hat);
+ // log_message(winjoy_log, "POV %d: %s (%u)", joydev->num_hats - 1, hat->name, hat->code);
+ return DIENUM_CONTINUE;
+}
+
+/** \brief Callback for IDirectInput8_EnumDevices()
+ *
+ *
+ * \param[in] lpddi DirectInput device instance
+ * \param[in] pvref extra data for callback
+ *
+ * \return \c DIENUM_CONTINUE on success, \c DIENUM_STOP on failure
+ */
+static BOOL enum_devices_callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvref)
+{
+ LPDIRECTINPUTDEVICE8 didev;
+ DIDEVCAPS caps;
+ joystick_device_t *joydev;
+ joy_priv_t *priv;
+ HRESULT result;
+ int raxes; /* reported number of axes */
+ int rbuttons; /* reported number of buttons */
+ int rpovs; /* reported number of POVs */
+
+ /* create device instance */
+ result = IDirectInput8_CreateDevice(dinput_handle,
+ &lpddi->guidInstance,
+ &didev,
+ NULL);
+ if (result != DI_OK) {
+ log_err_helper("IDirectInput8::CreateDevice() failed", result);
+ return DIENUM_STOP;
+ }
+
+ /* we want the extended DIJOYSTATE2 data format */
+ IDirectInputDevice8_SetDataFormat(didev, &c_dfDIJoystick2);
+ IDirectInputDevice8_SetCooperativeLevel(didev,
+ (HWND)window_handle,
+ DISCL_NONEXCLUSIVE|DISCL_BACKGROUND);
+
+ /* get capabilities of device */
+ caps.dwSize = sizeof(DIDEVCAPS);
+ result = IDirectInputDevice8_GetCapabilities(didev, &caps);
+ if (result != DI_OK) {
+ log_err_helper("IDirectInput8::GetCapabilities() failed", result);
+ return DIENUM_STOP;
+ }
+
+ /* create VICE device instance */
+ joydev = joystick_device_new();
+ joydev->name = lib_strdup(lpddi->tszProductName);
+ joydev->vendor = (uint16_t)(lpddi->guidProduct.Data1 & 0xffff);
+ joydev->product = (uint16_t)((lpddi->guidProduct.Data1 > 16u) & 0xffff);
+ /* don't set num axes etc here, the joystick_device_add_foo() functions
+ * update the number of inputs when called. */
+ raxes = caps.dwAxes;
+ rbuttons = caps.dwButtons;
+ rpovs = caps.dwPOVs;
+
+ /* generate GUID as string for the node member */
+ joydev->node = lib_calloc(GUIDSTR_BUFSIZE, 1);
+ guid_to_str(&lpddi->guidInstance, joydev->node);
+
+ log_message(winjoy_log,
+ "got device \"%s\" [%04x:%04x] GUID: %s, axes: %d, buttons: %d, POVs: %d",
+ joydev->name, (unsigned int)joydev->vendor, (unsigned int)joydev->product,
+ joydev->node, raxes, rbuttons, rpovs);
+
+ /* store arch-specific data */
+ priv = joy_priv_new();
+ priv->guid = lpddi->guidInstance;
+ priv->didev = didev;
+ joydev->priv = priv;
+
+ /* enumerate (absolute) axes */
+ IDirectInputDevice8_EnumObjects(didev,
+ enum_axes_callback,
+ (LPVOID)joydev,
+ DIDFT_ABSAXIS);
+
+ /* enumerate buttons */
+ IDirectInputDevice8_EnumObjects(didev,
+ enum_buttons_callback,
+ (LPVOID)joydev,
+ DIDFT_BUTTON);
+ /* enumerate POVs */
+ IDirectInputDevice8_EnumObjects(didev,
+ enum_hats_callback,
+ (LPVOID)joydev,
+ DIDFT_POV);
+
+ /* TODO: Open device for polling (until the driver's open() method has been
+ * properly implemented and tested. */
+
+ /* register device and continue */
+ joystick_device_register(joydev);
+ return DIENUM_CONTINUE;
+}
+
+
+/** \brief Initialize driver and enumerate and register devices
+ */
+void win32_joystick_init(void)
+{
+ HRESULT result;
+
+ /* initialize DirectInput for use */
+ winjoy_log = log_open("Joystick");
+ log_message(winjoy_log, "Initializing DirectInput8:");
+ window_handle = GetModuleHandle(NULL);
+ result = DirectInput8Create(window_handle,
+ DIRECTINPUT_VERSION,
+ &IID_IDirectInput8,
+ (void *)&dinput_handle,
+ NULL);
+ if (result != DI_OK) {
+ log_error(winjoy_log,
+ "failed to initialize DirectInput8: 0x%08lx, giving up.",
+ (unsigned long)result);
+ log_close(winjoy_log);
+ return;
+ }
+ log_message(winjoy_log, "OK.");
+
+ /* register driver */
+ joystick_driver_register(&win32_joy_driver);
+
+ /* enumerate devices */
+ log_message(winjoy_log, "Obtaining devices list:");
+ result = IDirectInput8_EnumDevices(dinput_handle,
+ DIDEVTYPE_JOYSTICK,
+ enum_devices_callback,
+ NULL,
+ DIEDFL_ATTACHEDONLY);
+ if (result != DI_OK) {
+ log_err_helper("IDirectInput8::EnumDevices() failed", result);
+ }
+}
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.c
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-20 08:37:23 UTC (rev 45551)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-21 11:04:22 UTC (rev 45552)
@@ -2732,8 +2732,7 @@
#elif defined MAC_JOYSTICK
joy_hidlib_init();
#elif defined HAVE_DINPUT
- if (win32_directinput_joystick_init()) {
- }
+ win32_joystick_init();
#elif defined HAVE_SDL_NUMJOYSTICKS
joy_sdl_init();
#endif
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.h
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-20 08:37:23 UTC (rev 45551)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-21 11:04:22 UTC (rev 45552)
@@ -354,7 +354,7 @@
void bsd_joystick_init(void);
void joy_hidlib_init(void);
void joy_hidlib_exit(void);
-int win32_directinput_joystick_init(void);
+void win32_joystick_init(void);
uint16_t get_joystick_value(int index);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-20 08:37:36
|
Revision: 45551
http://sourceforge.net/p/vice-emu/code/45551
Author: compyx
Date: 2025-03-20 08:37:23 +0000 (Thu, 20 Mar 2025)
Log Message:
-----------
Joystick: fix indentation
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-20 08:33:21 UTC (rev 45550)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-20 08:37:23 UTC (rev 45551)
@@ -189,8 +189,8 @@
{
struct libevdev *evdev;
joy_priv_t *priv;
- int fd;
- int rc;
+ int fd;
+ int rc;
if (joydev == NULL || joydev->node == NULL) {
return false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-20 08:33:42
|
Revision: 45550
http://sourceforge.net/p/vice-emu/code/45550
Author: compyx
Date: 2025-03-20 08:33:21 +0000 (Thu, 20 Mar 2025)
Log Message:
-----------
Joystick: add accessor functions for axes, buttons hats by event code
Add `joystick_axis_from_code()`, `joystick_button_from_code()` and
`joystick_hat_from_code()`, which look up event sources by event code for a
given joystick device.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/joyport/joystick.c
branches/compyx/joymap-001/vice/src/joyport/joystick.h
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.c
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-20 08:04:27 UTC (rev 45549)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-20 08:33:21 UTC (rev 45550)
@@ -3794,3 +3794,69 @@
}
joydev->hats[joydev->num_hats++] = hat;
}
+
+
+/** \brief Look up axis by code
+ *
+ * Look up axis in \a joydev by event \a code.
+ *
+ * \return axis or \c NULL when \a code isn't found
+ */
+joystick_axis_t *joystick_axis_from_code(joystick_device_t *joydev, uint32_t code)
+{
+ int i;
+
+ for (i = 0; i < joydev->num_axes; i++) {
+ if (joydev->axes[i]->code == code) {
+ return joydev->axes[i];
+ } else if (joydev->axes[i]->code > code) {
+ /* codes are in-order: done */
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+
+/** \brief Look up button by code
+ *
+ * Look up button in \a joydev by event \a code.
+ *
+ * \return button or \c NULL when \a code isn't found
+ */
+joystick_button_t *joystick_button_from_code(joystick_device_t *joydev, uint32_t code)
+{
+ int i;
+
+ for (i = 0; i < joydev->num_buttons; i++) {
+ if (joydev->buttons[i]->code == code) {
+ return joydev->buttons[i];
+ } else if (joydev->buttons[i]->code > code) {
+ /* codes are in-order: done */
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+
+/** \brief Look up hat by code
+ *
+ * Look up hat in \a joydev by event \a code.
+ *
+ * \return hat or \c NULL when \a code isn't found
+ */
+joystick_hat_t *joystick_hat_from_code(joystick_device_t *joydev, uint32_t code)
+{
+ int i;
+
+ for (i = 0; i < joydev->num_hats; i++) {
+ if (joydev->hats[i]->code == code) {
+ return joydev->hats[i];
+ } else if (joydev->hats[i]->code > code) {
+ /* codes are in-order: done */
+ return NULL;
+ }
+ }
+ return NULL;
+}
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.h
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-20 08:04:27 UTC (rev 45549)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-20 08:33:21 UTC (rev 45550)
@@ -422,10 +422,18 @@
void joystick_mapping_init (joystick_mapping_t *mapping);
joystick_axis_t *joystick_axis_new (const char *name);
+joystick_axis_t *joystick_axis_from_code (joystick_device_t *joydev,
+ uint32_t code);
void joystick_axis_free (joystick_axis_t *axis);
+
joystick_button_t *joystick_button_new (const char *name);
+joystick_button_t *joystick_button_from_code (joystick_device_t *joydev,
+ uint32_t code);
void joystick_button_free (joystick_button_t *button);
+
joystick_hat_t *joystick_hat_new (const char *name);
+joystick_hat_t *joystick_hat_from_code (joystick_device_t *joydev,
+ uint32_t code);
void joystick_hat_free (joystick_hat_t *hat);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-20 08:04:48
|
Revision: 45549
http://sourceforge.net/p/vice-emu/code/45549
Author: compyx
Date: 2025-03-20 08:04:27 +0000 (Thu, 20 Mar 2025)
Log Message:
-----------
Joystick: update BSD code to use updated driver methods
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c 2025-03-19 22:48:49 UTC (rev 45548)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_bsd.c 2025-03-20 08:04:27 UTC (rev 45549)
@@ -226,8 +226,8 @@
/* Forward declarations */
-static bool bsd_joy_open (int joyport, joystick_device_t *joydev);
-static void bsd_joy_poll (int joyport, joystick_device_t *joydev);
+static bool bsd_joy_open (joystick_device_t *joydev);
+static void bsd_joy_poll (joystick_device_t *joydev);
static void bsd_joy_close(joystick_device_t *joydev);
static void joy_priv_free(void *priv);
@@ -298,13 +298,13 @@
}
-static bool bsd_joy_open (int joyport, joystick_device_t *joydev)
+static bool bsd_joy_open (joystick_device_t *joydev)
{
return true; /* NOP */
}
-static int joy_axis_index(joystick_device_t *joydev, uint16_t code)
+static int joy_axis_index(joystick_device_t *joydev, uint32_t code)
{
int i;
@@ -311,14 +311,14 @@
for (i = 0; i < joydev->num_axes; i++) {
if (joydev->axes[i]->code == code) {
return i;
+ } else if (joydev->axes[i]->code > code) {
+ return -1;
}
- /* axis codes are *not* stored in-order like with Linux evdev, so we
- * must finish the loop */
}
return -1;
}
-static int joy_button_index(joystick_device_t *joydev, uint16_t code)
+static int joy_button_index(joystick_device_t *joydev, uint32_t code)
{
int i;
@@ -325,14 +325,14 @@
for (i = 0; i < joydev->num_buttons; i++) {
if (joydev->buttons[i]->code == code) {
return i;
+ } else if (joydev->buttons[i]->code > code) {
+ return -1;
}
- /* button codes are *not* stored in-order like with Linux evdev, so we
- * must finish the loop */
}
return -1;
}
-static int joy_hat_index(joystick_device_t *joydev, uint16_t code)
+static int joy_hat_index(joystick_device_t *joydev, uint32_t code)
{
int i;
@@ -339,15 +339,15 @@
for (i = 0; i < joydev->num_hats; i++) {
if (joydev->hats[i]->code == code) {
return i;
+ } else if (joydev->hats[i]->code > code) {
+ return -1;
}
- /* hat codes are *not* stored in-order like with Linux evdev, so we
- * must finish the loop */
}
return -1;
}
-static void bsd_joy_poll(int joyport, joystick_device_t *joydev)
+static void bsd_joy_poll(joystick_device_t *joydev)
{
joy_priv_t *priv = joydev->priv;
@@ -381,7 +381,7 @@
case HUG_RZ: /* fall through */
case HUG_SLIDER:
/* axis */
- index = joy_axis_index(joydev, (uint16_t)usage);
+ index = joy_axis_index(joydev, (uint32_t)usage);
if (index >= 0) {
joystick_axis_t *axis = joydev->axes[index];
joystick_axis_value_t direction = JOY_AXIS_MIDDLE;
@@ -390,21 +390,27 @@
printf("%s(): AXIS: index = %d, usage = %d, value = %d\n",
__func__, index, usage, value);
#endif
- /* FIXME: some on my Logitech F710 the Y axis is inverted */
+ /* XXX: On my Logitech F710 the Y axis is inverted by
+ * FreeBSD, NetBSD just reports insane values.
+ * So for FreeBSD we'd need calibration to be
+ * implemented for the F710 to work.
+ */
if (value <= (axis->minimum + (range / 4))) {
direction = JOY_AXIS_NEGATIVE;
} else if (value >= (axis->maximum - (range / 4))) {
direction = JOY_AXIS_POSITIVE;
}
- joy_axis_event(joyport, (uint8_t)index, direction);
+ joy_axis_event(joydev, axis, direction);
}
break;
case HUG_HAT_SWITCH:
/* hat */
- index = joy_hat_index(joydev, (uint16_t)usage);
+ index = joy_hat_index(joydev, (uint32_t)usage);
if (index >= 0) {
- joy_hat_event(joyport, (uint8_t)index, (uint8_t)value);
+ joy_hat_event(joydev,
+ joydev->hats[index],
+ (int32_t)value);
}
break;
@@ -413,9 +419,11 @@
case HUG_D_PAD_LEFT: /* fall through */
case HUG_D_PAD_RIGHT:
/* D-Pad is mapped as buttons */
- index = joy_button_index(joydev, (uint16_t)usage);
+ index = joy_button_index(joydev, (uint32_t)usage);
if (index >= 0) {
- joy_button_event(joyport, (uint8_t)index, (uint8_t)value);
+ joy_button_event(joydev,
+ joydev->buttons[index],
+ (int32_t)value);
}
break;
default:
@@ -424,9 +432,11 @@
break;
case HUP_BUTTON:
/* button event */
- index = joy_button_index(joydev, (uint16_t)usage);
+ index = joy_button_index(joydev, (uint32_t)usage);
if (index >= 0) {
- joy_button_event(joyport, (uint8_t)index, (uint8_t)value);
+ joy_button_event(joydev,
+ joydev->buttons[index],
+ (int32_t)value);
}
break;
default:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-19 22:49:01
|
Revision: 45548
http://sourceforge.net/p/vice-emu/code/45548
Author: compyx
Date: 2025-03-19 22:48:49 +0000 (Wed, 19 Mar 2025)
Log Message:
-----------
joystick: SDL: make building against SDL 1.2 work again
Work around limited features of ancient SDL 1.2.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/sdl/joy.c
branches/compyx/joymap-001/vice/src/arch/sdl/ui.c
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/joy.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/joy.c 2025-03-19 21:46:40 UTC (rev 45547)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/joy.c 2025-03-19 22:48:49 UTC (rev 45548)
@@ -185,7 +185,6 @@
typedef struct joy_priv_s {
- SDL_JoystickGUID guid;
SDL_Joystick *sdldev;
VICE_SDL_JoystickID id;
int joynum;
@@ -198,8 +197,11 @@
priv->sdldev = sdldev;
priv->joynum = joynum;
- priv->guid = SDL_JoystickGetGUID(sdldev);
+#ifdef USE_SDL2UI
priv->id = SDL_JoystickInstanceID(sdldev);
+#else
+ priv->id = (VICE_SDL_JoystickID)joynum;
+#endif
return priv;
}
@@ -251,7 +253,11 @@
char buffer[64];
int i;
+#ifdef USE_SDL2UI
name = SDL_JoystickName(sdldev);
+#else
+ name = SDL_JoystickName(index);
+#endif
if (name != NULL) {
joydev->name = lib_strdup(name);
} else {
@@ -259,8 +265,10 @@
"couldn't retrieve joystick name: %s.", SDL_GetError());
joydev->name = lib_msprintf("Joystick_%d", index + 1);
}
+#ifdef USE_SDL2UI
joydev->vendor = SDL_JoystickGetVendor(sdldev);
joydev->product = SDL_JoystickGetProduct(sdldev);
+#endif
joydev->priv = priv;
/* enumerate axes */
@@ -270,8 +278,10 @@
snprintf(buffer, sizeof buffer, "Axis_%d", i + 1);
axis = joystick_axis_new(buffer);
axis->code = i;
+#ifdef USE_SDL2UI
axis->minimum = SDL_JOYSTICK_AXIS_MIN;
axis->maximum = SDL_JOYSTICK_AXIS_MAX;
+#endif
joystick_device_add_axis(joydev, axis);
}
@@ -312,9 +322,11 @@
log_message(sdljoy_log, "Got %d potential devices.", njoys);
for (num = 0; num < njoys; num++) {
+#ifdef USE_SDL2UI
log_message(sdljoy_log,
"SDL_JoystickNameForIndex(%d) = \"%s\"",
num, SDL_JoystickNameForIndex(num));
+#endif
}
for (num = 0; num < njoys; num++) {
SDL_Joystick *sdldev = SDL_JoystickOpen(num);
@@ -469,6 +481,7 @@
int count = joystick_device_count();
if (count > 0) {
+#ifdef USE_SDL2UI
int i;
for (i = 0; i < count; i++) {
@@ -485,6 +498,14 @@
return true;
}
}
+#else
+ if (joy_device != NULL) {
+ *joy_device = joystick_device_by_index((int)device_id);
+ }
+ if (joy_index != NULL) {
+ *joy_index = (int)device_id;
+ }
+#endif
}
return false;
}
@@ -492,26 +513,35 @@
joystick_device_t *sdljoy_get_joydev_for_event(VICE_SDL_JoystickID event_device_id)
{
- int i;
int count;
count = joystick_device_count();
- for (i = 0; i < count; i++) {
- joystick_device_t *joydev = joystick_device_by_index(i);
+ if (count > 0) {
+#ifdef USE_SDL2UI
+ int i;
- if (joydev != NULL) {
- joy_priv_t *priv = joydev->priv;
+ for (i = 0; i < count; i++) {
+ joystick_device_t *joydev = joystick_device_by_index(i);
- if (priv->id == event_device_id) {
- return joydev;
+ if (joydev != NULL) {
+ joy_priv_t *priv = joydev->priv;
+
+ if (priv->id == event_device_id) {
+ return joydev;
+ }
}
}
+#else
+ return joystick_device_by_index((int)event_device_id);
+#endif
}
+ return NULL;
}
int sdljoy_get_joynum_for_event(VICE_SDL_JoystickID event_device_id)
{
+#ifdef USE_SDL2UI
int i;
int count;
@@ -528,6 +558,10 @@
}
}
return -1;
+#else
+ /* SDL 1.2 doesn't have instance IDs, just indexes */
+ return (int)event_device_id;
+#endif
}
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/ui.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/ui.c 2025-03-19 21:46:40 UTC (rev 45547)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/ui.c 2025-03-19 22:48:49 UTC (rev 45548)
@@ -262,7 +262,6 @@
while (SDL_PollEvent(&e)) {
joystick_device_t *joydev = NULL;
joystick_button_t *button = NULL;
- joystick_hat_t *hat = NULL;
switch (e.type) {
case SDL_KEYDOWN:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-19 21:46:42
|
Revision: 45547
http://sourceforge.net/p/vice-emu/code/45547
Author: compyx
Date: 2025-03-19 21:46:40 +0000 (Wed, 19 Mar 2025)
Log Message:
-----------
Joystick: fix SDL UI to use updated joystick event functions
Only tested with SDL 2.x so far.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/sdl/joy.c
branches/compyx/joymap-001/vice/src/arch/sdl/joy.h
branches/compyx/joymap-001/vice/src/arch/sdl/ui.c
branches/compyx/joymap-001/vice/src/arch/sdl/uimenu.c
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/joy.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/joy.c 2025-03-19 15:39:19 UTC (rev 45546)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/joy.c 2025-03-19 21:46:40 UTC (rev 45547)
@@ -164,12 +164,12 @@
/* ------------------------------------------------------------------------- */
-static bool sdl_joystick_open(int joyport, joystick_device_t *joydev)
+static bool sdl_joystick_open(joystick_device_t *joydev)
{
return true;
}
-static void sdl_joystick_poll(int joyport, joystick_device_t *joydev)
+static void sdl_joystick_poll(joystick_device_t *joydev)
{
/* NOP: handled in SDL event loop */
}
@@ -461,6 +461,55 @@
return 0;
}
+
+bool sdljoy_get_joy_for_event(VICE_SDL_JoystickID device_id,
+ joystick_device_t **joy_device,
+ int *joy_index)
+{
+ int count = joystick_device_count();
+
+ if (count > 0) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ joystick_device_t *joydev = joystick_device_by_index(i);
+ joy_priv_t *priv = joydev->priv;
+
+ if (priv->id == device_id) {
+ if (joy_device != NULL) {
+ *joy_device = joydev;
+ }
+ if (joy_index != NULL) {
+ *joy_index = i;
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+joystick_device_t *sdljoy_get_joydev_for_event(VICE_SDL_JoystickID event_device_id)
+{
+ int i;
+ int count;
+
+ count = joystick_device_count();
+ for (i = 0; i < count; i++) {
+ joystick_device_t *joydev = joystick_device_by_index(i);
+
+ if (joydev != NULL) {
+ joy_priv_t *priv = joydev->priv;
+
+ if (priv->id == event_device_id) {
+ return joydev;
+ }
+ }
+ }
+}
+
+
int sdljoy_get_joynum_for_event(VICE_SDL_JoystickID event_device_id)
{
int i;
@@ -481,6 +530,9 @@
return -1;
}
+
+
+
static joystick_mapping_t *sdljoy_get_mapping(SDL_Event e)
{
joystick_mapping_t *retval = NULL;
@@ -593,15 +645,17 @@
return cur;
}
-void sdljoy_axis_event(Uint8 joynum, Uint8 axis, Sint16 value)
+void sdljoy_axis_event(Uint8 joynum, Uint8 axisnum, Sint16 value)
{
+ joystick_device_t *joydev = joystick_device_by_index(joynum);
+ joystick_axis_t *axis = joydev->axes[axisnum];
joystick_axis_value_t cur, prev;
- prev = joy_axis_prev(joynum, axis);
+ prev = joy_axis_prev(joynum, axisnum);
cur = sdljoy_axis_direction(value, prev);
- joy_axis_event(joynum, axis, cur);
+ joy_axis_event(joydev, axis, cur);
}
static ui_menu_action_t sdljoy_perform_event_for_menu_action(joystick_mapping_t* event, Sint16 value)
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/joy.h
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/joy.h 2025-03-19 15:39:19 UTC (rev 45546)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/joy.h 2025-03-19 21:46:40 UTC (rev 45547)
@@ -34,7 +34,7 @@
#include "types.h"
#include "vice_sdl.h"
-
+#include "joystick.h"
#include "uimenu.h"
void joystick_close(void);
@@ -59,7 +59,12 @@
void sdljoy_unset(SDL_Event e);
void sdljoy_set_joystick_axis(SDL_Event e, int pot);
void sdljoy_delete_extra_mapping(int type);
+joystick_device_t *sdljoy_get_joydev_for_event(VICE_SDL_JoystickID event_device_id);
int sdljoy_get_joynum_for_event(VICE_SDL_JoystickID event_device_id);
+bool sdljoy_get_joy_for_event(VICE_SDL_JoystickID device_id,
+ joystick_device_t **joy_device,
+ int *joy_index);
+
int sdljoy_rescan(void);
void sdljoy_clear_presses(void);
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/ui.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/ui.c 2025-03-19 15:39:19 UTC (rev 45546)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/ui.c 2025-03-19 21:46:40 UTC (rev 45547)
@@ -260,6 +260,10 @@
int joynum;
while (SDL_PollEvent(&e)) {
+ joystick_device_t *joydev = NULL;
+ joystick_button_t *button = NULL;
+ joystick_hat_t *hat = NULL;
+
switch (e.type) {
case SDL_KEYDOWN:
ui_display_kbd_status(&e);
@@ -271,28 +275,21 @@
break;
#ifdef HAVE_SDL_NUMJOYSTICKS
case SDL_JOYAXISMOTION:
- joynum = sdljoy_get_joynum_for_event((VICE_SDL_JoystickID)e.jaxis.which);
- if (joynum != -1) {
+ if (sdljoy_get_joy_for_event((VICE_SDL_JoystickID)e.jaxis.which, &joydev, &joynum)) {
sdljoy_axis_event(joynum, e.jaxis.axis, e.jaxis.value);
joystick_set_axis_value(joynum, e.jaxis.axis, (uint8_t)((~e.jaxis.value + 32768) >> 8));
}
break;
- case SDL_JOYBUTTONDOWN:
- joynum = sdljoy_get_joynum_for_event((VICE_SDL_JoystickID)e.jaxis.which);
- if (joynum != -1) {
- joy_button_event(joynum, e.jbutton.button, 1);
- }
- break;
+ case SDL_JOYBUTTONDOWN: /* fall through */
case SDL_JOYBUTTONUP:
- joynum = sdljoy_get_joynum_for_event((VICE_SDL_JoystickID)e.jaxis.which);
- if (joynum != -1) {
- joy_button_event(joynum, e.jbutton.button, 0);
+ if (sdljoy_get_joy_for_event((VICE_SDL_JoystickID)e.jbutton.which, &joydev, &joynum)) {
+ button = joydev->buttons[e.jbutton.button];
+ joy_button_event(joydev, button, e.type == SDL_JOYBUTTONDOWN ? 1: 0);
}
break;
case SDL_JOYHATMOTION:
- joynum = sdljoy_get_joynum_for_event((VICE_SDL_JoystickID)e.jaxis.which);
- if (joynum != -1) {
- joy_hat_event(joynum, e.jhat.hat, hat_map[e.jhat.value]);
+ if (sdljoy_get_joy_for_event((VICE_SDL_JoystickID)e.jaxis.which, &joydev, &joynum)) {
+ joy_hat_event(joydev, joydev->hats[e.jhat.hat], hat_map[e.jhat.value]);
}
break;
#endif
Modified: branches/compyx/joymap-001/vice/src/arch/sdl/uimenu.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/sdl/uimenu.c 2025-03-19 15:39:19 UTC (rev 45546)
+++ branches/compyx/joymap-001/vice/src/arch/sdl/uimenu.c 2025-03-19 21:46:40 UTC (rev 45547)
@@ -1163,6 +1163,9 @@
#endif
do {
+ joystick_device_t *joydev = NULL;
+ int joynum = -1;
+
SDL_WaitEvent(&e);
switch (e.type) {
@@ -1198,13 +1201,22 @@
#ifdef HAVE_SDL_NUMJOYSTICKS
case SDL_JOYAXISMOTION:
- sdljoy_axis_event(e.jaxis.which, e.jaxis.axis, e.jaxis.value);
+ if (sdljoy_get_joy_for_event(e.jaxis.which, &joydev, &joynum)) {
+ sdljoy_axis_event(joynum, e.jaxis.axis, e.jaxis.value);
+ }
break;
- case SDL_JOYBUTTONDOWN:
- joy_button_event(e.jbutton.which, e.jbutton.button, 1);
+ case SDL_JOYBUTTONDOWN: /* fall through */
+ case SDL_JOYBUTTONUP:
+ if (sdljoy_get_joy_for_event(e.jbutton.which, &joydev, &joynum)) {
+ joy_button_event(joydev,
+ joydev->buttons[e.jbutton.button],
+ e.type == SDL_JOYBUTTONDOWN ? 1 : 0);
+ }
break;
case SDL_JOYHATMOTION:
- joy_hat_event(e.jhat.which, e.jhat.hat, e.jhat.value);
+ if (sdljoy_get_joy_for_event(e.jhat.which, &joydev, &joynum)) {
+ joy_hat_event(joydev, joydev->hats[e.jhat.hat], e.jhat.value);
+ }
break;
#endif
default:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2025-03-19 15:39:22
|
Revision: 45546
http://sourceforge.net/p/vice-emu/code/45546
Author: compyx
Date: 2025-03-19 15:39:19 +0000 (Wed, 19 Mar 2025)
Log Message:
-----------
Joystick: get rid of `joyport` argument in driver methods, pass objects, not indexes
The `joyport` argument to `poll()` and `open()` was not actually a joystick port
number, but the index of the joystick device in the registered devices list.
We already pass the device, so no need to do indexed lookups for something we
already have.
Also change the joy event handlers to accept (joystick-device, event-object,
event-value) instead of indexes requiring more lookups. The event values are
still "cooked" by the drivers and should be passed raw so the common joystick
code becomes responsible for determining the right value (inside the event
objects is all the data required for this). This should result in simpler and
easier to maintain drivers.
So far only the Linux evdev driver has been updated the changed methods, the
rest will follow soon.
Modified Paths:
--------------
branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
branches/compyx/joymap-001/vice/src/joyport/joystick.c
branches/compyx/joymap-001/vice/src/joyport/joystick.h
Modified: branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c
===================================================================
--- branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-18 21:16:53 UTC (rev 45545)
+++ branches/compyx/joymap-001/vice/src/arch/gtk3/joystickdrv/joystick_linux_evdev.c 2025-03-19 15:39:19 UTC (rev 45546)
@@ -136,13 +136,10 @@
/** \brief Dispatcher for joystick events
*
- * \param[in] joyport joystick port index
* \param[in] joydev joystick device instance
* \param[in] event event data
*/
-static void dispatch_event(int joyport,
- joystick_device_t *joydev,
- struct input_event *event)
+static void dispatch_event(joystick_device_t *joydev, struct input_event *event)
{
joy_priv_t *priv = joydev->priv;
int index;
@@ -155,7 +152,7 @@
#endif
index = priv->button_index[event->code - BUTTON_CODE_MIN];
if (index >= 0) {
- joy_button_event((uint8_t)joyport, (uint8_t)index, (uint8_t)event->value);
+ joy_button_event(joydev, joydev->buttons[index], event->value);
}
} else if (event->type == EV_ABS) {
#if 0
@@ -165,10 +162,11 @@
#endif
index = priv->axis_index[event->code - AXIS_CODE_MIN];
if (index >= 0) {
- int32_t minimum = joydev->axes[index]->minimum;
- int32_t maximum = joydev->axes[index]->maximum;
- int32_t range = maximum - minimum + 1;
- joystick_axis_value_t direction = JOY_AXIS_MIDDLE;
+ joystick_axis_t *axis = joydev->axes[index];
+ int32_t minimum = axis->minimum;
+ int32_t maximum = axis->maximum;
+ int32_t range = maximum - minimum;
+ joystick_axis_value_t direction = JOY_AXIS_MIDDLE;
/* ABS_HAT[0-3]XY axes return -1, 0 or 1: */
if (minimum == -1 && maximum == 1) {
@@ -182,12 +180,12 @@
} else if (event->value > (maximum - (range / 4))) {
direction = JOY_AXIS_POSITIVE;
}
- joy_axis_event((uint8_t)joyport, (uint8_t)index, direction);
+ joy_axis_event(joydev, axis, direction);
}
}
}
-static bool linux_joystick_evdev_open(int joyport, joystick_device_t *joydev)
+static bool linux_joystick_evdev_open(joystick_device_t *joydev)
{
struct libevdev *evdev;
joy_priv_t *priv;
@@ -220,10 +218,9 @@
/** \brief Poll callback for the joystick system
*
- * \param[in] joyport joystick port index
* \param[in] priv driver-specific joystick data
*/
-static void linux_joystick_evdev_poll(int joyport, joystick_device_t *joydev)
+static void linux_joystick_evdev_poll(joystick_device_t *joydev)
{
struct libevdev *evdev;
joy_priv_t *priv;
@@ -243,7 +240,7 @@
}
} else if (rc == LIBEVDEV_READ_STATUS_SUCCESS) {
if (event.type == EV_ABS || event.type == EV_KEY) {
- dispatch_event(joyport, joydev, &event);
+ dispatch_event(joydev, &event);
}
}
}
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.c
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-18 21:16:53 UTC (rev 45545)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.c 2025-03-19 15:39:19 UTC (rev 45546)
@@ -2998,10 +2998,10 @@
}
-void joy_axis_event(uint8_t joynum, uint8_t axis_index, joystick_axis_value_t value)
+void joy_axis_event(joystick_device_t *joydev,
+ joystick_axis_t *axis,
+ joystick_axis_value_t value)
{
- joystick_device_t *joydev = joystick_devices[joynum];
- joystick_axis_t *axis = joydev->axes[axis_index];
joystick_axis_value_t prev = axis->prev;
int joyport = joydev->joyport;
@@ -3009,7 +3009,8 @@
return;
}
- DBG(("joy_axis_event: joynum: %d axis: %d value: %u prev: %u\n", joynum, axis, value, prev));
+ DBG(("joy_axis_event: joy: %s axis: %d value: %d prev: %u\n",
+ joydev->name, axis->index, value, prev));
/* release directions first if needed */
if (prev == JOY_AXIS_POSITIVE) {
@@ -3030,10 +3031,11 @@
axis->prev = value;
}
-void joy_button_event(uint8_t joynum, uint8_t button, uint8_t value)
+void joy_button_event(joystick_device_t *joydev,
+ joystick_button_t *button,
+ int32_t value)
{
- joystick_device_t *joydev = joystick_devices[joynum];
- int32_t pressed = value ? 1 : 0;
+ int32_t pressed = value ? 1 : 0;
#if 0
int num_buttons = joystick_devices[joynum].num_buttons;
int joy_pin = joystick_devices[joynum].button_mapping[button].value.joy_pin;
@@ -3047,29 +3049,27 @@
}
}
#endif
- if (pressed != joydev->buttons[button]->prev) {
- DBG(("joy_button_event: joynum: %d, button: %d pressed: %d\n",
- joynum, button, pressed));
- joy_perform_event(&joydev->buttons[button]->mapping,
- joydev->joyport,
- pressed);
- joydev->buttons[button]->prev = pressed;
+ if (pressed != button->prev) {
+ DBG(("joy_button_event: joy: %s, button: %d (%s) pressed: %d\n",
+ joydev->name, button->index, button->name, pressed));
+ joy_perform_event(&button->mapping, joydev->joyport, pressed);
+ button->prev = pressed;
}
}
-void joy_hat_event(uint8_t joynum, uint8_t hat_idx, uint8_t value)
+
+void joy_hat_event(joystick_device_t *joydev,
+ joystick_hat_t *hat,
+ int32_t value)
{
- joystick_device_t *joydev = joystick_devices[joynum];
- joystick_hat_t *hat = joydev->hats[hat_idx];
- int joyport = joydev->joyport;
- int32_t prev = hat->prev;
+ int joyport = joydev->joyport;
+ int32_t prev = hat->prev;
if (value == prev) {
return;
}
- joyport = joystick_devices[joynum]->joyport;
- DBG(("joy_hat_event:\n"));
+ DBG(("joy_hat_event (%s): %d\n", hat->name, value));
/* release directions first if needed */
if (prev & JOYSTICK_DIRECTION_UP && !(value & JOYSTICK_DIRECTION_UP)) {
joy_perform_event(&hat->mapping.up, joyport, 0);
@@ -3216,7 +3216,7 @@
int i;
for (i = 0; i < num_joystick_devices; i++) {
- joy_driver.poll(i, joystick_devices[i]);
+ joy_driver.poll(joystick_devices[i]);
}
}
}
Modified: branches/compyx/joymap-001/vice/src/joyport/joystick.h
===================================================================
--- branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-18 21:16:53 UTC (rev 45545)
+++ branches/compyx/joymap-001/vice/src/joyport/joystick.h 2025-03-19 15:39:19 UTC (rev 45546)
@@ -307,11 +307,11 @@
* this somehow?).
*/
typedef struct joystick_driver_s {
- /** \brief Open host device for specific machine port */
- bool (*open) (int, joystick_device_t *);
+ /** \brief Open host device for use */
+ bool (*open) (joystick_device_t *);
- /** \brief Poll host device for specific machine port */
- void (*poll) (int, joystick_device_t *);
+ /** \brief Poll host device */
+ void (*poll) (joystick_device_t *);
/** \brief Close host device */
void (*close) (joystick_device_t *);
@@ -366,9 +366,17 @@
extern int joystick_port_map[JOYPORT_MAX_PORTS];
void joystick_set_snes_mapping(int port);
-void joy_axis_event(uint8_t joynum, uint8_t axis, joystick_axis_value_t value);
-void joy_button_event(uint8_t joynum, uint8_t button, uint8_t value);
-void joy_hat_event(uint8_t joynum, uint8_t button, uint8_t value);
+
+/* TODO: Pass raw value to joy_axis_event(), let the joystick code figure out
+ * what the axis value should be, based on limits and calibration data
+ * inside the axis object.
+ * Same for buttons and hats: let the joystick code decide what to do,
+ * not the driver.
+ */
+void joy_axis_event (joystick_device_t *joydev, joystick_axis_t *axis, joystick_axis_value_t value);
+void joy_button_event(joystick_device_t *joydev, joystick_button_t *button, int32_t value);
+void joy_hat_event (joystick_device_t *joydev, joystick_hat_t *hat, int32_t value);
+
void joystick(void);
void joystick_close(void);
void joystick_resources_shutdown(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|