# SDL: Reset rawInputEnableCount when RawInput is not supported

**URL:** <https://discourse.libsdl.org/t/sdl-reset-rawinputenablecount-when-rawinput-is-not-supported/32115>\
**Category:** SDL Commits\
**Created:** [July 11, 2021, 9:52pm UTC](https://discourse.libsdl.org/t/sdl-reset-rawinputenablecount-when-rawinput-is-not-supported/32115 "2021-07-11T21:52:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [July 11, 2021, 9:52pm UTC](https://discourse.libsdl.org/t/sdl-reset-rawinputenablecount-when-rawinput-is-not-supported/32115/1 "2021-07-11T21:52:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/7fe6dbafa33e109ccb7d1742016fc2caeedc89b0>

```diff
From 7fe6dbafa33e109ccb7d1742016fc2caeedc89b0 Mon Sep 17 00:00:00 2001
From: Brick <[EMAIL REDACTED]>
Date: Sun, 11 Jul 2021 15:25:24 +0100
Subject: [PATCH] Reset rawInputEnableCount when RawInput is not supported

---
 src/video/windows/SDL_windowsmouse.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 8d7a1b0348..7d004df169 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -31,7 +31,7 @@ HCURSOR SDL_cursor = NULL;
 
 static int rawInputEnableCount = 0;
 
-static int 
+static int
 ToggleRawInput(SDL_bool enabled)
 {
     RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
@@ -57,6 +57,9 @@ ToggleRawInput(SDL_bool enabled)
 
     /* (Un)register raw input for mice */
     if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
+ /* Reset the enable count, otherwise subsequent enable calls will
+ believe raw input is enabled */
+ rawInputEnableCount = 0;
 
         /* Only return an error when registering. If we unregister and fail,
            then it's probably that we unregistered twice. That's OK. */

```
