Skip to content

Conversation

kakra
Copy link
Collaborator

@kakra kakra commented Mar 28, 2021

Todo:

  • Add support for mouse buttons (left, right, forward, backward)
  • Add support for scrolling
  • Add support for simple keyboard events (cursor keys, enter, escape)
  • Add support for haptic feedback on button clicks
  • Re-structure into separate source-code files just before v0.10 release so we can still back-port fixes until then
  • Test profile switching with XBE2 controller

@kakra kakra added this to the v0.10 milestone Mar 28, 2021
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 3 times, most recently from 1bcec4b to 632d509 Compare April 1, 2021 20:57
This was referenced Apr 1, 2021
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 5 times, most recently from 67dbffd to 6f3058f Compare April 3, 2021 16:48
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 2 times, most recently from 6951ccd to 9856f89 Compare April 12, 2021 19:26
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 3 times, most recently from 1f49e7c to 77ecd72 Compare June 25, 2021 21:28
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 2 times, most recently from 217abf9 to 43919e5 Compare July 6, 2021 21:22
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 43919e5 to 0dfa5bd Compare August 28, 2021 21:37
@JonisK JonisK mentioned this pull request Jan 9, 2022
26 tasks
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 0dfa5bd to b7fac5d Compare March 6, 2022 20:24
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from b7fac5d to 6b89563 Compare April 30, 2022 11:39
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 6b89563 to 26a0ecc Compare May 9, 2022 06:44
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 3 times, most recently from a9a4633 to 0a2226b Compare May 30, 2022 22:30
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 0a2226b to 118d57c Compare September 17, 2022 20:28
@kakra kakra mentioned this pull request Jan 28, 2024
41 tasks
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 118d57c to 1873fb9 Compare February 23, 2024 00:40
kakra added a commit to kakra/xpadneo that referenced this pull request Mar 4, 2024
To properly sync our multiple sub-devices, we need to synchronize the
input frame in xpadneo instead of the generic HID handler, otherwise
we may see input late or duplicated.

See-also: atar-axis#460
See-also: atar-axis#282
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit that referenced this pull request Mar 4, 2024
To properly sync our multiple sub-devices, we need to synchronize the
input frame in xpadneo instead of the generic HID handler, otherwise
we may see input late or duplicated.

See-also: #460
See-also: #282
Signed-off-by: Kai Krakow <[email protected]>
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 2 times, most recently from f16f26f to d4539af Compare March 4, 2024 00:51
@kakra kakra marked this pull request as ready for review March 4, 2024 00:51
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch 2 times, most recently from f9ffcf5 to 55715d0 Compare March 4, 2024 01:35
@kakra kakra added 1 | state: testing solution Solution is in testing phase and removed 1 | state: work in progress labels Mar 4, 2024
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 55715d0 to 89b24ac Compare April 22, 2024 22:17
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 89b24ac to 55466f5 Compare November 24, 2024 14:22
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 55466f5 to ffbb921 Compare December 2, 2024 18:49
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from ffbb921 to 447f301 Compare December 19, 2024 23:04
Co-authored-by: Jacob Essex <[email protected]>
Co-authored-by: Florian Dollinger <[email protected]>
Closes: atar-axis#99
Closes: atar-axis#105
Closes: atar-axis#160
Closes: atar-axis#511
Fixes: atar-axis#333
See-also: atar-axis#419
See-also: atar-axis#435
Signed-off-by: Kai Krakow <[email protected]>
@kakra kakra force-pushed the queue/reimplement-mouse-mode branch from 447f301 to c5620e8 Compare December 23, 2024 13:02
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit c5620e8 and detected 0 issues on this pull request.

View more on Code Climate.

@kakra kakra requested a review from Copilot September 19, 2025 09:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reimplements the mouse mode functionality for Xbox controllers, adding support for mouse buttons, scrolling, and basic keyboard events. The implementation includes timer-based mouse movement reporting and maps controller inputs to mouse and keyboard actions.

  • Adds a new mouse.c file with comprehensive mouse emulation functionality
  • Implements timer-based mouse movement and scrolling with error accumulation
  • Maps controller inputs to mouse buttons, cursor keys, and special functions

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
hid-xpadneo/src/xpadneo/mouse.c New file implementing complete mouse emulation with analog stick movement, button mapping, and keyboard event handling
hid-xpadneo/src/xpadneo/keyboard.c Adds keyboard capabilities for mouse mode (arrow keys, Enter, Escape)
hid-xpadneo/src/xpadneo/core.c Adds mouse synchronization support and consumer control error handling
hid-xpadneo/src/xpadneo/consumer.c Enables on-screen keyboard capability for mouse mode
hid-xpadneo/src/xpadneo.h Adds mouse-related data structures, timer, and function declarations
hid-xpadneo/src/hid-xpadneo.c Integrates mouse functionality into main driver with timer setup and event routing
hid-xpadneo/src/Makefile Includes mouse.c in the build
docs/README.md Documents mouse mode usage and controls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

xdata->profile_switched = true;
}

#define mouse_report_rel(a,v) if((v)!=0)input_report_rel(mouse,(a),(v))
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro lacks spaces around operators and parameters, making it hard to read. Consider reformatting as #define mouse_report_rel(a, v) if ((v) != 0) input_report_rel(mouse, (a), (v))

Suggested change
#define mouse_report_rel(a,v) if((v)!=0)input_report_rel(mouse,(a),(v))
#define mouse_report_rel(a, v) if ((v) != 0) input_report_rel(mouse, (a), (v))

Copilot uses AI. Check for mistakes.

}

#define rescale_axis(v,d) (((v)<(d)&&(v)>-(d))?0:(32768*((v)>0?(v)-(d):(v)+(d))/(32768-(d))))
#define digipad(v,v1,v2,v3) (((v==(v1))||(v==(v2))||(v==(v3)))?1:0)
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These macros contain complex logic with magic numbers (3072, 32768) and lack spacing around operators. Consider replacing with properly formatted inline functions with descriptive parameter names and documented constants.

Suggested change
#define digipad(v,v1,v2,v3) (((v==(v1))||(v==(v2))||(v==(v3)))?1:0)
/**
* digipad - Check if value matches any of three possible values.
* @value: The value to check.
* @v1: First possible value.
* @v2: Second possible value.
* @v3: Third possible value.
*
* Returns 1 if value equals v1, v2, or v3; otherwise returns 0.
*/
static inline int digipad(int value, int v1, int v2, int v3)
{
return (value == v1) || (value == v2) || (value == v3);
}

Copilot uses AI. Check for mistakes.

Comment on lines +118 to +121
input_report_key(keyboard, KEY_UP, digipad(value, 8, 1, 2));
input_report_key(keyboard, KEY_RIGHT, digipad(value, 2, 3, 4));
input_report_key(keyboard, KEY_DOWN, digipad(value, 4, 5, 6));
input_report_key(keyboard, KEY_LEFT, digipad(value, 6, 7, 8));
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic numbers (1, 2, 3, 4, 5, 6, 7, 8) representing directional values should be defined as named constants to improve code readability and maintainability.

Copilot uses AI. Check for mistakes.

xdata->mouse_state.wheel_y = rescale_axis(value - 32768, 3072);
return 1;
case ABS_RZ:
if (xdata->mouse_state.analog_button.left && value < 384) {
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threshold values 384 and 640 are magic numbers that should be defined as named constants to clarify their purpose and make them easier to maintain.

Copilot uses AI. Check for mistakes.

xdata->mouse_state.analog_button.left = false;
input_report_key(mouse, BTN_LEFT, 0);
xdata->mouse_sync = true;
} else if (!xdata->mouse_state.analog_button.left && value > 640) {
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threshold values 384 and 640 are magic numbers that should be defined as named constants to clarify their purpose and make them easier to maintain.

Copilot uses AI. Check for mistakes.

}
return 1;
case ABS_Z:
if (xdata->mouse_state.analog_button.right && value < 384) {
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threshold values 384 and 640 are magic numbers that should be defined as named constants to clarify their purpose and make them easier to maintain.

Copilot uses AI. Check for mistakes.

xdata->mouse_state.analog_button.right = false;
input_report_key(mouse, BTN_RIGHT, 0);
xdata->mouse_sync = true;
} else if (!xdata->mouse_state.analog_button.right && value > 640) {
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threshold values 384 and 640 are magic numbers that should be defined as named constants to clarify their purpose and make them easier to maintain.

Copilot uses AI. Check for mistakes.

* Supports customization through profiles (work in progress)
* Optional high-precision mode for Wine/Proton users (disables dead zones so games don't apply an additional one)
* Share button support on supported controllers
* Works as a mouse if you're are in couch-mode (press <key>Guide</key>+<key>Select</key>)
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a grammatical error with double 'are'. It should be 'if you're in couch-mode' or 'if you are in couch-mode'.

Suggested change
* Works as a mouse if you're are in couch-mode (press <key>Guide</key>+<key>Select</key>)
* Works as a mouse if you're in couch-mode (press <key>Guide</key>+<key>Select</key>)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 | type: enhancement New feature or request 1 | state: testing solution Solution is in testing phase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant