Skip to content

Commit cb7464c

Browse files
mardyWinterMute
authored andcommitted
ogc: correct mouse position to take screen resolution into account
The WiiMote IR coordinates are based on a hypotehtical screen resolution of 640x480, but now that we added support for different video modes, we need to scale the coordinates accordingly.
1 parent 4b8191c commit cb7464c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/video/ogc/SDL_ogcevents.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static const struct {
4949

5050
static void pump_ir_events(_THIS)
5151
{
52+
int screen_w, screen_h;
53+
5254
if (!_this->windows) return;
5355

5456
if (!SDL_WasInit(SDL_INIT_JOYSTICK)) {
@@ -58,13 +60,17 @@ static void pump_ir_events(_THIS)
5860
WPAD_ReadPending(WPAD_CHAN_ALL, NULL);
5961
}
6062

63+
screen_w = _this->displays[0].current_mode.w;
64+
screen_h = _this->displays[0].current_mode.h;
65+
6166
for (int i = 0; i < 4; i++) {
6267
WPADData *data = WPAD_Data(i);
6368

6469
if (!data->ir.valid) continue;
6570

66-
SDL_SendMouseMotion(_this->windows, i,
67-
0, data->ir.x, data->ir.y);
71+
SDL_SendMouseMotion(_this->windows, i, 0,
72+
data->ir.x * screen_w / 640,
73+
data->ir.y * screen_h / 480);
6874

6975
for (int b = 0; b < MAX_WII_MOUSE_BUTTONS; b++) {
7076
if (data->btns_d & s_mouse_button_map[b].wii) {

0 commit comments

Comments
 (0)