diff --git a/src/Input.c b/src/Input.c index aa86d8644..47d522ea3 100644 --- a/src/Input.c +++ b/src/Input.c @@ -312,6 +312,40 @@ void Pointer_SetPosition(int idx, int x, int y) { } +/*########################################################################################################################* +*--------------------------------------------------------Crosshairs-------------------------------------------------------* +*#########################################################################################################################*/ +#define CH_EXTENT 16 + +#ifdef CC_BUILD_TOUCH +static int GetTouchCrosshairs(struct Crosshairs* buffer) { + int i, count = 0; + for (i = 0; i < Pointers_Count; i++) { + if (!(touches[i].type & TOUCH_TYPE_BLOCKS)) continue; + if ( touches[i].type == TOUCH_TYPE_ALL) continue; + + buffer[count].centreX = Pointers[i].x; + buffer[count].centreY = Pointers[i].y; + buffer[count].radius = Display_ScaleX(80); + count++; + } + return count; +} +#endif + +int Input_GetCrosshairs(struct Crosshairs* buffer) { +#ifdef CC_BUILD_TOUCH + if (Input_TouchMode) return GetTouchCrosshairs(buffer); +#endif + + buffer->radius = (int)(CH_EXTENT * Gui_Scale(WindowInfo.Height / 480.0f)); + buffer->centreX = WindowInfo.Width / 2; + buffer->centreY = WindowInfo.Height / 2; + + return 1; +} + + /*########################################################################################################################* *---------------------------------------------------------Keybinds--------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/Input.h b/src/Input.h index 4f0490099..addccbdc4 100644 --- a/src/Input.h +++ b/src/Input.h @@ -118,6 +118,10 @@ void Mouse_ScrollWheel(float delta); void Pointer_SetPosition(int idx, int x, int y); +struct Crosshairs { int centreX, centreY, radius; }; +int Input_GetCrosshairs(struct Crosshairs* buffer); + + /* Enumeration of all key bindings. */ enum KeyBind_ { KEYBIND_FORWARD, KEYBIND_BACK, KEYBIND_LEFT, KEYBIND_RIGHT, diff --git a/src/Screens.c b/src/Screens.c index 0319bbd97..dcd1a5d4a 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -768,7 +768,6 @@ static struct ChatScreen { struct Texture clientStatusTextures[CHAT_MAX_CLIENTSTATUS]; struct Texture chatTextures[GUI_MAX_CHATLINES]; } ChatScreen_Instance; -#define CH_EXTENT 16 static void ChatScreen_UpdateChatYOffsets(struct ChatScreen* s) { int pad, y; @@ -963,17 +962,22 @@ static void ChatScreen_ChatReceived(void* screen, const cc_string* msg, int type static void ChatScreen_DrawCrosshairs(void) { static struct Texture tex = { 0, Tex_Rect(0,0,0,0), Tex_UV(0.0f,0.0f, 15/256.0f,15/256.0f) }; - int extent; + struct Crosshairs crosshairs[INPUT_MAX_POINTERS]; + int i, extent, numCrosshairs; + if (!Gui.IconsTex) return; + numCrosshairs = Input_GetCrosshairs(crosshairs); - extent = (int)(CH_EXTENT * Gui_Scale(WindowInfo.Height / 480.0f)); - tex.ID = Gui.IconsTex; - tex.X = (WindowInfo.Width / 2) - extent; - tex.Y = (WindowInfo.Height / 2) - extent; + for (i = 0; i < numCrosshairs; i++) { + extent = crosshairs[i].radius; + tex.ID = Gui.IconsTex; + tex.X = crosshairs[i].centreX - extent; + tex.Y = crosshairs[i].centreY - extent; - tex.Width = extent * 2; - tex.Height = extent * 2; - Texture_Render(&tex); + tex.Width = extent * 2; + tex.Height = extent * 2; + Texture_Render(&tex); + } } static void ChatScreen_DrawChatBackground(struct ChatScreen* s) {