mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Move touchbox functions to hid.c / hid.h
This commit is contained in:
parent
2f64a8046a
commit
c3152838db
@ -106,6 +106,23 @@ bool HID_SetCalibrationData(const HID_CalibrationData *calibs, int point_cnt, in
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TouchBoxGet(u16* x, u16* y, u32* id, const TouchBox* tbs, const u32 tbn) {
|
||||
*id = 0;
|
||||
|
||||
// read coordinates, check if inside touchbox
|
||||
if (!HID_ReadTouchState(x, y)) return false;
|
||||
for (u32 i = 0; i < tbn; i++) {
|
||||
const TouchBox* tb = tbs + i;
|
||||
if ((*x >= tb->x) && (*y >= tb->y) &&
|
||||
(*x < tb->x + tb->w) && (*y < tb->y + tb->h)) {
|
||||
*id = tb->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 InputWait(u32 timeout_sec) {
|
||||
static u64 delay = 0;
|
||||
u64 timer = timer_start();
|
||||
|
@ -26,6 +26,17 @@ u32 HID_ReadRawTouchState(void);
|
||||
bool HID_ReadTouchState(u16 *x, u16 *y);
|
||||
bool HID_SetCalibrationData(const HID_CalibrationData *calibs, int point_cnt, int screen_w, int screen_h);
|
||||
|
||||
typedef struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 w;
|
||||
u16 h;
|
||||
u32 id; // shouldn't be zero
|
||||
} __attribute__((packed)) TouchBox;
|
||||
|
||||
// abstraction for HID_ReadTouchState, also returns touchbox id (if any)
|
||||
bool TouchBoxGet(u16* x, u16* y, u32* id, const TouchBox* tbs, const u32 tbn);
|
||||
|
||||
u32 InputWait(u32 timeout_sec);
|
||||
bool CheckButton(u32 button);
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include "touchui.h"
|
||||
#include "hid.h"
|
||||
|
||||
|
||||
bool TouchBoxGet(u16* x, u16* y, u32* id, const TouchBox* tbs, const u32 tbn) {
|
||||
*id = 0;
|
||||
|
||||
// read coordinates, check if inside touchbox
|
||||
if (!HID_ReadTouchState(x, y)) return false;
|
||||
for (u32 i = 0; i < tbn; i++) {
|
||||
const TouchBox* tb = tbs + i;
|
||||
if ((*x >= tb->x) && (*y >= tb->y) &&
|
||||
(*x < tb->x + tb->w) && (*y < tb->y + tb->h)) {
|
||||
*id = tb->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 w;
|
||||
u16 h;
|
||||
u32 id; // shouldn't be zero
|
||||
} __attribute__((packed)) TouchBox;
|
||||
|
||||
// this assumes the touchscreen is actually in use
|
||||
bool TouchBoxGet(u16* x, u16* y, u32* id, const TouchBox* tbs, const u32 tbn);
|
@ -1,5 +1,4 @@
|
||||
#include "paint9.h"
|
||||
#include "touchui.h"
|
||||
#include "hid.h"
|
||||
#include "ui.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user